forked from Public-Mirror/Textractor
Feature: Show original text
This commit is contained in:
parent
b4c5b31482
commit
f86a776536
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
extern const char* EXTRA_WINDOW_INFO;
|
extern const char* EXTRA_WINDOW_INFO;
|
||||||
extern const char* TOPMOST;
|
extern const char* TOPMOST;
|
||||||
|
extern const char* SHOW_ORIGINAL;
|
||||||
extern const char* SIZE_LOCK;
|
extern const char* SIZE_LOCK;
|
||||||
extern const char* BG_COLOR;
|
extern const char* BG_COLOR;
|
||||||
extern const char* TEXT_COLOR;
|
extern const char* TEXT_COLOR;
|
||||||
@ -72,6 +73,9 @@ public:
|
|||||||
setSizeGripEnabled(!lock);
|
setSizeGripEnabled(!lock);
|
||||||
settings->setValue(SIZE_LOCK, lock);
|
settings->setValue(SIZE_LOCK, lock);
|
||||||
};
|
};
|
||||||
|
auto setShowOriginal = [=](bool showOriginal) {
|
||||||
|
settings->setValue(SHOW_ORIGINAL, showOriginal);
|
||||||
|
};
|
||||||
setGeometry(settings->value(WINDOW, geometry()).toRect());
|
setGeometry(settings->value(WINDOW, geometry()).toRect());
|
||||||
setLock(settings->value(SIZE_LOCK, false).toBool());
|
setLock(settings->value(SIZE_LOCK, false).toBool());
|
||||||
setTopmost(settings->value(TOPMOST, false).toBool());
|
setTopmost(settings->value(TOPMOST, false).toBool());
|
||||||
@ -86,6 +90,9 @@ public:
|
|||||||
auto lock = menu->addAction(SIZE_LOCK, setLock);
|
auto lock = menu->addAction(SIZE_LOCK, setLock);
|
||||||
lock->setCheckable(true);
|
lock->setCheckable(true);
|
||||||
lock->setChecked(settings->value(SIZE_LOCK, false).toBool());
|
lock->setChecked(settings->value(SIZE_LOCK, false).toBool());
|
||||||
|
auto showOriginal = menu->addAction(SHOW_ORIGINAL, setShowOriginal);
|
||||||
|
showOriginal->setCheckable(true);
|
||||||
|
showOriginal->setChecked(settings->value(SHOW_ORIGINAL, true).toBool());
|
||||||
menu->addAction(BG_COLOR, [=] { setBackgroundColor(QColorDialog::getColor(bgColor, this, BG_COLOR, QColorDialog::ShowAlphaChannel)); });
|
menu->addAction(BG_COLOR, [=] { setBackgroundColor(QColorDialog::getColor(bgColor, this, BG_COLOR, QColorDialog::ShowAlphaChannel)); });
|
||||||
menu->addAction(TEXT_COLOR, [=] { setTextColor(QColorDialog::getColor(display->palette().windowText().color(), this, TEXT_COLOR, QColorDialog::ShowAlphaChannel)); });
|
menu->addAction(TEXT_COLOR, [=] { setTextColor(QColorDialog::getColor(display->palette().windowText().color(), this, TEXT_COLOR, QColorDialog::ShowAlphaChannel)); });
|
||||||
menu->addAction(FONT_SIZE, [=] { setFontSize(QInputDialog::getInt(this, FONT_SIZE, "", display->font().pointSize(), 0, INT_MAX, 1, nullptr, Qt::WindowCloseButtonHint)); });
|
menu->addAction(FONT_SIZE, [=] { setFontSize(QInputDialog::getInt(this, FONT_SIZE, "", display->font().pointSize(), 0, INT_MAX, 1, nullptr, Qt::WindowCloseButtonHint)); });
|
||||||
@ -156,6 +163,14 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
|||||||
{
|
{
|
||||||
std::lock_guard l(m);
|
std::lock_guard l(m);
|
||||||
if (window == nullptr || !sentenceInfo["current select"]) return false;
|
if (window == nullptr || !sentenceInfo["current select"]) return false;
|
||||||
QMetaObject::invokeMethod(window, [=] { window->display->setText(QString::fromStdWString(sentence)); });
|
|
||||||
|
QString qSentence = QString::fromStdWString(sentence);
|
||||||
|
if (!window->settings->value(SHOW_ORIGINAL).toBool())
|
||||||
|
{
|
||||||
|
int middle = qSentence.count('\n') / 2;
|
||||||
|
qSentence = qSentence.section('\n', middle + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(window, [=] { window->display->setText(qSentence); });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
2
text.cpp
2
text.cpp
@ -109,6 +109,7 @@ const wchar_t* TRANSLATION_ERROR = L"Error while translating";
|
|||||||
const char* EXTRA_WINDOW_INFO = u8R"(Right click to change settings
|
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)";
|
Click and drag on window edges to move, or the bottom right corner to resize)";
|
||||||
const char* TOPMOST = u8"Always on Top";
|
const char* TOPMOST = u8"Always on Top";
|
||||||
|
const char* SHOW_ORIGINAL = u8"Original Text";
|
||||||
const char* SIZE_LOCK = u8"Size Locked";
|
const char* SIZE_LOCK = u8"Size Locked";
|
||||||
const char* BG_COLOR = u8"Background Color";
|
const char* BG_COLOR = u8"Background Color";
|
||||||
const char* TEXT_COLOR = u8"Text Color";
|
const char* TEXT_COLOR = u8"Text Color";
|
||||||
@ -377,6 +378,7 @@ I'm currently looking for a new job: email me if you know anyone hiring US softw
|
|||||||
EXTRA_WINDOW_INFO = u8R"(Правый клик для изменения настроек
|
EXTRA_WINDOW_INFO = u8R"(Правый клик для изменения настроек
|
||||||
Нажмите и перетащите за края - для перемещения, или за правый-нижний угол - для изменения размера)";
|
Нажмите и перетащите за края - для перемещения, или за правый-нижний угол - для изменения размера)";
|
||||||
TOPMOST = u8"Поверх всех окон";
|
TOPMOST = u8"Поверх всех окон";
|
||||||
|
SHOW_ORIGINAL = u8"Исходный текст";
|
||||||
SIZE_LOCK = u8"Фиксированный размер";
|
SIZE_LOCK = u8"Фиксированный размер";
|
||||||
BG_COLOR = u8"Цвет заднего фона";
|
BG_COLOR = u8"Цвет заднего фона";
|
||||||
TEXT_COLOR = u8"Цвет текста";
|
TEXT_COLOR = u8"Цвет текста";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user