From 9688f37bbe54568aba09e2dd755e0ea35eef2bb1 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 16 Nov 2019 20:47:30 -0500 Subject: added loot output --- src/loot.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/loot.cpp b/src/loot.cpp index c0051e61..a9e716ae 100644 --- a/src/loot.cpp +++ b/src/loot.cpp @@ -26,6 +26,19 @@ public: m_progress->setMaximum(0); } + void addOutput(const QString& s) + { + const auto lines = s.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts); + + for (auto&& line : lines) { + if (line.isEmpty()) { + continue; + } + + addLineOutput(line); + } + } + bool cancelled() const { return m_cancelled; @@ -35,6 +48,8 @@ private: QLabel* m_label; QProgressBar* m_progress; QDialogButtonBox* m_buttons; + QPlainTextEdit* m_output; + QString m_lastLine; bool m_cancelled; void createUI() @@ -52,7 +67,8 @@ private: m_progress = new QProgressBar; ly->addWidget(m_progress); - ly->addStretch(1); + m_output = new QPlainTextEdit; + ly->addWidget(m_output); m_buttons = new QDialogButtonBox(QDialogButtonBox::Cancel); connect(m_buttons, &QDialogButtonBox::clicked, [&](auto* b){ onButton(b); }); @@ -70,6 +86,16 @@ private: m_cancelled = true; } } + + void addLineOutput(const QString& line) + { + if (line == m_lastLine) { + return; + } + + m_output->appendPlainText(line); + m_lastLine = line; + } }; @@ -117,6 +143,8 @@ void processLOOTOut( OrganizerCore& core, const std::string &lootOut, std::string &errorMessages, LootDialog& dialog) { + dialog.addOutput(QString::fromStdString(lootOut)); + std::vector lines; boost::split(lines, lootOut, boost::is_any_of("\r\n")); -- cgit v1.3.1