feat: 完善插件系统;完善本地化;

This commit is contained in:
寂静的羽夏 2025-01-19 23:27:46 +08:00
parent a22e1f8f00
commit da4e576d16
7 changed files with 254 additions and 147 deletions

View File

@ -1703,7 +1703,7 @@
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3632"/> <location filename="../../src/dialog/mainwindow.cpp" line="3642"/>
<source>ConfirmAPPSave</source> <source>ConfirmAPPSave</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2171,167 +2171,172 @@
<context> <context>
<name>PluginSystem</name> <name>PluginSystem</name>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="84"/> <location filename="../../src/plugin/pluginsystem.cpp" line="72"/>
<source>LoadingPlugin</source> <source>LoadingPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="102"/> <location filename="../../src/plugin/pluginsystem.cpp" line="90"/>
<source>InvalidPluginBrokenInfo</source> <source>InvalidPluginBrokenInfo</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="604"/> <location filename="../../src/plugin/pluginsystem.cpp" line="499"/>
<source>AppClosingCanceled:</source>
<translation></translation>
</message>
<message>
<location filename="../../src/plugin/pluginsystem.cpp" line="616"/>
<source>FoundDrvPluginCount</source> <source>FoundDrvPluginCount</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="644"/> <location filename="../../src/plugin/pluginsystem.cpp" line="656"/>
<source>RegisteredFnDup</source> <source>RegisteredFnDup</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="854"/> <location filename="../../src/plugin/pluginsystem.cpp" line="870"/>
<source>ErrLoadPluginSign</source> <source>ErrLoadPluginSign</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="858"/> <location filename="../../src/plugin/pluginsystem.cpp" line="874"/>
<source>ErrLoadPluginSDKVersion</source> <source>ErrLoadPluginSDKVersion</source>
<translation> SDK </translation> <translation> SDK </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="862"/> <location filename="../../src/plugin/pluginsystem.cpp" line="878"/>
<source>ErrLoadPluginNoName</source> <source>ErrLoadPluginNoName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="887"/> <location filename="../../src/plugin/pluginsystem.cpp" line="903"/>
<source>ErrLoadInitPlugin</source> <source>ErrLoadInitPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="894"/> <location filename="../../src/plugin/pluginsystem.cpp" line="910"/>
<source>PluginName :</source> <source>PluginName :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="895"/> <location filename="../../src/plugin/pluginsystem.cpp" line="911"/>
<source>PluginAuthor :</source> <source>PluginAuthor :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="896"/> <location filename="../../src/plugin/pluginsystem.cpp" line="912"/>
<source>PluginWidgetRegister</source> <source>PluginWidgetRegister</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1000"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1016"/>
<source>ErrLoadExtPluginSign</source> <source>ErrLoadExtPluginSign</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1004"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1020"/>
<source>ErrLoadExtPluginSDKVersion</source> <source>ErrLoadExtPluginSDKVersion</source>
<translation> SDK </translation> <translation> SDK </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1008"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1024"/>
<source>ErrLoadExtPluginNoName</source> <source>ErrLoadExtPluginNoName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1011"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1027"/>
<source>ExtPluginName :</source> <source>ExtPluginName :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1012"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1028"/>
<source>ExtPluginAuthor :</source> <source>ExtPluginAuthor :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1013"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1029"/>
<source>ExtPluginWidgetRegister</source> <source>ExtPluginWidgetRegister</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1032"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1048"/>
<source>ErrLoadInitExtPlugin</source> <source>ErrLoadInitExtPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1099"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1115"/>
<source>EmptyNameDockWidget:</source> <source>EmptyNameDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1109"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1125"/>
<source>InvalidNameDockWidget:</source> <source>InvalidNameDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1117"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1133"/>
<source>InvalidNullDockWidget:</source> <source>InvalidNullDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1257"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1273"/>
<source>[EvilCall]</source> <source>[EvilCall]</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="2800"/> <location filename="../../src/plugin/pluginsystem.cpp" line="2842"/>
<source>Not allowed operation in non-UI thread</source> <source>Not allowed operation in non-UI thread</source>
<translation> UI 线</translation> <translation> UI 线</translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="626"/> <location filename="../../src/plugin/pluginsystem.cpp" line="638"/>
<source>UnsafePluginDir</source> <source>UnsafePluginDir</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="109"/> <location filename="../../src/plugin/pluginsystem.cpp" line="97"/>
<source>InvalidPluginID</source> <source>InvalidPluginID</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="112"/> <location filename="../../src/plugin/pluginsystem.cpp" line="100"/>
<source>InvalidDupPlugin</source> <source>InvalidDupPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="540"/> <location filename="../../src/plugin/pluginsystem.cpp" line="552"/>
<source>FoundPluginCount</source> <source>FoundPluginCount</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="567"/> <location filename="../../src/plugin/pluginsystem.cpp" line="579"/>
<source>PluginLoadingFailedSummary</source> <source>PluginLoadingFailedSummary</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="571"/> <location filename="../../src/plugin/pluginsystem.cpp" line="583"/>
<source>- PluginName:</source> <source>- PluginName:</source>
<translation>- </translation> <translation>- </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="572"/> <location filename="../../src/plugin/pluginsystem.cpp" line="584"/>
<source>- Dependencies:</source> <source>- Dependencies:</source>
<translation>- </translation> <translation>- </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="574"/> <location filename="../../src/plugin/pluginsystem.cpp" line="586"/>
<source>PUID:</source> <source>PUID:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="575"/> <location filename="../../src/plugin/pluginsystem.cpp" line="587"/>
<source>Version:</source> <source>Version:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="582"/> <location filename="../../src/plugin/pluginsystem.cpp" line="594"/>
<source>PluginLoadingFinished</source> <source>PluginLoadingFinished</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5330,22 +5335,22 @@ Do you wish to keep up to date by reloading the file?</source>
<translation> AngelScript API </translation> <translation> AngelScript API </translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1234"/> <location filename="../../src/class/wingangelapi.cpp" line="1239"/>
<source>RegisterScriptFnInvalidSig:</source> <source>RegisterScriptFnInvalidSig:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1256"/> <location filename="../../src/class/wingangelapi.cpp" line="1261"/>
<source>InvalidEnumName:</source> <source>InvalidEnumName:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1264"/> <location filename="../../src/class/wingangelapi.cpp" line="1269"/>
<source>InvalidEnumValue:</source> <source>InvalidEnumValue:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1529"/> <location filename="../../src/class/wingangelapi.cpp" line="1534"/>
<source>NotSupportedQMetaType:</source> <source>NotSupportedQMetaType:</source>
<translation> QT </translation> <translation> QT </translation>
</message> </message>

View File

@ -1703,7 +1703,7 @@
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3632"/> <location filename="../../src/dialog/mainwindow.cpp" line="3642"/>
<source>ConfirmAPPSave</source> <source>ConfirmAPPSave</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2171,167 +2171,172 @@
<context> <context>
<name>PluginSystem</name> <name>PluginSystem</name>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="84"/> <location filename="../../src/plugin/pluginsystem.cpp" line="72"/>
<source>LoadingPlugin</source> <source>LoadingPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="102"/> <location filename="../../src/plugin/pluginsystem.cpp" line="90"/>
<source>InvalidPluginBrokenInfo</source> <source>InvalidPluginBrokenInfo</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="604"/> <location filename="../../src/plugin/pluginsystem.cpp" line="499"/>
<source>AppClosingCanceled:</source>
<translation></translation>
</message>
<message>
<location filename="../../src/plugin/pluginsystem.cpp" line="616"/>
<source>FoundDrvPluginCount</source> <source>FoundDrvPluginCount</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="644"/> <location filename="../../src/plugin/pluginsystem.cpp" line="656"/>
<source>RegisteredFnDup</source> <source>RegisteredFnDup</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="854"/> <location filename="../../src/plugin/pluginsystem.cpp" line="870"/>
<source>ErrLoadPluginSign</source> <source>ErrLoadPluginSign</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="858"/> <location filename="../../src/plugin/pluginsystem.cpp" line="874"/>
<source>ErrLoadPluginSDKVersion</source> <source>ErrLoadPluginSDKVersion</source>
<translation> SDK </translation> <translation> SDK </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="862"/> <location filename="../../src/plugin/pluginsystem.cpp" line="878"/>
<source>ErrLoadPluginNoName</source> <source>ErrLoadPluginNoName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="887"/> <location filename="../../src/plugin/pluginsystem.cpp" line="903"/>
<source>ErrLoadInitPlugin</source> <source>ErrLoadInitPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="894"/> <location filename="../../src/plugin/pluginsystem.cpp" line="910"/>
<source>PluginName :</source> <source>PluginName :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="895"/> <location filename="../../src/plugin/pluginsystem.cpp" line="911"/>
<source>PluginAuthor :</source> <source>PluginAuthor :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="896"/> <location filename="../../src/plugin/pluginsystem.cpp" line="912"/>
<source>PluginWidgetRegister</source> <source>PluginWidgetRegister</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1000"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1016"/>
<source>ErrLoadExtPluginSign</source> <source>ErrLoadExtPluginSign</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1004"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1020"/>
<source>ErrLoadExtPluginSDKVersion</source> <source>ErrLoadExtPluginSDKVersion</source>
<translation> SDK </translation> <translation> SDK </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1008"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1024"/>
<source>ErrLoadExtPluginNoName</source> <source>ErrLoadExtPluginNoName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1011"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1027"/>
<source>ExtPluginName :</source> <source>ExtPluginName :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1012"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1028"/>
<source>ExtPluginAuthor :</source> <source>ExtPluginAuthor :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1013"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1029"/>
<source>ExtPluginWidgetRegister</source> <source>ExtPluginWidgetRegister</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1032"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1048"/>
<source>ErrLoadInitExtPlugin</source> <source>ErrLoadInitExtPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1099"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1115"/>
<source>EmptyNameDockWidget:</source> <source>EmptyNameDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1109"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1125"/>
<source>InvalidNameDockWidget:</source> <source>InvalidNameDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1117"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1133"/>
<source>InvalidNullDockWidget:</source> <source>InvalidNullDockWidget:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1257"/> <location filename="../../src/plugin/pluginsystem.cpp" line="1273"/>
<source>[EvilCall]</source> <source>[EvilCall]</source>
<translation>調</translation> <translation>調</translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="2800"/> <location filename="../../src/plugin/pluginsystem.cpp" line="2842"/>
<source>Not allowed operation in non-UI thread</source> <source>Not allowed operation in non-UI thread</source>
<translation> UI </translation> <translation> UI </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="626"/> <location filename="../../src/plugin/pluginsystem.cpp" line="638"/>
<source>UnsafePluginDir</source> <source>UnsafePluginDir</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="109"/> <location filename="../../src/plugin/pluginsystem.cpp" line="97"/>
<source>InvalidPluginID</source> <source>InvalidPluginID</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="112"/> <location filename="../../src/plugin/pluginsystem.cpp" line="100"/>
<source>InvalidDupPlugin</source> <source>InvalidDupPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="540"/> <location filename="../../src/plugin/pluginsystem.cpp" line="552"/>
<source>FoundPluginCount</source> <source>FoundPluginCount</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="567"/> <location filename="../../src/plugin/pluginsystem.cpp" line="579"/>
<source>PluginLoadingFailedSummary</source> <source>PluginLoadingFailedSummary</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="571"/> <location filename="../../src/plugin/pluginsystem.cpp" line="583"/>
<source>- PluginName:</source> <source>- PluginName:</source>
<translation>- </translation> <translation>- </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="572"/> <location filename="../../src/plugin/pluginsystem.cpp" line="584"/>
<source>- Dependencies:</source> <source>- Dependencies:</source>
<translation>- </translation> <translation>- </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="574"/> <location filename="../../src/plugin/pluginsystem.cpp" line="586"/>
<source>PUID:</source> <source>PUID:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="575"/> <location filename="../../src/plugin/pluginsystem.cpp" line="587"/>
<source>Version:</source> <source>Version:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="582"/> <location filename="../../src/plugin/pluginsystem.cpp" line="594"/>
<source>PluginLoadingFinished</source> <source>PluginLoadingFinished</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5330,22 +5335,22 @@ Do you wish to keep up to date by reloading the file?</source>
<translation> AngelScript 調 API </translation> <translation> AngelScript 調 API </translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1234"/> <location filename="../../src/class/wingangelapi.cpp" line="1239"/>
<source>RegisterScriptFnInvalidSig:</source> <source>RegisterScriptFnInvalidSig:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1256"/> <location filename="../../src/class/wingangelapi.cpp" line="1261"/>
<source>InvalidEnumName:</source> <source>InvalidEnumName:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1264"/> <location filename="../../src/class/wingangelapi.cpp" line="1269"/>
<source>InvalidEnumValue:</source> <source>InvalidEnumValue:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/class/wingangelapi.cpp" line="1529"/> <location filename="../../src/class/wingangelapi.cpp" line="1534"/>
<source>NotSupportedQMetaType:</source> <source>NotSupportedQMetaType:</source>
<translation> QT </translation> <translation> QT </translation>
</message> </message>

View File

@ -509,6 +509,11 @@ void WingAngelAPI::installHexReaderAPI(asIScriptEngine *engine) {
std::bind(&WingHex::WingPlugin::Reader::currentDocFilename, reader), std::bind(&WingHex::WingPlugin::Reader::currentDocFilename, reader),
"string currentDocFilename()"); "string currentDocFilename()");
registerAPI<bool(void)>(
engine,
std::bind(&WingHex::WingPlugin::Reader::isInsertionMode, reader),
"bool isInsertionMode()");
registerAPI<bool(void)>( registerAPI<bool(void)>(
engine, std::bind(&WingHex::WingPlugin::Reader::isReadOnly, reader), engine, std::bind(&WingHex::WingPlugin::Reader::isReadOnly, reader),
"bool isReadOnly()"); "bool isReadOnly()");

View File

@ -3600,7 +3600,17 @@ QJsonObject MainWindow::extractModelData(const QAbstractItemModel *model,
void MainWindow::closeEvent(QCloseEvent *event) { void MainWindow::closeEvent(QCloseEvent *event) {
m_isOnClosing = true; m_isOnClosing = true;
// first checking the scripting dialog
// plugin first checking
auto closing = PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::AppClosing, {});
if (!closing) {
event->ignore();
m_isOnClosing = false;
return;
}
// then checking the scripting dialog
if (!m_scriptDialog->about2Close()) { if (!m_scriptDialog->about2Close()) {
event->ignore(); event->ignore();
m_isOnClosing = false; m_isOnClosing = false;
@ -3662,6 +3672,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
set.save(); set.save();
LangService::instance().saveSnippets(); LangService::instance().saveSnippets();
PluginSystem::instance().destory();
FramelessMainWindow::closeEvent(event); FramelessMainWindow::closeEvent(event);
} }

View File

@ -107,6 +107,7 @@ signals:
// document // document
Q_REQUIRED_RESULT bool isReadOnly(); Q_REQUIRED_RESULT bool isReadOnly();
Q_REQUIRED_RESULT bool isInsertionMode();
Q_REQUIRED_RESULT bool isKeepSize(); Q_REQUIRED_RESULT bool isKeepSize();
Q_REQUIRED_RESULT bool isLocked(); Q_REQUIRED_RESULT bool isLocked();
Q_REQUIRED_RESULT qsizetype documentLines(); Q_REQUIRED_RESULT qsizetype documentLines();
@ -437,15 +438,16 @@ public:
enum class RegisteredEvent : uint { enum class RegisteredEvent : uint {
None, None,
AppReady = 1u, AppReady = 1u,
SelectionChanged = 1u << 1, AppClosing = 1u << 1,
CursorPositionChanged = 1u << 2, SelectionChanged = 1u << 2,
FileOpened = 1u << 3, CursorPositionChanged = 1u << 3,
FileSaved = 1u << 4, FileOpened = 1u << 4,
FileSwitched = 1u << 5, FileSaved = 1u << 5,
FileClosed = 1u << 6, FileSwitched = 1u << 6,
ScriptPragma = 1u << 7, FileClosed = 1u << 7,
PluginFileOpened = 1u << 8, ScriptPragma = 1u << 8,
PluginFileClosed = 1u << 9, PluginFileOpened = 1u << 9,
PluginFileClosed = 1u << 10,
}; };
Q_DECLARE_FLAGS(RegisteredEvents, RegisteredEvent) Q_DECLARE_FLAGS(RegisteredEvents, RegisteredEvent)
@ -518,6 +520,8 @@ public:
virtual void eventReady() {} virtual void eventReady() {}
virtual bool eventClosing() { return true; }
public: public:
virtual bool eventOnScriptPragma(const QStringList &comments) { virtual bool eventOnScriptPragma(const QStringList &comments) {
Q_UNUSED(comments); Q_UNUSED(comments);

View File

@ -41,20 +41,8 @@
PluginSystem::PluginSystem(QObject *parent) : QObject(parent) {} PluginSystem::PluginSystem(QObject *parent) : QObject(parent) {}
PluginSystem::~PluginSystem() { PluginSystem::~PluginSystem() {
QDir udir(Utilities::getAppDataPath()); Q_ASSERT(_loadedplgs.isEmpty());
auto plgset = QStringLiteral("plgset"); Q_ASSERT(_loadeddevs.isEmpty());
udir.mkdir(plgset);
if (!udir.cd(plgset)) {
qApp->exit(int(CrashCode::PluginSetting));
}
for (auto &item : _loadedplgs) {
auto set = std::make_unique<QSettings>(
udir.absoluteFilePath(item->metaObject()->className()),
QSettings::Format::IniFormat);
item->unload(set);
delete item;
}
} }
const QList<IWingPlugin *> &PluginSystem::plugins() const { const QList<IWingPlugin *> &PluginSystem::plugins() const {
@ -157,6 +145,15 @@ EditorView *PluginSystem::handle2EditorView(IWingPlugin *plg, int handle) {
return nullptr; return nullptr;
} }
bool PluginSystem::equalCompareHandle(const SharedUniqueId &id, int handle) {
return (*id) == handle;
}
int PluginSystem::getUIDHandle(const SharedUniqueId &id) {
Q_ASSERT(id.data());
return int(*id);
}
PluginSystem::SharedUniqueId PluginSystem::SharedUniqueId
PluginSystem::assginHandleForPluginView(IWingPlugin *plg, EditorView *view) { PluginSystem::assginHandleForPluginView(IWingPlugin *plg, EditorView *view) {
if (plg == nullptr || view == nullptr) { if (plg == nullptr || view == nullptr) {
@ -277,7 +274,8 @@ void PluginSystem::cleanUpEditorViewHandle(EditorView *view) {
handles.begin(), handles.end(), handles.begin(), handles.end(),
[view, this](const PluginFileContext &v) { [view, this](const PluginFileContext &v) {
if (v.view == view) { if (v.view == view) {
if (v.fid == m_plgCurrentfid[v.linkedplg]) { if (equalCompareHandle(v.fid,
m_plgCurrentfid[v.linkedplg])) {
m_plgCurrentfid[v.linkedplg] = -1; m_plgCurrentfid[v.linkedplg] = -1;
} }
dispatchEvent( dispatchEvent(
@ -294,12 +292,14 @@ void PluginSystem::cleanUpEditorViewHandle(EditorView *view) {
#else #else
handles.removeIf([view, this](const PluginFileContext &v) { handles.removeIf([view, this](const PluginFileContext &v) {
if (v.view == view) { if (v.view == view) {
if (v.fid == m_plgCurrentfid[v.linkedplg]) { if (equalCompareHandle(v.fid,
m_plgCurrentfid[v.linkedplg])) {
m_plgCurrentfid[v.linkedplg] = -1; m_plgCurrentfid[v.linkedplg] = -1;
} }
dispatchEvent( dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileClosed, IWingPlugin::RegisteredEvent::PluginFileClosed,
{quintptr(v.linkedplg), v.view->fileName(), int(v.fid), {quintptr(v.linkedplg), v.view->fileName(),
getUIDHandle(v.fid),
QVariant::fromValue( QVariant::fromValue(
_win->getEditorViewFileType(view))}); _win->getEditorViewFileType(view))});
return true; return true;
@ -317,7 +317,7 @@ bool PluginSystem::closeEditor(IWingPlugin *plg, int handle, bool force) {
auto &handles = m_plgviewMap[plg]; auto &handles = m_plgviewMap[plg];
auto r = std::find_if(handles.begin(), handles.end(), auto r = std::find_if(handles.begin(), handles.end(),
[handle](const PluginFileContext &d) { [handle](const PluginFileContext &d) {
return (*d.fid) == handle; return equalCompareHandle(d.fid, handle);
}); });
if (r == handles.end()) { if (r == handles.end()) {
return false; return false;
@ -347,9 +347,10 @@ bool PluginSystem::closeHandle(IWingPlugin *plg, int handle) {
return false; return false;
} }
auto &handles = m_plgviewMap[plg]; auto &handles = m_plgviewMap[plg];
auto r = std::find_if( auto r = std::find_if(handles.begin(), handles.end(),
handles.begin(), handles.end(), [handle](const PluginFileContext &d) {
[handle](const PluginFileContext &d) { return (*d.fid) == handle; }); return equalCompareHandle(d.fid, handle);
});
if (r == handles.end()) { if (r == handles.end()) {
return false; return false;
} }
@ -491,6 +492,17 @@ bool PluginSystem::dispatchEvent(IWingPlugin::RegisteredEvent event,
fileType, fileName, id, {}); fileType, fileName, id, {});
} }
} break; } break;
case WingHex::IWingPlugin::RegisteredEvent::AppClosing:
for (auto &plg : _evplgs[event]) {
auto ret = plg->eventClosing();
if (!ret) {
Logger::warning(tr("AppClosingCanceled:") + plg->pluginName() +
QStringLiteral(" (") + getPluginID(plg) +
QStringLiteral(")"));
return ret;
}
}
break;
default: default:
return false; return false;
} }
@ -695,6 +707,10 @@ void PluginSystem::registerEvents(IWingPlugin *plg) {
_evplgs[IWingPlugin::RegisteredEvent::AppReady].append(plg); _evplgs[IWingPlugin::RegisteredEvent::AppReady].append(plg);
} }
if (evs.testFlag(IWingPlugin::RegisteredEvent::AppClosing)) {
_evplgs[IWingPlugin::RegisteredEvent::AppClosing].append(plg);
}
if (evs.testFlag(IWingPlugin::RegisteredEvent::FileClosed)) { if (evs.testFlag(IWingPlugin::RegisteredEvent::FileClosed)) {
_evplgs[IWingPlugin::RegisteredEvent::FileClosed].append(plg); _evplgs[IWingPlugin::RegisteredEvent::FileClosed].append(plg);
} }
@ -1295,6 +1311,14 @@ void PluginSystem::connectReaderInterface(IWingPlugin *plg) {
} }
return QString(); return QString();
}); });
connect(preader, &WingPlugin::Reader::isInsertionMode, _win, [=]() -> bool {
auto e = pluginCurrentEditor(plg);
if (e) {
return e->hexEditor()->cursor()->insertionMode() ==
QHexCursor::InsertMode;
}
return false;
});
connect(preader, &WingPlugin::Reader::isLocked, _win, [=]() -> bool { connect(preader, &WingPlugin::Reader::isLocked, _win, [=]() -> bool {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
@ -2340,33 +2364,50 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
if (view) { if (view) {
auto id = assginHandleForPluginView(plg, view); auto id = assginHandleForPluginView(plg, view);
m_plgCurrentfid[plg] = id; m_plgCurrentfid[plg] = id;
return ErrFile(int(*id)); auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened,
{quintptr(plg),
{},
handle,
QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile(handle);
} else { } else {
return ErrFile::Error; return ErrFile::Error;
} }
}); });
connect(pctl, &WingPlugin::Controller::openWorkSpace, _win, connect(
[=](const QString &filename) -> ErrFile { pctl, &WingPlugin::Controller::openWorkSpace, _win,
if (!checkThreadAff()) { [=](const QString &filename) -> ErrFile {
return ErrFile::NotAllowedInNoneGUIThread; if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
EditorView *view = nullptr;
if (!checkPluginCanOpenedFile(plg)) {
return ErrFile::TooManyOpenedFile;
}
auto ret = _win->openWorkSpace(filename, &view);
if (view) {
if (ret == ErrFile::AlreadyOpened &&
checkPluginHasAlreadyOpened(plg, view)) {
return ErrFile::AlreadyOpened;
} }
EditorView *view = nullptr; auto id = assginHandleForPluginView(plg, view);
if (!checkPluginCanOpenedFile(plg)) { m_plgCurrentfid[plg] = id;
return ErrFile::TooManyOpenedFile; auto handle = getUIDHandle(id);
}
auto ret = _win->openWorkSpace(filename, &view); PluginSystem::instance().dispatchEvent(
if (view) { IWingPlugin::RegisteredEvent::PluginFileOpened,
if (ret == ErrFile::AlreadyOpened && {quintptr(plg), filename, handle,
checkPluginHasAlreadyOpened(plg, view)) { QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile::AlreadyOpened;
} return ErrFile(handle);
auto id = assginHandleForPluginView(plg, view); } else {
m_plgCurrentfid[plg] = id; return ret;
return ErrFile(int(*id)); }
} else { });
return ret;
}
});
connect( connect(
pctl, &WingPlugin::Controller::openFile, _win, pctl, &WingPlugin::Controller::openFile, _win,
[=](const QString &filename) -> ErrFile { [=](const QString &filename) -> ErrFile {
@ -2385,13 +2426,13 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto id = assginHandleForPluginView(plg, view); auto id = assginHandleForPluginView(plg, view);
m_plgCurrentfid[plg] = id; m_plgCurrentfid[plg] = id;
auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent( PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened, IWingPlugin::RegisteredEvent::PluginFileOpened,
{quintptr(plg), filename, int(*id), {quintptr(plg), filename, handle,
QVariant::fromValue(_win->getEditorViewFileType(view))}); QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile(int(*id)); return ErrFile(handle);
} else { } else {
return ret; return ret;
} }
@ -2416,12 +2457,13 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto id = assginHandleForPluginView(plg, view); auto id = assginHandleForPluginView(plg, view);
m_plgCurrentfid[plg] = id; m_plgCurrentfid[plg] = id;
auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent( PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened, IWingPlugin::RegisteredEvent::PluginFileOpened,
{quintptr(plg), file, int(*id), {quintptr(plg), file, handle,
QVariant::fromValue(_win->getEditorViewFileType(view))}); QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile(int(*id)); return ErrFile(handle);
} else { } else {
return ret; return ret;
} }
@ -2445,13 +2487,13 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto id = assginHandleForPluginView(plg, view); auto id = assginHandleForPluginView(plg, view);
m_plgCurrentfid[plg] = id; m_plgCurrentfid[plg] = id;
auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent( PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened, IWingPlugin::RegisteredEvent::PluginFileOpened,
{quintptr(plg), filename, int(*id), {quintptr(plg), filename, handle,
QVariant::fromValue(_win->getEditorViewFileType(view))}); QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile(int(*id)); return ErrFile(handle);
} else { } else {
return ret; return ret;
} }
@ -2474,13 +2516,13 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto id = assginHandleForPluginView(plg, view); auto id = assginHandleForPluginView(plg, view);
m_plgCurrentfid[plg] = id; m_plgCurrentfid[plg] = id;
auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent( PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened, IWingPlugin::RegisteredEvent::PluginFileOpened,
{quintptr(plg), driver, int(*id), {quintptr(plg), driver, handle,
QVariant::fromValue(_win->getEditorViewFileType(view))}); QVariant::fromValue(_win->getEditorViewFileType(view))});
return ErrFile(int(*id)); return ErrFile(handle);
} else { } else {
return ret; return ret;
} }
@ -2633,7 +2675,7 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto &maps = m_plgviewMap[plg]; auto &maps = m_plgviewMap[plg];
for (auto &item : maps) { for (auto &item : maps) {
closeEditor(plg, item.fid, true); closeEditor(plg, getUIDHandle(item.fid), true);
} }
m_plgCurrentfid[plg] = -1; m_plgCurrentfid[plg] = -1;
maps.clear(); maps.clear();
@ -2853,6 +2895,33 @@ void PluginSystem::loadAllPlugin() {
loadExtPlugin(); loadExtPlugin();
} }
void PluginSystem::destory() {
QDir udir(Utilities::getAppDataPath());
auto plgset = QStringLiteral("plgset");
udir.mkdir(plgset);
if (!udir.cd(plgset)) {
qApp->exit(int(CrashCode::PluginSetting));
}
for (auto &item : _loadedplgs) {
auto set =
std::make_unique<QSettings>(udir.absoluteFilePath(_pinfos[item].id),
QSettings::Format::IniFormat);
item->unload(set);
delete item;
}
_loadedplgs.clear();
for (auto &item : _loadeddevs) {
auto set =
std::make_unique<QSettings>(udir.absoluteFilePath(_pinfos[item].id),
QSettings::Format::IniFormat);
item->unload(set);
delete item;
}
_loadeddevs.clear();
}
EditorView *PluginSystem::pluginCurrentEditor(IWingPlugin *plg) const { EditorView *PluginSystem::pluginCurrentEditor(IWingPlugin *plg) const {
if (plg) { if (plg) {
auto fid = m_plgCurrentfid[plg]; auto fid = m_plgCurrentfid[plg];
@ -2874,9 +2943,10 @@ PluginSystem::pluginContextById(IWingPlugin *plg, int fid) const {
return std::nullopt; return std::nullopt;
} }
auto &handles = m_plgviewMap[plg]; auto &handles = m_plgviewMap[plg];
auto r = std::find_if( auto r = std::find_if(handles.begin(), handles.end(),
handles.begin(), handles.end(), [fid](const PluginFileContext &d) {
[fid](const PluginFileContext &d) { return (*d.fid) == fid; }); return equalCompareHandle(d.fid, fid);
});
if (r == handles.end()) { if (r == handles.end()) {
return std::nullopt; return std::nullopt;
} }
@ -2889,9 +2959,10 @@ PluginSystem::pluginContextByIdIt(IWingPlugin *plg, int fid) {
if (fid < 0) { if (fid < 0) {
return std::nullopt; return std::nullopt;
} }
auto r = std::find_if( auto r = std::find_if(handles.begin(), handles.end(),
handles.begin(), handles.end(), [fid](const PluginFileContext &d) {
[fid](const PluginFileContext &d) { return (*d.fid) == fid; }); return equalCompareHandle(d.fid, fid);
});
if (r == handles.end()) { if (r == handles.end()) {
return std::nullopt; return std::nullopt;
} }

View File

@ -142,6 +142,8 @@ public:
void loadAllPlugin(); void loadAllPlugin();
void unloadAllPlugin(); void unloadAllPlugin();
void destory();
const QList<IWingPlugin *> &plugins() const; const QList<IWingPlugin *> &plugins() const;
IWingPlugin *plugin(qsizetype index) const; IWingPlugin *plugin(qsizetype index) const;
@ -188,6 +190,10 @@ private:
SharedUniqueId assginHandleForPluginView(IWingPlugin *plg, SharedUniqueId assginHandleForPluginView(IWingPlugin *plg,
EditorView *view); EditorView *view);
static bool equalCompareHandle(const SharedUniqueId &id, int handle);
static int getUIDHandle(const SharedUniqueId &id);
private: private:
PluginInfo parsePluginMetadata(const QJsonObject &meta); PluginInfo parsePluginMetadata(const QJsonObject &meta);