From cd876a0f9ffd03c711812c2ade92836e5d6c0203 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 24 Nov 2019 20:11:50 -0500 Subject: split loot dialog, added ui file --- src/lootdialog.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/lootdialog.h (limited to 'src/lootdialog.h') diff --git a/src/lootdialog.h b/src/lootdialog.h new file mode 100644 index 00000000..e4647b5c --- /dev/null +++ b/src/lootdialog.h @@ -0,0 +1,47 @@ +#ifndef MODORGANIZER_LOOTDIALOG_H +#define MODORGANIZER_LOOTDIALOG_H + +#include +#include + +namespace Ui { class LootDialog; } + +class OrganizerCore; +class Loot; + +class LootDialog : public QDialog +{ +public: + LootDialog(QWidget* parent, OrganizerCore& core, Loot& loot); + ~LootDialog(); + + void setText(const QString& s); + void setProgress(lootcli::Progress p); + + QString progressToString(lootcli::Progress p); + + void addOutput(const QString& s); + + bool result() const; + + void cancel(); + + void openReport(); + +private: + std::unique_ptr ui; + OrganizerCore& m_core; + Loot& m_loot; + bool m_finished; + bool m_cancelling; + + void createUI(); + void closeEvent(QCloseEvent* e) override; + void onButton(QAbstractButton* b); + void addLineOutput(const QString& line); + void onFinished(); + void log(MOBase::log::Levels lv, const QString& s); + void handleReport(); +}; + +#endif // MODORGANIZER_LOOTDIALOG_H -- cgit v1.3.1 From 70ee786102c8436c7f8f9e8a5d2ea71035d8d572 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 24 Nov 2019 22:19:23 -0500 Subject: changed loot report to webengine with markdown support --- src/loot.cpp | 4 +- src/lootdialog.cpp | 74 +++++++++-- src/lootdialog.h | 31 +++++ src/lootdialog.ui | 49 ++++++-- src/resources/markdown.html | 299 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 434 insertions(+), 23 deletions(-) create mode 100644 src/resources/markdown.html (limited to 'src/lootdialog.h') diff --git a/src/loot.cpp b/src/loot.cpp index f0618b0b..5d75eeaa 100644 --- a/src/loot.cpp +++ b/src/loot.cpp @@ -67,7 +67,9 @@ Loot::Loot() Loot::~Loot() { - m_thread->wait(); + if (m_thread) { + m_thread->wait(); + } if (!m_outPath.isEmpty() && QFile::exists(m_outPath)) { const auto r = shell::Delete(m_outPath); diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp index db41959d..9c7b482e 100644 --- a/src/lootdialog.cpp +++ b/src/lootdialog.cpp @@ -4,9 +4,44 @@ #include "organizercore.h" #include #include +#include using namespace MOBase; + +MarkdownDocument::MarkdownDocument(QObject* parent) + : QObject(parent) +{ +} + +void MarkdownDocument::setText(const QString& text) +{ + if (m_text == text) + return; + + m_text = text; + emit textChanged(m_text); +} + + +MarkdownPage::MarkdownPage(QObject* parent) + : QWebEnginePage(parent) +{ +} + +bool MarkdownPage::acceptNavigationRequest(const QUrl &url, NavigationType, bool) +{ + static const QStringList allowed = {"qrc", "data"}; + + if (!allowed.contains(url.scheme())) { + QDesktopServices::openUrl(url); + return false; + } + + return true; +} + + LootDialog::LootDialog(QWidget* parent, OrganizerCore& core, Loot& loot) : QDialog(parent), ui(new Ui::LootDialog), m_core(core), m_loot(loot), m_finished(false), m_cancelling(false) @@ -108,6 +143,27 @@ void LootDialog::createUI() ui->setupUi(this); ui->progressBar->setMaximum(0); + auto* page = new MarkdownPage(this); + ui->report->setPage(page); + + auto* channel = new QWebChannel(this); + channel->registerObject("content", &m_report); + page->setWebChannel(channel); + + const QString path = QApplication::applicationDirPath() + "/resources/markdown.html"; + QFile f(path); + + if (f.open(QFile::ReadOnly)) { + const QString html = f.readAll(); + if (!html.isEmpty()) { + ui->report->setHtml(html); + } else { + log::error("failed to read '{}', {}", path, f.errorString()); + } + } else { + log::error("can't open '{}', {}", path, f.errorString()); + } + ui->openJsonReport->setEnabled(false); connect(ui->openJsonReport, &QPushButton::clicked, [&]{ openReport(); }); @@ -176,27 +232,25 @@ void LootDialog::handleReport() addLineOutput(""); } - QString html; + QString md; if (!report.messages.empty()) { - html += "
    "; - for (auto&& m : report.messages) { log(m.type, m.text); - html += "
  • "; + md += " - "; switch (m.type) { case log::Error: { - html += "" + QObject::tr("Error") + ": "; + md += "**" + QObject::tr("Error") + "**: "; break; } case log::Warning: { - html += "" + QObject::tr("Warning") + ": "; + md += "**" + QObject::tr("Warning") + "**: "; break; } @@ -206,15 +260,13 @@ void LootDialog::handleReport() } } - html += m.text + "
  • "; + md += m.text + "\n"; } - - html + "
"; } else { - html += QObject::tr("No messages."); + md += QObject::tr("**No messages.**"); } - ui->report->setHtml(html); + m_report.setText(md); for (auto&& p : report.plugins) { m_core.pluginList()->addLootReport(p.name, p); diff --git a/src/lootdialog.h b/src/lootdialog.h index e4647b5c..df9e546d 100644 --- a/src/lootdialog.h +++ b/src/lootdialog.h @@ -9,6 +9,36 @@ namespace Ui { class LootDialog; } class OrganizerCore; class Loot; + +class MarkdownDocument : public QObject +{ + Q_OBJECT; + Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged FINAL); + +public: + explicit MarkdownDocument(QObject* parent=nullptr); + void setText(const QString& text); + +signals: + void textChanged(const QString &text); + +private: + QString m_text; +}; + + +class MarkdownPage : public QWebEnginePage +{ + Q_OBJECT; + +public: + explicit MarkdownPage(QObject* parent=nullptr); + +protected: + bool acceptNavigationRequest(const QUrl &url, NavigationType, bool) override; +}; + + class LootDialog : public QDialog { public: @@ -34,6 +64,7 @@ private: Loot& m_loot; bool m_finished; bool m_cancelling; + MarkdownDocument m_report; void createUI(); void closeEvent(QCloseEvent* e) override; diff --git a/src/lootdialog.ui b/src/lootdialog.ui index 7e10b1db..e366ce41 100644 --- a/src/lootdialog.ui +++ b/src/lootdialog.ui @@ -7,7 +7,7 @@ 0 0 457 - 343 + 600 @@ -16,7 +16,7 @@ - + 0 @@ -31,7 +31,7 @@ - + 0 @@ -62,16 +62,36 @@ - - - true + + + QFrame::StyledPanel - - Qt::TextBrowserInteraction - - - LOOT Report + + QFrame::Sunken + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + about:blank + + + + + @@ -176,6 +196,13 @@ + + + QWebEngineView + QWidget +
QtWebEngineWidgets/QWebEngineView
+
+
diff --git a/src/resources/markdown.html b/src/resources/markdown.html new file mode 100644 index 00000000..a09b2209 --- /dev/null +++ b/src/resources/markdown.html @@ -0,0 +1,299 @@ + + + + + + + + + +
+ + + \ No newline at end of file -- cgit v1.3.1 From 0e45044dbd724e9050bea00511585dc023afe144 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 25 Nov 2019 00:47:45 -0500 Subject: fixed cancel button debug logs, some cleanup --- src/loot.cpp | 47 +++++++++++++++++++++------- src/lootdialog.cpp | 92 ++++++++++++++++++++++++++++++++++-------------------- src/lootdialog.h | 11 +++---- 3 files changed, 98 insertions(+), 52 deletions(-) (limited to 'src/lootdialog.h') diff --git a/src/loot.cpp b/src/loot.cpp index 2faf9c2e..9c8cf8c4 100644 --- a/src/loot.cpp +++ b/src/loot.cpp @@ -199,6 +199,7 @@ Loot::~Loot() } if (!m_outPath.isEmpty() && QFile::exists(m_outPath)) { + log::debug("deleting temporary loot report '{}'", m_outPath); const auto r = shell::Delete(m_outPath); if (!r) { @@ -211,6 +212,8 @@ Loot::~Loot() bool Loot::start(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList) { + log::debug("starting loot"); + m_outPath = QDir::temp().absoluteFilePath("lootreport.json"); const auto logLevel = core.settings().diagnostics().lootLogLevel(); @@ -271,8 +274,19 @@ bool Loot::start(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList) core.pluginList()->clearAdditionalInformation(); + log::debug("starting loot thread"); + m_thread.reset(QThread::create([&]{ - lootThread(); + try + { + lootThread(); + } + catch(...) + { + log::error("unhandled exception in loot thread"); + } + + log::debug("finishing loot thread"); emit finished(); })); @@ -283,7 +297,10 @@ bool Loot::start(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList) void Loot::cancel() { - m_cancel = true; + if (!m_cancel) { + log::debug("loot received cancel request"); + m_cancel = true; + } } bool Loot::result() const @@ -303,6 +320,8 @@ const Loot::Report& Loot::report() const void Loot::lootThread() { + ::SetThreadDescription(GetCurrentThread(), L"loot"); + try { m_result = false; @@ -321,10 +340,13 @@ bool Loot::waitForCompletion() { bool terminating = false; + log::debug("loot thread waiting for completion on lootcli"); + for (;;) { DWORD res = WaitForSingleObject(m_lootProcess.get(), 100); if (res == WAIT_OBJECT_0) { + log::debug("lootcli has completed"); // done break; } @@ -336,9 +358,13 @@ bool Loot::waitForCompletion() } if (m_cancel) { - // terminate and wait to finish + log::debug("terminating lootcli process"); ::TerminateProcess(m_lootProcess.get(), 1); + + log::debug("waiting for loocli process to terminate"); WaitForSingleObject(m_lootProcess.get(), INFINITE); + + log::debug("lootcli terminated"); return false; } @@ -396,6 +422,12 @@ void Loot::processStdout(const std::string &lootOut) emit output(QString::fromStdString(lootOut)); m_outputBuffer += lootOut; + if (m_outputBuffer.empty()) { + return; + } + + log::debug("loot: processing stdout ({} bytes)", m_outputBuffer.size()); + std::size_t start = 0; for (;;) { @@ -440,7 +472,7 @@ void Loot::processMessage(const lootcli::Message& m) void Loot::processOutputFile() { - log::info("parsing json output file at '{}'", m_outPath); + log::debug("parsing json output file at '{}'", m_outPath); QFile outFile(m_outPath); if (!outFile.open(QIODevice::ReadOnly)) { @@ -645,20 +677,13 @@ std::vector Loot::reportStringArray(const QJsonArray& array) const bool runLoot(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList) { - //m_OrganizerCore.currentProfile()->writeModlistNow(); core.savePluginList(); - //Create a backup of the load orders w/ LOOT in name - //to make sure that any sorting is easily undo-able. - //Need to figure out how I want to do that. - try { Loot loot; LootDialog dialog(parent, core, loot); loot.start(parent, core, didUpdateMasterList); - - dialog.setText(QObject::tr("Please wait while LOOT is running")); dialog.exec(); return dialog.result(); diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp index 80664415..43929c00 100644 --- a/src/lootdialog.cpp +++ b/src/lootdialog.cpp @@ -8,6 +8,29 @@ using namespace MOBase; +QString progressToString(lootcli::Progress p) +{ + using P = lootcli::Progress; + + static const std::map map = { + {P::CheckingMasterlistExistence, QObject::tr("Checking masterlist existence")}, + {P::UpdatingMasterlist, QObject::tr("Updating masterlist")}, + {P::LoadingLists, QObject::tr("Loading lists")}, + {P::ReadingPlugins, QObject::tr("Reading plugins")}, + {P::SortingPlugins, QObject::tr("Sorting plugins")}, + {P::WritingLoadorder, QObject::tr("Writing loadorder.txt")}, + {P::ParsingLootMessages, QObject::tr("Parsing loot messages")}, + {P::Done, QObject::tr("Done")} + }; + + auto itor = map.find(p); + if (itor == map.end()) { + return QString("unknown progress %1").arg(static_cast(p)); + } else { + return itor->second; + } +} + MarkdownDocument::MarkdownDocument(QObject* parent) : QObject(parent) @@ -74,7 +97,11 @@ void LootDialog::setText(const QString& s) void LootDialog::setProgress(lootcli::Progress p) { - setText(progressToString(p)); + // don't overwrite the "stopping loot" message even if lootcli generates a new + // progress message + if (!m_cancelling) { + setText(progressToString(p)); + } if (p == lootcli::Progress::Done) { ui->progressBar->setRange(0, 1); @@ -82,24 +109,6 @@ void LootDialog::setProgress(lootcli::Progress p) } } -QString LootDialog::progressToString(lootcli::Progress p) -{ - using P = lootcli::Progress; - - switch (p) - { - case P::CheckingMasterlistExistence: return tr("Checking masterlist existence"); - case P::UpdatingMasterlist: return tr("Updating masterlist"); - case P::LoadingLists: return tr("Loading lists"); - case P::ReadingPlugins: return tr("Reading plugins"); - case P::SortingPlugins: return tr("Sorting plugins"); - case P::WritingLoadorder: return tr("Writing loadorder.txt"); - case P::ParsingLootMessages: return tr("Parsing loot messages"); - case P::Done: return tr("Done"); - default: return QString("unknown progress %1").arg(static_cast(p)); - } -} - void LootDialog::addOutput(const QString& s) { if (m_core.settings().diagnostics().lootLogLevel() > lootcli::LogLevels::Debug) { @@ -125,8 +134,12 @@ bool LootDialog::result() const void LootDialog::cancel() { if (!m_finished && !m_cancelling) { - addLineOutput(tr("Stopping LOOT...")); + log::debug("loot dialog: cancelling"); m_loot.cancel(); + + setText(tr("Stopping LOOT...")); + addLineOutput("stopping loot"); + ui->buttons->setEnabled(false); m_cancelling = true; } @@ -138,6 +151,22 @@ void LootDialog::openReport() shell::Open(path); } +void LootDialog::accept() +{ + // no-op +} + +void LootDialog::reject() +{ + if (m_finished) { + log::debug("loot dialog reject: loot finished, closing"); + QDialog::reject(); + } else { + log::debug("loot dialog reject: not finished, cancelling"); + cancel(); + } +} + void LootDialog::createUI() { ui->setupUi(this); @@ -169,7 +198,7 @@ void LootDialog::createUI() new ExpanderWidget(ui->details, ui->detailsPanel); - connect(ui->buttons, &QDialogButtonBox::clicked, [&](auto* b){ onButton(b); }); + ui->buttons->setStandardButtons(QDialogButtonBox::Cancel); resize(650, 450); } @@ -177,24 +206,15 @@ void LootDialog::createUI() void LootDialog::closeEvent(QCloseEvent* e) { if (m_finished) { + log::debug("loot dialog close event: finished, closing"); QDialog::closeEvent(e); } else { + log::debug("loot dialog close event: not finished, cancelling"); cancel(); e->ignore(); } } -void LootDialog::onButton(QAbstractButton* b) -{ - if (ui->buttons->buttonRole(b) == QDialogButtonBox::RejectRole) { - if (m_finished) { - close(); - } else { - cancel(); - } - } -} - void LootDialog::addLineOutput(const QString& line) { ui->output->appendPlainText(line); @@ -202,12 +222,16 @@ void LootDialog::addLineOutput(const QString& line) void LootDialog::onFinished() { + log::debug("loot dialog: loot is finished"); + m_finished = true; if (m_cancelling) { + log::debug("loot dialog: was cancelling, closing"); close(); } else { - handleReport(); + log::debug("loot dialog: showing report"); + showReport(); ui->openJsonReport->setEnabled(true); ui->buttons->setStandardButtons(QDialogButtonBox::Close); } @@ -224,7 +248,7 @@ void LootDialog::log(log::Levels lv, const QString& s) } } -void LootDialog::handleReport() +void LootDialog::showReport() { const auto& lootReport = m_loot.report(); diff --git a/src/lootdialog.h b/src/lootdialog.h index df9e546d..fcdeb304 100644 --- a/src/lootdialog.h +++ b/src/lootdialog.h @@ -48,16 +48,14 @@ public: void setText(const QString& s); void setProgress(lootcli::Progress p); - QString progressToString(lootcli::Progress p); - void addOutput(const QString& s); - bool result() const; - void cancel(); - void openReport(); + void accept() override; + void reject() override; + private: std::unique_ptr ui; OrganizerCore& m_core; @@ -68,11 +66,10 @@ private: void createUI(); void closeEvent(QCloseEvent* e) override; - void onButton(QAbstractButton* b); void addLineOutput(const QString& line); void onFinished(); void log(MOBase::log::Levels lv, const QString& s); - void handleReport(); + void showReport(); }; #endif // MODORGANIZER_LOOTDIALOG_H -- cgit v1.3.1 From f1b621d0babd33537cde97fc9d53e0dfa0ad5ea5 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 25 Nov 2019 03:34:51 -0500 Subject: save/restore state for loot dialog --- src/lootdialog.cpp | 18 +++++++++++++++--- src/lootdialog.h | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/lootdialog.h') diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp index a8f73cdc..9e269fef 100644 --- a/src/lootdialog.cpp +++ b/src/lootdialog.cpp @@ -3,7 +3,6 @@ #include "loot.h" #include "organizercore.h" #include -#include #include using namespace MOBase; @@ -151,6 +150,20 @@ void LootDialog::openReport() shell::Open(path); } +int LootDialog::exec() +{ + auto& s = m_core.settings(); + + GeometrySaver gs(s, this); + s.geometry().restoreState(&m_expander); + + const auto r = QDialog::exec(); + + s.geometry().saveState(&m_expander); + + return r; +} + void LootDialog::accept() { // no-op @@ -193,11 +206,10 @@ void LootDialog::createUI() log::error("can't open '{}', {}", path, f.errorString()); } + m_expander.set(ui->details, ui->detailsPanel); ui->openJsonReport->setEnabled(false); connect(ui->openJsonReport, &QPushButton::clicked, [&]{ openReport(); }); - new ExpanderWidget(ui->details, ui->detailsPanel); - ui->buttons->setStandardButtons(QDialogButtonBox::Cancel); resize(650, 450); diff --git a/src/lootdialog.h b/src/lootdialog.h index fcdeb304..bc8c01fb 100644 --- a/src/lootdialog.h +++ b/src/lootdialog.h @@ -3,6 +3,7 @@ #include #include +#include namespace Ui { class LootDialog; } @@ -53,11 +54,13 @@ public: void cancel(); void openReport(); + int exec() override; void accept() override; void reject() override; private: std::unique_ptr ui; + MOBase::ExpanderWidget m_expander; OrganizerCore& m_core; Loot& m_loot; bool m_finished; -- cgit v1.3.1 From 51e3e078be10a085702014b4b873d69c502e8b0a Mon Sep 17 00:00:00 2001 From: Silarn Date: Sat, 14 Dec 2019 18:11:57 -0600 Subject: Fix problem with translated unmanaged mods and origin names - (Also adds translatable strings to directoryentry.cpp) --- src/lootdialog.h | 1 + src/modinfoforeign.cpp | 8 +++---- src/modinfoforeign.h | 5 ++-- src/organizer_en.ts | 53 +++++++++++++++++++++++++++++++++++++++---- src/shared/directoryentry.cpp | 19 ++++++++-------- 5 files changed, 66 insertions(+), 20 deletions(-) (limited to 'src/lootdialog.h') diff --git a/src/lootdialog.h b/src/lootdialog.h index bc8c01fb..3cec15c6 100644 --- a/src/lootdialog.h +++ b/src/lootdialog.h @@ -42,6 +42,7 @@ protected: class LootDialog : public QDialog { + Q_OBJECT; public: LootDialog(QWidget* parent, OrganizerCore& core, Loot& loot); ~LootDialog(); diff --git a/src/modinfoforeign.cpp b/src/modinfoforeign.cpp index 7312d5b7..84199eae 100644 --- a/src/modinfoforeign.cpp +++ b/src/modinfoforeign.cpp @@ -8,11 +8,6 @@ using namespace MOBase; using namespace MOShared; -QString ModInfoForeign::name() const -{ - return m_Name; -} - QDateTime ModInfoForeign::creationTime() const { return m_CreationTime; @@ -59,11 +54,14 @@ ModInfoForeign::ModInfoForeign(const QString &modName, switch (modType) { case ModInfo::EModType::MOD_DLC: m_Name = tr("DLC: ") + modName; + m_InternalName = QString("DLC: ") + modName; break; case ModInfo::EModType::MOD_CC: m_Name = tr("Creation Club: ") + modName; + m_InternalName = QString("Creation Club: ") + modName; break; default: m_Name = tr("Unmanaged: ") + modName; + m_InternalName = QString("Unmanaged: ") + modName; } } diff --git a/src/modinfoforeign.h b/src/modinfoforeign.h index 72fbb04f..3308d42f 100644 --- a/src/modinfoforeign.h +++ b/src/modinfoforeign.h @@ -35,8 +35,8 @@ public: virtual void track(bool) {} virtual void parseNexusInfo() {} virtual bool isEmpty() const { return false; } - virtual QString name() const; - virtual QString internalName() const { return name(); } + virtual QString name() const { return m_Name; } + virtual QString internalName() const { return m_InternalName; } virtual QString comments() const { return ""; } virtual QString notes() const { return ""; } virtual QDateTime creationTime() const; @@ -72,6 +72,7 @@ protected: private: QString m_Name; + QString m_InternalName; QString m_ReferenceFile; QStringList m_Archives; QDateTime m_CreationTime; diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 271599e4..2540b1ba 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -4035,22 +4035,22 @@ p, li { white-space: pre-wrap; } ModInfoForeign - + This pseudo mod represents content managed outside MO. It isn't modified by MO. - + DLC: - + Creation Club: - + Unmanaged: @@ -6771,6 +6771,51 @@ You can restart Mod Organizer as administrator and try launching the program aga %1 is loaded. This program is known to cause issues with Mod Organizer, such as freezing or blank windows. Consider uninstalling it. (%2) + + + invalid origin name: + + + + + failed to change name lookup from {} to {} + + + + + failed to determine file time + + + + + invalid bsa file: + + + + + file "{}" not in directory "{}" + + + + + file "{}" not in directory "{}", directory empty + + + + + unexpected end of path + + + + + invalid file index for remove: {} + + + + + invalid file index for remove (for origin): {} + + QueryOverwriteDialog diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index 2cdbac74..00bf319e 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include namespace MOShared { @@ -83,7 +84,7 @@ public: return m_Origins[iter->second]; } else { std::ostringstream stream; - stream << "invalid origin name: " << ToString(name, false); + stream << QObject::tr("invalid origin name: ").toStdString() << ToString(name, true); throw std::runtime_error(stream.str()); } } @@ -106,7 +107,7 @@ public: m_OriginsNameMap.erase(iter); m_OriginsNameMap[newName] = idx; } else { - log::error("failed to change name lookup from {} to {}", oldName, newName); + log::error(QObject::tr("failed to change name lookup from {} to {}").toStdString(), oldName, newName); } } @@ -520,7 +521,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di WIN32_FILE_ATTRIBUTE_DATA fileData; if (::GetFileAttributesExW(fileName.c_str(), GetFileExInfoStandard, &fileData) == 0) { - throw windows_error("failed to determine file time"); + throw windows_error(QObject::tr("failed to determine file time").toStdString()); } FILETIME now; ::GetSystemTimeAsFileTime(&now); @@ -542,7 +543,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di BSA::EErrorCode res = archive.read(ToString(fileName, false).c_str(), false); if ((res != BSA::ERROR_NONE) && (res != BSA::ERROR_INVALIDHASHES)) { std::ostringstream stream; - stream << "invalid bsa file: " << ToString(fileName, false) << " errorcode " << res << " - " << ::GetLastError(); + stream << QObject::tr("invalid bsa file: ").toStdString() << ToString(fileName, false) << " errorcode " << res << " - " << ::GetLastError(); throw std::runtime_error(stream.str()); } @@ -718,12 +719,12 @@ void DirectoryEntry::removeFile(FileEntry::Index index) m_Files.erase(iter); } else { log::error( - "file \"{}\" not in directory \"{}\"", + QObject::tr("file \"{}\" not in directory \"{}\"").toStdString(), m_FileRegister->getFile(index)->getName(), this->getName()); } } else { log::error( - "file \"{}\" not in directory \"{}\", directory empty", + QObject::tr("file \"{}\" not in directory \"{}\", directory empty").toStdString(), m_FileRegister->getFile(index)->getName(), this->getName()); } } @@ -847,7 +848,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const DirectoryEntry *temp = findSubDirectory(pathComponent); if (temp != nullptr) { if (len >= path.size()) { - log::error("unexpected end of path"); + log::error(QObject::tr("unexpected end of path").toStdString()); return FileEntry::Ptr(); } return temp->searchFile(path.substr(len + 1), directory); @@ -991,7 +992,7 @@ bool FileRegister::removeFile(FileEntry::Index index) m_Files.erase(index); return true; } else { - log::error("invalid file index for remove: {}", index); + log::error(QObject::tr("invalid file index for remove: {}").toStdString(), index); return false; } } @@ -1005,7 +1006,7 @@ void FileRegister::removeOrigin(FileEntry::Index index, int originID) m_Files.erase(iter); } } else { - log::error("invalid file index for remove (for origin): {}", index); + log::error(QObject::tr("invalid file index for remove (for origin): {}").toStdString(), index); } } -- cgit v1.3.1