2024-04-21 17:38:47 +08:00
|
|
|
#include "qtcommon.h"
|
|
|
|
#include "extension.h"
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
|
|
|
extern const char* LOAD_SCRIPT;
|
|
|
|
|
|
|
|
constexpr auto STYLE_SAVE_FILE = u8"Textractor.qss";
|
|
|
|
|
|
|
|
class Window : public QDialog, Localizer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
|
|
|
{
|
|
|
|
connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript);
|
|
|
|
|
|
|
|
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*/");
|
|
|
|
layout.addWidget(&scriptEditor);
|
|
|
|
layout.addWidget(&loadButton);
|
|
|
|
|
|
|
|
resize(800, 600);
|
|
|
|
setWindowTitle("Styler");
|
2024-04-24 09:04:02 +08:00
|
|
|
//QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
|
2024-04-21 17:38:47 +08:00
|
|
|
|
|
|
|
LoadScript();
|
|
|
|
}
|
|
|
|
|
|
|
|
~Window()
|
|
|
|
{
|
|
|
|
qApp->setStyleSheet("");
|
|
|
|
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;
|
|
|
|
}
|
2024-04-24 09:04:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport) void VisSetting(bool vis)
|
|
|
|
{
|
|
|
|
if(vis)
|
|
|
|
QMetaObject::invokeMethod(&window, &QWidget::show, Qt::QueuedConnection);
|
|
|
|
else
|
|
|
|
QMetaObject::invokeMethod(&window, &QWidget::hide, Qt::QueuedConnection);
|
|
|
|
}
|