|
| 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 | +} |
0 commit comments