From a9a9c0cea55fe6a28b9a499ddd8a5cebb1aab0d3 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 16 Jun 2019 15:50:17 -0400 Subject: [PATCH] note showing original works iff used after translation extension --- extensions/extrawindow.cpp | 12 ++++++------ text.cpp | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/extensions/extrawindow.cpp b/extensions/extrawindow.cpp index d01c58c..becddfa 100644 --- a/extensions/extrawindow.cpp +++ b/extensions/extrawindow.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,7 @@ extern const char* EXTRA_WINDOW_INFO; extern const char* TOPMOST; extern const char* SHOW_ORIGINAL; +extern const char* SHOW_ORIGINAL_INFO; extern const char* SIZE_LOCK; extern const char* BG_COLOR; extern const char* TEXT_COLOR; @@ -73,7 +75,9 @@ public: setSizeGripEnabled(!lock); settings->setValue(SIZE_LOCK, lock); }; - auto setShowOriginal = [=](bool showOriginal) { + auto setShowOriginal = [=](bool showOriginal) + { + if (!showOriginal) QMessageBox::information(this, SHOW_ORIGINAL, SHOW_ORIGINAL_INFO); settings->setValue(SHOW_ORIGINAL, showOriginal); }; setGeometry(settings->value(WINDOW, geometry()).toRect()); @@ -165,11 +169,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) if (window == nullptr || !sentenceInfo["current select"]) return false; QString qSentence = QString::fromStdWString(sentence); - if (!window->settings->value(SHOW_ORIGINAL).toBool()) - { - int middle = qSentence.count('\n') / 2; - qSentence = qSentence.section('\n', middle + 1); - }; + if (!window->settings->value(SHOW_ORIGINAL).toBool()) qSentence = qSentence.section('\n', qSentence.count('\n') / 2 + 1); QMetaObject::invokeMethod(window, [=] { window->display->setText(qSentence); }); return false; diff --git a/text.cpp b/text.cpp index fdad540..5d541cf 100644 --- a/text.cpp +++ b/text.cpp @@ -110,6 +110,8 @@ const char* EXTRA_WINDOW_INFO = u8R"(Right click to change settings Click and drag on window edges to move, or the bottom right corner to resize)"; const char* TOPMOST = u8"Always on Top"; const char* SHOW_ORIGINAL = u8"Original Text"; +const char* SHOW_ORIGINAL_INFO = u8R"(Original text will not be shown +Only works if this extension is used directly after a translation extension)"; const char* SIZE_LOCK = u8"Size Locked"; const char* BG_COLOR = u8"Background Color"; const char* TEXT_COLOR = u8"Text Color";