-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleplugin.cpp
More file actions
96 lines (83 loc) · 2.78 KB
/
Copy pathexampleplugin.cpp
File metadata and controls
96 lines (83 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* @file exampleplugin.cpp
* @brief Implementation file for the example plugin.
* @author howdy213
* @date 2026-05-04
* @version 2.0.0
*
* @copyright Copyright 2025-2026 howdy213
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "exampleplugin.h"
#include "WECore/service/wserviceproxy.h"
#include "exampledialog.h"
#include "examplewidget.h"
#include "WECore/plugin/wplugin.h"
#include "WECore/plugin/wplugindata.h"
#include "WECore/widget/wwidgetmanager.h"
#include "../LightWidget/ILightMain.h"
#include <QWidget>
#include <Windows.h>
using namespace LightWidget::Consts;
using namespace we::Consts;
using namespace we;
/**
* @brief Constructs the ExamplePlugin object.
*/
ExamplePlugin::ExamplePlugin() {}
/**
* @brief Destroys the ExamplePlugin object.
*/
ExamplePlugin::~ExamplePlugin() {}
/**
* @brief Initializes the plugin.
* @param msg Initialization message.
* @return True if initialization succeeded, false otherwise.
*/
bool ExamplePlugin::init(WMessage &msg) {
PluginData::setData(qvariant_cast<WEBase *>(msg.map[Data::WEBase]));
PluginData::setPlugin(qvariant_cast<WPlugin *>(msg.map[Data::Plugin]));
auto widgetManager = PClass->widgetManager();
widget = new ExampleWidget(PData);
widgetManager->addWidget(QUuid::createUuid(), widget, this);
WPlugin *plugin = qvariant_cast<WPlugin *>(msg.map[Data::Plugin]);
plugin->setMetaData(Plugin::Name, "Example");
plugin->setMetaData(Plugin::Author, "WidgetExplorer");
// Add a menu item to the main window
QAction *action = new QAction("Example: open", nullptr);
QObject::connect(action, &QAction::triggered,
[this]() { widget->handleStartCommand(); });
WMessage msg2;
msg2.map[Key::MenuPath] = QVariant::fromValue(QString("Example"));
msg2.object = action;
WEvent extEvent(QString("ui.mainwindow.") + Event::MenuAction, msg2);
widgetManager->publish(extEvent);
return true;
}
/**
* @brief Receives messages sent to the plugin.
* @param msg The incoming message.
*/
void ExamplePlugin::recMsg(WMessage &msg) {
Q_UNUSED(msg);
}
/**
* @brief Deinitializes the plugin.
* @param msg Deinitialization message.
* @return True if deinitialization succeeded.
*/
bool ExamplePlugin::deinit(WMessage &msg) {
Q_UNUSED(msg);
return true;
}