mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat(gsettings): control all module visible
This commit is contained in:
parent
d83077fa75
commit
ef232eea04
@ -66,3 +66,6 @@ install(FILES "cmake/DdeDock/DdeDockConfig.cmake"
|
||||
## services files
|
||||
install(FILES frame/com.deepin.dde.Dock.service
|
||||
DESTINATION /usr/share/dbus-1/services)
|
||||
|
||||
install(FILES gschema/com.deepin.dde.dock.module.gschema.xml
|
||||
DESTINATION share/glib-2.0/schemas)
|
||||
|
4
debian/control
vendored
4
debian/control
vendored
@ -22,8 +22,8 @@ Build-Depends: debhelper (>= 8.0.0),
|
||||
libdframeworkdbus-dev,
|
||||
libgsettings-qt-dev,
|
||||
cmake,
|
||||
libdde-network-utils-dev (>= 0.1.4),
|
||||
libdde-network-utils-dev (<< 0.1.5),
|
||||
libdde-network-utils-dev (>= 5.0.1),
|
||||
libdde-network-utils-dev (<< 5.0.2),
|
||||
libdbusmenu-qt5-dev,
|
||||
clang [mips64el]
|
||||
Standards-Version: 3.9.8
|
||||
|
1
debian/dde-dock.install
vendored
1
debian/dde-dock.install
vendored
@ -7,4 +7,5 @@ usr/lib/dde-dock/plugins/libtrash.so
|
||||
usr/lib/dde-dock/plugins/libtray.so
|
||||
usr/lib/dde-dock/plugins/liboverlay-warning.so
|
||||
usr/lib/dde-dock/plugins/system-trays
|
||||
usr/share
|
||||
etc/dde-dock
|
||||
|
@ -39,12 +39,28 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QTimeLine>
|
||||
#include <QX11Info>
|
||||
#include <QGSettings>
|
||||
|
||||
#define APP_DRAG_THRESHOLD 20
|
||||
|
||||
int AppItem::IconBaseSize;
|
||||
QPoint AppItem::MousePressPos;
|
||||
|
||||
static QGSettings* GSettingsByApp() {
|
||||
static QGSettings settings("com.deepin.dde.dock.module.app");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
static QGSettings* GSettingsByActiveApp() {
|
||||
static QGSettings settings("com.deepin.dde.dock.module.activeapp");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
static QGSettings* GSettingsByDockApp() {
|
||||
static QGSettings settings("com.deepin.dde.dock.module.dockapp");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
: DockItem(parent),
|
||||
m_appNameTips(new TipsWidget(this)),
|
||||
@ -106,6 +122,9 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
|
||||
updateWindowInfos(m_itemEntryInter->windowInfos());
|
||||
refershIcon();
|
||||
|
||||
connect(GSettingsByApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
connect(GSettingsByDockApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
}
|
||||
|
||||
AppItem::~AppItem()
|
||||
@ -296,6 +315,10 @@ void AppItem::paintEvent(QPaintEvent *e)
|
||||
|
||||
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->button() == Qt::MiddleButton) {
|
||||
m_itemEntryInter->NewInstance(QX11Info::getTimestamp());
|
||||
|
||||
@ -322,6 +345,10 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
|
||||
void AppItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_updateIconGeometryTimer->stop();
|
||||
hidePopup();
|
||||
|
||||
@ -355,6 +382,10 @@ void AppItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
||||
void AppItem::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::wheelEvent(e);
|
||||
|
||||
if (qAbs(e->angleDelta().y()) > 20) {
|
||||
@ -371,6 +402,10 @@ void AppItem::resizeEvent(QResizeEvent *e)
|
||||
|
||||
void AppItem::dragEnterEvent(QDragEnterEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore drag from panel
|
||||
if (e->source()) {
|
||||
return e->ignore();
|
||||
@ -387,6 +422,10 @@ void AppItem::dragEnterEvent(QDragEnterEvent *e)
|
||||
|
||||
void AppItem::dragMoveEvent(QDragMoveEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DockItem::dragMoveEvent(e);
|
||||
|
||||
if (m_windowInfos.isEmpty())
|
||||
@ -422,11 +461,19 @@ void AppItem::showEvent(QShowEvent *e)
|
||||
{
|
||||
DockItem::showEvent(e);
|
||||
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
onGSettingsChanged("enable");
|
||||
});
|
||||
|
||||
refershIcon();
|
||||
}
|
||||
|
||||
void AppItem::showHoverTips()
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_windowInfos.isEmpty())
|
||||
return showPreview();
|
||||
|
||||
@ -447,6 +494,10 @@ const QString AppItem::contextMenu() const
|
||||
|
||||
QWidget *AppItem::popupTips()
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_dragging)
|
||||
return nullptr;
|
||||
|
||||
@ -464,6 +515,10 @@ QWidget *AppItem::popupTips()
|
||||
|
||||
void AppItem::startDrag()
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_dragging = true;
|
||||
update();
|
||||
|
||||
@ -643,3 +698,27 @@ void AppItem::checkAttentionEffect()
|
||||
});
|
||||
}
|
||||
|
||||
void AppItem::onGSettingsChanged(const QString& key) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
|
||||
if (setting->keys().contains("enable")) {
|
||||
const bool isEnable = GSettingsByApp()->keys().contains("enable") && GSettingsByApp()->get("enable").toBool();
|
||||
setVisible(isEnable && setting->get("enable").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
bool AppItem::checkGSettingsControl() const
|
||||
{
|
||||
QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
|
||||
return (setting->keys().contains("control") && setting->get("control").toBool()) ||
|
||||
(GSettingsByApp()->keys().contains("control") && GSettingsByApp()->get("control").toBool());
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ private slots:
|
||||
void playSwingEffect();
|
||||
void stopSwingEffect();
|
||||
void checkAttentionEffect();
|
||||
void onGSettingsChanged(const QString& key);
|
||||
bool checkGSettingsControl() const;
|
||||
|
||||
private:
|
||||
TipsWidget *m_appNameTips;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <DDBusSender>
|
||||
#include <QApplication>
|
||||
#include <QGSettings>
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
|
||||
@ -35,12 +36,15 @@ LauncherItem::LauncherItem(QWidget *parent)
|
||||
: DockItem(parent)
|
||||
, m_launcherInter(new LauncherInter("com.deepin.dde.Launcher", "/com/deepin/dde/Launcher", QDBusConnection::sessionBus(), this))
|
||||
, m_tips(new TipsWidget(this))
|
||||
, m_gsettings(new QGSettings("com.deepin.dde.dock.module.launcher"))
|
||||
{
|
||||
m_launcherInter->setSync(true, false);
|
||||
|
||||
setAccessibleName("Launcher");
|
||||
m_tips->setVisible(false);
|
||||
m_tips->setObjectName("launcher");
|
||||
|
||||
connect(m_gsettings, &QGSettings::changed, this, &LauncherItem::onGSettingsChanged);
|
||||
}
|
||||
|
||||
void LauncherItem::refershIcon()
|
||||
@ -58,6 +62,14 @@ void LauncherItem::refershIcon()
|
||||
update();
|
||||
}
|
||||
|
||||
void LauncherItem::showEvent(QShowEvent* event) {
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
onGSettingsChanged("enable");
|
||||
});
|
||||
|
||||
return DockItem::showEvent(event);
|
||||
}
|
||||
|
||||
void LauncherItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
DockItem::paintEvent(e);
|
||||
@ -85,6 +97,10 @@ void LauncherItem::resizeEvent(QResizeEvent *e)
|
||||
|
||||
void LauncherItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
hidePopup();
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
@ -92,6 +108,10 @@ void LauncherItem::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
void LauncherItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
@ -102,6 +122,26 @@ void LauncherItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
|
||||
QWidget *LauncherItem::popupTips()
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_tips->setText(tr("Launcher"));
|
||||
return m_tips;
|
||||
}
|
||||
|
||||
void LauncherItem::onGSettingsChanged(const QString& key) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gsettings->keys().contains("enable")) {
|
||||
setVisible(m_gsettings->get("enable").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
bool LauncherItem::checkGSettingsControl() const
|
||||
{
|
||||
return m_gsettings->keys().contains("control")
|
||||
&& m_gsettings->get("control").toBool();
|
||||
}
|
||||
|
@ -27,8 +27,10 @@
|
||||
|
||||
#include <com_deepin_dde_launcher.h>
|
||||
|
||||
|
||||
using LauncherInter = com::deepin::dde::Launcher;
|
||||
|
||||
class QGSettings;
|
||||
class LauncherItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -40,6 +42,9 @@ public:
|
||||
|
||||
void refershIcon();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
@ -48,11 +53,16 @@ private:
|
||||
|
||||
QWidget *popupTips();
|
||||
|
||||
void onGSettingsChanged(const QString& key);
|
||||
|
||||
bool checkGSettingsControl() const;
|
||||
|
||||
private:
|
||||
QPixmap m_smallIcon;
|
||||
QPixmap m_largeIcon;
|
||||
LauncherInter *m_launcherInter;
|
||||
TipsWidget *m_tips;
|
||||
QGSettings* m_gsettings;
|
||||
};
|
||||
|
||||
#endif // LAUNCHERITEM_H
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QGSettings>
|
||||
|
||||
#define PLUGIN_ITEM_DRAG_THRESHOLD 20
|
||||
|
||||
@ -57,6 +58,10 @@ PluginsItem::PluginsItem(PluginsItemInterface* const pluginInter, const QString
|
||||
setLayout(hLayout);
|
||||
setAccessibleName(pluginInter->pluginName() + "-" + m_itemKey);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
m_gsettings = new QGSettings(QString("com.deepin.dde.dock.module.%1").arg(pluginInter->pluginName()).toUtf8());
|
||||
m_gsettings->setParent(this);
|
||||
connect(m_gsettings, &QGSettings::changed, this, &PluginsItem::onGSettingsChanged);
|
||||
}
|
||||
|
||||
PluginsItem::~PluginsItem()
|
||||
@ -147,6 +152,16 @@ void PluginsItem::refershIcon()
|
||||
m_pluginInter->refreshIcon(m_itemKey);
|
||||
}
|
||||
|
||||
void PluginsItem::onGSettingsChanged(const QString& key) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gsettings->keys().contains("enable")) {
|
||||
setVisible(m_gsettings->get("enable").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *PluginsItem::centralWidget() const
|
||||
{
|
||||
return m_centralWidget;
|
||||
@ -154,6 +169,10 @@ QWidget *PluginsItem::centralWidget() const
|
||||
|
||||
void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_hover = false;
|
||||
update();
|
||||
|
||||
@ -169,6 +188,10 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
void PluginsItem::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->buttons() != Qt::LeftButton)
|
||||
return DockItem::mouseMoveEvent(e);
|
||||
|
||||
@ -181,6 +204,10 @@ void PluginsItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
||||
void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DockItem::mouseReleaseEvent(e);
|
||||
|
||||
if (e->button() != Qt::LeftButton)
|
||||
@ -200,6 +227,10 @@ void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
|
||||
void PluginsItem::enterEvent(QEvent *event)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_hover = true;
|
||||
update();
|
||||
|
||||
@ -220,9 +251,23 @@ void PluginsItem::leaveEvent(QEvent *event)
|
||||
DockItem::leaveEvent(event);
|
||||
}
|
||||
|
||||
void PluginsItem::showEvent(QShowEvent* event) {
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
onGSettingsChanged("enable");
|
||||
});
|
||||
|
||||
return DockItem::showEvent(event);
|
||||
}
|
||||
|
||||
bool PluginsItem::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_centralWidget) {
|
||||
if (event->type() == QEvent::MouseButtonPress ||
|
||||
event->type() == QEvent::MouseButtonRelease) {
|
||||
if (checkGSettingsControl()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
m_hover = false;
|
||||
update();
|
||||
@ -252,6 +297,10 @@ const QString PluginsItem::contextMenu() const
|
||||
|
||||
QWidget *PluginsItem::popupTips()
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return m_pluginInter->itemTipsWidget(m_itemKey);
|
||||
}
|
||||
|
||||
@ -301,3 +350,9 @@ void PluginsItem::mouseClicked()
|
||||
if (w)
|
||||
showPopupApplet(w);
|
||||
}
|
||||
|
||||
bool PluginsItem::checkGSettingsControl() const
|
||||
{
|
||||
return m_gsettings->keys().contains("control")
|
||||
&& m_gsettings->get("control").toBool();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "dockitem.h"
|
||||
#include "pluginsiteminterface.h"
|
||||
|
||||
class QGSettings;
|
||||
class PluginsItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -54,6 +55,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void refershIcon() override;
|
||||
void onGSettingsChanged(const QString& key);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
@ -62,6 +64,7 @@ protected:
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
void invokedMenuItem(const QString &itemId, const bool checked) override;
|
||||
void showPopupWindow(QWidget * const content, const bool model = false) override;
|
||||
@ -71,6 +74,7 @@ protected:
|
||||
private:
|
||||
void startDrag();
|
||||
void mouseClicked();
|
||||
bool checkGSettingsControl() const;
|
||||
|
||||
private:
|
||||
PluginsItemInterface * const m_pluginInter;
|
||||
@ -81,6 +85,7 @@ private:
|
||||
bool m_hover;
|
||||
|
||||
static QPoint MousePressPoint;
|
||||
QGSettings* m_gsettings;
|
||||
};
|
||||
|
||||
#endif // PLUGINSITEM_H
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "traypluginitem.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QGSettings>
|
||||
|
||||
TrayPluginItem::TrayPluginItem(PluginsItemInterface * const pluginInter, const QString &itemKey, QWidget *parent)
|
||||
: PluginsItem(pluginInter, itemKey, parent)
|
||||
@ -47,6 +48,17 @@ bool TrayPluginItem::eventFilter(QObject *watched, QEvent *e)
|
||||
// 监听插件Widget的"FashionTraySize"属性
|
||||
// 当接收到这个属性变化的事件后,重新计算和设置dock的大小
|
||||
|
||||
if (watched == centralWidget()) {
|
||||
if (e->type() == QEvent::MouseButtonPress ||
|
||||
e->type() == QEvent::MouseButtonRelease) {
|
||||
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
||||
if (settings.keys().contains("control")
|
||||
&& settings.get("control").toBool()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (watched == centralWidget() && e->type() == QEvent::DynamicPropertyChange) {
|
||||
const QString &propertyName = static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName();
|
||||
if (propertyName == "FashionTraySize") {
|
||||
|
211
gschema/com.deepin.dde.dock.module.gschema.xml
Normal file
211
gschema/com.deepin.dde.dock.module.gschema.xml
Normal file
@ -0,0 +1,211 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
<schema path="/com/deepin/dde/dock/module/app/" id="com.deepin.dde.dock.module.app" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/activeapp/" id="com.deepin.dde.dock.module.activeapp" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/dockapp/" id="com.deepin.dde.dock.module.dockapp" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/launcher/" id="com.deepin.dde.dock.module.launcher" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/datetime/" id="com.deepin.dde.dock.module.datetime" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/network/" id="com.deepin.dde.dock.module.network" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/onboard/" id="com.deepin.dde.dock.module.onboard" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/power/" id="com.deepin.dde.dock.module.power" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/shutdown/" id="com.deepin.dde.dock.module.shutdown" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/sound/" id="com.deepin.dde.dock.module.sound" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/trash/" id="com.deepin.dde.dock.module.trash" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/systemtray/" id="com.deepin.dde.dock.module.systemtray" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/tray/" id="com.deepin.dde.dock.module.tray" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
@ -26,6 +26,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <QGSettings>
|
||||
|
||||
Dock::Position SystemTrayItem::DockPosition = Dock::Position::Top;
|
||||
QPointer<DockPopupWindow> SystemTrayItem::PopupWindow = nullptr;
|
||||
@ -78,6 +79,10 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface * const pluginInter, const Q
|
||||
connect(m_popupAdjustDelayTimer, &QTimer::timeout, this, &SystemTrayItem::updatePopupPosition, Qt::QueuedConnection);
|
||||
|
||||
grabGesture(Qt::TapAndHoldGesture);
|
||||
|
||||
m_gsettings = new QGSettings(QString("com.deepin.dde.dock.module.%1").arg(pluginInter->pluginName()).toUtf8());
|
||||
m_gsettings->setParent(this);
|
||||
connect(m_gsettings, &QGSettings::changed, this, &SystemTrayItem::onGSettingsChanged);
|
||||
}
|
||||
|
||||
SystemTrayItem::~SystemTrayItem()
|
||||
@ -175,6 +180,10 @@ bool SystemTrayItem::event(QEvent *event)
|
||||
|
||||
void SystemTrayItem::enterEvent(QEvent *event)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_popupTipsDelayTimer->start();
|
||||
update();
|
||||
|
||||
@ -196,6 +205,10 @@ void SystemTrayItem::leaveEvent(QEvent *event)
|
||||
|
||||
void SystemTrayItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hideNonModel();
|
||||
|
||||
@ -210,6 +223,10 @@ void SystemTrayItem::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void SystemTrayItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
@ -230,6 +247,14 @@ void SystemTrayItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
AbstractTrayWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void SystemTrayItem::showEvent(QShowEvent* event) {
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
onGSettingsChanged("enable");
|
||||
});
|
||||
|
||||
return AbstractTrayWidget::showEvent(event);
|
||||
}
|
||||
|
||||
const QPoint SystemTrayItem::popupMarkPoint() const
|
||||
{
|
||||
QPoint p(topleftPoint());
|
||||
@ -447,3 +472,20 @@ void SystemTrayItem::updatePopupPosition()
|
||||
const QPoint p = popupMarkPoint();
|
||||
PopupWindow->show(p, PopupWindow->model());
|
||||
}
|
||||
|
||||
void SystemTrayItem::onGSettingsChanged(const QString &key) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gsettings->keys().contains("enable")) {
|
||||
const bool visible = m_gsettings->get("enable").toBool();
|
||||
setVisible(visible);
|
||||
emit itemVisibleChanged(visible);
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemTrayItem::checkGSettingsControl() const
|
||||
{
|
||||
return m_gsettings->get("control").toBool();
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QGestureEvent>
|
||||
|
||||
class QGSettings;
|
||||
class SystemTrayItem : public AbstractTrayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -61,12 +62,16 @@ public:
|
||||
void showPopupApplet(QWidget * const applet);
|
||||
void hidePopup();
|
||||
|
||||
signals:
|
||||
void itemVisibleChanged(bool visible);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
protected:
|
||||
const QPoint popupMarkPoint() const;
|
||||
@ -86,6 +91,8 @@ protected Q_SLOTS:
|
||||
|
||||
private:
|
||||
void updatePopupPosition();
|
||||
void onGSettingsChanged(const QString &key);
|
||||
bool checkGSettingsControl() const;
|
||||
|
||||
private:
|
||||
bool m_popupShown;
|
||||
@ -103,6 +110,7 @@ private:
|
||||
|
||||
static Dock::Position DockPosition;
|
||||
static QPointer<DockPopupWindow> PopupWindow;
|
||||
QGSettings* m_gsettings;
|
||||
};
|
||||
|
||||
#endif // SYSTEMTRAYITEM_H
|
||||
|
@ -41,6 +41,14 @@ void SystemTraysController::itemAdded(PluginsItemInterface * const itemInter, co
|
||||
return;
|
||||
|
||||
SystemTrayItem *item = new SystemTrayItem(itemInter, itemKey);
|
||||
connect(item, &SystemTrayItem::itemVisibleChanged, this, [=] (bool visible){
|
||||
if (visible) {
|
||||
emit pluginItemAdded(itemKey, item);
|
||||
}
|
||||
else {
|
||||
emit pluginItemRemoved(itemKey, item);
|
||||
}
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
item->setVisible(false);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QWindow>
|
||||
#include <QWidget>
|
||||
#include <QX11Info>
|
||||
#include <QGSettings>
|
||||
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "xcb/xcb_icccm.h"
|
||||
@ -403,6 +404,11 @@ void TrayPlugin::trayXEmbedAdded(const QString &itemKey, quint32 winId)
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
||||
if (settings.keys().contains("enable") && !settings.get("enable").toBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractTrayWidget *trayWidget = new XEmbedTrayWidget(winId);
|
||||
addTrayWidget(itemKey, trayWidget);
|
||||
}
|
||||
@ -413,6 +419,11 @@ void TrayPlugin::traySNIAdded(const QString &itemKey, const QString &sniServiceP
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
||||
if (settings.keys().contains("enable") && !settings.get("enable").toBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SNITrayWidget *trayWidget = new SNITrayWidget(sniServicePath);
|
||||
if (trayWidget->status() == SNITrayWidget::ItemStatus::Passive) {
|
||||
m_passiveSNITrayMap.insert(itemKey, trayWidget);
|
||||
@ -429,6 +440,11 @@ void TrayPlugin::trayIndicatorAdded(const QString &itemKey, const QString &indic
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
||||
if (settings.keys().contains("enable") && !settings.get("enable").toBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IndicatorTray *indicatorTray = nullptr;
|
||||
if (!m_indicatorMap.keys().contains(indicatorName)) {
|
||||
indicatorTray = new IndicatorTray(indicatorName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user