mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: 任务栏增加跳转控制中心菜单
任务栏增加跳转控制中心菜单,同时去除插件和多屏配置的菜单 插件部分的指针不用处理,由插件框架管理 Log: 任务栏部分配置转移到控制中心 Task: https://pms.uniontech.com/zentao/task-view-86359.html Change-Id: Icb792198c8967f122fb8b8ae4acf2dee79064203
This commit is contained in:
parent
95243706b4
commit
00392c0617
@ -28,6 +28,7 @@
|
||||
#include <QGSettings>
|
||||
|
||||
#include <DApplication>
|
||||
#include <DDBusSender>
|
||||
|
||||
#define DIS_INS DisplayManager::instance()
|
||||
|
||||
@ -145,98 +146,10 @@ QMenu *MenuWorker::createMenu()
|
||||
settingsMenu->addAction(act);
|
||||
}
|
||||
|
||||
// 插件
|
||||
if (!menuSettings || !menuSettings->keys().contains("hideVisible") || menuSettings->get("hideVisible").toBool()) {
|
||||
QMenu *hideSubMenu = new QMenu(settingsMenu);
|
||||
hideSubMenu->setAccessibleName("pluginsmenu");
|
||||
|
||||
QAction *hideSubMenuAct = new QAction(tr("Plugins"), this);
|
||||
hideSubMenuAct->setMenu(hideSubMenu);
|
||||
|
||||
// create actions
|
||||
QList<QAction *> actions;
|
||||
for (auto *p : DockItemManager::instance()->pluginList()) {
|
||||
if (!p->pluginIsAllowDisable())
|
||||
continue;
|
||||
|
||||
const bool enable = !p->pluginIsDisable();
|
||||
const QString &name = p->pluginName();
|
||||
const QString &display = p->pluginDisplayName();
|
||||
|
||||
// 模块和菜单均需要响应enable配置的变化
|
||||
const QGSettings *setting = Utils::ModuleSettingsPtr(name);
|
||||
if (setting && setting->keys().contains("enable") && !setting->get("enable").toBool()) {
|
||||
continue;
|
||||
}
|
||||
delete setting;
|
||||
setting = nullptr;
|
||||
|
||||
// 未开启窗口特效时,同样不显示多任务视图插件
|
||||
if (name == "multitasking" && !DWindowManagerHelper::instance()->hasComposite()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name == "deepin-screen-recorder-plugin") {
|
||||
continue;
|
||||
}
|
||||
|
||||
QAction *act = new QAction(display, this);
|
||||
act->setCheckable(true);
|
||||
act->setChecked(enable);
|
||||
act->setData(name);
|
||||
|
||||
connect(act, &QAction::triggered, this, [ p ]{p->pluginStateSwitched();});
|
||||
|
||||
// check plugin hide menu.
|
||||
const QGSettings *pluginSettings = Utils::ModuleSettingsPtr(name);
|
||||
if (pluginSettings && (!pluginSettings->keys().contains("visible") || pluginSettings->get("visible").toBool()))
|
||||
actions << act;
|
||||
}
|
||||
|
||||
// sort by name
|
||||
std::sort(actions.begin(), actions.end(), [](QAction * a, QAction * b) -> bool {
|
||||
return a->data().toString() > b->data().toString();
|
||||
});
|
||||
|
||||
// add plugins actions
|
||||
qDeleteAll(hideSubMenu->actions());
|
||||
for (auto act : actions)
|
||||
hideSubMenu->addAction(act);
|
||||
|
||||
// add plugins menu
|
||||
settingsMenu->addAction(hideSubMenuAct);
|
||||
}
|
||||
|
||||
// 多屏显示设置 仅多屏扩展模式显示菜单
|
||||
if ((!menuSettings || !menuSettings->keys().contains("multiscreenVisible") || menuSettings->get("multiscreenVisible").toBool())
|
||||
&& (QApplication::screens().size() > 1) && !DIS_INS->isCopyMode()) {
|
||||
bool onlyShowPrimary = Utils::SettingValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", false).toBool();
|
||||
|
||||
QMenu *displaySubMenu = new QMenu(settingsMenu);
|
||||
displaySubMenu->setAccessibleName("displaysubmenu");
|
||||
|
||||
QAction *onlyPrimaryScreenModeAct = new QAction(tr("Only on main screen"), this);
|
||||
QAction *followMouseModeAct = new QAction(tr("On screen where the cursor is"), this);
|
||||
|
||||
onlyPrimaryScreenModeAct->setCheckable(true);
|
||||
followMouseModeAct->setCheckable(true);
|
||||
|
||||
onlyPrimaryScreenModeAct->setChecked(onlyShowPrimary);
|
||||
followMouseModeAct->setChecked(!onlyShowPrimary);
|
||||
|
||||
connect(onlyPrimaryScreenModeAct, &QAction::triggered, this, [ = ]{
|
||||
Utils::SettingSaveValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", true);
|
||||
});
|
||||
connect(followMouseModeAct, &QAction::triggered, this, [ = ]{
|
||||
Utils::SettingSaveValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", false);
|
||||
});
|
||||
|
||||
displaySubMenu->addAction(onlyPrimaryScreenModeAct);
|
||||
displaySubMenu->addAction(followMouseModeAct);
|
||||
|
||||
QAction *act = new QAction(tr("Show the Dock"), this);
|
||||
act->setMenu(displaySubMenu);
|
||||
|
||||
// 任务栏配置
|
||||
if (!menuSettings || !menuSettings->keys().contains("settingVisible") || menuSettings->get("settingVisible").toBool()) {
|
||||
QAction *act = new QAction(tr("Dock setting"), this);
|
||||
connect(act, &QAction::triggered, this, &MenuWorker::onDockSettingsTriggered);
|
||||
settingsMenu->addAction(act);
|
||||
}
|
||||
|
||||
@ -245,6 +158,17 @@ QMenu *MenuWorker::createMenu()
|
||||
return settingsMenu;
|
||||
}
|
||||
|
||||
void MenuWorker::onDockSettingsTriggered()
|
||||
{
|
||||
DDBusSender().service("com.deepin.dde.ControlCenter")
|
||||
.path("/com/deepin/dde/ControlCenter")
|
||||
.interface("com.deepin.dde.ControlCenter")
|
||||
.method("ShowPage")
|
||||
.arg(QString("personalization"))
|
||||
.arg(QString("Dock"))
|
||||
.call();
|
||||
}
|
||||
|
||||
void MenuWorker::showDockSettingsMenu()
|
||||
{
|
||||
// 菜单功能被禁用
|
||||
|
@ -49,6 +49,9 @@ public slots:
|
||||
private:
|
||||
QMenu *createMenu();
|
||||
|
||||
private slots:
|
||||
void onDockSettingsTriggered();
|
||||
|
||||
private:
|
||||
DBusDock *m_dockInter;
|
||||
bool m_autoHide;
|
||||
|
@ -426,6 +426,14 @@
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="setting-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
<description>
|
||||
Control Setting Menu Visible
|
||||
</description>
|
||||
</key>
|
||||
<!-- start 以下配置不再起作用,对应的菜单已经被删除,为了防止定制化场景调用出错,暂时保留-->
|
||||
<key type="b" name="hide-visible">
|
||||
<default>true</default>
|
||||
<summary>Module Visible</summary>
|
||||
@ -440,7 +448,7 @@
|
||||
Control Multiscreen Visible
|
||||
</description>
|
||||
</key>
|
||||
|
||||
<!-- end -->
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/AiAssistant/" id="com.deepin.dde.dock.module.AiAssistant" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
|
@ -33,7 +33,7 @@ SettingsModule::SettingsModule()
|
||||
|
||||
SettingsModule::~SettingsModule()
|
||||
{
|
||||
delete m_moduleWidget;
|
||||
|
||||
}
|
||||
|
||||
void SettingsModule::initialize()
|
||||
|
Loading…
x
Reference in New Issue
Block a user