| 7 | constexpr auto STYLE_SAVE_FILE = u8"Textractor.css"; |
| 8 | |
| 9 | class Window : public QDialog, Localizer |
| 10 | { |
| 11 | public: |
| 12 | Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint) |
| 13 | { |
| 14 | connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript); |
| 15 | |
| 16 | if (scriptEditor.toPlainText().isEmpty()) scriptEditor.setPlainText("/*https://doc.qt.io/qt-5/stylesheet-syntax.html*/"); |
| 17 | layout.addWidget(&scriptEditor); |
| 18 | layout.addWidget(&loadButton); |
| 19 | |
| 20 | resize(800, 600); |
| 21 | setWindowTitle("Styler"); |
| 22 | QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection); |
| 23 | |
| 24 | LoadScript(); |
| 25 | } |
| 26 | |
| 27 | ~Window() |
| 28 | { |
| 29 | qApp->setStyleSheet(""); |
| 30 | Save(); |
| 31 | } |
| 32 | |
| 33 | private: |
| 34 | void LoadScript() |
| 35 | { |
| 36 | qApp->setStyleSheet(scriptEditor.toPlainText()); |
| 37 | Save(); |
| 38 | } |
| 39 | |
| 40 | void Save() |
| 41 | { |
| 42 | QTextFile(STYLE_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Truncate).write(scriptEditor.toPlainText().toUtf8()); |
| 43 | } |
| 44 | |
| 45 | QHBoxLayout layout{ this }; |
| 46 | QPlainTextEdit scriptEditor{ QTextFile(STYLE_SAVE_FILE, QIODevice::ReadOnly).readAll(), this }; |
| 47 | QPushButton loadButton{ LOAD_SCRIPT, this }; |
| 48 | } window; |
| 49 | |
| 50 | bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) |
| 51 | { |