Skip to content

Commit 568c3b6

Browse files
18202781743deepin-bot[bot]
authored andcommitted
chore: add applet-widget example
it's useful to debug. pms:TASK-365879
1 parent d3c4c44 commit 568c3b6

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

example/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Quick)
66

77
add_subdirectory(applet-example)
8+
add_subdirectory(applet-widget-example)
89
add_subdirectory(applet-example-data)
910
add_subdirectory(containment-example)
1011
add_subdirectory(panel-example)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Widgets)
6+
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Widget)
7+
8+
add_library(ds-example-applet-widget SHARED
9+
exampleapplet.h
10+
exampleapplet.cpp
11+
)
12+
13+
target_link_libraries(ds-example-applet-widget PRIVATE
14+
dde-shell-frame
15+
Qt${QT_VERSION_MAJOR}::Widgets
16+
Dtk${DTK_VERSION_MAJOR}::Widget
17+
)
18+
19+
ds_install_package(PACKAGE org.deepin.ds.example.applet-widget TARGET ds-example-applet-widget)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#include "exampleapplet.h"
6+
7+
#include "pluginfactory.h"
8+
9+
#include <DIconButton>
10+
#include <DIconTheme>
11+
#include <dplatformwindowhandle.h>
12+
13+
#include <QVBoxLayout>
14+
#include <QWidget>
15+
16+
DGUI_USE_NAMESPACE
17+
DWIDGET_USE_NAMESPACE
18+
19+
WidgetExampleApplet::WidgetExampleApplet(QObject *parent)
20+
: DApplet(parent)
21+
{
22+
}
23+
24+
bool WidgetExampleApplet::init()
25+
{
26+
auto widget = new QWidget();
27+
DPlatformWindowHandle handle(widget);
28+
widget->setFixedSize(QSize(200, 200));
29+
auto layout = new QVBoxLayout(widget);
30+
auto btn = new DIconButton();
31+
btn->setIcon(DIconTheme::findQIcon("deepin-home"));
32+
btn->setIconSize(QSize(36, 36));
33+
layout->addWidget(btn);
34+
widget->show();
35+
36+
return DApplet::init();
37+
}
38+
39+
D_APPLET_CLASS(WidgetExampleApplet)
40+
41+
#include "exampleapplet.moc"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#pragma once
6+
7+
#include "applet.h"
8+
9+
DS_USE_NAMESPACE
10+
11+
class WidgetExampleApplet : public DApplet
12+
{
13+
Q_OBJECT
14+
public:
15+
explicit WidgetExampleApplet(QObject *parent = nullptr);
16+
17+
virtual bool init() override;
18+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Plugin": {
3+
"Version": "1.0",
4+
"Id": "org.deepin.ds.example.applet-widget",
5+
"Parent": "org.deepin.ds.example.containment"
6+
}
7+
}

0 commit comments

Comments
 (0)