feat: 增加设置任务栏是否开启窗口多开的接口
增加接口setShowMultiWindow和showMultiWindow接口,用于设置和返回任务栏是否支持窗口多开的功能 Log: 增加设置任务栏是否开启窗口多开的功能 Influence: 控制中心-个性化-任务栏,设置开启或者关闭任务栏支持窗口多开,观察任务栏相同的应用打开多个窗口的情况下,是否在多开区域存在多开的窗口 Task: https://pms.uniontech.com/task-view-170977.html Change-Id: I208aba19f3ab94a02f72e64d0d4eeb1e83a7a6bf
This commit is contained in:
		@ -161,6 +161,16 @@
 | 
			
		||||
			"description": "show or hide recent app in dock",
 | 
			
		||||
			"permissions": "readwrite",
 | 
			
		||||
			"visibility": "private"
 | 
			
		||||
		},
 | 
			
		||||
		"Show_MultiWindow": {
 | 
			
		||||
			"value": false,
 | 
			
		||||
			"serial": 0,
 | 
			
		||||
			"flags": [],
 | 
			
		||||
			"name": "Show_MultiWindow",
 | 
			
		||||
			"name[zh_CN]": "*****",
 | 
			
		||||
			"description": "show or hide Multi Window in dock when the Entry has subWindow",
 | 
			
		||||
			"permissions": "readwrite",
 | 
			
		||||
			"visibility": "private"
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -43,6 +43,7 @@ const QString keyPluginSettings       = "Plugin_Settings";
 | 
			
		||||
const QString keyForceQuitApp         = "Force_Quit_App";
 | 
			
		||||
const QString keyRecentApp            = "Recent_App";
 | 
			
		||||
const QString keyShowRecent           = "Show_Recent";
 | 
			
		||||
const QString keyShowMultiWindow      = "Show_MultiWindow";
 | 
			
		||||
 | 
			
		||||
const QString scratchDir = QDir::homePath() + "/.local/dock/scratch/";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,7 @@ DBusAdaptorDock::DBusAdaptorDock(QObject *parent)
 | 
			
		||||
        connect(dock, &Dock::hideStateChanged, this, &DBusAdaptorDock::HideStateChanged);
 | 
			
		||||
        connect(dock, &Dock::frontendWindowRectChanged, this, &DBusAdaptorDock::FrontendWindowRectChanged);
 | 
			
		||||
        connect(dock, &Dock::showRecentChanged, this, &DBusAdaptorDock::showRecentChanged);
 | 
			
		||||
        connect(dock, &Dock::showMultiWindowChanged, this, &DBusAdaptorDock::ShowMultiWindowChanged);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -180,6 +181,11 @@ bool DBusAdaptorDock::showRecent() const
 | 
			
		||||
    return parent()->showRecent();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool DBusAdaptorDock::showMultiWindow() const
 | 
			
		||||
{
 | 
			
		||||
    return parent()->showMultiWindow();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Dock *DBusAdaptorDock::parent() const
 | 
			
		||||
{
 | 
			
		||||
    return static_cast<Dock *>(QObject::parent());
 | 
			
		||||
@ -256,6 +262,11 @@ void DBusAdaptorDock::SetShowRecent(bool visible)
 | 
			
		||||
    parent()->setShowRecent(visible);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DBusAdaptorDock::SetShowMultiWindow(bool showMultiWindow)
 | 
			
		||||
{
 | 
			
		||||
    parent()->setShowMultiWindow(showMultiWindow);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DBusAdaptorDock::SetFrontendWindowRect(int x, int y, uint width, uint height)
 | 
			
		||||
{
 | 
			
		||||
    parent()->setFrontendWindowRect(x, y, width, height);
 | 
			
		||||
 | 
			
		||||
@ -96,6 +96,9 @@ class DBusAdaptorDock: public QDBusAbstractAdaptor
 | 
			
		||||
                                       "    <method name=\"SetShowRecent\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"b\" name=\"visible\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"SetShowMultiWindow\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"b\" name=\"visible\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"SetFrontendWindowRect\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
 | 
			
		||||
@ -124,6 +127,7 @@ class DBusAdaptorDock: public QDBusAbstractAdaptor
 | 
			
		||||
                                       "    <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"b\" name=\"ShowRecent\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"b\" name=\"ShowMultiWindow\"/>\n"
 | 
			
		||||
                                       "  </interface>\n"
 | 
			
		||||
                                       "")
 | 
			
		||||
public:
 | 
			
		||||
@ -181,6 +185,9 @@ public: // PROPERTIES
 | 
			
		||||
    Q_PROPERTY(bool ShowRecent READ showRecent NOTIFY showRecentChanged)
 | 
			
		||||
    bool showRecent() const;
 | 
			
		||||
 | 
			
		||||
    Q_PROPERTY(bool ShowMultiWindow READ showMultiWindow NOTIFY ShowMultiWindowChanged)
 | 
			
		||||
    bool showMultiWindow() const;
 | 
			
		||||
 | 
			
		||||
    Dock *parent() const;
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS: // METHODS
 | 
			
		||||
@ -198,6 +205,7 @@ public Q_SLOTS: // METHODS
 | 
			
		||||
    bool RequestDock(const QString &desktopFile, int index);
 | 
			
		||||
    bool RequestUndock(const QString &desktopFile);
 | 
			
		||||
    void SetShowRecent(bool visible);
 | 
			
		||||
    void SetShowMultiWindow(bool showMultiWindow);
 | 
			
		||||
    void SetFrontendWindowRect(int x, int y, uint width, uint height);
 | 
			
		||||
 | 
			
		||||
Q_SIGNALS: // SIGNALS
 | 
			
		||||
@ -219,6 +227,7 @@ Q_SIGNALS: // SIGNALS
 | 
			
		||||
    void WindowSizeEfficientChanged(uint value) const;
 | 
			
		||||
    void WindowSizeFashionChanged(uint value) const;
 | 
			
		||||
    void showRecentChanged(bool) const;
 | 
			
		||||
    void ShowMultiWindowChanged(bool) const;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -122,6 +122,11 @@ void DBusAdaptorEntry::ForceQuit()
 | 
			
		||||
    parent()->forceQuit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DBusAdaptorEntry::ActiveWindow(quint32 winId)
 | 
			
		||||
{
 | 
			
		||||
    parent()->activeWindow(winId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<QVariant> DBusAdaptorEntry::GetAllowedCloseWindows()
 | 
			
		||||
{
 | 
			
		||||
    auto ids = parent()->getAllowedClosedWindowIds();
 | 
			
		||||
 | 
			
		||||
@ -52,6 +52,9 @@ class DBusAdaptorEntry: public QDBusAbstractAdaptor
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"Check\"/>\n"
 | 
			
		||||
                                       "    <method name=\"ForceQuit\"/>\n"
 | 
			
		||||
                                       "    <method name=\"ActiveWindow\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"u\" name=\"winId\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"GetAllowedCloseWindows\">\n"
 | 
			
		||||
                                       "      <arg direction=\"out\" type=\"au\" name=\"windows\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
@ -124,6 +127,7 @@ public Q_SLOTS: // METHODS
 | 
			
		||||
    void Activate(uint timestamp);
 | 
			
		||||
    void Check();
 | 
			
		||||
    void ForceQuit();
 | 
			
		||||
    void ActiveWindow(quint32 winId);
 | 
			
		||||
    QList<QVariant> GetAllowedCloseWindows();
 | 
			
		||||
    void HandleDragDrop(uint timestamp, const QStringList &files);
 | 
			
		||||
    void HandleMenuItem(uint timestamp, const QString &id);
 | 
			
		||||
 | 
			
		||||
@ -50,6 +50,8 @@ Dock::Dock(QObject *parent)
 | 
			
		||||
 , m_activeWindowOld(nullptr)
 | 
			
		||||
 , m_dbusHandler(new DBusHandler(this))
 | 
			
		||||
 , m_windowOperateMutex(QMutex(QMutex::NonRecursive))
 | 
			
		||||
 , m_showRecent(false)
 | 
			
		||||
 , m_showMultiWindow(false)
 | 
			
		||||
{
 | 
			
		||||
    registeModule("dock");
 | 
			
		||||
 | 
			
		||||
@ -199,8 +201,8 @@ void Dock::undockEntry(Entry *entry, bool moveToEnd)
 | 
			
		||||
{
 | 
			
		||||
    if (!entry->getIsDocked()) {
 | 
			
		||||
        qInfo() << "undockEntry: " << entry->getId() << " is not docked";
 | 
			
		||||
        // 在当前未驻留的情况下执行取消驻留操作,则让其直接从当前列表中移除
 | 
			
		||||
        // 这种情况一般是在从最近打开应用中拖动应用到回收站的时候执行的操作
 | 
			
		||||
        // 当应用图标在最近打开区域的时候,此时该应用是未驻留的应用,如果该最近打开应用没有打开窗口,将这个图标
 | 
			
		||||
        // 拖动到回收站了,此时调用的是undock方法,根据需求,需要将该图标删除
 | 
			
		||||
        if (!entry->hasWindow()) {
 | 
			
		||||
            // 没有子窗口的情况下,从列表中移除
 | 
			
		||||
            removeAppEntry(entry);
 | 
			
		||||
@ -574,6 +576,20 @@ bool Dock::showRecent() const
 | 
			
		||||
    return m_showRecent;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Dock::setShowMultiWindow(bool visible)
 | 
			
		||||
{
 | 
			
		||||
    if (m_showMultiWindow == visible)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    SETTING->setShowMultiWindow(visible);
 | 
			
		||||
    onShowMultiWindowChanged(visible);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Dock::showMultiWindow() const
 | 
			
		||||
{
 | 
			
		||||
    return m_showMultiWindow;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Dock::moveEntry 移动驻留程序顺序
 | 
			
		||||
 * @param oldIndex
 | 
			
		||||
@ -688,6 +704,7 @@ void Dock::initSettings()
 | 
			
		||||
       m_entries->updateEntriesMenu();
 | 
			
		||||
    });
 | 
			
		||||
    connect(SETTING, &DockSettings::showRecentChanged, this, &Dock::onShowRecentChanged);
 | 
			
		||||
    connect(SETTING, &DockSettings::showMultiWindowChanged, this, &Dock::onShowMultiWindowChanged);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -706,6 +723,8 @@ void Dock::loadAppInfos()
 | 
			
		||||
{
 | 
			
		||||
    // 读取是否显示最近打开应用
 | 
			
		||||
    m_showRecent = SETTING->showRecent();
 | 
			
		||||
    // 读取是否显示多开窗口拆分
 | 
			
		||||
    m_showMultiWindow = SETTING->showMultiWindow();
 | 
			
		||||
    // 初始化驻留应用信息和最近使用的应用的信息
 | 
			
		||||
    auto loadApps = [ this ](const QStringList &apps, bool isDocked) {
 | 
			
		||||
        for (const QString &app : apps) {
 | 
			
		||||
@ -717,6 +736,7 @@ void Dock::loadAppInfos()
 | 
			
		||||
            AppInfo *appInfo = new AppInfo(info);
 | 
			
		||||
            Entry *entryObj = new Entry(this, appInfo, appInfo->getInnerId());
 | 
			
		||||
            entryObj->setIsDocked(isDocked);
 | 
			
		||||
            entryObj->updateMode();
 | 
			
		||||
            entryObj->updateMenu();
 | 
			
		||||
            entryObj->startExport();
 | 
			
		||||
            m_entries->append(entryObj);
 | 
			
		||||
@ -927,9 +947,9 @@ bool Dock::shouldHideOnSmartHideMode()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    } else {
 | 
			
		||||
        return isWindowDockOverlapK(m_activeWindow);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return isWindowDockOverlapK(m_activeWindow);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -1260,6 +1280,15 @@ void Dock::onShowRecentChanged(bool visible)
 | 
			
		||||
    Q_EMIT showRecentChanged(visible);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Dock::onShowMultiWindowChanged(bool visible)
 | 
			
		||||
{
 | 
			
		||||
    if (m_showMultiWindow == visible)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    m_showMultiWindow = visible;
 | 
			
		||||
    Q_EMIT showMultiWindowChanged(visible);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 移除应用实例
 | 
			
		||||
 * @brief Dock::removeAppEntry
 | 
			
		||||
 * @param entry
 | 
			
		||||
 | 
			
		||||
@ -135,6 +135,8 @@ public:
 | 
			
		||||
    bool requestUndock(QString desktopFile);
 | 
			
		||||
    void setShowRecent(bool visible);
 | 
			
		||||
    bool showRecent() const;
 | 
			
		||||
    void setShowMultiWindow(bool visible);
 | 
			
		||||
    bool showMultiWindow() const;
 | 
			
		||||
    void moveEntry(int oldIndex, int newIndex);
 | 
			
		||||
    bool isOnDock(QString desktopFile);
 | 
			
		||||
    QString queryWindowIdentifyMethod(XWindow windowId);
 | 
			
		||||
@ -151,6 +153,7 @@ Q_SIGNALS:
 | 
			
		||||
    void hideStateChanged(int);
 | 
			
		||||
    void frontendWindowRectChanged();
 | 
			
		||||
    void showRecentChanged(bool);
 | 
			
		||||
    void showMultiWindowChanged(bool);
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS:
 | 
			
		||||
    void updateHideState(bool delay);
 | 
			
		||||
@ -176,6 +179,7 @@ private:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void onShowRecentChanged(bool visible);
 | 
			
		||||
    void onShowMultiWindowChanged(bool visible);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    WindowIdentify *m_windowIdentify; // 窗口识别
 | 
			
		||||
@ -196,6 +200,7 @@ private:
 | 
			
		||||
    DBusHandler *m_dbusHandler;   // 处理dbus交互
 | 
			
		||||
    QMutex m_windowOperateMutex;  // 窗口合并或拆分锁
 | 
			
		||||
    bool m_showRecent;
 | 
			
		||||
    bool m_showMultiWindow;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // DOCK_H
 | 
			
		||||
 | 
			
		||||
@ -54,6 +54,8 @@ void DockSettings::init()
 | 
			
		||||
                    Q_EMIT forceQuitAppChanged(ForceQuitAppModeHandler(mode).toEnum());
 | 
			
		||||
                } else if (key == keyShowRecent) {
 | 
			
		||||
                    Q_EMIT showRecentChanged(m_dockSettings->value(key).toBool());
 | 
			
		||||
                } else if (key == keyShowMultiWindow) {
 | 
			
		||||
                    Q_EMIT showMultiWindowChanged(m_dockSettings->value(key).toBool());
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
@ -291,6 +293,22 @@ bool DockSettings::showRecent() const
 | 
			
		||||
    return m_dockSettings->value(keyShowRecent).toBool();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DockSettings::setShowMultiWindow(bool showMultiWindow)
 | 
			
		||||
{
 | 
			
		||||
    if (!m_dockSettings)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    m_dockSettings->setValue(keyShowMultiWindow, showMultiWindow);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool DockSettings::showMultiWindow() const
 | 
			
		||||
{
 | 
			
		||||
    if (!m_dockSettings)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    return m_dockSettings->value(keyShowMultiWindow).toBool();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DockSettings::getPluginSettings()
 | 
			
		||||
{
 | 
			
		||||
    QString ret;
 | 
			
		||||
 | 
			
		||||
@ -238,6 +238,9 @@ public:
 | 
			
		||||
    void setShowRecent(bool visible);
 | 
			
		||||
    bool showRecent() const;
 | 
			
		||||
 | 
			
		||||
    void setShowMultiWindow(bool showMultiWindow);
 | 
			
		||||
    bool showMultiWindow() const;
 | 
			
		||||
 | 
			
		||||
    // plugin settings
 | 
			
		||||
    QString getPluginSettings();
 | 
			
		||||
    void setPluginSettings(QString jsonStr);
 | 
			
		||||
@ -256,6 +259,8 @@ Q_SIGNALS:
 | 
			
		||||
    void forceQuitAppChanged(ForceQuitAppMode mode);
 | 
			
		||||
    // 是否显示最近打开应用改变
 | 
			
		||||
    void showRecentChanged(bool);
 | 
			
		||||
    // 是否显示多开应用改变
 | 
			
		||||
    void showMultiWindowChanged(bool);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    DockSettings(QObject *paret = nullptr);
 | 
			
		||||
 | 
			
		||||
@ -715,6 +715,33 @@ void Entry::active(uint32_t timestamp)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Entry::activeWindow(quint32 winId)
 | 
			
		||||
{
 | 
			
		||||
    if (dock->isWaylandEnv()) {
 | 
			
		||||
        if (!m_windowInfoMap.contains(winId))
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        WindowInfoBase *winInfo = m_windowInfoMap[winId];
 | 
			
		||||
        if (dock->isActiveWindow(winInfo)) {
 | 
			
		||||
            bool showing = dock->isShowingDesktop();
 | 
			
		||||
            if (showing || winInfo->isMinimized()) {
 | 
			
		||||
                winInfo->activate();
 | 
			
		||||
            } else if (m_windowInfoMap.size() == 1) {
 | 
			
		||||
                winInfo->minimize();
 | 
			
		||||
            } else {
 | 
			
		||||
                WindowInfoBase *nextWin = findNextLeader();
 | 
			
		||||
                if (nextWin) {
 | 
			
		||||
                    nextWin->activate();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            winInfo->activate();
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        dock->doActiveWindow(winId);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Entry::mode()
 | 
			
		||||
{
 | 
			
		||||
    return m_mode;
 | 
			
		||||
 | 
			
		||||
@ -92,6 +92,7 @@ public:
 | 
			
		||||
    void forceQuit();
 | 
			
		||||
    void presentWindows();
 | 
			
		||||
    void active(uint32_t timestamp);
 | 
			
		||||
    void activeWindow(quint32 winId);
 | 
			
		||||
    int mode();
 | 
			
		||||
 | 
			
		||||
    XWindow getCurrentWindow();
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user