mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Merge branch 'dev/config1040'
Change-Id: Iadc925cb0026ac6375e570576d819e7f5935378e
This commit is contained in:
commit
1201947955
@ -161,8 +161,18 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
if (e->button() == Qt::LeftButton)
|
||||
MousePressPoint = e->pos();
|
||||
|
||||
// context menu will handle in DockItem
|
||||
DockItem::mousePressEvent(e);
|
||||
//handle context menu
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hideNonModel();
|
||||
|
||||
if (e->button() == Qt::RightButton) {
|
||||
if (perfectIconRect().contains(e->pos())) {
|
||||
return (m_gsettings && m_gsettings->get("menuEnable").toBool()) ? showContextMenu() : void();
|
||||
}
|
||||
}
|
||||
|
||||
// same as e->ignore above
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void PluginsItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
@ -27,18 +27,6 @@
|
||||
|
||||
#include <DApplication>
|
||||
|
||||
static QGSettings *GSettingsByMenu()
|
||||
{
|
||||
static QGSettings settings("com.deepin.dde.dock.module.menu");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
static QGSettings *GSettingsByTrash()
|
||||
{
|
||||
static QGSettings settings("com.deepin.dde.dock.module.trash");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
MenuWorker::MenuWorker(DBusDock *dockInter,QWidget *parent)
|
||||
: QObject (parent)
|
||||
, m_itemManager(DockItemManager::instance(this))
|
||||
@ -68,6 +56,15 @@ MenuWorker::MenuWorker(DBusDock *dockInter,QWidget *parent)
|
||||
MenuWorker::~MenuWorker()
|
||||
{
|
||||
delete m_settingsMenu;
|
||||
|
||||
QList<QString> keys = m_settingsModuleMap.keys();
|
||||
foreach (QString key, keys) {
|
||||
QGSettings *settings = m_settingsModuleMap[key];
|
||||
m_settingsModuleMap.remove(key);
|
||||
|
||||
delete settings;
|
||||
settings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuWorker::initMember()
|
||||
@ -91,8 +88,8 @@ void MenuWorker::initUI()
|
||||
modeSubMenu->setAccessibleName("modesubmenu");
|
||||
modeSubMenu->addAction(m_fashionModeAct);
|
||||
modeSubMenu->addAction(m_efficientModeAct);
|
||||
QAction *modeSubMenuAct = new QAction(tr("Mode"), this);
|
||||
modeSubMenuAct->setMenu(modeSubMenu);
|
||||
m_modeSubMenuAct = new QAction(tr("Mode"), this);
|
||||
m_modeSubMenuAct->setMenu(modeSubMenu);
|
||||
|
||||
QMenu *locationSubMenu = new QMenu(m_settingsMenu);
|
||||
locationSubMenu->setAccessibleName("locationsubmenu");
|
||||
@ -100,26 +97,23 @@ void MenuWorker::initUI()
|
||||
locationSubMenu->addAction(m_bottomPosAct);
|
||||
locationSubMenu->addAction(m_leftPosAct);
|
||||
locationSubMenu->addAction(m_rightPosAct);
|
||||
QAction *locationSubMenuAct = new QAction(tr("Location"), this);
|
||||
locationSubMenuAct->setMenu(locationSubMenu);
|
||||
m_locationSubMenuAct = new QAction(tr("Location"), this);
|
||||
m_locationSubMenuAct->setMenu(locationSubMenu);
|
||||
|
||||
QMenu *statusSubMenu = new QMenu(m_settingsMenu);
|
||||
statusSubMenu->setAccessibleName("statussubmenu");
|
||||
statusSubMenu->addAction(m_keepShownAct);
|
||||
statusSubMenu->addAction(m_keepHiddenAct);
|
||||
statusSubMenu->addAction(m_smartHideAct);
|
||||
QAction *statusSubMenuAct = new QAction(tr("Status"), this);
|
||||
statusSubMenuAct->setMenu(statusSubMenu);
|
||||
m_statusSubMenuAct = new QAction(tr("Status"), this);
|
||||
m_statusSubMenuAct->setMenu(statusSubMenu);
|
||||
|
||||
m_hideSubMenu = new QMenu(m_settingsMenu);
|
||||
m_hideSubMenu->setAccessibleName("pluginsmenu");
|
||||
QAction *hideSubMenuAct = new QAction(tr("Plugins"), this);
|
||||
hideSubMenuAct->setMenu(m_hideSubMenu);
|
||||
m_hideSubMenuAct = new QAction(tr("Plugins"), this);
|
||||
m_hideSubMenuAct->setMenu(m_hideSubMenu);
|
||||
|
||||
m_settingsMenu->addAction(modeSubMenuAct);
|
||||
m_settingsMenu->addAction(locationSubMenuAct);
|
||||
m_settingsMenu->addAction(statusSubMenuAct);
|
||||
m_settingsMenu->addAction(hideSubMenuAct);
|
||||
setSettingsMenu();
|
||||
m_settingsMenu->setTitle("Settings Menu");
|
||||
}
|
||||
|
||||
@ -127,8 +121,8 @@ void MenuWorker::initConnection()
|
||||
{
|
||||
connect(m_settingsMenu, &QMenu::triggered, this, &MenuWorker::menuActionClicked);
|
||||
|
||||
connect(GSettingsByMenu(), &QGSettings::changed, this, &MenuWorker::onGSettingsChanged);
|
||||
connect(GSettingsByTrash(), &QGSettings::changed, this, &MenuWorker::onTrashGSettingsChanged);
|
||||
connect(settingsModule("menu"), &QGSettings::changed, this, &MenuWorker::onGSettingsChanged);
|
||||
connect(settingsModule("trash"), &QGSettings::changed, this, &MenuWorker::onTrashGSettingsChanged);
|
||||
|
||||
connect(m_itemManager, &DockItemManager::trayVisableCountChanged, this, &MenuWorker::trayVisableCountChanged, Qt::QueuedConnection);
|
||||
|
||||
@ -138,6 +132,32 @@ void MenuWorker::initConnection()
|
||||
}
|
||||
}
|
||||
|
||||
const QGSettings *MenuWorker::settingsModule(const QString &module)
|
||||
{
|
||||
if (!m_settingsModuleMap.contains(module))
|
||||
m_settingsModuleMap.insert(module, new QGSettings(QString("com.deepin.dde.dock.module." + module).toUtf8()));
|
||||
|
||||
return m_settingsModuleMap[module];
|
||||
}
|
||||
|
||||
void MenuWorker::setSettingsMenu()
|
||||
{
|
||||
for (auto act : m_settingsMenu->actions())
|
||||
m_settingsMenu->removeAction(act);
|
||||
|
||||
if (settingsModule("menu")->get("modeVisible").toBool())
|
||||
m_settingsMenu->addAction(m_modeSubMenuAct);
|
||||
|
||||
if (settingsModule("menu")->get("locationVisible").toBool())
|
||||
m_settingsMenu->addAction(m_locationSubMenuAct);
|
||||
|
||||
if (settingsModule("menu")->get("statusVisible").toBool())
|
||||
m_settingsMenu->addAction(m_statusSubMenuAct);
|
||||
|
||||
if (settingsModule("menu")->get("hideVisible").toBool())
|
||||
m_settingsMenu->addAction(m_hideSubMenuAct);
|
||||
}
|
||||
|
||||
void MenuWorker::showDockSettingsMenu()
|
||||
{
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
@ -145,6 +165,7 @@ void MenuWorker::showDockSettingsMenu()
|
||||
});
|
||||
|
||||
setAutoHide(false);
|
||||
setSettingsMenu();
|
||||
|
||||
bool hasComposite = DWindowManagerHelper::instance()->hasComposite();
|
||||
|
||||
@ -174,7 +195,8 @@ void MenuWorker::showDockSettingsMenu()
|
||||
act->setChecked(enable);
|
||||
act->setData(name);
|
||||
|
||||
actions << act;
|
||||
if (!settingsModule(name)->keys().contains("visible") || settingsModule(name)->get("visible").toBool())
|
||||
actions << act;
|
||||
}
|
||||
|
||||
// sort by name
|
||||
@ -212,12 +234,8 @@ void MenuWorker::onGSettingsChanged(const QString &key)
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings *setting = GSettingsByMenu();
|
||||
|
||||
if (setting->keys().contains("enable")) {
|
||||
const bool isEnable = GSettingsByMenu()->keys().contains("enable") && GSettingsByMenu()->get("enable").toBool();
|
||||
m_menuEnable=isEnable && setting->get("enable").toBool();
|
||||
}
|
||||
const QGSettings *setting = settingsModule("menu");
|
||||
m_menuEnable = setting->keys().contains("enable") ? setting->get("enable").toBool() : m_menuEnable;
|
||||
}
|
||||
|
||||
void MenuWorker::onTrashGSettingsChanged(const QString &key)
|
||||
@ -226,11 +244,8 @@ void MenuWorker::onTrashGSettingsChanged(const QString &key)
|
||||
return ;
|
||||
}
|
||||
|
||||
QGSettings *setting = GSettingsByTrash();
|
||||
|
||||
if (setting->keys().contains("enable")) {
|
||||
m_trashPluginShow = GSettingsByTrash()->keys().contains("enable") && GSettingsByTrash()->get("enable").toBool();
|
||||
}
|
||||
const QGSettings *setting = settingsModule("trash");
|
||||
m_trashPluginShow = setting->keys().contains("enable") ? setting->get("enable").toBool() : m_trashPluginShow;
|
||||
}
|
||||
|
||||
void MenuWorker::menuActionClicked(QAction *action)
|
||||
|
@ -30,6 +30,7 @@ using DBusDock = com::deepin::dde::daemon::Dock;
|
||||
class QMenu;
|
||||
class QAction;
|
||||
class DockItemManager;
|
||||
class QGSettings;
|
||||
/**
|
||||
* @brief The MenuWorker class 此类用于处理任务栏右键菜单的逻辑
|
||||
*/
|
||||
@ -53,6 +54,10 @@ public:
|
||||
// TODO 是否还有其他的插件未处理其gsettings配置,这里只是移植之前的代码
|
||||
void onTrashGSettingsChanged(const QString &key);
|
||||
|
||||
private:
|
||||
const QGSettings *settingsModule(const QString &module);
|
||||
void setSettingsMenu();
|
||||
|
||||
signals:
|
||||
void autoHideChanged(const bool autoHide) const;
|
||||
void trayCountChanged();
|
||||
@ -68,6 +73,7 @@ public slots:
|
||||
private:
|
||||
DockItemManager *m_itemManager;
|
||||
DBusDock *m_dockInter;
|
||||
QMap<QString, QGSettings*> m_settingsModuleMap;
|
||||
|
||||
QMenu *m_settingsMenu;
|
||||
QMenu *m_hideSubMenu;
|
||||
@ -80,6 +86,10 @@ private:
|
||||
QAction *m_keepShownAct;
|
||||
QAction *m_keepHiddenAct;
|
||||
QAction *m_smartHideAct;
|
||||
QAction *m_modeSubMenuAct;
|
||||
QAction *m_locationSubMenuAct;
|
||||
QAction *m_statusSubMenuAct;
|
||||
QAction *m_hideSubMenuAct;
|
||||
|
||||
bool m_menuEnable;
|
||||
bool m_autoHide;
|
||||
|
@ -105,6 +105,20 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</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">
|
||||
@ -121,6 +135,13 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu 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">
|
||||
@ -137,6 +158,20 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/bluetooth/" id="com.deepin.dde.dock.module.bluetooth" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
@ -153,6 +188,13 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu 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">
|
||||
@ -176,6 +218,13 @@
|
||||
Show TimeToFull
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu 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">
|
||||
@ -192,6 +241,20 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</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">
|
||||
@ -208,6 +271,13 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu 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">
|
||||
@ -224,6 +294,20 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</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">
|
||||
@ -271,7 +355,36 @@
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="mode-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
<description>
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="location-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
<description>
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="status-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
<description>
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="hide-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
<description>
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/AiAssistant/" id="com.deepin.dde.dock.module.AiAssistant" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
@ -288,6 +401,66 @@
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/multitasking/" id="com.deepin.dde.dock.module.multitasking" gettext-domain="DDE">
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/show-desktop/" id="com.deepin.dde.dock.module.show-desktop" gettext-domain="DDE">
|
||||
<key type="b" name="enable">
|
||||
<default>true</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="menu-enable">
|
||||
<default>true</default>
|
||||
<summary>Menu Enable</summary>
|
||||
<description>
|
||||
Control Menu Enable
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="visible">
|
||||
<default>true</default>
|
||||
<summary>Module visible</summary>
|
||||
<description>
|
||||
Control Menu pluginsettings visible
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/touch/" id="com.deepin.dde.dock.touch" gettext-domain="DDE">
|
||||
<key type="i" name="resize-height">
|
||||
|
@ -239,7 +239,7 @@ void SystemTrayItem::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
if (perfectIconRect().contains(event->pos(), true)) {
|
||||
return showContextMenu();
|
||||
return (m_gsettings && m_gsettings->get("menuEnable").toBool()) ? showContextMenu() : void();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user