-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加DDockApplet类型,dock的子插件应统一继承此类,方便统一管理 增加DDockItem类型,导出qml组件,提供统一视觉的的tips,icon,... log: as title
- Loading branch information
Showing
11 changed files
with
398 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
|
||
import org.deepin.ds 1.0 | ||
import org.deepin.dtk 1.0 as D | ||
import org.deepin.dtk.private 1.0 as DP | ||
import org.deepin.ds.dock 1.0 | ||
|
||
AppletItem { | ||
id: root | ||
property int dockOrder | ||
property bool shouldVisible | ||
property alias toolButtonColor: backgroundButton.color1 | ||
property alias toolButtonBorderColor: backgroundButton.outsideBorderColor | ||
property alias toolTip: toolTip.text | ||
property alias icon: button.icon.name | ||
|
||
signal clicked | ||
|
||
PanelToolTip { | ||
id: toolTip | ||
} | ||
D.ToolButton { | ||
id: button | ||
anchors.centerIn: parent | ||
width: 30 | ||
height: 30 | ||
icon.width: 16 | ||
icon.height: 16 | ||
|
||
display: D.IconLabel.IconOnly | ||
onClicked: { | ||
toolTip.close() | ||
root.clicked() | ||
} | ||
|
||
onHoveredChanged: { | ||
if (toolTip.text === "") | ||
return | ||
|
||
if (hovered) { | ||
var point = Applet.rootObject.mapToItem(null, Applet.rootObject.width / 2, 0) | ||
toolTip.toolTipX = point.x | ||
toolTip.toolTipY = point.y | ||
toolTip.open() | ||
} else { | ||
toolTip.close() | ||
} | ||
} | ||
|
||
background: DP.ButtonPanel { | ||
id: backgroundButton | ||
|
||
button: button | ||
color2: color1 | ||
insideBorderColor: null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "ddockapplet.h" | ||
#include "private/ddockapplet_p.h" | ||
|
||
#include <QLoggingCategory> | ||
|
||
DS_BEGIN_NAMESPACE | ||
|
||
DCORE_USE_NAMESPACE | ||
|
||
Q_DECLARE_LOGGING_CATEGORY(dsLog) | ||
|
||
DDockAppletPrivate::DDockAppletPrivate(DDockApplet *qq) | ||
: DAppletPrivate(qq) | ||
{ | ||
|
||
} | ||
|
||
DDockAppletPrivate::~DDockAppletPrivate() | ||
{ | ||
|
||
} | ||
|
||
DDockApplet::DDockApplet(QObject *parent) | ||
: DDockApplet(*new DDockAppletPrivate(this), parent) | ||
{ | ||
|
||
} | ||
|
||
DDockApplet::DDockApplet(DDockAppletPrivate &dd, QObject *parent) | ||
: DApplet(dd, parent) | ||
{ | ||
|
||
} | ||
|
||
DDockApplet::~DDockApplet() | ||
{ | ||
qDebug(dsLog) << "Destroyed DDockApplet:" << pluginId() << id(); | ||
} | ||
|
||
/*! | ||
A unique name that identifies the plug-in. The default implementation is `pluginId`. | ||
*/ | ||
QString DDockApplet::name() const | ||
{ | ||
return DApplet::pluginId(); | ||
} | ||
|
||
/*! | ||
A name that displays a name that matches the current locale | ||
*/ | ||
/** | ||
* @brief DDockApplet::displayName | ||
* @return | ||
*/ | ||
|
||
/** | ||
* @brief DDockApplet::itemKey | ||
* @return | ||
*/ | ||
|
||
/** | ||
* @brief DDockApplet::settingKey | ||
* @return | ||
*/ | ||
|
||
/*! | ||
A dci icon for display | ||
*/ | ||
QString DDockApplet::icon() const | ||
{ | ||
D_DC(DDockApplet); | ||
|
||
return d->icon; | ||
} | ||
|
||
void DDockApplet::setIcon(const QString &icon) | ||
{ | ||
D_D(DDockApplet); | ||
|
||
d->icon = icon; | ||
Q_EMIT iconChanged(icon); | ||
} | ||
|
||
/*! | ||
Whether the plug-in is displayed on the panel | ||
*/ | ||
bool DDockApplet::visible() const | ||
{ | ||
D_DC(DDockApplet); | ||
|
||
return d->visible; | ||
} | ||
|
||
void DDockApplet::setVisible(bool visible) | ||
{ | ||
D_D(DDockApplet); | ||
|
||
if (d->visible == visible) | ||
return; | ||
|
||
d->visible = visible; | ||
Q_EMIT visibleChanged(visible); | ||
} | ||
|
||
DS_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "applet.h" | ||
#include "dsglobal.h" | ||
|
||
#include <DObject> | ||
|
||
#include <QVariant> | ||
|
||
DS_BEGIN_NAMESPACE | ||
/** | ||
* @brief You Can Used As Dock Plugins Sub Class | ||
*/ | ||
class DDockAppletPrivate; | ||
class DS_SHARE DDockApplet : public DApplet | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QString name READ name CONSTANT FINAL) | ||
Q_PROPERTY(QString displayName READ displayName CONSTANT FINAL) | ||
Q_PROPERTY(QString itemKey READ itemKey CONSTANT FINAL) | ||
Q_PROPERTY(QString settingKey READ settingKey CONSTANT FINAL) | ||
Q_PROPERTY(QString icon READ icon NOTIFY iconChanged FINAL) | ||
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL); | ||
|
||
D_DECLARE_PRIVATE(DDockApplet); | ||
|
||
public: | ||
explicit DDockApplet(QObject *parent = nullptr); | ||
virtual ~DDockApplet() override; | ||
|
||
virtual QString name() const; | ||
virtual QString displayName() const = 0; | ||
virtual QString itemKey() const = 0; | ||
virtual QString settingKey() const = 0; | ||
|
||
QString icon() const; | ||
void setIcon(const QString &icon); | ||
|
||
bool visible() const; | ||
void setVisible(bool visible); | ||
|
||
Q_SIGNALS: | ||
void iconChanged(const QString &); | ||
void visibleChanged(bool); | ||
|
||
protected: | ||
explicit DDockApplet(DDockAppletPrivate &dd, QObject *parent = nullptr); | ||
}; | ||
|
||
DS_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
add_library(dock-shell-example SHARED | ||
item.cpp | ||
item.h | ||
) | ||
|
||
target_link_libraries(dock-shell-example PRIVATE | ||
dock-plugin | ||
) | ||
|
||
ds_install_package(PACKAGE org.deepin.ds.dock.dock-shell-example TARGET dock-shell-example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "item.h" | ||
#include "pluginfactory.h" | ||
|
||
namespace dock { | ||
|
||
Item::Item(QObject *parent) | ||
: DDockApplet(parent) | ||
{ | ||
// for debug | ||
setVisible(true); | ||
} | ||
|
||
void Item::activate() | ||
{ | ||
qDebug() << "item clicked"; | ||
} | ||
|
||
QString Item::displayName() const | ||
{ | ||
return "dock-shell-example"; | ||
} | ||
|
||
QString Item::itemKey() const | ||
{ | ||
return "dock-shell-example"; | ||
} | ||
|
||
QString Item::settingKey() const | ||
{ | ||
return "dock-shell-example"; | ||
} | ||
|
||
D_APPLET_CLASS(Item) | ||
} | ||
|
||
|
||
#include "item.moc" |
Oops, something went wrong.