Textractor/extensions/styler.cpp

55 lines
1.3 KiB
C++
Raw Normal View History

2021-01-15 09:53:57 -07:00
#include "qtcommon.h"
#include "extension.h"
#include <QPlainTextEdit>
extern const char* LOAD_SCRIPT;
2022-09-10 20:01:48 -04:00
constexpr auto STYLE_SAVE_FILE = u8"Textractor.qss";
2021-01-15 09:53:57 -07:00
class Window : public QDialog, Localizer
2021-01-15 09:53:57 -07:00
{
public:
2021-01-30 12:07:37 -07:00
Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
2021-01-15 09:53:57 -07:00
{
connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript);
2022-09-10 20:01:48 -04:00
if (scriptEditor.toPlainText().isEmpty())
scriptEditor.setPlainText("/*\nhttps://www.google.com/search?q=Qt+stylesheet+gallery\nhttps://doc.qt.io/qt-5/stylesheet-syntax.html\n*/");
2021-01-15 09:53:57 -07:00
layout.addWidget(&scriptEditor);
layout.addWidget(&loadButton);
resize(800, 600);
setWindowTitle("Styler");
QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
LoadScript();
}
~Window()
{
2021-01-30 12:07:37 -07:00
qApp->setStyleSheet("");
2021-01-15 09:53:57 -07:00
Save();
}
private:
void LoadScript()
{
qApp->setStyleSheet(scriptEditor.toPlainText());
Save();
}
void Save()
{
QTextFile(STYLE_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Truncate).write(scriptEditor.toPlainText().toUtf8());
}
QHBoxLayout layout{ this };
QPlainTextEdit scriptEditor{ QTextFile(STYLE_SAVE_FILE, QIODevice::ReadOnly).readAll(), this };
QPushButton loadButton{ LOAD_SCRIPT, this };
} window;
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
return false;
}