Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Quick)

add_subdirectory(applet-example)
add_subdirectory(applet-widget-example)
add_subdirectory(applet-example-data)
add_subdirectory(containment-example)
add_subdirectory(panel-example)
Expand Down
19 changes: 19 additions & 0 deletions example/applet-widget-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Widgets)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Widget)

add_library(ds-example-applet-widget SHARED
exampleapplet.h
exampleapplet.cpp
)

target_link_libraries(ds-example-applet-widget PRIVATE
dde-shell-frame
Qt${QT_VERSION_MAJOR}::Widgets
Dtk${DTK_VERSION_MAJOR}::Widget
)

ds_install_package(PACKAGE org.deepin.ds.example.applet-widget TARGET ds-example-applet-widget)
41 changes: 41 additions & 0 deletions example/applet-widget-example/exampleapplet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "exampleapplet.h"

#include "pluginfactory.h"

Check warning on line 7 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "pluginfactory.h" not found.

#include <DIconButton>

Check warning on line 9 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DIconButton> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DIconTheme>

Check warning on line 10 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DIconTheme> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dplatformwindowhandle.h>

Check warning on line 11 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dplatformwindowhandle.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QVBoxLayout>

Check warning on line 13 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWidget>

Check warning on line 14 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWidget> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DGUI_USE_NAMESPACE
DWIDGET_USE_NAMESPACE

WidgetExampleApplet::WidgetExampleApplet(QObject *parent)
: DApplet(parent)
{
}

bool WidgetExampleApplet::init()
{
auto widget = new QWidget();
DPlatformWindowHandle handle(widget);
widget->setFixedSize(QSize(200, 200));
auto layout = new QVBoxLayout(widget);
auto btn = new DIconButton();
btn->setIcon(DIconTheme::findQIcon("deepin-home"));
btn->setIconSize(QSize(36, 36));
layout->addWidget(btn);
widget->show();

return DApplet::init();
}

D_APPLET_CLASS(WidgetExampleApplet)

#include "exampleapplet.moc"

Check warning on line 41 in example/applet-widget-example/exampleapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "exampleapplet.moc" not found.
18 changes: 18 additions & 0 deletions example/applet-widget-example/exampleapplet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "applet.h"

Check warning on line 7 in example/applet-widget-example/exampleapplet.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "applet.h" not found.

DS_USE_NAMESPACE

class WidgetExampleApplet : public DApplet
{
Q_OBJECT
public:
explicit WidgetExampleApplet(QObject *parent = nullptr);

virtual bool init() override;
};
7 changes: 7 additions & 0 deletions example/applet-widget-example/package/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Plugin": {
"Version": "1.0",
"Id": "org.deepin.ds.example.applet-widget",
"Parent": "org.deepin.ds.example.containment"
}
}