From eddf1bf0ee55e10b595154e71387ce786f48fab8 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 6 Sep 2021 02:02:36 -0600 Subject: [PATCH] ui improvements --- extensions/regexfilter.ui | 2 +- extensions/threadlinker.cpp | 23 +++++++++++++---------- extensions/threadlinker.ui | 4 ++-- text.cpp | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/extensions/regexfilter.ui b/extensions/regexfilter.ui index edd6e77..6e98269 100644 --- a/extensions/regexfilter.ui +++ b/extensions/regexfilter.ui @@ -7,7 +7,7 @@ 0 0 500 - 107 + 80 diff --git a/extensions/threadlinker.cpp b/extensions/threadlinker.cpp index 6b5a167..5582ec3 100644 --- a/extensions/threadlinker.cpp +++ b/extensions/threadlinker.cpp @@ -12,7 +12,7 @@ extern const char* HEXADECIMAL; std::unordered_map> links; std::unordered_set universalLinks, empty; -bool separateSentences = true; // allow user to change? +bool separateSentences = false; // allow user to change? concurrency::reader_writer_lock m; class Window : public QDialog, Localizer @@ -34,14 +34,17 @@ private: void Link() { bool ok1, ok2, ok3, ok4; - QString fromInput = QInputDialog::getText(this, THREAD_LINK_FROM, HEXADECIMAL, QLineEdit::Normal, "X", &ok1, Qt::WindowCloseButtonHint); - int from = fromInput.toInt(&ok2, 16), - to = QInputDialog::getText(this, THREAD_LINK_TO, HEXADECIMAL, QLineEdit::Normal, "", &ok3, Qt::WindowCloseButtonHint).toInt(&ok4, 16); - if (ok1 && (ok2 || fromInput == "X") && ok3 && ok4) + QString fromInput = QInputDialog::getText(this, THREAD_LINK_FROM, HEXADECIMAL, QLineEdit::Normal, "All", &ok1, Qt::WindowCloseButtonHint); + int from = fromInput.toInt(&ok2, 16); + if (ok1 && (fromInput == "All" || ok2)) { - std::scoped_lock lock(m); - if ((ok2 ? links[from] : universalLinks).insert(to).second) - ui.linkList->addItem((ok2 ? QString::number(from, 16) : "X") + "->" + QString::number(to, 16)); + int to = QInputDialog::getText(this, THREAD_LINK_TO, HEXADECIMAL, QLineEdit::Normal, "", &ok3, Qt::WindowCloseButtonHint).toInt(&ok4, 16); + if (ok3 && ok4) + { + std::scoped_lock lock(m); + if ((ok2 ? links[from] : universalLinks).insert(to).second) + ui.linkList->addItem((ok2 ? QString::number(from, 16) : "All") + "->" + QString::number(to, 16)); + } } } @@ -52,7 +55,7 @@ private: QStringList link = ui.linkList->currentItem()->text().split("->"); ui.linkList->takeItem(ui.linkList->currentRow()); std::scoped_lock lock(m); - (link[0] == "X" ? universalLinks : links[link[0].toInt(nullptr, 16)]).erase(link[1].toInt(nullptr, 16)); + (link[0] == "All" ? universalLinks : links[link[0].toInt(nullptr, 16)]).erase(link[1].toInt(nullptr, 16)); } } @@ -69,7 +72,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) concurrency::reader_writer_lock::scoped_lock_read readLock(m); auto action = separateSentences ? sentenceInfo["add sentence"] : sentenceInfo["add text"]; auto it = links.find(sentenceInfo["text number"]); - for (const auto& linkSet : { it != links.end() ? it->second : empty, universalLinks }) + for (const auto& linkSet : { it != links.end() ? it->second : empty, sentenceInfo["text number"] > 1 ? universalLinks : empty }) for (auto link : linkSet) ((void(*)(int64_t, const wchar_t*))action)(link, sentence.c_str()); return false; diff --git a/extensions/threadlinker.ui b/extensions/threadlinker.ui index 1247c63..4788efc 100644 --- a/extensions/threadlinker.ui +++ b/extensions/threadlinker.ui @@ -24,11 +24,11 @@ - + - + diff --git a/text.cpp b/text.cpp index 6b83176..c624979 100644 --- a/text.cpp +++ b/text.cpp @@ -222,7 +222,7 @@ This file must be encoded in Unicode (UTF-16 Little Endian).)"; const char* THREAD_LINKER = u8"Thread Linker"; const char* LINK = u8"Link"; const char* UNLINK = u8"Unlink"; -const char* THREAD_LINK_FROM = u8"Thread number to link from (or X to link from all threads)"; +const char* THREAD_LINK_FROM = u8"Thread number to link from"; const char* THREAD_LINK_TO = u8"Thread number to link to"; const char* HEXADECIMAL = u8"Hexadecimal";