Skip to content

Commit 606e55c

Browse files
committed
fix: 插件函数重命名;完善插件系统;
1 parent 58cabdf commit 606e55c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2742
-2004
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(CMAKE_AUTORCC ON)
88

99
set(CMAKE_CXX_STANDARD 17)
1010
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11-
set(PROJECT_VERSION "2.1.0")
11+
set(PROJECT_VERSION "2.2.0")
1212

1313
find_package(
1414
QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent
@@ -165,8 +165,6 @@ set(DIALOG_SRC
165165
src/dialog/colorpickerdialog.h
166166
src/dialog/colorpickerdialog.cpp
167167
src/dialog/colorpickerdialog.ui
168-
src/dialog/showtextdialog.h
169-
src/dialog/showtextdialog.cpp
170168
src/dialog/splashdialog.ui
171169
src/dialog/splashdialog.cpp
172170
src/dialog/splashdialog.h

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
  如果你想将本软件的代码用于闭源的商业代码,想要解除`GPL`系列的必须开源的限制,请必须亲自咨询我,商讨商业授权相关事宜。
111111

112-
  对于插件开发相关的,对应的开源协议就不一样了。只针对本仓库下的`src/plugin/iwingplugin.h``src/plugin/iwingpluginbase.h``src/plugin/iwingdevice.h``src/plugin/settingpage.h`遵守`BSD 3-Clause`协议,以允许想要做闭源和商业开发。对于本仓库下的`TestPlugin`的代码(除`TranslationUtils.cmake`这一个文件遵守`BSD 3-Clause`)遵守`MIT`协议。
112+
  对于插件开发相关的,对应的开源协议就不一样了。只针对本仓库下的`WingPlugin`的代码遵守`BSD 3-Clause`协议,以允许闭源商业开发。对于本仓库下的`TestPlugin`的代码(除`TranslationUtils.cmake`这一个文件遵守`BSD 3-Clause`)遵守`MIT`协议。
113113

114114
### 使用声明
115115

README_en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ This software complies with the `AGPL-3.0` agreement. Please do not use it for p
109109

110110
If you want to use the code of this software for closed-source commercial code and want to lift the restriction of the `GPL` series that it must be open source, please consult me ​​in person to discuss commercial licensing matters.
111111

112-
For plugin development, the corresponding open source agreements are different. Only `src/plugin/iwingplugin.h`, `src/plugin/iwingpluginbase.h`, `src/plugin/iwingdevice.h` and `src/plugin/settingpage.h` in this repository comply with the `BSD 3-Clause` agreement to allow closed-source and commercial development. The code of `TestPlugin` in this repository (except the file `TranslationUtils.cmake` which complies with `BSD 3-Clause`) complies with the `MIT` agreement.
112+
For plugin development, the corresponding open source agreements are different. Only the code of `WingPlugin` in this repository comply with the `BSD 3-Clause` agreement to allow closed-source commercial development. The code of `TestPlugin` in this repository (except the file `TranslationUtils.cmake` which complies with `BSD 3-Clause`) complies with the `MIT` agreement.
113113

114114
### Usage Statement
115115

ShareMemoryDrv/sharememorydrv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ QIcon SharedMemoryDriver::supportedFileIcon() const {
6868

6969
QString SharedMemoryDriver::onOpenFileBegin() {
7070
bool ok;
71-
auto id = getText(nullptr, tr("SharedMemory"), tr("PleaseInputID:"),
72-
QLineEdit::Normal, {}, &ok);
71+
auto id = dlgGetText(nullptr, tr("SharedMemory"), tr("PleaseInputID:"),
72+
QLineEdit::Normal, {}, &ok);
7373
if (!ok) {
7474
return {};
7575
}

TestPlugin/ctltestform.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323

2424
CtlTestForm::CtlTestForm(WingHex::IWingPlugin *plg, QTextBrowser *br,
2525
QWidget *parent)
26-
: QWidget(parent), WingHex::IWingPluginAPICalls(plg),
27-
ui(new Ui::CtlTestForm), _plg(plg), _br(br) {
26+
: WingHex::WingPluginWidget(plg, parent), ui(new Ui::CtlTestForm), _br(br) {
2827
ui->setupUi(this);
2928
}
3029

3130
CtlTestForm::~CtlTestForm() { delete ui; }
3231

3332
void CtlTestForm::on_btnInt8_clicked() {
3433
bool ok;
35-
auto ret = getInt(this, QStringLiteral("Test"), tr("PleaseInputInt8"), 0,
36-
INT8_MIN, UINT8_MAX, 1, &ok);
34+
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt8"), 0,
35+
INT8_MIN, UINT8_MAX, 1, &ok);
3736
if (ok) {
3837
auto buffer = qint8(ret);
3938
if (ui->rbInsert->isChecked()) {
@@ -56,8 +55,8 @@ void CtlTestForm::on_btnInt8_clicked() {
5655

5756
void CtlTestForm::on_btnInt16_clicked() {
5857
bool ok;
59-
auto ret = getInt(this, QStringLiteral("Test"), tr("PleaseInputInt16"), 0,
60-
INT16_MIN, UINT16_MAX, 1, &ok);
58+
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt16"),
59+
0, INT16_MIN, UINT16_MAX, 1, &ok);
6160
if (ok) {
6261
auto buffer = qint16(ret);
6362
if (ui->rbInsert->isChecked()) {
@@ -80,8 +79,8 @@ void CtlTestForm::on_btnInt16_clicked() {
8079

8180
void CtlTestForm::on_btnInt32_clicked() {
8281
bool ok;
83-
auto ret = getInt(this, QStringLiteral("Test"), tr("PleaseInputInt32"), 0,
84-
INT32_MIN, INT32_MAX, 1, &ok);
82+
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt32"),
83+
0, INT32_MIN, INT32_MAX, 1, &ok);
8584
if (ok) {
8685
auto buffer = qint32(ret);
8786
if (ui->rbInsert->isChecked()) {
@@ -104,8 +103,8 @@ void CtlTestForm::on_btnInt32_clicked() {
104103

105104
void CtlTestForm::on_btnInt64_clicked() {
106105
bool ok;
107-
auto ret = getText(this, QStringLiteral("Test"), tr("PleaseInputInt64"),
108-
QLineEdit::Normal, QStringLiteral("0"), &ok);
106+
auto ret = dlgGetText(this, QStringLiteral("Test"), tr("PleaseInputInt64"),
107+
QLineEdit::Normal, QStringLiteral("0"), &ok);
109108
if (ok) {
110109
auto buffer = qint64(ret.toULongLong(&ok));
111110
if (ok) {
@@ -131,8 +130,9 @@ void CtlTestForm::on_btnInt64_clicked() {
131130
void CtlTestForm::on_btnFloat_clicked() {
132131
bool ok;
133132
auto limit = std::numeric_limits<float>();
134-
auto ret = getDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"),
135-
0, limit.min(), limit.max(), 0.0, &ok);
133+
auto ret =
134+
dlgGetDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0,
135+
limit.min(), limit.max(), 0.0, &ok);
136136
if (ok) {
137137
auto buffer = float(ret);
138138
if (ui->rbInsert->isChecked()) {
@@ -156,8 +156,9 @@ void CtlTestForm::on_btnFloat_clicked() {
156156
void CtlTestForm::on_btnDouble_clicked() {
157157
bool ok;
158158
auto limit = std::numeric_limits<double>();
159-
auto ret = getDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"),
160-
0, limit.min(), limit.max(), 0.0, &ok);
159+
auto ret =
160+
dlgGetDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0,
161+
limit.min(), limit.max(), 0.0, &ok);
161162
if (ok) {
162163
auto buffer = double(ret);
163164
if (ui->rbInsert->isChecked()) {
@@ -180,8 +181,9 @@ void CtlTestForm::on_btnDouble_clicked() {
180181

181182
void CtlTestForm::on_btnString_clicked() {
182183
bool ok;
183-
auto buffer = getText(this, QStringLiteral("Test"), tr("PleaseInputString"),
184-
QLineEdit::Normal, "wingsummer", &ok);
184+
auto buffer =
185+
dlgGetText(this, QStringLiteral("Test"), tr("PleaseInputString"),
186+
QLineEdit::Normal, "wingsummer", &ok);
185187
if (ok) {
186188
if (ui->rbInsert->isChecked()) {
187189
ok = insertContent(ui->sbOffset->value(), buffer);
@@ -195,9 +197,9 @@ void CtlTestForm::on_btnString_clicked() {
195197

196198
void CtlTestForm::on_btnByteArray_clicked() {
197199
bool ok;
198-
auto ret = getText(this, QStringLiteral("Test"),
199-
tr("PleaseInputByteArray(00 23 5A)"), QLineEdit::Normal,
200-
QStringLiteral("00"), &ok);
200+
auto ret = dlgGetText(this, QStringLiteral("Test"),
201+
tr("PleaseInputByteArray(00 23 5A)"),
202+
QLineEdit::Normal, QStringLiteral("00"), &ok);
201203
if (ok) {
202204
auto buffer = QByteArray::fromHex(ret.toUtf8());
203205
if (buffer.isEmpty()) {

TestPlugin/ctltestform.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
#define CTLTESTFORM_H
2323

2424
#include <QTextBrowser>
25-
#include <QWidget>
2625

27-
#include "WingPlugin/iwingplugin.h"
26+
#include "WingPlugin/wingpluginwidget.h"
2827

2928
namespace Ui {
3029
class CtlTestForm;
3130
}
3231

33-
class CtlTestForm : public QWidget, public WingHex::IWingPluginAPICalls {
32+
class CtlTestForm : public WingHex::WingPluginWidget {
3433
Q_OBJECT
3534

3635
public:
@@ -58,7 +57,6 @@ private slots:
5857
private:
5958
template <typename T>
6059
bool writeContent(qsizetype offset, const T &value) {
61-
Q_ASSERT(_plg);
6260
if constexpr (std::is_integral_v<T>) {
6361
if constexpr (sizeof(T) == sizeof(qint8)) {
6462
return writeInt8(offset, value);
@@ -90,7 +88,6 @@ private slots:
9088

9189
template <typename T>
9290
bool insertContent(qsizetype offset, const T &value) {
93-
Q_ASSERT(_plg);
9491
if constexpr (std::is_integral_v<T>) {
9592
if constexpr (sizeof(T) == sizeof(qint8)) {
9693
return insertInt8(offset, value);
@@ -122,7 +119,6 @@ private slots:
122119

123120
template <typename T>
124121
bool appendContent(const T &value) {
125-
Q_ASSERT(_plg);
126122
if constexpr (std::is_integral_v<T>) {
127123
if constexpr (sizeof(T) == sizeof(qint8)) {
128124
return appendInt8(value);
@@ -155,7 +151,6 @@ private slots:
155151
private:
156152
Ui::CtlTestForm *ui;
157153

158-
WingHex::IWingPlugin *_plg;
159154
QTextBrowser *_br;
160155
};
161156

TestPlugin/lang/TestPlugin_zh_CN.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,38 @@
3434
<translation>类型</translation>
3535
</message>
3636
<message>
37-
<location filename="../ctltestform.cpp" line="35"/>
37+
<location filename="../ctltestform.cpp" line="34"/>
3838
<source>PleaseInputInt8</source>
3939
<translation>请输入8位整数</translation>
4040
</message>
4141
<message>
42-
<location filename="../ctltestform.cpp" line="59"/>
42+
<location filename="../ctltestform.cpp" line="58"/>
4343
<source>PleaseInputInt16</source>
4444
<translation>请输入16位整数</translation>
4545
</message>
4646
<message>
47-
<location filename="../ctltestform.cpp" line="83"/>
47+
<location filename="../ctltestform.cpp" line="82"/>
4848
<source>PleaseInputInt32</source>
4949
<translation>请输入32位整数</translation>
5050
</message>
5151
<message>
52-
<location filename="../ctltestform.cpp" line="107"/>
52+
<location filename="../ctltestform.cpp" line="106"/>
5353
<source>PleaseInputInt64</source>
5454
<translation>请输入64位整数</translation>
5555
</message>
5656
<message>
5757
<location filename="../ctltestform.cpp" line="134"/>
58-
<location filename="../ctltestform.cpp" line="159"/>
58+
<location filename="../ctltestform.cpp" line="160"/>
5959
<source>PleaseInputFloat</source>
6060
<translation>请输入单精度浮点数</translation>
6161
</message>
6262
<message>
63-
<location filename="../ctltestform.cpp" line="183"/>
63+
<location filename="../ctltestform.cpp" line="185"/>
6464
<source>PleaseInputString</source>
6565
<translation>请输入字符串</translation>
6666
</message>
6767
<message>
68-
<location filename="../ctltestform.cpp" line="199"/>
68+
<location filename="../ctltestform.cpp" line="201"/>
6969
<source>PleaseInputByteArray(00 23 5A)</source>
7070
<translation>请输入字节数组(举例:00 23 5A)</translation>
7171
</message>
@@ -272,23 +272,23 @@
272272
<translation>数据可视化</translation>
273273
</message>
274274
<message>
275-
<location filename="../testform.cpp" line="336"/>
276-
<location filename="../testform.cpp" line="345"/>
275+
<location filename="../testform.cpp" line="340"/>
276+
<location filename="../testform.cpp" line="349"/>
277277
<source>UpdateTextTreeError</source>
278278
<translation>更新文本树失败</translation>
279279
</message>
280280
<message>
281-
<location filename="../testform.cpp" line="360"/>
281+
<location filename="../testform.cpp" line="364"/>
282282
<source>UpdateTextListByModelError</source>
283283
<translation>通过模型更新文本列表失败</translation>
284284
</message>
285285
<message>
286-
<location filename="../testform.cpp" line="370"/>
286+
<location filename="../testform.cpp" line="374"/>
287287
<source>UpdateTextTableByModelError</source>
288288
<translation>通过模型更新文本表格失败</translation>
289289
</message>
290290
<message>
291-
<location filename="../testform.cpp" line="381"/>
291+
<location filename="../testform.cpp" line="385"/>
292292
<source>UpdateTextTreeByModelError</source>
293293
<translation>通过模型更新文本树失败</translation>
294294
</message>
@@ -357,15 +357,15 @@
357357
<context>
358358
<name>TestPluginPage</name>
359359
<message>
360-
<location filename="../testpluginpage.cpp" line="16"/>
360+
<location filename="../testpluginpage.cpp" line="36"/>
361361
<source>TestPluginPage</source>
362362
<translation>测试插件页</translation>
363363
</message>
364364
</context>
365365
<context>
366366
<name>TestWingEditorViewWidget</name>
367367
<message>
368-
<location filename="../testwingeditorviewwidget.cpp" line="28"/>
368+
<location filename="../testwingeditorviewwidget.cpp" line="48"/>
369369
<source>TestWingEditorView</source>
370370
<translation>测试插件编辑视图</translation>
371371
</message>

TestPlugin/readertestform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
ReaderTestForm::ReaderTestForm(WingHex::IWingPlugin *plg, QTextBrowser *br,
2727
QWidget *parent)
28-
: QWidget(parent), WingHex::IWingPluginCalls(plg),
29-
ui(new Ui::ReaderTestForm), _plg(plg), _br(br) {
28+
: WingHex::WingPluginWidget(plg, parent), ui(new Ui::ReaderTestForm),
29+
_br(br) {
3030
ui->setupUi(this);
3131
ui->sbOffset->setRange(0, INT_MAX);
3232
}

TestPlugin/readertestform.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
#define READERTESTFORM_H
2323

2424
#include <QTextBrowser>
25-
#include <QWidget>
2625

27-
#include "WingPlugin/iwingplugin.h"
26+
#include "WingPlugin/wingpluginwidget.h"
2827

2928
namespace Ui {
3029
class ReaderTestForm;
3130
}
3231

33-
class ReaderTestForm : public QWidget, public WingHex::IWingPluginCalls {
32+
class ReaderTestForm : public WingHex::WingPluginWidget {
3433
Q_OBJECT
3534

3635
public:
@@ -63,7 +62,6 @@ private slots:
6362
private:
6463
Ui::ReaderTestForm *ui;
6564

66-
WingHex::IWingPlugin *_plg;
6765
QTextBrowser *_br;
6866
};
6967

0 commit comments

Comments
 (0)