add styler extension
This commit is contained in:
parent
dcff7e550c
commit
662ca45321
@ -17,6 +17,7 @@ add_library(Remove\ Repeated\ Phrases MODULE removerepeatphrase.cpp extensionimp
|
|||||||
add_library(Remove\ Repeated\ Phrases\ 2 MODULE removerepeatphrase2.cpp extensionimpl.cpp)
|
add_library(Remove\ Repeated\ Phrases\ 2 MODULE removerepeatphrase2.cpp extensionimpl.cpp)
|
||||||
add_library(Remove\ 30\ Repeated\ Sentences MODULE removerepeatsentence.cpp extensionimpl.cpp)
|
add_library(Remove\ 30\ Repeated\ Sentences MODULE removerepeatsentence.cpp extensionimpl.cpp)
|
||||||
add_library(Replacer MODULE replacer.cpp extensionimpl.cpp)
|
add_library(Replacer MODULE replacer.cpp extensionimpl.cpp)
|
||||||
|
add_library(Styler MODULE styler.cpp extensionimpl.cpp)
|
||||||
add_library(Thread\ Linker MODULE threadlinker.cpp extensionimpl.cpp)
|
add_library(Thread\ Linker MODULE threadlinker.cpp extensionimpl.cpp)
|
||||||
|
|
||||||
target_precompile_headers(Bing\ Translate REUSE_FROM pch)
|
target_precompile_headers(Bing\ Translate REUSE_FROM pch)
|
||||||
@ -33,6 +34,7 @@ target_precompile_headers(Remove\ Repeated\ Phrases REUSE_FROM pch)
|
|||||||
target_precompile_headers(Remove\ Repeated\ Phrases\ 2 REUSE_FROM pch)
|
target_precompile_headers(Remove\ Repeated\ Phrases\ 2 REUSE_FROM pch)
|
||||||
target_precompile_headers(Remove\ 30\ Repeated\ Sentences REUSE_FROM pch)
|
target_precompile_headers(Remove\ 30\ Repeated\ Sentences REUSE_FROM pch)
|
||||||
target_precompile_headers(Replacer REUSE_FROM pch)
|
target_precompile_headers(Replacer REUSE_FROM pch)
|
||||||
|
target_precompile_headers(Styler REUSE_FROM pch)
|
||||||
target_precompile_headers(Thread\ Linker REUSE_FROM pch)
|
target_precompile_headers(Thread\ Linker REUSE_FROM pch)
|
||||||
|
|
||||||
target_link_libraries(Bing\ Translate winhttp Qt5::Widgets)
|
target_link_libraries(Bing\ Translate winhttp Qt5::Widgets)
|
||||||
@ -42,6 +44,7 @@ target_link_libraries(Extra\ Window Qt5::Widgets)
|
|||||||
target_link_libraries(Google\ Translate winhttp Qt5::Widgets)
|
target_link_libraries(Google\ Translate winhttp Qt5::Widgets)
|
||||||
target_link_libraries(Lua lua53 Qt5::Widgets)
|
target_link_libraries(Lua lua53 Qt5::Widgets)
|
||||||
target_link_libraries(Regex\ Filter Qt5::Widgets)
|
target_link_libraries(Regex\ Filter Qt5::Widgets)
|
||||||
|
target_link_libraries(Styler Qt5::Widgets)
|
||||||
target_link_libraries(Thread\ Linker Qt5::Widgets)
|
target_link_libraries(Thread\ Linker Qt5::Widgets)
|
||||||
|
|
||||||
if (NOT EXISTS ${CMAKE_FINAL_OUTPUT_DIRECTORY}/Qt5WebSockets.dll AND NOT EXISTS ${CMAKE_FINAL_OUTPUT_DIRECTORY}/Qt5WebSocketsd.dll)
|
if (NOT EXISTS ${CMAKE_FINAL_OUTPUT_DIRECTORY}/Qt5WebSockets.dll AND NOT EXISTS ${CMAKE_FINAL_OUTPUT_DIRECTORY}/Qt5WebSocketsd.dll)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
extern const char* LUA_INTRO;
|
extern const char* LUA_INTRO;
|
||||||
extern const char* LOAD_LUA_SCRIPT;
|
extern const char* LOAD_SCRIPT;
|
||||||
extern const wchar_t* LUA_ERROR;
|
extern const wchar_t* LUA_ERROR;
|
||||||
|
|
||||||
constexpr auto LUA_SAVE_FILE = u8"Textractor.lua";
|
constexpr auto LUA_SAVE_FILE = u8"Textractor.lua";
|
||||||
@ -81,7 +81,7 @@ private:
|
|||||||
|
|
||||||
QHBoxLayout layout{ this };
|
QHBoxLayout layout{ this };
|
||||||
QPlainTextEdit scriptEditor{ QTextFile(LUA_SAVE_FILE, QIODevice::ReadOnly).readAll(), this };
|
QPlainTextEdit scriptEditor{ QTextFile(LUA_SAVE_FILE, QIODevice::ReadOnly).readAll(), this };
|
||||||
QPushButton loadButton{ LOAD_LUA_SCRIPT, this };
|
QPushButton loadButton{ LOAD_SCRIPT, this };
|
||||||
} window;
|
} window;
|
||||||
|
|
||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
|
56
extensions/styler.cpp
Normal file
56
extensions/styler.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "qtcommon.h"
|
||||||
|
#include "extension.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
|
extern const char* LOAD_SCRIPT;
|
||||||
|
|
||||||
|
constexpr auto STYLE_SAVE_FILE = u8"Textractor.css";
|
||||||
|
|
||||||
|
class Window : public QDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Window()
|
||||||
|
: QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
||||||
|
{
|
||||||
|
Localize();
|
||||||
|
connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript);
|
||||||
|
|
||||||
|
if (scriptEditor.toPlainText().isEmpty()) scriptEditor.setPlainText("/*https://doc.qt.io/qt-5/stylesheet-syntax.html*/");
|
||||||
|
layout.addWidget(&scriptEditor);
|
||||||
|
layout.addWidget(&loadButton);
|
||||||
|
|
||||||
|
resize(800, 600);
|
||||||
|
setWindowTitle("Styler");
|
||||||
|
QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
LoadScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
~Window()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
10
text.cpp
10
text.cpp
@ -204,7 +204,7 @@ Properties in sentenceInfo:
|
|||||||
function ProcessSentence(sentence, sentenceInfo)
|
function ProcessSentence(sentence, sentenceInfo)
|
||||||
--Your code here...
|
--Your code here...
|
||||||
end)";
|
end)";
|
||||||
const char* LOAD_LUA_SCRIPT = u8"Load script";
|
const char* LOAD_SCRIPT = u8"Load script";
|
||||||
const wchar_t* LUA_ERROR = L"Lua error: %s";
|
const wchar_t* LUA_ERROR = L"Lua error: %s";
|
||||||
const char* REGEX_FILTER = u8"Regex Filter";
|
const char* REGEX_FILTER = u8"Regex Filter";
|
||||||
const char* INVALID_REGEX = u8"Invalid regex";
|
const char* INVALID_REGEX = u8"Invalid regex";
|
||||||
@ -454,7 +454,7 @@ sentenceInfo有以下成员:
|
|||||||
function ProcessSentence(sentence, sentenceInfo)
|
function ProcessSentence(sentence, sentenceInfo)
|
||||||
--在此处添加你的代码...
|
--在此处添加你的代码...
|
||||||
end)";
|
end)";
|
||||||
LOAD_LUA_SCRIPT = u8"加载脚本";
|
LOAD_SCRIPT = u8"加载脚本";
|
||||||
LUA_ERROR = L"Lua 错误";
|
LUA_ERROR = L"Lua 错误";
|
||||||
REGEX_FILTER = u8"正则表达式过滤器";
|
REGEX_FILTER = u8"正则表达式过滤器";
|
||||||
INVALID_REGEX = u8"无效的正则表达式";
|
INVALID_REGEX = u8"无效的正则表达式";
|
||||||
@ -648,7 +648,7 @@ Param sentenceInfo: таблица различной информации о п
|
|||||||
function ProcessSentence(sentence, sentenceInfo)
|
function ProcessSentence(sentence, sentenceInfo)
|
||||||
--Ваш код здесь...
|
--Ваш код здесь...
|
||||||
end)";
|
end)";
|
||||||
LOAD_LUA_SCRIPT = u8"Загрузить скрипт";
|
LOAD_SCRIPT = u8"Загрузить скрипт";
|
||||||
LUA_ERROR = L"Ошибка Lua: %s";
|
LUA_ERROR = L"Ошибка Lua: %s";
|
||||||
REGEX_FILTER = u8"Фильтр Regex";
|
REGEX_FILTER = u8"Фильтр Regex";
|
||||||
INVALID_REGEX = u8"Неверный regex";
|
INVALID_REGEX = u8"Неверный regex";
|
||||||
@ -908,7 +908,7 @@ Proprietà in sentenceInfo:
|
|||||||
function ProcessSentence(sentence, sentenceInfo)
|
function ProcessSentence(sentence, sentenceInfo)
|
||||||
--Tuo codice qui...
|
--Tuo codice qui...
|
||||||
end)";
|
end)";
|
||||||
LOAD_LUA_SCRIPT = u8"Carica script";
|
LOAD_SCRIPT = u8"Carica script";
|
||||||
LUA_ERROR = L"Errore Lua: %s";
|
LUA_ERROR = L"Errore Lua: %s";
|
||||||
REGEX_FILTER = u8"Filtro regex";
|
REGEX_FILTER = u8"Filtro regex";
|
||||||
INVALID_REGEX = u8"Regex non valido";
|
INVALID_REGEX = u8"Regex non valido";
|
||||||
@ -1323,7 +1323,7 @@ Properties in sentenceInfo:
|
|||||||
function ProcessSentence(sentence, sentenceInfo)
|
function ProcessSentence(sentence, sentenceInfo)
|
||||||
--Your code here...
|
--Your code here...
|
||||||
end)";
|
end)";
|
||||||
LOAD_LUA_SCRIPT = u8"Charger le script";
|
LOAD_SCRIPT = u8"Charger le script";
|
||||||
LUA_ERROR = L"Erreur Lua: %s";
|
LUA_ERROR = L"Erreur Lua: %s";
|
||||||
REGEX_FILTER = u8"Filtre regex";
|
REGEX_FILTER = u8"Filtre regex";
|
||||||
INVALID_REGEX = u8"Regex invalide";
|
INVALID_REGEX = u8"Regex invalide";
|
||||||
|
Loading…
Reference in New Issue
Block a user