Skip to content

Commit 9ccfb9a

Browse files
committed
首次提交
0 parents  commit 9ccfb9a

75 files changed

Lines changed: 6247 additions & 0 deletions

Some content is hidden

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

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Build and Release Folders
2+
build/
3+
4+
# Other files and folders
5+
*.user

ExamplePlugin/ExamplePlugin.pro

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
QT += core gui
2+
QT += widgets
3+
4+
TEMPLATE = lib
5+
CONFIG += plugin
6+
7+
CONFIG += c++17
8+
TARGET = ExamplePlugin #生成插件的名称
9+
10+
LIBS += -luser32
11+
LIBS+=-lshell32
12+
win32 {
13+
CONFIG(debug, debug|release) {
14+
DESTDIR = ../LightWidget/debug/widget/Example
15+
} else {
16+
DESTDIR = ../LightWidget/release/widget/Example
17+
}
18+
}#生成插件的目录
19+
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../LightWidget/release/ -lwidgetexplorersdk
20+
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../LightWidget/debug -lwidgetexplorersdk
21+
# You can make your code fail to compile if it uses deprecated APIs.
22+
# In order to do so, uncomment the following line.
23+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
24+
include(../WidgetExplorerSDK/WidgetExplorerSDK.pri)
25+
SOURCES += \
26+
exampledialog.cpp \
27+
exampleplugin.cpp \
28+
examplewidget.cpp
29+
30+
HEADERS += \
31+
exampledialog.h \
32+
exampleplugin.h \
33+
examplewidget.h
34+
35+
DISTFILES +=
36+
37+
# Default rules for deployment.
38+
unix {
39+
target.path = $$[QT_INSTALL_PLUGINS]/generic
40+
}
41+
!isEmpty(target.path): INSTALLS += target
42+
43+
FORMS += \
44+
exampledialog.ui
45+

ExamplePlugin/exampledialog.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @file exampledialog.cpp
3+
* @brief 示例对话框实现文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#include"exampledialog.h"
23+
#include"ui_exampledialog.h"
24+
#include<windows.h>
25+
26+
ExampleDialog::ExampleDialog(QWidget *parent)
27+
: ui(new Ui::ExampleDialog)
28+
{
29+
Q_UNUSED(parent);
30+
ui->setupUi(this);
31+
}
32+
33+
ExampleDialog::~ExampleDialog()
34+
{
35+
delete ui;
36+
}
37+
38+
void ExampleDialog::setCommand(QMap<QString,QVariant> map){
39+
ui->textEdit->clear();
40+
QString str="";
41+
for(auto it=map.begin();it!=map.end();it++){
42+
str+=it.key();
43+
str+=":";
44+
str+=it->toString();
45+
str+="\n";
46+
}
47+
ui->textEdit->setText(str);
48+
}
49+
void ExampleDialog::appCommand(QMap<QString,QVariant> map){
50+
QString str="";
51+
for(auto it=map.begin();it!=map.end();it++){
52+
str+=it.key();
53+
str+=":";
54+
str+=it->toString();
55+
str+="\n";
56+
}
57+
appCommand(str);
58+
}
59+
void ExampleDialog::appCommand(QString str){
60+
QString org=ui->textEdit->toPlainText();
61+
str=org+str;
62+
ui->textEdit->setText(str);
63+
}

ExamplePlugin/exampledialog.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @file exampledialog.h
3+
* @brief 示例对话框类头文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#ifndef EXAMPLEDIALOG_H
23+
#define EXAMPLEDIALOG_H
24+
#include <QDialog>
25+
26+
namespace Ui {
27+
class ExampleDialog;
28+
}
29+
class ExamplePlugin;
30+
class ExampleDialog : public QWidget
31+
{
32+
Q_OBJECT
33+
public:
34+
explicit ExampleDialog(QWidget *parent = nullptr);
35+
~ExampleDialog();
36+
void setCommand(QMap<QString,QVariant> map);
37+
void appCommand(QMap<QString,QVariant> map);
38+
void appCommand(QString str);
39+
ExamplePlugin* plugin=nullptr;
40+
private:
41+
Ui::ExampleDialog *ui;
42+
};
43+
44+
#endif // EXAMPLEDIALOG_H

ExamplePlugin/exampledialog.ui

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ExampleDialog</class>
4+
<widget class="QWidget" name="ExampleDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>ExampleDialog</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0">
18+
<widget class="QTextEdit" name="textEdit"/>
19+
</item>
20+
</layout>
21+
</widget>
22+
<resources/>
23+
<connections/>
24+
</ui>

ExamplePlugin/exampleplugin.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @file exampleplugin.cpp
3+
* @brief 示例插件实现文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#include"examplewidget.h"
23+
#include"exampledialog.h"
24+
#include"exampleplugin.h"
25+
#include"../WidgetExplorerSDK/we.h"
26+
#include"../WidgetExplorerSDK/wfile.h"
27+
#include"../WidgetExplorerSDK/WPlugin/wplugin.h"
28+
#include"../WidgetExplorerSDK/WPlugin/wwidgetmanager.h"
29+
30+
#include<QWidget>
31+
#include<windows.h>
32+
33+
ExamplePlugin::ExamplePlugin() {}
34+
35+
ExamplePlugin::~ExamplePlugin()
36+
{
37+
38+
}
39+
40+
void ExamplePlugin::init(QMap<QString,QVariant> &data) {
41+
PluginData::setData(qvariant_cast<WEBase*>(data[W_DATA_WE]));
42+
PluginData::setPlugin(qvariant_cast<WPlugin*>(data[W_DATA_PLUGIN]));
43+
44+
auto widgetManager=PClass->widgetManager();
45+
widget=new ExampleWidget(PData);
46+
widgetManager->addWidget(QUuid::createUuid(),widget);
47+
48+
WPlugin* plugin=qvariant_cast<WPlugin*>(data[W_DATA_PLUGIN]);
49+
plugin->setMetaData(W_PLUGIN_ATTR_NAME,"Example");
50+
}
51+
52+
void ExamplePlugin::recMsg(WMetaData &msg) {
53+
widget->sendMessageCallback(msg);
54+
}

ExamplePlugin/exampleplugin.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @file exampleplugin.h
3+
* @brief 示例插件类头文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#ifndef EXAMPLEPLUGIN_H
23+
#define EXAMPLEPLUGIN_H
24+
#include"exampledialog.h"
25+
#include"examplewidget.h"
26+
#include"../WidgetExplorerSDK/WPlugin/wplugininterface.h"
27+
#include"../WidgetExplorerSDK/WPlugin/wpluginmanager.h"
28+
29+
#include<QObject>
30+
#include<QtPlugin>
31+
32+
class ExamplePlugin :public QObject, public WPluginInterface
33+
{
34+
public:
35+
Q_OBJECT
36+
Q_PLUGIN_METADATA(IID PluginInterface_iid)
37+
Q_INTERFACES(WPluginInterface)
38+
W_DECLARE_PLUGIN(ExamplePlugin);
39+
signals:
40+
void sendMsg(WMetaData&);
41+
public:
42+
ExamplePlugin();
43+
~ExamplePlugin();
44+
void init(QMap<QString,QVariant> &data) override;
45+
void recMsg(WMetaData &msg) override;
46+
private:
47+
ExampleWidget* widget=nullptr;
48+
};
49+
50+
#endif // EXAMPLEPLUGIN_H

ExamplePlugin/examplewidget.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @file examplewidget.cpp
3+
* @brief 示例窗口实现文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#include"examplewidget.h"
23+
#include"exampledialog.h"
24+
#include"../WidgetExplorerSDK/we.h"
25+
#include"../WidgetExplorerSDK/wfile.h"
26+
#include"../WidgetExplorerSDK/WPlugin/wplugin.h"
27+
#include"../WidgetExplorerSDK/WPlugin/wwidgetmanager.h"
28+
29+
#include<QWidget>
30+
#include<windows.h>
31+
32+
ExampleWidget::ExampleWidget(WEBase* parent){
33+
Q_UNUSED(parent)
34+
35+
}
36+
ExampleWidget::~ExampleWidget(){
37+
38+
}
39+
void ExampleWidget::receiveMessage(WMetaData &msg){
40+
if(msg.map[W_DATA_COMMAND]=="start"){
41+
if(widget.isHidden())widget.show();
42+
else widget.activateWindow();
43+
}
44+
widget.appCommand((QString)
45+
"\n--"+qvariant_cast<QString>(PPlugin->getMetaData(W_PLUGIN_ATTR_NAME))
46+
+"@"+qvariant_cast<QString>(PPlugin->getMetaData(W_PLUGIN_ATTR_PATH))
47+
+"--\nfrom:"+msg.from
48+
+"\ndest:"+msg.dest
49+
+"\nmsg:\n");
50+
widget.appCommand(msg.map);
51+
if(msg.map[W_DATA_COMMAND]=="clear"){
52+
widget.setCommand(data);
53+
if(widget.isHidden())widget.show();
54+
else widget.activateWindow();
55+
}
56+
}
57+
void ExampleWidget::initWidget(){
58+
this->setAttr(WNAME,"ExampleWidget");
59+
}

ExamplePlugin/examplewidget.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @file examplewidget.h
3+
* @brief 示例窗口类头文件
4+
* @author howdy213
5+
* @date 2025-07-11
6+
* @version 1.0.0
7+
*
8+
* Copyright 2025 howdy213
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#ifndef EXAMPLEWIDGET_H
23+
#define EXAMPLEWIDGET_H
24+
#include"exampledialog.h"
25+
#include"../WidgetExplorerSDK/WPlugin/wwidget.h"
26+
#include"../WidgetExplorerSDK/we.h"
27+
#include"../WidgetExplorerSDK/WPlugin/wplugindata.h"
28+
29+
#include <QObject>
30+
31+
class ExampleWidget :public WWidget
32+
{
33+
public:
34+
Q_OBJECT
35+
public:
36+
ExampleWidget(WEBase* parent=nullptr);
37+
~ExampleWidget();
38+
virtual void receiveMessage(WMetaData &msg);
39+
virtual void initWidget();
40+
private:
41+
QMap<QString,QVariant> data;
42+
ExampleDialog widget;
43+
};
44+
45+
#endif // EXAMPLEWIDGET_H

0 commit comments

Comments
 (0)