Skip to content

Commit 55ebbcd

Browse files
committed
feat: 设置页相关调整优化;
1 parent 7bbe4da commit 55ebbcd

31 files changed

Lines changed: 1254 additions & 326 deletions

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_definitions(-DAS_NO_THREADS)
2828

2929
if(BUILD_TEST_PLUGIN)
3030
add_subdirectory(TestPlugin)
31+
add_subdirectory(TestBadPlugin)
3132
add_subdirectory(TestManager)
3233
endif()
3334

@@ -302,7 +303,9 @@ set(CLASS_SRC
302303
src/class/wingangel.h
303304
src/class/wingangel.cpp
304305
src/class/winggeneric.h
305-
src/class/winggeneric.cpp)
306+
src/class/winggeneric.cpp
307+
src/class/changedstringlist.h
308+
src/class/changedstringlist.cpp)
306309

307310
set(INTERNAL_PLG_SRC
308311
src/class/wingangelapi.h src/class/wingangelapi.cpp

TestBadPlugin/CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(TestBadPlugin)
4+
5+
set(CMAKE_AUTOMOC ON)
6+
set(CMAKE_AUTORCC ON)
7+
set(CMAKE_AUTOUIC ON)
8+
set(CMAKE_CXX_STANDARD 17)
9+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
set(CMAKE_CXX_EXTENSIONS OFF)
11+
12+
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
13+
14+
# Test mode, please configure the main program directory to facilitate debugging
15+
16+
# 测试模式,启用请配置主程序目录,方便调试
17+
18+
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
19+
option(TEST_MODE TRUE)
20+
21+
# For Qt
22+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
23+
find_package(
24+
Qt${QT_VERSION_MAJOR}
25+
COMPONENTS Widgets
26+
REQUIRED)
27+
28+
add_library(TestBadPlugin SHARED TestBadPlugin.json
29+
testbadplugin.h testbadplugin.cpp)
30+
31+
set_target_properties(TestBadPlugin PROPERTIES SUFFIX ".wingplg")
32+
33+
if(TEST_MODE)
34+
# If you want to be able to debug easily every time you compile, please set
35+
# this variable. Because this test plugin is a subproject of the main
36+
# project, use CMAKE_BINARY_DIR
37+
38+
# 如果你想每次编译都能够方便调试的话,请设置这个变量。因为这个测试插件是和主项目子项目,所以用 CMAKE_BINARY_DIR
39+
40+
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
41+
set(WINGHEX_PATH "${CMAKE_BINARY_DIR}")
42+
43+
set(WINGHEX_PLUGIN_PATH "${WINGHEX_PATH}/plugin")
44+
add_custom_command(
45+
TARGET TestBadPlugin
46+
POST_BUILD
47+
COMMAND ${CMAKE_COMMAND} -E make_directory ${WINGHEX_PLUGIN_PATH}
48+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
49+
$<TARGET_FILE:TestBadPlugin> ${WINGHEX_PLUGIN_PATH})
50+
endif()
51+
52+
target_link_libraries(TestBadPlugin PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
53+
WingPlugin)

TestBadPlugin/TestBadPlugin.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Id": "TestBadPlugin",
3+
"SDK": 18,
4+
"Version": "0.0.1",
5+
"Vendor": "WingCloudStudio",
6+
"Dependencies": [
7+
8+
],
9+
"Author": "wingsummer",
10+
"License": "MIT",
11+
"Url": "https://github.com/Wing-summer/WingHexExplorer2"
12+
}

TestBadPlugin/testbadplugin.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*==============================================================================
2+
** Copyright (C) 2024-2027 WingSummer
3+
**
4+
** Permission is hereby granted, free of charge, to any person obtaining a copy
5+
** of this software and associated documentation files (the "Software"), to deal
6+
** in the Software without restriction, including without limitation the rights
7+
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
** copies of the Software, and to permit persons to whom the Software is
9+
** furnished to do so.
10+
**
11+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
** THE SOFTWARE.
18+
** =============================================================================
19+
*/
20+
21+
#include "testbadplugin.h"
22+
23+
TestBadPlugin::TestBadPlugin() {}
24+
25+
bool TestBadPlugin::init(const std::unique_ptr<QSettings> &set) {
26+
Q_UNUSED(set);
27+
msgCritical(
28+
nullptr, QStringLiteral("TestBadPlugin"),
29+
QStringLiteral("Hello, pals! I'm a evil MESSAGEBOX! PLEASE BAN ME!"));
30+
return true;
31+
}
32+
33+
void TestBadPlugin::unload(std::unique_ptr<QSettings> &set) { Q_UNUSED(set); }
34+
35+
const QString TestBadPlugin::pluginName() const {
36+
return QStringLiteral("TestBadPlugin");
37+
}
38+
39+
const QString TestBadPlugin::pluginComment() const {
40+
return QStringLiteral("TestBadPlugin: popup a messagebox when startup!");
41+
}

TestBadPlugin/testbadplugin.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*==============================================================================
2+
** Copyright (C) 2024-2027 WingSummer
3+
**
4+
** Permission is hereby granted, free of charge, to any person obtaining a copy
5+
** of this software and associated documentation files (the "Software"), to deal
6+
** in the Software without restriction, including without limitation the rights
7+
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
** copies of the Software, and to permit persons to whom the Software is
9+
** furnished to do so.
10+
**
11+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
** THE SOFTWARE.
18+
** =============================================================================
19+
*/
20+
21+
#ifndef TESTBADPLUGIN_H
22+
#define TESTBADPLUGIN_H
23+
24+
#include "WingPlugin/iwingplugin.h"
25+
26+
class TestBadPlugin : public WingHex::IWingPlugin {
27+
Q_OBJECT
28+
29+
Q_PLUGIN_METADATA(IID "com.wingsummer.iwingplugin" FILE
30+
"TestBadPlugin.json")
31+
Q_INTERFACES(WingHex::IWingPlugin)
32+
public:
33+
TestBadPlugin();
34+
35+
// IWingPluginCoreBase interface
36+
public:
37+
virtual bool init(const std::unique_ptr<QSettings> &set) override;
38+
virtual void unload(std::unique_ptr<QSettings> &set) override;
39+
40+
// IWingPluginBase interface
41+
public:
42+
virtual const QString pluginName() const override;
43+
virtual const QString pluginComment() const override;
44+
};
45+
46+
#endif // TESTBADPLUGIN_H

TestManager/TestManager.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"Version": "0.0.1",
55
"Vendor": "WingCloudStudio",
66
"Author": "wingsummer",
7-
"License": "AGPL-3.0",
7+
"License": "MIT",
88
"Url": "https://github.com/Wing-summer/WingHexExplorer2"
99
}

TestManager/testmanager.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ TestManager::~TestManager() {
2828
}
2929

3030
bool TestManager::init(const std::unique_ptr<QSettings> &set) {
31-
Q_UNUSED(set);
31+
_banTestBadPlugin = set->value("BanTestBadPlugin").toBool();
32+
content->initConfig(this);
3233
return true;
3334
}
3435

35-
void TestManager::unload(std::unique_ptr<QSettings> &set) { Q_UNUSED(set); }
36+
void TestManager::unload(std::unique_ptr<QSettings> &set) {
37+
set->setValue("BanTestBadPlugin", _banTestBadPlugin);
38+
}
3639

3740
const QString TestManager::comment() const {
3841
return QStringLiteral("Hello world!");
@@ -55,3 +58,12 @@ bool TestManager::enterGuard(const QMetaObject *sender, const QString &sig,
5558

5659
return true;
5760
}
61+
62+
bool TestManager::onLoadingPlugin(const QString &fileName,
63+
const WingHex::PluginInfo &info) {
64+
Q_UNUSED(fileName);
65+
if (info.id == QStringLiteral("TestBadPlugin")) {
66+
return !_banTestBadPlugin;
67+
}
68+
return true;
69+
}

TestManager/testmanager.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class TestManager : public WingHex::IWingManager {
5656
_cbblk = new QCheckBox(QStringLiteral("Disable msg*"), this);
5757
_cbblk->setChecked(false);
5858
layout->addWidget(_cbblk);
59+
60+
_banclk = new QCheckBox(QStringLiteral("BanTestBadPlugin"), this);
61+
62+
layout->addWidget(_banclk);
5963
layout->addStretch();
6064
}
6165
// PageBase interface
@@ -74,19 +78,31 @@ class TestManager : public WingHex::IWingManager {
7478
public:
7579
virtual void restore() override { _cbblk->setChecked(false); }
7680

81+
void initConfig(TestManager *man) {
82+
_banclk->setChecked(man->_banTestBadPlugin);
83+
connect(_banclk, &QCheckBox::toggled, this, [man, this](bool b) {
84+
man->_banTestBadPlugin = b;
85+
Q_EMIT optionNeedRestartChanged();
86+
});
87+
}
88+
7789
public:
7890
bool isDisableMsg() const { return _cbblk->isChecked(); }
7991

8092
private:
81-
QCheckBox *_cbblk;
93+
QCheckBox *_cbblk, *_banclk;
8294
};
8395

8496
public slots:
8597
virtual bool enterGuard(const QMetaObject *sender, const QString &sig,
8698
const QVariantList &params) override;
8799

100+
virtual bool onLoadingPlugin(const QString &fileName,
101+
const WingHex::PluginInfo &info) override;
102+
88103
private:
89104
TestPage *content;
105+
bool _banTestBadPlugin = false;
90106
};
91107

92108
#endif // TESTMANAGER_H

TestPlugin/TestPlugin.json

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

88
],
99
"Author": "wingsummer",
10-
"License": "AGPL-3.0",
10+
"License": "MIT",
1111
"Url": "https://github.com/Wing-summer/WingHexExplorer2"
1212
}

WingPlugin

0 commit comments

Comments
 (0)