mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
多屏扩展模式下,任务栏右键菜单添加“多屏显示设置”
多屏模式扩展模式下,任务栏右键菜单添加“多屏显示设置”,可以设置为仅主屏显示或者跟随鼠标位置显示 Log: 任务栏支持配置仅显示在主屏 Task: https://pms.uniontech.com/zentao/task-view-83869.html Change-Id: I790f8bef24884162729cb8ede91397b149fe4954
This commit is contained in:
parent
d78a53e6ab
commit
85872693ed
@ -116,6 +116,28 @@ bool DisplayManager::canDock(QScreen *s, Position pos) const
|
||||
return s ? m_screenPositionMap[s].value(pos) : false;
|
||||
}
|
||||
|
||||
/**判断屏幕是否为复制模式的依据,第一个屏幕的X和Y值是否和其他的屏幕的X和Y值相等
|
||||
* 对于复制模式,这两个值肯定是相等的,如果不是复制模式,这两个值肯定不等,目前支持双屏
|
||||
* @brief DisplayManager::isCopyMode
|
||||
* @return
|
||||
*/
|
||||
bool DisplayManager::isCopyMode()
|
||||
{
|
||||
QList<QScreen *> screens = this->screens();
|
||||
if (screens.size() < 2)
|
||||
return false;
|
||||
|
||||
// 在多个屏幕的情况下,如果所有屏幕的位置的X和Y值都相等,则认为是复制模式
|
||||
QRect screenRect = screens[0]->availableGeometry();
|
||||
for (int i = 1; i < screens.size(); i++) {
|
||||
QRect rect = screens[i]->availableGeometry();
|
||||
if (screenRect.x() != rect.x() || screenRect.y() != rect.y())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DisplayManager::updateScreenDockInfo
|
||||
* 更新屏幕停靠信息
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
int screenRawWidth() const;
|
||||
int screenRawHeight() const;
|
||||
bool canDock(QScreen *s, Position pos) const;
|
||||
bool isCopyMode();
|
||||
|
||||
private:
|
||||
void updateScreenDockInfo();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "menuworker.h"
|
||||
#include "dockitemmanager.h"
|
||||
#include "utils.h"
|
||||
#include "displaymanager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
@ -28,6 +29,8 @@
|
||||
|
||||
#include <DApplication>
|
||||
|
||||
#define DIS_INS DisplayManager::instance()
|
||||
|
||||
MenuWorker::MenuWorker(DBusDock *dockInter,QWidget *parent)
|
||||
: QObject (parent)
|
||||
, m_dockInter(dockInter)
|
||||
@ -208,6 +211,39 @@ QMenu *MenuWorker::createMenu()
|
||||
settingsMenu->addAction(hideSubMenuAct);
|
||||
}
|
||||
|
||||
// 多屏显示设置 仅多屏扩展模式显示菜单
|
||||
if ((!menuSettings || !menuSettings->keys().contains("multiscreenVisible") || menuSettings->get("multiscreenVisible").toBool())
|
||||
&& !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);
|
||||
|
||||
settingsMenu->addAction(act);
|
||||
}
|
||||
|
||||
delete menuSettings;
|
||||
menuSettings = nullptr;
|
||||
|
||||
|
@ -690,27 +690,6 @@ void MultiScreenWorker::onRequestUpdateFrontendGeometry()
|
||||
emit requestUpdateDockEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断屏幕是否为复制模式的依据,第一个屏幕的X和Y值是否和其他的屏幕的X和Y值相等
|
||||
* 对于复制模式,这两个值肯定是相等的,如果不是复制模式,这两个值肯定不等,目前支持双屏
|
||||
*/
|
||||
static bool isCopyMode()
|
||||
{
|
||||
QList<QScreen *> screens = DIS_INS->screens();
|
||||
if (screens.size() < 2)
|
||||
return false;
|
||||
|
||||
// 在多个屏幕的情况下,如果所有屏幕的位置的X和Y值都相等,则认为是复制模式
|
||||
QRect rect0 = screens[0]->availableGeometry();
|
||||
for (int i = 1; i < screens.size(); i++) {
|
||||
QRect rect = screens[i]->availableGeometry();
|
||||
if (rect0.x() != rect.x() || rect0.y() != rect.y())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 这里用到xcb去设置任务栏的高度,比较特殊,参考_NET_WM_STRUT_PARTIAL属性
|
||||
* 在屏幕旋转后,所有参数以控制中心自定义设置里主屏显示的图示为准(旋转不用特殊处理)
|
||||
@ -722,7 +701,7 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
|
||||
static int lastScreenHeight = 0;
|
||||
|
||||
/* 在非主屏或非一直显示状态时,清除任务栏区域,不挤占应用 */
|
||||
if ((!isCopyMode() && m_ds.current() != m_ds.primary()) || m_hideMode != HideMode::KeepShowing) {
|
||||
if ((!DIS_INS->isCopyMode() && m_ds.current() != m_ds.primary()) || m_hideMode != HideMode::KeepShowing) {
|
||||
lastRect = QRect();
|
||||
|
||||
const auto display = QX11Info::display();
|
||||
|
@ -38,7 +38,8 @@ namespace Utils {
|
||||
* @param parent 创建指针的付对象
|
||||
* @return
|
||||
*/
|
||||
inline const QGSettings *SettingsPtr(const QString &schema_id, const QByteArray &path = QByteArray(), QObject *parent = nullptr) {
|
||||
inline QGSettings *SettingsPtr(const QString &schema_id, const QByteArray &path = QByteArray(), QObject *parent = nullptr)
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled(schema_id.toUtf8())) {
|
||||
QGSettings *settings = new QGSettings(schema_id.toUtf8(), path, parent);
|
||||
return settings;
|
||||
@ -54,7 +55,8 @@ inline const QGSettings *SettingsPtr(const QString &schema_id, const QByteArray
|
||||
* @param parent 创建指针的付对象
|
||||
* @return
|
||||
*/
|
||||
inline const QGSettings *ModuleSettingsPtr(const QString &module, const QByteArray &path = QByteArray(), QObject *parent = nullptr) {
|
||||
inline const QGSettings *ModuleSettingsPtr(const QString &module, const QByteArray &path = QByteArray(), QObject *parent = nullptr)
|
||||
{
|
||||
return SettingsPtr("com.deepin.dde.dock.module." + module, path, parent);
|
||||
}
|
||||
|
||||
@ -90,7 +92,8 @@ inline QString qtify_name(const char *name)
|
||||
* @param fallback 如果找不到信息,返回此默认值
|
||||
* @return
|
||||
*/
|
||||
inline const QVariant SettingValue(const QString &schema_id, const QByteArray &path = QByteArray(), const QString &key = QString(), const QVariant &fallback = QVariant()){
|
||||
inline const QVariant SettingValue(const QString &schema_id, const QByteArray &path = QByteArray(), const QString &key = QString(), const QVariant &fallback = QVariant())
|
||||
{
|
||||
const QGSettings *settings = SettingsPtr(schema_id, path);
|
||||
|
||||
if (settings && ((settings->keys().contains(key)) || settings->keys().contains(qtify_name(key.toUtf8().data())))) {
|
||||
@ -101,11 +104,34 @@ inline const QVariant SettingValue(const QString &schema_id, const QByteArray &p
|
||||
qDebug() << "Cannot find gsettings, schema_id:" << schema_id
|
||||
<< " path:" << path << " key:" << key
|
||||
<< "Use fallback value:" << fallback;
|
||||
// 如果settings->keys()不包含key则会存在内存泄露,所以需要释放
|
||||
if (settings)
|
||||
delete settings;
|
||||
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
||||
inline bool SettingSaveValue(const QString &schema_id, const QByteArray &path, const QString &key, const QVariant &value)
|
||||
{
|
||||
QGSettings *settings = SettingsPtr(schema_id, path);
|
||||
|
||||
if (settings && ((settings->keys().contains(key)) || settings->keys().contains(qtify_name(key.toUtf8().data())))) {
|
||||
settings->set(key, value);
|
||||
delete settings;
|
||||
return true;
|
||||
} else{
|
||||
qDebug() << "Cannot find gsettings, schema_id:" << schema_id
|
||||
<< " path:" << path << " key:" << key;
|
||||
if (settings)
|
||||
delete settings;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio)
|
||||
{
|
||||
QImageReader reader;
|
||||
QPixmap pixmap;
|
||||
reader.setFileName(path);
|
||||
@ -146,7 +172,8 @@ inline QScreen *screenAtByScaled(const QPoint &point) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline bool isSettingConfigured(const QString& id, const QString& path, const QString& keyName) {
|
||||
inline bool isSettingConfigured(const QString& id, const QString& path, const QString& keyName)
|
||||
{
|
||||
if (!QGSettings::isSchemaInstalled(id.toUtf8())) {
|
||||
return false;
|
||||
}
|
||||
@ -164,7 +191,8 @@ inline bool isSettingConfigured(const QString& id, const QString& path, const QS
|
||||
* @param pluginApi2 第二个插件版本号
|
||||
* @return 0:两个版本号相等,1:第一个版本号大,-1:第二个版本号大
|
||||
*/
|
||||
inline int comparePluginApi(const QString &pluginApi1, const QString &pluginApi2) {
|
||||
inline int comparePluginApi(const QString &pluginApi1, const QString &pluginApi2)
|
||||
{
|
||||
// 版本号相同
|
||||
if (pluginApi1 == pluginApi2)
|
||||
return 0;
|
||||
|
@ -410,6 +410,13 @@
|
||||
Control Module Visible
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="multiscreen-visible">
|
||||
<default>true</default>
|
||||
<summary>Multiscreen Visible</summary>
|
||||
<description>
|
||||
Control Multiscreen Visible
|
||||
</description>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/AiAssistant/" id="com.deepin.dde.dock.module.AiAssistant" gettext-domain="DDE">
|
||||
|
Loading…
x
Reference in New Issue
Block a user