Skip to content

Commit 0b6077f

Browse files
committed
fix: 修复优化脚本和插件相关的问题;
1 parent 7e2709d commit 0b6077f

39 files changed

Lines changed: 1032 additions & 642 deletions

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ endif()
4949

5050
if(WINGHEX_BUILD_TEST_PLUGIN)
5151
add_subdirectory(TestPlugin)
52+
add_subdirectory(TestDepPlugin)
5253
endif()
5354

5455
if(WINGHEX_BUILD_SHARED_MEM_EXT)

TestDepPlugin/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(TestDepPlugin LANGUAGES CXX)
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+
option(WINGHEX_TEST_MODE TRUE)
15+
16+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
17+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
18+
19+
add_library(TestDepPlugin SHARED testdepplugin.cpp testdepplugin.h
20+
TestDepPlugin.json)
21+
22+
target_link_libraries(TestDepPlugin PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
23+
WingPlugin)
24+
25+
target_compile_definitions(TestDepPlugin PRIVATE TESTDEPPLUGIN_LIBRARY)
26+
27+
set_target_properties(TestDepPlugin PROPERTIES SUFFIX ".wingplg")
28+
29+
if(WINGHEX_TEST_MODE)
30+
set(WINGHEX_PATH "${CMAKE_BINARY_DIR}")
31+
32+
set(WINGHEX_PLUGIN_PATH "${WINGHEX_PATH}/plugin")
33+
add_custom_command(
34+
TARGET TestDepPlugin
35+
POST_BUILD
36+
COMMAND ${CMAKE_COMMAND} -E make_directory ${WINGHEX_PLUGIN_PATH}
37+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
38+
$<TARGET_FILE:TestDepPlugin> ${WINGHEX_PLUGIN_PATH})
39+
endif()

TestDepPlugin/TestDepPlugin.json

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

TestDepPlugin/testdepplugin.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*==============================================================================
2+
** Copyright (C) 2026-2029 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 "testdepplugin.h"
22+
23+
#include <QTimer>
24+
25+
TestDepPlugin::TestDepPlugin() : WingHex::IWingPlugin() {}
26+
27+
bool TestDepPlugin::init(const std::unique_ptr<QSettings> &set) {
28+
invokeService(QStringLiteral("TestPlugin"), "test_a");
29+
return true;
30+
}
31+
32+
void TestDepPlugin::unload(std::unique_ptr<QSettings> &set) {
33+
invokeService(QStringLiteral("TestPlugin"), "test_a");
34+
}
35+
36+
const QString TestDepPlugin::pluginName() const {
37+
return QStringLiteral("TestDepPlugin");
38+
}
39+
40+
const QString TestDepPlugin::pluginComment() const {
41+
return QStringLiteral("Test");
42+
}
43+
44+
void TestDepPlugin::eventReady() {
45+
// This may be unsuccessful because TestPlugin will call
46+
// WingAngelAPI::execCode as well and it will be busy.
47+
// The script running is timer event driven so wait for a moment.
48+
QTimer::singleShot(100, this, [this]() {
49+
bool ret;
50+
invokeService(QStringLiteral("WingAngelAPI"), "execCode",
51+
Qt::AutoConnection, qReturnArg(ret),
52+
QStringLiteral(R"(println("Hello? TestDepPlugin!");)"));
53+
});
54+
}
55+
56+
WingHex::IWingPlugin::RegisteredEvents TestDepPlugin::registeredEvents() const {
57+
return WingHex::IWingPlugin::RegisteredEvent::AppReady;
58+
}

TestDepPlugin/testdepplugin.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*==============================================================================
2+
** Copyright (C) 2026-2029 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 TESTDEPPLUGIN_H
22+
#define TESTDEPPLUGIN_H
23+
24+
#include "WingPlugin/iwingplugin.h"
25+
26+
class TestDepPlugin final : public WingHex::IWingPlugin {
27+
Q_OBJECT
28+
Q_PLUGIN_METADATA(IID "com.wingsummer.iwingplugin" FILE
29+
"TestDepPlugin.json")
30+
Q_INTERFACES(WingHex::IWingPlugin)
31+
32+
public:
33+
explicit TestDepPlugin();
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+
// IWingPlugin interface
46+
public:
47+
virtual RegisteredEvents registeredEvents() const override;
48+
virtual void eventReady() override;
49+
};
50+
51+
#endif // TESTDEPPLUGIN_H

TestPlugin/TestPlugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Version": "0.0.1",
55
"Vendor": "WingCloudStudio",
66
"Dependencies": [
7-
7+
"WingAngelAPI"
88
],
99
"Author": "wingsummer",
1010
"License": "MIT",

TestPlugin/testplugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void TestPlugin::eventReady() {
524524
bool ret;
525525
invokeService(QStringLiteral("WingAngelAPI"), "execCode",
526526
Qt::AutoConnection, qReturnArg(ret),
527-
QStringLiteral(R"(print("Hello, this is TestPlugin!");)"));
527+
QStringLiteral(R"(println("Hello, this is TestPlugin!");)"));
528528
}
529529

530530
void TestPlugin::onRegisterScriptObj(WingHex::IWingAngel *o) {

0 commit comments

Comments
 (0)