feat: 完善插件系统和测试插件;更新上游组件;

This commit is contained in:
寂静的羽夏 2024-12-21 21:02:45 +08:00
parent 4a6febadf2
commit 542055796d
15 changed files with 840 additions and 275 deletions

@ -1 +1 @@
Subproject commit b3e7421d4a55ce85124db2e2ae712040cc758f0a Subproject commit 147afda646faa0a8b10309dd2716b961bcb54051

2
3rdparty/json vendored

@ -1 +1 @@
Subproject commit a006a7a48bb30a247f0344b788c62c2806edd90b Subproject commit 663058e7d18241338aec42846d4f77995275ccf6

2
3rdparty/qwindowkit vendored

@ -1 +1 @@
Subproject commit ba8e8a32fc6e909ad0a2c152e36b6660c01fdad5 Subproject commit 782a52020a9823bb7dc744ab20849f2558b64652

View File

@ -494,7 +494,7 @@ if(WINGHEX_USE_FRAMELESS)
QJsonModel QJsonModel
angelscript angelscript
nlohmann_json::nlohmann_json nlohmann_json::nlohmann_json
qt${QT_VERSION_MAJOR}advanceddocking) qtadvanceddocking-qt${QT_VERSION_MAJOR})
else() else()
target_link_libraries( target_link_libraries(
${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}
@ -511,7 +511,7 @@ else()
QJsonModel QJsonModel
angelscript angelscript
nlohmann_json::nlohmann_json nlohmann_json::nlohmann_json
qt${QT_VERSION_MAJOR}advanceddocking) qtadvanceddocking-qt${QT_VERSION_MAJOR})
endif() endif()
target_include_directories( target_include_directories(

View File

@ -128,7 +128,7 @@
<message> <message>
<location filename="../testform.ui" line="97"/> <location filename="../testform.ui" line="97"/>
<location filename="../testform.ui" line="194"/> <location filename="../testform.ui" line="194"/>
<location filename="../testform.ui" line="521"/> <location filename="../testform.ui" line="693"/>
<source>Text</source> <source>Text</source>
<translation> </translation> <translation> </translation>
</message> </message>
@ -142,9 +142,9 @@
<location filename="../testform.ui" line="131"/> <location filename="../testform.ui" line="131"/>
<location filename="../testform.ui" line="228"/> <location filename="../testform.ui" line="228"/>
<location filename="../testform.ui" line="293"/> <location filename="../testform.ui" line="293"/>
<location filename="../testform.ui" line="344"/> <location filename="../testform.ui" line="444"/>
<location filename="../testform.ui" line="811"/> <location filename="../testform.ui" line="983"/>
<location filename="../testform.ui" line="972"/> <location filename="../testform.ui" line="1144"/>
<source>Clear</source> <source>Clear</source>
<translation></translation> <translation></translation>
</message> </message>
@ -155,7 +155,7 @@
</message> </message>
<message> <message>
<location filename="../testform.ui" line="184"/> <location filename="../testform.ui" line="184"/>
<location filename="../testform.ui" line="558"/> <location filename="../testform.ui" line="730"/>
<source>Icon</source> <source>Icon</source>
<translation></translation> <translation></translation>
</message> </message>
@ -166,151 +166,152 @@
</message> </message>
<message> <message>
<location filename="../testform.ui" line="305"/> <location filename="../testform.ui" line="305"/>
<source>EditorAttr</source>
<translation></translation>
</message>
<message>
<location filename="../testform.ui" line="369"/>
<source>Visible</source>
<translation></translation>
</message>
<message>
<location filename="../testform.ui" line="382"/>
<source>Invisible</source>
<translation></translation>
</message>
<message>
<location filename="../testform.ui" line="405"/>
<source>Controller</source> <source>Controller</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="356"/> <location filename="../testform.ui" line="456"/>
<source>MutiFile</source> <source>MutiFile</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="368"/> <location filename="../testform.ui" line="480"/>
<source>Hangle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../testform.ui" line="391"/>
<source>Operation</source> <source>Operation</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="403"/> <location filename="../testform.ui" line="621"/>
<source>NewFile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../testform.ui" line="416"/>
<source>OpenFile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../testform.ui" line="429"/>
<source>Switch</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../testform.ui" line="442"/>
<source>CloseAll</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../testform.ui" line="449"/>
<source>Metadata</source> <source>Metadata</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="454"/> <location filename="../testform.ui" line="626"/>
<source>BookMark</source> <source>BookMark</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="459"/> <location filename="../testform.ui" line="631"/>
<location filename="../testform.ui" line="490"/> <location filename="../testform.ui" line="662"/>
<source>MessageBox</source> <source>MessageBox</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="467"/> <location filename="../testform.ui" line="639"/>
<location filename="../testform.ui" line="504"/> <location filename="../testform.ui" line="676"/>
<location filename="../testform.ui" line="681"/> <location filename="../testform.ui" line="853"/>
<source>Title</source> <source>Title</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="538"/> <location filename="../testform.ui" line="710"/>
<source>Buttons</source> <source>Buttons</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="548"/> <location filename="../testform.ui" line="720"/>
<source>DefaultButton</source> <source>DefaultButton</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="659"/> <location filename="../testform.ui" line="831"/>
<source>InputBox</source> <source>InputBox</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="674"/> <location filename="../testform.ui" line="846"/>
<source>Label</source> <source>Label</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="710"/> <location filename="../testform.ui" line="311"/>
<location filename="../testform.ui" line="884"/> <location filename="../testform.ui" line="882"/>
<location filename="../testform.ui" line="1073"/> <location filename="../testform.ui" line="1056"/>
<location filename="../testform.ui" line="1245"/>
<source>Type</source> <source>Type</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="823"/> <location filename="../testform.ui" line="469"/>
<source>Handle</source>
<translation></translation>
</message>
<message>
<location filename="../testform.ui" line="995"/>
<source>FileDialog</source> <source>FileDialog</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="838"/> <location filename="../testform.ui" line="1010"/>
<source>Filter</source> <source>Filter</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="845"/> <location filename="../testform.ui" line="1017"/>
<location filename="../testform.ui" line="998"/> <location filename="../testform.ui" line="1170"/>
<source>Caption</source> <source>Caption</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="866"/> <location filename="../testform.ui" line="1038"/>
<source>Options</source> <source>Options</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="984"/> <location filename="../testform.ui" line="1156"/>
<source>ColorDialog</source> <source>ColorDialog</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="1012"/> <location filename="../testform.ui" line="1184"/>
<source>Color</source> <source>Color</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.ui" line="1058"/> <location filename="../testform.ui" line="1230"/>
<source>DataVisual</source> <source>DataVisual</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.cpp" line="338"/> <location filename="../testform.cpp" line="345"/>
<location filename="../testform.cpp" line="348"/> <location filename="../testform.cpp" line="355"/>
<source>UpdateTextTreeError</source> <source>UpdateTextTreeError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.cpp" line="363"/> <location filename="../testform.cpp" line="370"/>
<source>UpdateTextListByModelError</source> <source>UpdateTextListByModelError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.cpp" line="373"/> <location filename="../testform.cpp" line="380"/>
<source>UpdateTextTableByModelError</source> <source>UpdateTextTableByModelError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../testform.cpp" line="384"/> <location filename="../testform.cpp" line="391"/>
<source>UpdateTextTreeByModelError</source> <source>UpdateTextTreeByModelError</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<location filename="../testform.cpp" line="492"/>
<source>Choose</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>TestPlugin</name> <name>TestPlugin</name>

View File

@ -51,6 +51,7 @@ TestForm::TestForm(WingHex::IWingPlugin *plg, QWidget *parent)
initMsgBoxCheckedBtnCombo(); initMsgBoxCheckedBtnCombo();
initMsgBoxIconCombo(); initMsgBoxIconCombo();
initFileDialogOps(); initFileDialogOps();
initFileHandleListWidget();
_click = std::bind(&TestForm::onDVClicked, this, std::placeholders::_1); _click = std::bind(&TestForm::onDVClicked, this, std::placeholders::_1);
_dblclick = _dblclick =
@ -123,6 +124,12 @@ void TestForm::initFileDialogOps() {
} }
} }
void TestForm::initFileHandleListWidget() {
auto item = new QListWidgetItem(QStringLiteral("HexEditor_Current (-1)"));
item->setData(Qt::UserRole, int(-1));
ui->lwHandle->addItem(item);
}
QMessageBox::StandardButtons TestForm::getMsgButtons() const { QMessageBox::StandardButtons TestForm::getMsgButtons() const {
QMessageBox::StandardButtons buttons = QMessageBox::StandardButtons buttons =
QMessageBox::StandardButton::NoButton; QMessageBox::StandardButton::NoButton;
@ -384,3 +391,140 @@ void TestForm::on_btnTextTreeByModel_clicked() {
tr("UpdateTextTreeByModelError")); tr("UpdateTextTreeByModelError"));
} }
} }
void TestForm::on_btnStatusVisible_clicked() {
if (ui->rbLockedFile->isChecked()) {
Q_UNUSED(emit _plg->controller.setLockedFile(true));
} else if (ui->rbAddressVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setAddressVisible(true));
} else if (ui->rbHeaderVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setHeaderVisible(true));
} else if (ui->rbKeepSize->isChecked()) {
Q_UNUSED(emit _plg->controller.setKeepSize(true));
} else if (ui->rbStringVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setStringVisible(true));
}
}
void TestForm::on_btnStatusInvisible_clicked() {
if (ui->rbLockedFile->isChecked()) {
Q_UNUSED(emit _plg->controller.setLockedFile(false));
} else if (ui->rbAddressVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setAddressVisible(false));
} else if (ui->rbHeaderVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setHeaderVisible(false));
} else if (ui->rbKeepSize->isChecked()) {
Q_UNUSED(emit _plg->controller.setKeepSize(false));
} else if (ui->rbStringVisible->isChecked()) {
Q_UNUSED(emit _plg->controller.setStringVisible(false));
}
}
void TestForm::on_btnSwitch_clicked() {
auto item = ui->lwHandle->currentItem();
auto handle = item->data(Qt::UserRole).toInt();
auto ret = emit _plg->controller.switchDocument(handle);
if (!ret) {
}
}
void TestForm::on_btnNewFile_clicked() {
auto h = emit _plg->controller.newFile();
if (h < 0) {
auto e = QMetaEnum::fromType<WingHex::ErrFile>();
emit _plg->msgbox.critical(this, QStringLiteral("Error"),
e.valueToKey(h));
} else {
auto item = new QListWidgetItem(QStringLiteral("NewFile (%1)").arg(h));
item->setData(Qt::UserRole, h);
ui->lwHandle->addItem(item);
}
}
void TestForm::on_btnOpenFile_clicked() {
auto filename =
emit _plg->filedlg.getOpenFileName(this, QStringLiteral("Test"));
if (filename.isEmpty()) {
return;
}
auto h = emit _plg->controller.openFile(filename);
if (h < 0) {
auto e = QMetaEnum::fromType<WingHex::ErrFile>();
emit _plg->msgbox.critical(this, QStringLiteral("Error"),
e.valueToKey(h));
} else {
auto item = new QListWidgetItem(QStringLiteral("%1 (%2)")
.arg(QFileInfo(filename).fileName())
.arg(h));
item->setData(Qt::UserRole, h);
ui->lwHandle->addItem(item);
}
}
void TestForm::on_btnOpenRegionFile_clicked() {
auto filename =
emit _plg->filedlg.getOpenFileName(this, QStringLiteral("Test"));
if (filename.isEmpty()) {
return;
}
auto h = emit _plg->controller.openWorkSpace(filename);
if (h < 0) {
auto e = QMetaEnum::fromType<WingHex::ErrFile>();
emit _plg->msgbox.critical(this, QStringLiteral("Error"),
e.valueToKey(h));
} else {
auto item = new QListWidgetItem(QStringLiteral("WS - %1 (%2)")
.arg(QFileInfo(filename).fileName())
.arg(h));
item->setData(Qt::UserRole, h);
ui->lwHandle->addItem(item);
}
}
void TestForm::on_btnOpenWorkSpace_clicked() {}
void TestForm::on_btnOpenDriver_clicked() {
auto drivers = emit _plg->reader.getStorageDrivers();
bool ok;
auto dr = emit _plg->inputbox.getItem(this, QStringLiteral("Test"),
tr("Choose"), drivers, 0, false, &ok);
if (!ok) {
return;
}
auto h = emit _plg->controller.openDriver(dr);
if (h < 0) {
auto e = QMetaEnum::fromType<WingHex::ErrFile>();
emit _plg->msgbox.critical(this, QStringLiteral("Error"),
e.valueToKey(h));
} else {
auto item =
new QListWidgetItem(QStringLiteral("%1 (%2)").arg(dr).arg(h));
item->setData(Qt::UserRole, h);
ui->lwHandle->addItem(item);
}
}
void TestForm::on_btnSaveFile_clicked() {}
void TestForm::on_btnSaveAsFile_clicked() {}
void TestForm::on_btnExportFile_clicked() {}
void TestForm::on_btnCloseFile_clicked() {
auto item = ui->lwHandle->currentItem();
auto handle = item->data(Qt::UserRole).toInt();
auto ret = emit _plg->controller.closeFile(handle);
if (ret == WingHex::ErrFile::Success) {
if (handle >= 0) {
ui->lwHandle->removeItemWidget(item);
delete item;
}
} else {
auto e = QMetaEnum::fromType<WingHex::ErrFile>();
emit _plg->msgbox.critical(this, QStringLiteral("Error"),
e.valueToKey(ret));
}
}

View File

@ -101,6 +101,30 @@ private slots:
void on_btnTextTreeByModel_clicked(); void on_btnTextTreeByModel_clicked();
void on_btnStatusVisible_clicked();
void on_btnStatusInvisible_clicked();
void on_btnSwitch_clicked();
void on_btnNewFile_clicked();
void on_btnOpenFile_clicked();
void on_btnOpenRegionFile_clicked();
void on_btnOpenWorkSpace_clicked();
void on_btnOpenDriver_clicked();
void on_btnSaveFile_clicked();
void on_btnSaveAsFile_clicked();
void on_btnExportFile_clicked();
void on_btnCloseFile_clicked();
private: private:
void initLogCombo(); void initLogCombo();
@ -114,6 +138,8 @@ private:
void initFileDialogOps(); void initFileDialogOps();
void initFileHandleListWidget();
private: private:
QMessageBox::StandardButtons getMsgButtons() const; QMessageBox::StandardButtons getMsgButtons() const;

View File

@ -23,7 +23,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">
@ -300,6 +300,106 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_12">
<attribute name="title">
<string>EditorAttr</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Type</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item>
<widget class="QRadioButton" name="rbLockedFile">
<property name="text">
<string notr="true">LockedFile</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbKeepSize">
<property name="text">
<string notr="true">KeepSize</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbStringVisible">
<property name="text">
<string notr="true">StringVisible</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAddressVisible">
<property name="text">
<string notr="true">AddressVisible</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbHeaderVisible">
<property name="text">
<string notr="true">HeaderVisible</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="btnStatusVisible">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStatusInvisible">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Invisible</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
<attribute name="title"> <attribute name="title">
<string>Controller</string> <string>Controller</string>
@ -355,94 +455,166 @@
<attribute name="title"> <attribute name="title">
<string>MutiFile</string> <string>MutiFile</string>
</attribute> </attribute>
<widget class="QLabel" name="label_14"> <layout class="QVBoxLayout" name="verticalLayout_24">
<property name="geometry"> <item>
<rect> <widget class="QSplitter" name="splitter_3">
<x>40</x> <property name="orientation">
<y>30</y> <enum>Qt::Horizontal</enum>
<width>40</width> </property>
<height>12</height> <widget class="QWidget" name="layoutWidget">
</rect> <layout class="QVBoxLayout" name="verticalLayout_23">
</property> <item>
<property name="text"> <widget class="QLabel" name="label_14">
<string>Hangle</string> <property name="text">
</property> <string>Handle</string>
</widget> </property>
<widget class="QListWidget" name="listWidget"> </widget>
<property name="geometry"> </item>
<rect> <item>
<x>40</x> <widget class="QListWidget" name="lwHandle"/>
<y>50</y> </item>
<width>211</width> </layout>
<height>191</height> </widget>
</rect> <widget class="QGroupBox" name="groupBox_7">
</property> <property name="title">
</widget> <string>Operation</string>
<widget class="QGroupBox" name="groupBox_7"> </property>
<property name="geometry"> <layout class="QVBoxLayout" name="verticalLayout_22">
<rect> <item>
<x>290</x> <widget class="QPushButton" name="btnSwitch">
<y>30</y> <property name="minimumSize">
<width>241</width> <size>
<height>211</height> <width>0</width>
</rect> <height>25</height>
</property> </size>
<property name="title"> </property>
<string>Operation</string> <property name="text">
</property> <string notr="true">Switch</string>
<widget class="QPushButton" name="pushButton"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>20</x> <item>
<y>60</y> <widget class="QPushButton" name="btnNewFile">
<width>171</width> <property name="minimumSize">
<height>21</height> <size>
</rect> <width>0</width>
</property> <height>25</height>
<property name="text"> </size>
<string>NewFile</string> </property>
</property> <property name="text">
</widget> <string notr="true">NewFile</string>
<widget class="QPushButton" name="pushButton_2"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>20</x> <item>
<y>90</y> <widget class="QPushButton" name="btnOpenFile">
<width>171</width> <property name="minimumSize">
<height>21</height> <size>
</rect> <width>0</width>
</property> <height>25</height>
<property name="text"> </size>
<string>OpenFile</string> </property>
</property> <property name="text">
</widget> <string notr="true">OpenFile</string>
<widget class="QPushButton" name="pushButton_3"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>20</x> <item>
<y>30</y> <widget class="QPushButton" name="btnOpenRegionFile">
<width>171</width> <property name="minimumSize">
<height>21</height> <size>
</rect> <width>0</width>
</property> <height>25</height>
<property name="text"> </size>
<string>Switch</string> </property>
</property> <property name="text">
</widget> <string notr="true">OpenRegionFile</string>
<widget class="QPushButton" name="pushButton_4"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>20</x> <item>
<y>120</y> <widget class="QPushButton" name="btnOpenWorkSpace">
<width>171</width> <property name="minimumSize">
<height>21</height> <size>
</rect> <width>0</width>
</property> <height>25</height>
<property name="text"> </size>
<string>CloseAll</string> </property>
</property> <property name="text">
</widget> <string notr="true">OpenWorkSpace</string>
</widget> </property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOpenDriver">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string notr="true">OpenDriver</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSaveFile">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string notr="true">SaveFile</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSaveAsFile">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string notr="true">SaveAsFile</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnExportFile">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string notr="true">ExportFile</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCloseFile">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string notr="true">Close</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget> </widget>
<widget class="QWidget" name="tab_10"> <widget class="QWidget" name="tab_10">
<attribute name="title"> <attribute name="title">

View File

@ -1613,12 +1613,12 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3061"/> <location filename="../../src/dialog/mainwindow.cpp" line="3074"/>
<source>ConfirmSave</source> <source>ConfirmSave</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3102"/> <location filename="../../src/dialog/mainwindow.cpp" line="3115"/>
<source>ConfirmAPPSave</source> <source>ConfirmAPPSave</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1992,57 +1992,62 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="310"/> <location filename="../../src/plugin/pluginsystem.cpp" line="217"/>
<source>RegisteredFnDup</source>
<translation></translation>
</message>
<message>
<location filename="../../src/plugin/pluginsystem.cpp" line="340"/>
<source>ErrLoadPluginSign</source> <source>ErrLoadPluginSign</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="314"/> <location filename="../../src/plugin/pluginsystem.cpp" line="344"/>
<source>ErrLoadPluginSDKVersion</source> <source>ErrLoadPluginSDKVersion</source>
<translation> SDK </translation> <translation> SDK </translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="318"/> <location filename="../../src/plugin/pluginsystem.cpp" line="348"/>
<source>ErrLoadPluginNoName</source> <source>ErrLoadPluginNoName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="323"/> <location filename="../../src/plugin/pluginsystem.cpp" line="353"/>
<source>ErrLoadLoadedPlugin</source> <source>ErrLoadLoadedPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="343"/> <location filename="../../src/plugin/pluginsystem.cpp" line="373"/>
<source>ErrLoadInitPlugin</source> <source>ErrLoadInitPlugin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="350"/> <location filename="../../src/plugin/pluginsystem.cpp" line="380"/>
<source>PluginName :</source> <source>PluginName :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="351"/> <location filename="../../src/plugin/pluginsystem.cpp" line="381"/>
<source>PluginAuthor :</source> <source>PluginAuthor :</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="352"/> <location filename="../../src/plugin/pluginsystem.cpp" line="382"/>
<source>PluginWidgetRegister</source> <source>PluginWidgetRegister</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1878"/> <location filename="../../src/plugin/pluginsystem.cpp" line="2060"/>
<source>Creating UI widget is not allowed in non-UI thread</source> <source>Not allowed operation in non-UI thread</source>
<translation>线</translation> <translation> UI 线</translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1929"/> <location filename="../../src/plugin/pluginsystem.cpp" line="2111"/>
<source>FoundPluginCount</source> <source>FoundPluginCount</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/plugin/pluginsystem.cpp" line="1942"/> <location filename="../../src/plugin/pluginsystem.cpp" line="2124"/>
<source>PluginLoadingFinished</source> <source>PluginLoadingFinished</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2500,17 +2505,17 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="193"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="201"/>
<source>List All Tabs</source> <source>List All Tabs</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="204"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="212"/>
<source>Detach Group</source> <source>Detach Group</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="231"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="239"/>
<source>Minimize</source> <source>Minimize</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5065,42 +5070,42 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>ads::CAutoHideTab</name> <name>ads::CAutoHideTab</name>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="383"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="394"/>
<source>Detach</source> <source>Detach</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="388"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="399"/>
<source>Pin To...</source> <source>Pin To...</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="390"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="401"/>
<source>Top</source> <source>Top</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="391"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="402"/>
<source>Left</source> <source>Left</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="392"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="403"/>
<source>Right</source> <source>Right</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="393"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="404"/>
<source>Bottom</source> <source>Bottom</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="395"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="406"/>
<source>Unpin (Dock)</source> <source>Unpin (Dock)</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="397"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/AutoHideTab.cpp" line="408"/>
<source>Close</source> <source>Close</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5108,83 +5113,83 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>ads::CDockAreaTitleBar</name> <name>ads::CDockAreaTitleBar</name>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="774"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="801"/>
<source>Detach</source> <source>Detach</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="774"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="801"/>
<source>Detach Group</source> <source>Detach Group</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="779"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="806"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="836"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="862"/>
<source>Unpin (Dock)</source> <source>Unpin (Dock)</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="779"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="806"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="841"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="867"/>
<source>Pin Group</source> <source>Pin Group</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="785"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="812"/>
<source>Pin Group To...</source> <source>Pin Group To...</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="787"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="814"/>
<source>Top</source> <source>Top</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="788"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="815"/>
<source>Left</source> <source>Left</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="789"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="816"/>
<source>Right</source> <source>Right</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="790"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="817"/>
<source>Bottom</source> <source>Bottom</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="798"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="825"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="853"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="879"/>
<source>Minimize</source> <source>Minimize</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="799"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="826"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="803"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="830"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="853"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="879"/>
<source>Close</source> <source>Close</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="803"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="830"/>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="862"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="888"/>
<source>Close Group</source> <source>Close Group</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="809"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="836"/>
<source>Close Other Groups</source> <source>Close Other Groups</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="845"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="871"/>
<source>Pin Active Tab (Press Ctrl to Pin Group)</source> <source>Pin Active Tab (Press Ctrl to Pin Group)</source>
<translation> Ctrl </translation> <translation> Ctrl </translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="858"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockAreaTitleBar.cpp" line="884"/>
<source>Close Active Tab</source> <source>Close Active Tab</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5192,7 +5197,7 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>ads::CDockManager</name> <name>ads::CDockManager</name>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockManager.cpp" line="513"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockManager.cpp" line="518"/>
<source>Show View</source> <source>Show View</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5200,47 +5205,47 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>ads::CDockWidgetTab</name> <name>ads::CDockWidgetTab</name>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="543"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="551"/>
<source>Detach</source> <source>Detach</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="547"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="555"/>
<source>Pin</source> <source>Pin</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="551"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="559"/>
<source>Pin To...</source> <source>Pin To...</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="553"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="561"/>
<source>Top</source> <source>Top</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="554"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="562"/>
<source>Left</source> <source>Left</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="555"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="563"/>
<source>Right</source> <source>Right</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="556"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="564"/>
<source>Bottom</source> <source>Bottom</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="561"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="569"/>
<source>Close</source> <source>Close</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="565"/> <location filename="../../3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp" line="573"/>
<source>Close Others</source> <source>Close Others</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -1115,7 +1115,7 @@ void WingAngelAPI::installHexControllerAPI(asIScriptEngine *engine) {
registerAPI<void()>( registerAPI<void()>(
engine, engine,
std::bind(&WingHex::WingPlugin::Controller::closeAllPluginFiles, ctl), std::bind(&WingHex::WingPlugin::Controller::closeAllPluginFiles, ctl),
"void closeAllPluginFiles()"); "bool closeAllPluginFiles()");
engine->SetDefaultNamespace(""); engine->SetDefaultNamespace("");
} }

View File

@ -347,7 +347,7 @@ void MainWindow::buildUpDockSystem(QWidget *container) {
qApp->processEvents(); qApp->processEvents();
CDockWidget *CentralDockWidget = CDockWidget *CentralDockWidget =
new CDockWidget(QStringLiteral("CentralWidget")); m_dock->createDockWidget(QStringLiteral("CentralWidget"));
CentralDockWidget->setWidget(label); CentralDockWidget->setWidget(label);
CentralDockWidget->setFeature(ads::CDockWidget::DockWidgetFocusable, false); CentralDockWidget->setFeature(ads::CDockWidget::DockWidgetFocusable, false);
CentralDockWidget->setFeature(ads::CDockWidget::NoTab, true); CentralDockWidget->setFeature(ads::CDockWidget::NoTab, true);
@ -2517,7 +2517,7 @@ ads::CDockWidget *MainWindow::buildDockWidget(ads::CDockManager *dock,
QWidget *content, QWidget *content,
ToolButtonIndex index) { ToolButtonIndex index) {
using namespace ads; using namespace ads;
auto dw = new CDockWidget(displayName, dock); auto dw = dock->createDockWidget(displayName, dock);
dw->setObjectName(widgetName); dw->setObjectName(widgetName);
dw->setFeatures(CDockWidget::DockWidgetMovable | dw->setFeatures(CDockWidget::DockWidgetMovable |
CDockWidget::DockWidgetClosable | CDockWidget::DockWidgetClosable |
@ -2775,10 +2775,10 @@ void MainWindow::openFiles(const QStringList &files) {
ErrFile MainWindow::openFile(const QString &file, EditorView **editor) { ErrFile MainWindow::openFile(const QString &file, EditorView **editor) {
auto e = findEditorView(file); auto e = findEditorView(file);
if (editor) {
*editor = e;
}
if (e) { if (e) {
if (editor) {
*editor = e;
}
return ErrFile::AlreadyOpened; return ErrFile::AlreadyOpened;
} }
@ -2800,16 +2800,19 @@ ErrFile MainWindow::openFile(const QString &file, EditorView **editor) {
m_views.insert(ev, QString()); m_views.insert(ev, QString());
registerEditorView(ev); registerEditorView(ev);
if (editor) {
*editor = ev;
}
m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea()); m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea());
return ErrFile::Success; return ErrFile::Success;
} }
ErrFile MainWindow::openDriver(const QString &driver, EditorView **editor) { ErrFile MainWindow::openDriver(const QString &driver, EditorView **editor) {
auto e = findEditorView(driver); auto e = findEditorView(driver);
if (editor) {
*editor = e;
}
if (e) { if (e) {
if (editor) {
*editor = e;
}
return ErrFile::AlreadyOpened; return ErrFile::AlreadyOpened;
} }
@ -2828,16 +2831,20 @@ ErrFile MainWindow::openDriver(const QString &driver, EditorView **editor) {
m_views.insert(ev, QString()); m_views.insert(ev, QString());
registerEditorView(ev); registerEditorView(ev);
if (editor) {
*editor = ev;
}
m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea()); m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea());
return ErrFile::Success; return ErrFile::Success;
} }
ErrFile MainWindow::openWorkSpace(const QString &file, EditorView **editor) { ErrFile MainWindow::openWorkSpace(const QString &file, EditorView **editor) {
auto e = findEditorView(file); auto e = findEditorView(file);
if (editor) {
*editor = e;
}
if (e) { if (e) {
if (editor) {
*editor = e;
}
return ErrFile::AlreadyOpened; return ErrFile::AlreadyOpened;
} }
@ -2859,6 +2866,9 @@ ErrFile MainWindow::openWorkSpace(const QString &file, EditorView **editor) {
m_views.insert(ev, file); m_views.insert(ev, file);
registerEditorView(ev); registerEditorView(ev);
if (editor) {
*editor = ev;
}
m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea()); m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea());
return ErrFile::Success; return ErrFile::Success;
} }
@ -2866,10 +2876,10 @@ ErrFile MainWindow::openWorkSpace(const QString &file, EditorView **editor) {
ErrFile MainWindow::openRegionFile(QString file, EditorView **editor, ErrFile MainWindow::openRegionFile(QString file, EditorView **editor,
qsizetype start, qsizetype length) { qsizetype start, qsizetype length) {
auto e = findEditorView(file); auto e = findEditorView(file);
if (editor) {
*editor = e;
}
if (e) { if (e) {
if (editor) {
*editor = e;
}
return ErrFile::AlreadyOpened; return ErrFile::AlreadyOpened;
} }
@ -2890,6 +2900,9 @@ ErrFile MainWindow::openRegionFile(QString file, EditorView **editor,
} }
registerEditorView(ev); registerEditorView(ev);
if (editor) {
*editor = ev;
}
m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea()); m_dock->addDockWidget(ads::CenterDockWidgetArea, ev, editorViewArea());
return ErrFile::Success; return ErrFile::Success;
} }

View File

@ -16,9 +16,9 @@
*/ */
#include "scriptingdialog.h" #include "scriptingdialog.h"
#include "DockSplitter.h"
#include "QWingRibbon/ribbontabcontent.h" #include "QWingRibbon/ribbontabcontent.h"
#include "Qt-Advanced-Docking-System/src/DockAreaWidget.h" #include "Qt-Advanced-Docking-System/src/DockAreaWidget.h"
#include "Qt-Advanced-Docking-System/src/DockSplitter.h"
#include "aboutsoftwaredialog.h" #include "aboutsoftwaredialog.h"
#include "class/langservice.h" #include "class/langservice.h"
#include "class/languagemanager.h" #include "class/languagemanager.h"
@ -679,7 +679,7 @@ void ScriptingDialog::buildUpDockSystem(QWidget *container) {
label->setPicture(backimg); label->setPicture(backimg);
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
CDockWidget *CentralDockWidget = CDockWidget *CentralDockWidget =
new CDockWidget(QStringLiteral("CentralWidget")); m_dock->createDockWidget(QStringLiteral("CentralWidget"));
CentralDockWidget->setWidget(label); CentralDockWidget->setWidget(label);
CentralDockWidget->setFeature(ads::CDockWidget::DockWidgetFocusable, false); CentralDockWidget->setFeature(ads::CDockWidget::DockWidgetFocusable, false);
CentralDockWidget->setFeature(ads::CDockWidget::NoTab, true); CentralDockWidget->setFeature(ads::CDockWidget::NoTab, true);
@ -730,7 +730,7 @@ ads::CDockWidget *ScriptingDialog::buildDockWidget(ads::CDockManager *dock,
QWidget *content, QWidget *content,
ToolButtonIndex index) { ToolButtonIndex index) {
using namespace ads; using namespace ads;
auto dw = new CDockWidget(displayName, dock); auto dw = dock->createDockWidget(displayName, dock);
dw->setObjectName(widgetName); dw->setObjectName(widgetName);
dw->setFeatures(CDockWidget::DockWidgetMovable | dw->setFeatures(CDockWidget::DockWidgetMovable |
CDockWidget::DockWidgetClosable | CDockWidget::DockWidgetClosable |

View File

@ -75,7 +75,8 @@ enum ErrFile : int {
SourceFileChanged = -9, SourceFileChanged = -9,
ClonedFile = -10, ClonedFile = -10,
InvalidFormat = -11, InvalidFormat = -11,
TooManyOpenedFile = -12 TooManyOpenedFile = -12,
NotAllowedInNoneGUIThread = -13
}; };
Q_ENUM_NS(ErrFile) Q_ENUM_NS(ErrFile)
@ -287,7 +288,7 @@ signals:
Q_REQUIRED_RESULT bool setCurrentEncoding(const QString &encoding); Q_REQUIRED_RESULT bool setCurrentEncoding(const QString &encoding);
// extension // extension
void closeAllPluginFiles(); bool closeAllPluginFiles();
}; };
class MessageBox : public QObject { class MessageBox : public QObject {

View File

@ -112,38 +112,33 @@ EditorView *PluginSystem::handle2EditorView(IWingPlugin *plg, int handle) {
return nullptr; return nullptr;
} }
PluginSystem::UniqueId PluginSystem::SharedUniqueId
PluginSystem::assginHandleForPluginView(IWingPlugin *plg, EditorView *view) { PluginSystem::assginHandleForPluginView(IWingPlugin *plg, EditorView *view) {
if (plg == nullptr || view == nullptr) { if (plg == nullptr || view == nullptr) {
return {}; return {};
} }
if (m_plgHandles.contains(plg)) {
auto id = m_idGen.get(); auto id = m_idGen.get();
m_plgHandles[plg].append(qMakePair(id, view)); m_plgHandles[plg].append(qMakePair(id, view));
m_viewBindings[view].append(plg); m_viewBindings[view].append(plg);
return id; return id;
}
return {};
} }
bool PluginSystem::checkPluginCanOpenedFile(IWingPlugin *plg) { bool PluginSystem::checkPluginCanOpenedFile(IWingPlugin *plg) {
if (plg == nullptr) { if (plg == nullptr) {
return false; return false;
} }
if (m_plgHandles.contains(plg)) { return m_plgHandles[plg].size() <= UCHAR_MAX;
return m_plgHandles.value(plg).size() <= RAND_MAX;
}
return false;
} }
bool PluginSystem::checkPluginHasAlreadyOpened(IWingPlugin *plg, bool PluginSystem::checkPluginHasAlreadyOpened(IWingPlugin *plg,
EditorView *view) { EditorView *view) {
auto &maps = m_plgHandles[plg]; auto &maps = m_plgHandles[plg];
auto ret = auto ret = std::find_if(
std::find_if(maps.begin(), maps.end(), maps.begin(), maps.end(),
[view](const QPair<UniqueId, EditorView *> &content) { [view](const QPair<SharedUniqueId, EditorView *> &content) {
return content.second == view; return content.second == view;
}); });
return ret != maps.end(); return ret != maps.end();
} }
@ -171,6 +166,41 @@ void PluginSystem::cleanUpEditorViewHandle(EditorView *view) {
} }
} }
bool PluginSystem::closeEditor(IWingPlugin *plg, int handle, bool force) {
if (handle >= 0) {
auto &handles = m_plgHandles[plg];
auto r = std::find_if(
handles.begin(), handles.end(),
[handle](const QPair<SharedUniqueId, EditorView *> &d) {
return (*d.first) == handle;
});
if (r == handles.end()) {
return false;
}
auto &bind = m_viewBindings[r->second];
bind.removeOne(plg);
if (bind.isEmpty()) {
_win->closeEditor(r->second, force);
}
} else {
if (_win->m_curEditor == nullptr) {
return false;
}
auto &bind = m_viewBindings[_win->m_curEditor];
bind.removeOne(plg);
if (bind.isEmpty()) {
_win->closeEditor(_win->m_curEditor, force);
}
}
m_plgviewMap.remove(plg);
m_plgHandles.remove(plg);
return true;
}
void PluginSystem::registerFns(IWingPlugin *plg) { void PluginSystem::registerFns(IWingPlugin *plg) {
Q_ASSERT(plg); Q_ASSERT(plg);
auto fns = plg->registeredScriptFn(); auto fns = plg->registeredScriptFn();
@ -184,7 +214,7 @@ void PluginSystem::registerFns(IWingPlugin *plg) {
auto &fn = p->second; auto &fn = p->second;
auto sig = getScriptFnSig(p->first, fn); auto sig = getScriptFnSig(p->first, fn);
if (rfns.find(sig) != rfns.end()) { if (rfns.find(sig) != rfns.end()) {
Logger::warning(tr("")); Logger::warning(tr("RegisteredFnDup"));
continue; continue;
} }
rfns.insert(sig, p->second); rfns.insert(sig, p->second);
@ -508,6 +538,9 @@ void PluginSystem::connectLoadingInterface(IWingPlugin *plg) {
void PluginSystem::connectBaseInterface(IWingPlugin *plg) { void PluginSystem::connectBaseInterface(IWingPlugin *plg) {
connect(plg, &IWingPlugin::toast, this, connect(plg, &IWingPlugin::toast, this,
[=](const QPixmap &icon, const QString &message) { [=](const QPixmap &icon, const QString &message) {
if (!checkThreadAff()) {
return;
}
if (message.isEmpty()) { if (message.isEmpty()) {
return; return;
} }
@ -532,6 +565,9 @@ void PluginSystem::connectBaseInterface(IWingPlugin *plg) {
}); });
connect(plg, &IWingPlugin::createDialog, this, connect(plg, &IWingPlugin::createDialog, this,
[=](QWidget *w) -> QDialog * { [=](QWidget *w) -> QDialog * {
if (!checkThreadAff()) {
return nullptr;
}
if (w) { if (w) {
auto d = new FramelessDialogBase; auto d = new FramelessDialogBase;
d->buildUpContent(w); d->buildUpContent(w);
@ -752,7 +788,9 @@ void PluginSystem::connectReaderInterface(IWingPlugin *plg) {
[=](qsizetype offset, qsizetype len) -> QByteArray { [=](qsizetype offset, qsizetype len) -> QByteArray {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->document()->read(offset, len); _rwlock.lockForRead();
auto ret = e->hexEditor()->document()->read(offset, len);
return ret;
} }
return {}; return {};
}); });
@ -785,6 +823,7 @@ void PluginSystem::connectReaderInterface(IWingPlugin *plg) {
[=](qsizetype offset, const QString &encoding) -> QString { [=](qsizetype offset, const QString &encoding) -> QString {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
_rwlock.lockForRead();
auto hexeditor = e->hexEditor(); auto hexeditor = e->hexEditor();
auto doc = hexeditor->document(); auto doc = hexeditor->document();
auto render = hexeditor->renderer(); auto render = hexeditor->renderer();
@ -802,6 +841,7 @@ void PluginSystem::connectReaderInterface(IWingPlugin *plg) {
enco = render->encoding(); enco = render->encoding();
} }
_rwlock.unlock();
return toByteArray(buffer, enco); return toByteArray(buffer, enco);
} }
return QString(); return QString();
@ -905,6 +945,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto pctl = &plg->controller; auto pctl = &plg->controller;
connect(pctl, &WingPlugin::Controller::switchDocument, _win, connect(pctl, &WingPlugin::Controller::switchDocument, _win,
[=](int handle) -> bool { [=](int handle) -> bool {
if (!checkThreadAff()) {
return false;
}
if (handle < 0) { if (handle < 0) {
m_plgviewMap[plg] = nullptr; m_plgviewMap[plg] = nullptr;
} else { } else {
@ -923,6 +966,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::raiseDocument, _win, connect(pctl, &WingPlugin::Controller::raiseDocument, _win,
[=](int handle) -> bool { [=](int handle) -> bool {
if (!checkThreadAff()) {
return false;
}
if (handle < 0) { if (handle < 0) {
auto cur = _win->m_curEditor; auto cur = _win->m_curEditor;
if (cur) { if (cur) {
@ -946,6 +993,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setLockedFile, _win, connect(pctl, &WingPlugin::Controller::setLockedFile, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->document()->setLockedFile(b); return e->hexEditor()->document()->setLockedFile(b);
@ -954,6 +1004,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setKeepSize, _win, connect(pctl, &WingPlugin::Controller::setKeepSize, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->document()->setKeepSize(b); return e->hexEditor()->document()->setKeepSize(b);
@ -962,6 +1015,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setStringVisible, _win, connect(pctl, &WingPlugin::Controller::setStringVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->setAsciiVisible(b); e->hexEditor()->setAsciiVisible(b);
@ -971,6 +1027,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setHeaderVisible, _win, connect(pctl, &WingPlugin::Controller::setHeaderVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->setHeaderVisible(b); e->hexEditor()->setHeaderVisible(b);
@ -980,6 +1039,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setAddressVisible, _win, connect(pctl, &WingPlugin::Controller::setAddressVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->setAddressVisible(b); e->hexEditor()->setAddressVisible(b);
@ -989,6 +1051,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setAddressBase, _win, connect(pctl, &WingPlugin::Controller::setAddressBase, _win,
[=](quintptr base) -> bool { [=](quintptr base) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->setAddressBase(base); e->hexEditor()->setAddressBase(base);
@ -1000,7 +1065,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
[=](qsizetype offset, const QByteArray &data) -> bool { [=](qsizetype offset, const QByteArray &data) -> bool {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->document()->insert(offset, data); _rwlock.lockForWrite();
auto ret = e->hexEditor()->document()->insert(offset, data);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1008,7 +1076,11 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
[=](qsizetype offset, const QByteArray &data) -> bool { [=](qsizetype offset, const QByteArray &data) -> bool {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->document()->replace(offset, data); _rwlock.lockForWrite();
auto ret =
e->hexEditor()->document()->replace(offset, data);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1053,7 +1125,11 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto unicode = toByteArray(value, enco); auto unicode = toByteArray(value, enco);
return doc->insert(offset, unicode);
_rwlock.lockForWrite();
auto ret = doc->insert(offset, unicode);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1098,7 +1174,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto unicode = toByteArray(value, enco); auto unicode = toByteArray(value, enco);
return doc->replace(offset, unicode); _rwlock.lockForWrite();
auto ret = doc->replace(offset, unicode);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1142,7 +1221,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
auto unicode = toByteArray(value, enco); auto unicode = toByteArray(value, enco);
return doc->insert(offset, unicode); _rwlock.lockForWrite();
auto ret = doc->insert(offset, unicode);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1152,7 +1234,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
return doc->remove(offset, len); _rwlock.lockForWrite();
auto ret = doc->remove(offset, len);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1161,7 +1246,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
auto len = doc->length(); auto len = doc->length();
return doc->remove(0, len); _rwlock.lockForWrite();
auto ret = doc->remove(0, len);
_rwlock.unlock();
return ret;
} }
return false; return false;
}); });
@ -1171,6 +1259,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
_win, _win,
[=](qsizetype line, qsizetype column, int nibbleindex, [=](qsizetype line, qsizetype column, int nibbleindex,
bool clearSelection) -> bool { bool clearSelection) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->cursor()->moveTo(line, column, nibbleindex, e->hexEditor()->cursor()->moveTo(line, column, nibbleindex,
@ -1182,6 +1273,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect(pctl, connect(pctl,
QOverload<qsizetype, bool>::of(&WingPlugin::Controller::moveTo), QOverload<qsizetype, bool>::of(&WingPlugin::Controller::moveTo),
_win, [=](qsizetype offset, bool clearSelection) -> bool { _win, [=](qsizetype offset, bool clearSelection) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->cursor()->moveTo(offset, clearSelection); e->hexEditor()->cursor()->moveTo(offset, clearSelection);
@ -1192,6 +1286,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect( connect(
pctl, &WingPlugin::Controller::select, _win, pctl, &WingPlugin::Controller::select, _win,
[=](qsizetype offset, qsizetype length, SelectionMode mode) -> bool { [=](qsizetype offset, qsizetype length, SelectionMode mode) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto cursor = e->hexEditor()->cursor(); auto cursor = e->hexEditor()->cursor();
@ -1215,6 +1312,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setInsertionMode, _win, connect(pctl, &WingPlugin::Controller::setInsertionMode, _win,
[=](bool isinsert) -> bool { [=](bool isinsert) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
e->hexEditor()->cursor()->setInsertionMode( e->hexEditor()->cursor()->setInsertionMode(
@ -1230,6 +1330,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
_win, _win,
[=](qsizetype begin, qusizetype length, const QColor &fgcolor, [=](qsizetype begin, qusizetype length, const QColor &fgcolor,
const QColor &bgcolor, const QString &comment) -> bool { const QColor &bgcolor, const QString &comment) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1244,6 +1347,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
_win, _win,
[=](qsizetype begin, qusizetype length, const QColor &fgcolor, [=](qsizetype begin, qusizetype length, const QColor &fgcolor,
const QColor &bgcolor, const QString &comment) -> bool { const QColor &bgcolor, const QString &comment) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1254,6 +1360,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::removeMetadata, _win, connect(pctl, &WingPlugin::Controller::removeMetadata, _win,
[=](qsizetype offset) -> bool { [=](qsizetype offset) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1263,6 +1372,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
return false; return false;
}); });
connect(pctl, &WingPlugin::Controller::clearMetadata, _win, [=]() -> bool { connect(pctl, &WingPlugin::Controller::clearMetadata, _win, [=]() -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1274,6 +1386,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect(pctl, &WingPlugin::Controller::comment, _win, connect(pctl, &WingPlugin::Controller::comment, _win,
[=](qsizetype begin, qusizetype length, [=](qsizetype begin, qusizetype length,
const QString &comment) -> bool { const QString &comment) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1285,6 +1400,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect( connect(
pctl, &WingPlugin::Controller::foreground, _win, pctl, &WingPlugin::Controller::foreground, _win,
[=](qsizetype begin, qusizetype length, const QColor &fgcolor) -> bool { [=](qsizetype begin, qusizetype length, const QColor &fgcolor) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1296,6 +1414,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect( connect(
pctl, &WingPlugin::Controller::background, _win, pctl, &WingPlugin::Controller::background, _win,
[=](qsizetype begin, qusizetype length, const QColor &bgcolor) -> bool { [=](qsizetype begin, qusizetype length, const QColor &bgcolor) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1306,6 +1427,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setMetaVisible, _win, connect(pctl, &WingPlugin::Controller::setMetaVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1318,6 +1442,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setMetafgVisible, _win, connect(pctl, &WingPlugin::Controller::setMetafgVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1328,6 +1455,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setMetabgVisible, _win, connect(pctl, &WingPlugin::Controller::setMetabgVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1338,6 +1468,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setMetaCommentVisible, _win, connect(pctl, &WingPlugin::Controller::setMetaCommentVisible, _win,
[=](bool b) -> bool { [=](bool b) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1348,6 +1481,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::setCurrentEncoding, _win, connect(pctl, &WingPlugin::Controller::setCurrentEncoding, _win,
[=](const QString &encoding) -> bool { [=](const QString &encoding) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
return e->hexEditor()->renderer()->setEncoding(encoding); return e->hexEditor()->renderer()->setEncoding(encoding);
@ -1357,6 +1493,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect(pctl, &WingPlugin::Controller::addBookMark, _win, connect(pctl, &WingPlugin::Controller::addBookMark, _win,
[=](qsizetype pos, const QString &comment) -> bool { [=](qsizetype pos, const QString &comment) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1366,6 +1505,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::modBookMark, _win, connect(pctl, &WingPlugin::Controller::modBookMark, _win,
[=](qsizetype pos, const QString &comment) -> bool { [=](qsizetype pos, const QString &comment) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1375,6 +1517,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::removeBookMark, _win, connect(pctl, &WingPlugin::Controller::removeBookMark, _win,
[=](qsizetype pos) -> bool { [=](qsizetype pos) -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1383,6 +1528,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
return false; return false;
}); });
connect(pctl, &WingPlugin::Controller::clearBookMark, _win, [=]() -> bool { connect(pctl, &WingPlugin::Controller::clearBookMark, _win, [=]() -> bool {
if (!checkThreadAff()) {
return false;
}
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
@ -1393,6 +1541,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
// mainwindow // mainwindow
connect(pctl, &WingPlugin::Controller::newFile, _win, [=]() -> ErrFile { connect(pctl, &WingPlugin::Controller::newFile, _win, [=]() -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
if (!checkPluginCanOpenedFile(plg)) { if (!checkPluginCanOpenedFile(plg)) {
return ErrFile::TooManyOpenedFile; return ErrFile::TooManyOpenedFile;
} }
@ -1407,6 +1558,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::openWorkSpace, _win, connect(pctl, &WingPlugin::Controller::openWorkSpace, _win,
[=](const QString &filename) -> ErrFile { [=](const QString &filename) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
EditorView *view = nullptr; EditorView *view = nullptr;
if (!checkPluginCanOpenedFile(plg)) { if (!checkPluginCanOpenedFile(plg)) {
return ErrFile::TooManyOpenedFile; return ErrFile::TooManyOpenedFile;
@ -1426,6 +1580,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::openFile, _win, connect(pctl, &WingPlugin::Controller::openFile, _win,
[=](const QString &filename) -> ErrFile { [=](const QString &filename) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
EditorView *view = nullptr; EditorView *view = nullptr;
if (!checkPluginCanOpenedFile(plg)) { if (!checkPluginCanOpenedFile(plg)) {
return ErrFile::TooManyOpenedFile; return ErrFile::TooManyOpenedFile;
@ -1446,6 +1603,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect(pctl, &WingPlugin::Controller::openRegionFile, _win, connect(pctl, &WingPlugin::Controller::openRegionFile, _win,
[=](const QString &filename, qsizetype start, [=](const QString &filename, qsizetype start,
qsizetype length) -> ErrFile { qsizetype length) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
EditorView *view = nullptr; EditorView *view = nullptr;
if (!checkPluginCanOpenedFile(plg)) { if (!checkPluginCanOpenedFile(plg)) {
return ErrFile::TooManyOpenedFile; return ErrFile::TooManyOpenedFile;
@ -1465,6 +1625,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::openDriver, _win, connect(pctl, &WingPlugin::Controller::openDriver, _win,
[=](const QString &driver) -> ErrFile { [=](const QString &driver) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
EditorView *view = nullptr; EditorView *view = nullptr;
auto ret = _win->openDriver(driver, &view); auto ret = _win->openDriver(driver, &view);
if (!checkPluginCanOpenedFile(plg)) { if (!checkPluginCanOpenedFile(plg)) {
@ -1484,15 +1647,19 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::closeFile, _win, connect(pctl, &WingPlugin::Controller::closeFile, _win,
[=](int handle, bool force) -> ErrFile { [=](int handle, bool force) -> ErrFile {
auto view = handle2EditorView(plg, handle); if (!checkThreadAff()) {
if (view) { return ErrFile::NotAllowedInNoneGUIThread;
_win->closeEditor(view, force); }
if (closeEditor(plg, handle, force)) {
return ErrFile::Success; return ErrFile::Success;
} }
return ErrFile::NotExist; return ErrFile::NotExist;
}); });
connect(pctl, &WingPlugin::Controller::saveFile, _win, connect(pctl, &WingPlugin::Controller::saveFile, _win,
[=](int handle, bool ignoreMd5) -> ErrFile { [=](int handle, bool ignoreMd5) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
auto view = handle2EditorView(plg, handle); auto view = handle2EditorView(plg, handle);
if (view) { if (view) {
_win->saveEditor(view, {}, ignoreMd5); _win->saveEditor(view, {}, ignoreMd5);
@ -1503,6 +1670,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect( connect(
pctl, &WingPlugin::Controller::exportFile, _win, pctl, &WingPlugin::Controller::exportFile, _win,
[=](int handle, const QString &savename, bool ignoreMd5) -> ErrFile { [=](int handle, const QString &savename, bool ignoreMd5) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
auto view = handle2EditorView(plg, handle); auto view = handle2EditorView(plg, handle);
if (view) { if (view) {
_win->saveEditor(view, savename, ignoreMd5, true); _win->saveEditor(view, savename, ignoreMd5, true);
@ -1514,6 +1684,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect( connect(
pctl, &WingPlugin::Controller::saveAsFile, _win, pctl, &WingPlugin::Controller::saveAsFile, _win,
[=](int handle, const QString &savename, bool ignoreMd5) -> ErrFile { [=](int handle, const QString &savename, bool ignoreMd5) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
auto view = handle2EditorView(plg, handle); auto view = handle2EditorView(plg, handle);
if (view) { if (view) {
_win->saveEditor(view, savename, ignoreMd5); _win->saveEditor(view, savename, ignoreMd5);
@ -1524,6 +1697,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
connect(pctl, &WingPlugin::Controller::closeCurrentFile, _win, connect(pctl, &WingPlugin::Controller::closeCurrentFile, _win,
[=](bool force) -> ErrFile { [=](bool force) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
auto view = getCurrentPluginView(plg); auto view = getCurrentPluginView(plg);
if (view == nullptr) { if (view == nullptr) {
return ErrFile::NotExist; return ErrFile::NotExist;
@ -1533,6 +1709,9 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::saveCurrentFile, _win, connect(pctl, &WingPlugin::Controller::saveCurrentFile, _win,
[=](bool ignoreMd5) -> ErrFile { [=](bool ignoreMd5) -> ErrFile {
if (!checkThreadAff()) {
return ErrFile::NotAllowedInNoneGUIThread;
}
auto view = getCurrentPluginView(plg); auto view = getCurrentPluginView(plg);
if (view) { if (view) {
auto ws = _win->m_views.value(view); auto ws = _win->m_views.value(view);
@ -1544,7 +1723,10 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}); });
connect(pctl, &WingPlugin::Controller::closeAllPluginFiles, _win, connect(pctl, &WingPlugin::Controller::closeAllPluginFiles, _win,
[=]() -> void { [=]() -> bool {
if (!checkThreadAff()) {
return false;
}
auto &maps = m_plgHandles[plg]; auto &maps = m_plgHandles[plg];
for (auto &item : maps) { for (auto &item : maps) {
auto &bind = m_viewBindings[item.second]; auto &bind = m_viewBindings[item.second];
@ -1555,6 +1737,7 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
} }
m_plgviewMap.remove(plg); m_plgviewMap.remove(plg);
m_plgHandles.remove(plg); m_plgHandles.remove(plg);
return true;
}); });
} }
@ -1874,8 +2057,7 @@ void PluginSystem::connectUIInterface(IWingPlugin *plg) {
bool PluginSystem::checkThreadAff() { bool PluginSystem::checkThreadAff() {
if (QThread::currentThread() != qApp->thread()) { if (QThread::currentThread() != qApp->thread()) {
Logger::warning( Logger::warning(tr("Not allowed operation in non-UI thread"));
tr("Creating UI widget is not allowed in non-UI thread"));
return false; return false;
} }
return true; return true;

View File

@ -88,7 +88,8 @@ private:
QQueue<int> releasedIds; QQueue<int> releasedIds;
}; };
using UniqueId = QExplicitlySharedDataPointer<UniqueIdGenerator::UniqueId>; using SharedUniqueId =
QExplicitlySharedDataPointer<UniqueIdGenerator::UniqueId>;
public: public:
static PluginSystem &instance(); static PluginSystem &instance();
@ -109,7 +110,8 @@ public:
EditorView *handle2EditorView(IWingPlugin *plg, int handle); EditorView *handle2EditorView(IWingPlugin *plg, int handle);
UniqueId assginHandleForPluginView(IWingPlugin *plg, EditorView *view); SharedUniqueId assginHandleForPluginView(IWingPlugin *plg,
EditorView *view);
bool checkPluginCanOpenedFile(IWingPlugin *plg); bool checkPluginCanOpenedFile(IWingPlugin *plg);
@ -117,6 +119,8 @@ public:
void cleanUpEditorViewHandle(EditorView *view); void cleanUpEditorViewHandle(EditorView *view);
bool closeEditor(IWingPlugin *plg, int handle, bool force);
private: private:
void registerFns(IWingPlugin *plg); void registerFns(IWingPlugin *plg);
@ -150,10 +154,15 @@ private:
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>); Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
_rwlock.lockForRead();
auto buffer = e->hexEditor()->document()->read(offset, sizeof(T)); auto buffer = e->hexEditor()->document()->read(offset, sizeof(T));
auto pb = reinterpret_cast<const T *>(buffer.constData()); if (buffer.size() == sizeof(T)) {
return *pb; auto pb = reinterpret_cast<const T *>(buffer.constData());
_rwlock.unlock();
return *pb;
}
} }
if constexpr (std::is_floating_point_v<T>) { if constexpr (std::is_floating_point_v<T>) {
return qQNaN(); return qQNaN();
} else { } else {
@ -167,9 +176,12 @@ private:
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>); Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
_rwlock.lockForWrite();
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
auto buffer = reinterpret_cast<const char *>(&value); auto buffer = reinterpret_cast<const char *>(&value);
return doc->insert(offset, QByteArray(buffer, sizeof(T))); auto ret = doc->insert(offset, QByteArray(buffer, sizeof(T)));
_rwlock.unlock();
return ret;
} }
return false; return false;
} }
@ -180,9 +192,12 @@ private:
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>); Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
_rwlock.lockForWrite();
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
auto buffer = reinterpret_cast<const char *>(&value); auto buffer = reinterpret_cast<const char *>(&value);
return doc->replace(offset, QByteArray(buffer, sizeof(T))); auto ret = doc->replace(offset, QByteArray(buffer, sizeof(T)));
_rwlock.unlock();
return ret;
} }
return false; return false;
} }
@ -192,11 +207,14 @@ private:
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>); Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
auto e = pluginCurrentEditor(plg); auto e = pluginCurrentEditor(plg);
if (e) { if (e) {
_rwlock.lockForWrite();
auto doc = e->hexEditor()->document(); auto doc = e->hexEditor()->document();
auto offset = doc->length(); auto offset = doc->length();
auto buffer = reinterpret_cast<const char *>(&value); auto buffer = reinterpret_cast<const char *>(&value);
QByteArray data(buffer, sizeof(T)); QByteArray data(buffer, sizeof(T));
return doc->insert(offset, data); auto ret = doc->insert(offset, data);
_rwlock.unlock();
return ret;
} }
return false; return false;
} }
@ -213,15 +231,18 @@ private:
QStringList loadedpuid; QStringList loadedpuid;
QList<IWingPlugin *> loadedplgs; QList<IWingPlugin *> loadedplgs;
QMap<IWingPlugin *, EditorView *> m_plgviewMap; QHash<IWingPlugin *, EditorView *> m_plgviewMap;
QMap<IWingPlugin *, QList<QPair<UniqueId, EditorView *>>> m_plgHandles; QHash<IWingPlugin *, QList<QPair<SharedUniqueId, EditorView *>>>
QMap<EditorView *, QList<IWingPlugin *>> m_viewBindings; m_plgHandles;
QHash<EditorView *, QList<IWingPlugin *>> m_viewBindings;
UniqueIdGenerator m_idGen; UniqueIdGenerator m_idGen;
QHash<QString, QHash<QString, WingAngelAPI::ScriptFnInfo>> _scfns; QHash<QString, QHash<QString, WingAngelAPI::ScriptFnInfo>> _scfns;
WingAngelAPI *_angelplg = nullptr; WingAngelAPI *_angelplg = nullptr;
QReadWriteLock _rwlock;
}; };
#endif // PLUGINSYSTEM_H #endif // PLUGINSYSTEM_H