mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat: 修改部分函数命名和注释
函数命名变更,部分注释转移到源文件中,方便阅读头文件,去除mock的部分代码文件 Log: Change-Id: I9cbb7d5a21a60c4643efbf78da7c599d85bd0829
This commit is contained in:
parent
a84c837ba1
commit
e2e9211d1c
@ -24,61 +24,15 @@
|
||||
#include "launcheritem.h"
|
||||
#include "pluginsitem.h"
|
||||
#include "traypluginitem.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGSettings>
|
||||
|
||||
DockItemManager *DockItemManager::INSTANCE = nullptr;
|
||||
|
||||
static QGSettingsInterface *GSettingsByApp(QGSettingsInterface::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case QGSettingsInterface::Type::ImplType:
|
||||
{
|
||||
static QGSettingsInterfaceImpl settings("com.deepin.dde.dock.module.app");
|
||||
return &settings;
|
||||
}
|
||||
default:
|
||||
{
|
||||
qWarning("Unless you are doing unit testing, you should't see this message");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static QGSettingsInterface *GSettingsByActiveApp(QGSettingsInterface::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case QGSettingsInterface::Type::ImplType:
|
||||
{
|
||||
static QGSettingsInterfaceImpl settings("com.deepin.dde.dock.module.activeapp");
|
||||
return &settings;
|
||||
}
|
||||
default:
|
||||
{
|
||||
qWarning("Unless you are doing unit testing, you should't see this message");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static QGSettingsInterface *GSettingsByDockApp(QGSettingsInterface::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case QGSettingsInterface::Type::ImplType:
|
||||
{
|
||||
static QGSettingsInterfaceImpl settings("com.deepin.dde.dock.module.dockapp");
|
||||
return &settings;
|
||||
}
|
||||
default:
|
||||
{
|
||||
qWarning("Unless you are doing unit testing, you should't see this message");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QGSettings *DockItemManager::m_appSettings = Utils::ModuleSettingsPtr("app");
|
||||
const QGSettings *DockItemManager::m_activeSettings = Utils::ModuleSettingsPtr("activeapp");
|
||||
const QGSettings *DockItemManager::m_dockedSettings = Utils::ModuleSettingsPtr("dockapp");
|
||||
|
||||
DockItemManager::DockItemManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
@ -91,10 +45,7 @@ DockItemManager::DockItemManager(QObject *parent)
|
||||
|
||||
// 应用区域
|
||||
for (auto entry : m_appInter->entries()) {
|
||||
AppItem *it = new AppItem(GSettingsByApp(QGSettingsInterface::ImplType)
|
||||
, GSettingsByActiveApp(QGSettingsInterface::ImplType)
|
||||
, GSettingsByDockApp(QGSettingsInterface::ImplType)
|
||||
, entry);
|
||||
AppItem *it = new AppItem(m_appSettings, m_activeSettings, m_dockedSettings, entry);
|
||||
manageItem(it);
|
||||
|
||||
connect(it, &AppItem::requestActivateWindow, m_appInter, &DBusDock::ActivateWindow, Qt::QueuedConnection);
|
||||
@ -149,14 +100,8 @@ bool DockItemManager::appIsOnDock(const QString &appDesktop) const
|
||||
|
||||
void DockItemManager::startLoadPlugins() const
|
||||
{
|
||||
if (!QGSettings::isSchemaInstalled("com.deepin.dde.dock")) {
|
||||
qWarning("com.deepin.dde.dock is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings gsetting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
||||
|
||||
QTimer::singleShot(gsetting.get("delay-plugins-time").toUInt(), m_pluginsInter, &DockPluginsController::startLoader);
|
||||
int delay = Utils::SettingValue("com.deepin.dde.dock", "/com/deepin/dde/dock/", "delay-plugins-time", 0).toInt();
|
||||
QTimer::singleShot(delay, m_pluginsInter, &DockPluginsController::startLoader);
|
||||
}
|
||||
|
||||
void DockItemManager::refershItemsIcon()
|
||||
@ -243,10 +188,7 @@ void DockItemManager::appItemAdded(const QDBusObjectPath &path, const int index)
|
||||
++insertIndex;
|
||||
}
|
||||
|
||||
AppItem *item = new AppItem(GSettingsByApp(QGSettingsInterface::ImplType)
|
||||
, GSettingsByActiveApp(QGSettingsInterface::ImplType)
|
||||
, GSettingsByDockApp(QGSettingsInterface::ImplType)
|
||||
, path);
|
||||
AppItem *item = new AppItem(m_appSettings, m_activeSettings, m_dockedSettings, path);
|
||||
|
||||
if (m_appIDist.contains(item->appId())) {
|
||||
delete item;
|
||||
|
@ -85,6 +85,10 @@ private:
|
||||
QList<QString> m_appIDist;
|
||||
|
||||
bool m_loadFinished; // 记录所有插件是否加载完成
|
||||
|
||||
static const QGSettings *m_appSettings;
|
||||
static const QGSettings *m_activeSettings;
|
||||
static const QGSettings *m_dockedSettings;
|
||||
};
|
||||
|
||||
#endif // DOCKITEMMANAGER_H
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "xcb_misc.h"
|
||||
#include "appswingeffectbuilder.h"
|
||||
#include "appspreviewprovider.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
@ -40,17 +39,18 @@
|
||||
#include <QTimeLine>
|
||||
#include <QX11Info>
|
||||
#include <QGSettings>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#define APP_DRAG_THRESHOLD 20
|
||||
|
||||
QPoint AppItem::MousePressPos;
|
||||
|
||||
AppItem::AppItem(QGSettingsInterface *appSettings, QGSettingsInterface *activeAppSettings, QGSettingsInterface *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent)
|
||||
AppItem::AppItem(const QGSettings *appSettings, const QGSettings *activeAppSettings, const QGSettings *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent)
|
||||
: DockItem(parent)
|
||||
, m_qgAppInterface(appSettings)
|
||||
, m_qgActiveAppInterface(activeAppSettings)
|
||||
, m_qgDockedAppInterface(dockedAppSettings)
|
||||
, m_appSettings(appSettings)
|
||||
, m_activeAppSettings(activeAppSettings)
|
||||
, m_dockedAppSettings(dockedAppSettings)
|
||||
, m_appNameTips(new TipsWidget(this))
|
||||
, m_appPreviewTips(nullptr)
|
||||
, m_itemEntryInter(new DockEntryInter("com.deepin.dde.daemon.Dock", entry.path(), QDBusConnection::sessionBus(), this))
|
||||
@ -106,12 +106,12 @@ AppItem::AppItem(QGSettingsInterface *appSettings, QGSettingsInterface *activeAp
|
||||
updateWindowInfos(m_itemEntryInter->windowInfos());
|
||||
refreshIcon();
|
||||
|
||||
if (m_qgAppInterface && m_qgAppInterface->gsettings())
|
||||
connect(m_qgAppInterface->gsettings(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
if (m_qgDockedAppInterface && m_qgDockedAppInterface->gsettings())
|
||||
connect(m_qgDockedAppInterface->gsettings(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
if (m_qgActiveAppInterface && m_qgActiveAppInterface->gsettings())
|
||||
connect(m_qgActiveAppInterface->gsettings(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
if (m_appSettings)
|
||||
connect(m_appSettings, &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
if (m_dockedAppSettings)
|
||||
connect(m_dockedAppSettings, &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
if (m_activeAppSettings)
|
||||
connect(m_activeAppSettings, &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &AppItem::onThemeTypeChanged);
|
||||
|
||||
@ -340,7 +340,6 @@ void AppItem::mousePressEvent(QMouseEvent *e)
|
||||
if (checkGSettingsControl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_updateIconGeometryTimer->stop();
|
||||
hidePopup();
|
||||
|
||||
@ -706,24 +705,24 @@ void AppItem::onGSettingsChanged(const QString &key)
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettingsInterface *setting = m_itemEntryInter->isDocked()
|
||||
? m_qgDockedAppInterface
|
||||
: m_qgActiveAppInterface;
|
||||
const QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? m_dockedAppSettings
|
||||
: m_activeAppSettings;
|
||||
|
||||
if (setting->keys().contains("enable")) {
|
||||
const bool isEnable = m_qgAppInterface->keys().contains("enable") && m_qgAppInterface->get("enable").toBool();
|
||||
if (setting && setting->keys().contains("enable")) {
|
||||
const bool isEnable = !m_appSettings || m_appSettings->keys().contains("enable") && m_appSettings->get("enable").toBool();
|
||||
setVisible(isEnable && setting->get("enable").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
bool AppItem::checkGSettingsControl() const
|
||||
{
|
||||
QGSettingsInterface *setting = m_itemEntryInter->isDocked()
|
||||
? m_qgDockedAppInterface
|
||||
: m_qgActiveAppInterface;
|
||||
const QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? m_dockedAppSettings
|
||||
: m_activeAppSettings;
|
||||
|
||||
return (setting->keys().contains("control") && setting->get("control").toBool()) ||
|
||||
(m_qgAppInterface->keys().contains("control") && m_qgAppInterface->get("control").toBool());
|
||||
return (setting && setting->keys().contains("control") && setting->get("control").toBool()) ||
|
||||
(m_appSettings && m_appSettings->keys().contains("control") && m_appSettings->get("control").toBool());
|
||||
}
|
||||
|
||||
void AppItem::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "appdrag.h"
|
||||
#include "dbusclientmanager.h"
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "qgsettingsinterface.h"
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsItem>
|
||||
@ -38,13 +37,13 @@
|
||||
#include <com_deepin_dde_daemon_dock_entry.h>
|
||||
|
||||
using DockEntryInter = com::deepin::dde::daemon::dock::Entry;
|
||||
|
||||
class QGSettings;
|
||||
class AppItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AppItem(QGSettingsInterface *appSettings, QGSettingsInterface *activeAppSettings, QGSettingsInterface *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent = nullptr);
|
||||
explicit AppItem(const QGSettings *appSettings, const QGSettings *activeAppSettings, const QGSettings *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent = nullptr);
|
||||
~AppItem() override;
|
||||
|
||||
void checkEntry() override;
|
||||
@ -103,9 +102,10 @@ private slots:
|
||||
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
||||
|
||||
private:
|
||||
QGSettingsInterface *m_qgAppInterface;
|
||||
QGSettingsInterface *m_qgActiveAppInterface;
|
||||
QGSettingsInterface *m_qgDockedAppInterface;
|
||||
const QGSettings *m_appSettings;
|
||||
const QGSettings *m_activeAppSettings;
|
||||
const QGSettings *m_dockedAppSettings;
|
||||
|
||||
TipsWidget *m_appNameTips;
|
||||
PreviewContainer *m_appPreviewTips;
|
||||
DockEntryInter *m_itemEntryInter;
|
||||
|
@ -20,11 +20,10 @@
|
||||
*/
|
||||
|
||||
#include "appdrag.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
|
||||
AppDrag::AppDrag(QGSettingsInterface *interface, QObject *dragSource)
|
||||
AppDrag::AppDrag(QObject *dragSource)
|
||||
: QDrag(dragSource)
|
||||
, m_appDragWidget(new AppDragWidget(interface))
|
||||
, m_appDragWidget(new AppDragWidget)
|
||||
{
|
||||
// delete by itself
|
||||
m_appDragWidget->setVisible(false);
|
||||
|
@ -30,7 +30,7 @@
|
||||
class AppDrag : public QDrag
|
||||
{
|
||||
public:
|
||||
explicit AppDrag(QGSettingsInterface *interface, QObject *dragSource);
|
||||
explicit AppDrag(QObject *dragSource);
|
||||
virtual ~AppDrag();
|
||||
|
||||
void setPixmap(const QPixmap &);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "../appitem.h"
|
||||
#include "appdragwidget.h"
|
||||
#include "qgsettingsinterface.h"
|
||||
#include "utils.h"
|
||||
|
||||
class AppGraphicsObject : public QGraphicsObject
|
||||
{
|
||||
@ -59,9 +59,8 @@ private:
|
||||
QPixmap m_appPixmap;
|
||||
};
|
||||
|
||||
AppDragWidget::AppDragWidget(QGSettingsInterface *interface, QWidget *parent)
|
||||
AppDragWidget::AppDragWidget(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
, m_qgInterface(interface)
|
||||
, m_object(new AppGraphicsObject)
|
||||
, m_scene(new QGraphicsScene(this))
|
||||
, m_followMouseTimer(new QTimer(this))
|
||||
@ -72,7 +71,7 @@ AppDragWidget::AppDragWidget(QGSettingsInterface *interface, QWidget *parent)
|
||||
, m_goBackAnim(new QPropertyAnimation(this, "pos", this))
|
||||
, m_removeTips(new TipsWidget(this))
|
||||
, m_popupWindow(nullptr)
|
||||
, m_distanceMultiple(interface->get("distance-multiple").toDouble())
|
||||
, m_distanceMultiple(Utils::SettingValue("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/", "distance-multiple", 1.5).toDouble())
|
||||
{
|
||||
m_removeTips->setText(tr("Remove"));
|
||||
m_removeTips->setObjectName("AppRemoveTips");
|
||||
@ -123,9 +122,6 @@ AppDragWidget::~AppDragWidget()
|
||||
delete m_popupWindow;
|
||||
m_popupWindow=nullptr;
|
||||
}
|
||||
|
||||
delete m_qgInterface;
|
||||
m_qgInterface = nullptr;
|
||||
}
|
||||
|
||||
void AppDragWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
|
@ -37,13 +37,12 @@
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "dockpopupwindow.h"
|
||||
|
||||
class QGSettingsInterface;
|
||||
class AppGraphicsObject;
|
||||
class AppDragWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppDragWidget(QGSettingsInterface *interface, QWidget *parent = Q_NULLPTR);
|
||||
explicit AppDragWidget(QWidget *parent = Q_NULLPTR);
|
||||
virtual ~AppDragWidget() override;
|
||||
|
||||
void setAppPixmap(const QPixmap &pix);
|
||||
@ -75,7 +74,6 @@ private:
|
||||
bool isRemoveItem();
|
||||
|
||||
private:
|
||||
QGSettingsInterface *m_qgInterface;
|
||||
AppGraphicsObject *m_object;
|
||||
QGraphicsScene *m_scene;
|
||||
QTimer *m_followMouseTimer;
|
||||
|
@ -36,7 +36,7 @@ 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(Utils::SettingsPtr("launcher", this))
|
||||
, m_gsettings(Utils::ModuleSettingsPtr("launcher", QByteArray(), this))
|
||||
{
|
||||
m_launcherInter->setSync(true, false);
|
||||
|
||||
|
@ -44,7 +44,7 @@ PluginsItem::PluginsItem(PluginsItemInterface *const pluginInter, const QString
|
||||
, m_pluginApi(plginApi)
|
||||
, m_itemKey(itemKey)
|
||||
, m_dragging(false)
|
||||
, m_gsettings(nullptr)
|
||||
, m_gsettings(Utils::ModuleSettingsPtr(pluginInter->pluginName()))
|
||||
{
|
||||
qDebug() << "load plugins item: " << pluginInter->pluginName() << itemKey << m_centralWidget;
|
||||
|
||||
@ -62,17 +62,8 @@ PluginsItem::PluginsItem(PluginsItemInterface *const pluginInter, const QString
|
||||
setAccessibleName(pluginInter->pluginName());
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
const QByteArray &schema{
|
||||
QString("com.deepin.dde.dock.module.%1").arg(pluginInter->pluginName()).toUtf8()
|
||||
};
|
||||
if (QGSettings::isSchemaInstalled(schema)) {
|
||||
m_gsettings = new QGSettings(schema);
|
||||
m_gsettings->setParent(this);
|
||||
connect(m_gsettings, &QGSettings::changed, this,
|
||||
&PluginsItem::onGSettingsChanged);
|
||||
} else {
|
||||
m_gsettings = nullptr;
|
||||
}
|
||||
if (m_gsettings)
|
||||
connect(m_gsettings, &QGSettings::changed, this, &PluginsItem::onGSettingsChanged);
|
||||
}
|
||||
|
||||
PluginsItem::~PluginsItem()
|
||||
@ -132,11 +123,11 @@ void PluginsItem::refreshIcon()
|
||||
|
||||
void PluginsItem::onGSettingsChanged(const QString &key)
|
||||
{
|
||||
if (key != "enable" || !m_gsettings) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gsettings->keys().contains("enable")) {
|
||||
if (m_gsettings && m_gsettings->keys().contains("enable")) {
|
||||
setVisible(m_gsettings->get("enable").toBool());
|
||||
}
|
||||
}
|
||||
@ -308,16 +299,13 @@ void PluginsItem::mouseClicked()
|
||||
}
|
||||
|
||||
// request popup applet
|
||||
QWidget *w = m_pluginInter->itemPopupApplet(m_itemKey);
|
||||
if (w)
|
||||
if (QWidget *w = m_pluginInter->itemPopupApplet(m_itemKey))
|
||||
showPopupApplet(w);
|
||||
}
|
||||
|
||||
bool PluginsItem::checkGSettingsControl() const
|
||||
{
|
||||
return m_gsettings ? m_gsettings->keys().contains("control") &&
|
||||
m_gsettings->get("control").toBool()
|
||||
: false;
|
||||
return m_gsettings ? m_gsettings->keys().contains("control") && m_gsettings->get("control").toBool() : false;
|
||||
}
|
||||
|
||||
void PluginsItem::resizeEvent(QResizeEvent *event)
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
|
||||
public slots:
|
||||
void refreshIcon() override;
|
||||
|
||||
private slots:
|
||||
void onGSettingsChanged(const QString &key);
|
||||
|
||||
protected:
|
||||
@ -84,7 +86,7 @@ private:
|
||||
bool m_dragging;
|
||||
|
||||
static QPoint MousePressPoint;
|
||||
QGSettings *m_gsettings;
|
||||
const QGSettings *m_gsettings;
|
||||
};
|
||||
|
||||
#endif // PLUGINSITEM_H
|
||||
|
@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
#include "traypluginitem.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QGSettings>
|
||||
|
||||
TrayPluginItem::TrayPluginItem(PluginsItemInterface * const pluginInter, const QString &itemKey, const QString &pluginApi, QWidget *parent)
|
||||
: PluginsItem(pluginInter, itemKey, pluginApi, parent)
|
||||
@ -54,11 +54,9 @@ bool TrayPluginItem::eventFilter(QObject *watched, QEvent *e)
|
||||
// 当接收到这个属性变化的事件后,重新计算和设置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()) {
|
||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) {
|
||||
const QGSettings *settings = Utils::ModuleSettingsPtr("systemtray", QByteArray(), this);
|
||||
if (settings && settings->keys().contains("control") && settings->get("control").toBool()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QDateTime>
|
||||
#include <QGSettings>
|
||||
#include <QDir>
|
||||
|
||||
#include <DApplication>
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QGSETTINGSINTERFACE_H
|
||||
#define QGSETTINGSINTERFACE_H
|
||||
|
||||
#include <QVariant>
|
||||
#include <QStringList>
|
||||
|
||||
class QGSettings;
|
||||
class QGSettingsInterface
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
ImplType, // 持有真正的QGSettings指针
|
||||
MockType // Mock类
|
||||
};
|
||||
|
||||
virtual ~QGSettingsInterface() {}
|
||||
|
||||
virtual Type type() = 0;
|
||||
virtual QGSettings *gsettings() = 0;
|
||||
virtual QVariant get(const QString &key) const = 0;
|
||||
virtual void set(const QString &key, const QVariant &value) = 0;
|
||||
virtual bool trySet(const QString &key, const QVariant &value) = 0;
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QVariantList choices(const QString &key) const = 0;
|
||||
virtual void reset(const QString &key) = 0;
|
||||
static bool isSchemaInstalled(const QByteArray &schema_id) {Q_UNUSED(schema_id); return false;}
|
||||
|
||||
};
|
||||
#endif // QGSETTINGSINTERFACE_H
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <QGSettings>
|
||||
#include <QVariant>
|
||||
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
|
||||
QGSettingsInterfaceImpl::QGSettingsInterfaceImpl(const QByteArray &schema_id, const QByteArray &path, QObject *parent)
|
||||
: m_gsettings(new QGSettings(schema_id, path, parent))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGSettingsInterfaceImpl::~QGSettingsInterfaceImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGSettingsInterface::Type QGSettingsInterfaceImpl::type()
|
||||
{
|
||||
return Type::ImplType;
|
||||
}
|
||||
|
||||
QGSettings *QGSettingsInterfaceImpl::gsettings()
|
||||
{
|
||||
return m_gsettings;
|
||||
}
|
||||
|
||||
QVariant QGSettingsInterfaceImpl::get(const QString &key) const
|
||||
{
|
||||
return m_gsettings->get(key);
|
||||
}
|
||||
|
||||
void QGSettingsInterfaceImpl::set(const QString &key, const QVariant &value)
|
||||
{
|
||||
return m_gsettings->set(key, value);
|
||||
}
|
||||
|
||||
bool QGSettingsInterfaceImpl::trySet(const QString &key, const QVariant &value)
|
||||
{
|
||||
return m_gsettings->trySet(key, value);
|
||||
}
|
||||
|
||||
QStringList QGSettingsInterfaceImpl::keys() const
|
||||
{
|
||||
return m_gsettings->keys();
|
||||
}
|
||||
|
||||
QVariantList QGSettingsInterfaceImpl::choices(const QString &key) const
|
||||
{
|
||||
return m_gsettings->choices(key);
|
||||
}
|
||||
|
||||
void QGSettingsInterfaceImpl::reset(const QString &key)
|
||||
{
|
||||
return m_gsettings->reset(key);
|
||||
}
|
||||
|
||||
bool QGSettingsInterfaceImpl::isSchemaInstalled(const QByteArray &schema_id)
|
||||
{
|
||||
return QGSettings::isSchemaInstalled(schema_id);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QGSETTINGSINTERFACEIMPL_H
|
||||
#define QGSETTINGSINTERFACEIMPL_H
|
||||
#include <QObject>
|
||||
|
||||
#include "qgsettingsinterface.h"
|
||||
|
||||
class QGSettings;
|
||||
class QGSettingsInterfaceImpl : public QGSettingsInterface
|
||||
{
|
||||
public:
|
||||
QGSettingsInterfaceImpl(const QByteArray &schema_id, const QByteArray &path = QByteArray(), QObject *parent = nullptr);
|
||||
~QGSettingsInterfaceImpl() override;
|
||||
|
||||
virtual Type type() override;
|
||||
virtual QGSettings *gsettings() override;
|
||||
virtual QVariant get(const QString &key) const override;
|
||||
virtual void set(const QString &key, const QVariant &value) override;
|
||||
virtual bool trySet(const QString &key, const QVariant &value) override;
|
||||
virtual QStringList keys() const override;
|
||||
virtual QVariantList choices(const QString &key) const override;
|
||||
virtual void reset(const QString &key) override;
|
||||
static bool isSchemaInstalled(const QByteArray &schema_id);
|
||||
|
||||
private:
|
||||
QGSettings *m_gsettings;
|
||||
};
|
||||
|
||||
#endif // QGSETTINGSINTERFACEIMPL_H
|
@ -28,7 +28,6 @@
|
||||
#include "traypluginitem.h"
|
||||
#include "dockitemmanager.h"
|
||||
#include "touchsignalmanager.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QDrag>
|
||||
@ -623,7 +622,7 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
static const QGSettings *g_settings = Utils::SettingsPtr("app");
|
||||
static const QGSettings *g_settings = Utils::ModuleSettingsPtr("app");
|
||||
if (!g_settings || !g_settings->keys().contains("removeable") || g_settings->get("removeable").toBool())
|
||||
startDrag(item);
|
||||
|
||||
@ -660,7 +659,7 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
|
||||
QDrag *drag = nullptr;
|
||||
if (item->itemType() == DockItem::App) {
|
||||
AppDrag *appDrag = new AppDrag(new QGSettingsInterfaceImpl("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/"),item);
|
||||
AppDrag *appDrag = new AppDrag(item);
|
||||
|
||||
m_appDragWidget = appDrag->appDragWidget();
|
||||
|
||||
|
@ -21,12 +21,13 @@
|
||||
|
||||
#include "abstractpluginscontroller.h"
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "DNotifySender"
|
||||
#include "utils.h"
|
||||
|
||||
#include <DNotifySender>
|
||||
#include <DSysInfo>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QGSettings>
|
||||
|
||||
static const QStringList CompatiblePluginApiList {
|
||||
"1.1.1",
|
||||
@ -160,11 +161,8 @@ void AbstractPluginsController::startLoader(PluginLoader *loader)
|
||||
});
|
||||
connect(loader, &PluginLoader::pluginFounded, this, &AbstractPluginsController::loadPlugin, Qt::QueuedConnection);
|
||||
|
||||
|
||||
QGSettings gsetting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
||||
|
||||
QTimer::singleShot(gsetting.get("delay-plugins-time").toUInt(),
|
||||
loader, [ = ] { loader->start(QThread::LowestPriority); });
|
||||
int delay = Utils::SettingValue("com.deepin.dde.dock", "/com/deepin/dde/dock/", "delay-plugins-time", 0).toInt();
|
||||
QTimer::singleShot(delay, loader, [ = ] { loader->start(QThread::LowestPriority); });
|
||||
}
|
||||
|
||||
void AbstractPluginsController::displayModeChanged()
|
||||
|
@ -50,7 +50,7 @@ QMenu *MenuWorker::createMenu()
|
||||
settingsMenu->setTitle("Settings Menu");
|
||||
|
||||
// 模式
|
||||
const QGSettings *menuSettings = Utils::SettingsPtr("menu");
|
||||
const QGSettings *menuSettings = Utils::ModuleSettingsPtr("menu");
|
||||
if (!menuSettings || !menuSettings->keys().contains("modeVisible") || menuSettings->get("modeVisible").toBool()) {
|
||||
const DisplayMode displayMode = static_cast<DisplayMode>(m_dockInter->displayMode());
|
||||
|
||||
@ -168,7 +168,7 @@ QMenu *MenuWorker::createMenu()
|
||||
const QString &display = p->pluginDisplayName();
|
||||
|
||||
// 模块和菜单均需要响应enable配置的变化
|
||||
const QGSettings *setting = Utils::SettingsPtr(name);
|
||||
const QGSettings *setting = Utils::ModuleSettingsPtr(name);
|
||||
if (setting && setting->keys().contains("enable") && !setting->get("enable").toBool()) {
|
||||
continue;
|
||||
}
|
||||
@ -192,7 +192,7 @@ QMenu *MenuWorker::createMenu()
|
||||
connect(act, &QAction::triggered, this, [ p ]{p->pluginStateSwitched();});
|
||||
|
||||
// check plugin hide menu.
|
||||
const QGSettings *pluginSettings = Utils::SettingsPtr(name);
|
||||
const QGSettings *pluginSettings = Utils::ModuleSettingsPtr(name);
|
||||
if (pluginSettings && (!pluginSettings->keys().contains("visible") || pluginSettings->get("visible").toBool()))
|
||||
actions << act;
|
||||
}
|
||||
@ -220,7 +220,7 @@ QMenu *MenuWorker::createMenu()
|
||||
void MenuWorker::showDockSettingsMenu()
|
||||
{
|
||||
// 菜单功能被禁用
|
||||
static const QGSettings *setting = Utils::SettingsPtr("menu", this);
|
||||
static const QGSettings *setting = Utils::ModuleSettingsPtr("menu", QByteArray(), this);
|
||||
if (setting && setting->keys().contains("enable") && !setting->get("enable").toBool()) {
|
||||
return;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "multiscreenworker.h"
|
||||
#include "mainwindow.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScreen>
|
||||
@ -50,8 +51,8 @@ MultiScreenWorker::MultiScreenWorker(QWidget *parent, DWindowManagerHelper *help
|
||||
, m_displayInter(new DisplayInter("com.deepin.daemon.Display", "/com/deepin/daemon/Display", QDBusConnection::sessionBus(), this))
|
||||
, m_launcherInter(new DBusLuncher("com.deepin.dde.Launcher", "/com/deepin/dde/Launcher", QDBusConnection::sessionBus()))
|
||||
, m_monitorUpdateTimer(new QTimer(this))
|
||||
, m_delayTimer(new QTimer(this))
|
||||
, m_monitorSetting(nullptr)
|
||||
, m_delayWakeTimer(new QTimer(this))
|
||||
, m_gsettings(Utils::SettingsPtr("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", this))
|
||||
, m_ds(m_displayInter->primary())
|
||||
, m_monitorRotation(1)
|
||||
, m_showAniStart(false)
|
||||
@ -80,7 +81,7 @@ void MultiScreenWorker::initShow()
|
||||
// 仅在初始化时调用一次
|
||||
static bool first = true;
|
||||
if (!first)
|
||||
qFatal("this method can only be called once");
|
||||
return;
|
||||
first = false;
|
||||
|
||||
// 这里是为了在调用时让MainWindow更新界面布局方向
|
||||
@ -104,6 +105,14 @@ void MultiScreenWorker::initShow()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief dockRect
|
||||
* @param screenName 屏幕名
|
||||
* @param pos 任务栏位置
|
||||
* @param hideMode 模式
|
||||
* @param displayMode 状态
|
||||
* @return 按照给定的数据计算出任务栏所在位置
|
||||
*/
|
||||
QRect MultiScreenWorker::dockRect(const QString &screenName, const Position &pos, const HideMode &hideMode, const DisplayMode &displayMode)
|
||||
{
|
||||
if (hideMode == HideMode::KeepShowing)
|
||||
@ -112,11 +121,24 @@ QRect MultiScreenWorker::dockRect(const QString &screenName, const Position &pos
|
||||
return getDockHideGeometry(screenName, pos, displayMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief dockRect
|
||||
* @param screenName 屏幕名
|
||||
* @return 按照当前屏幕的当前属性给出任务栏所在区域
|
||||
*/
|
||||
QRect MultiScreenWorker::dockRect(const QString &screenName)
|
||||
{
|
||||
return dockRect(screenName, m_position, m_hideMode, m_displayMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief realDockRect 给出不计算缩放情况的区域信息(和后端接口保持一致)
|
||||
* @param screenName 屏幕名
|
||||
* @param pos 任务栏位置
|
||||
* @param hideMode 模式
|
||||
* @param displayMode 状态
|
||||
* @return
|
||||
*/
|
||||
QRect MultiScreenWorker::dockRectWithoutScale(const QString &screenName, const Position &pos, const HideMode &hideMode, const DisplayMode &displayMode)
|
||||
{
|
||||
if (hideMode == HideMode::KeepShowing)
|
||||
@ -158,6 +180,10 @@ void MultiScreenWorker::onAutoHideChanged(bool autoHide)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief updateDaemonDockSize
|
||||
* @param dockSize 这里的高度是通过qt获取的,不能使用后端的接口数据
|
||||
*/
|
||||
void MultiScreenWorker::updateDaemonDockSize(int dockSize)
|
||||
{
|
||||
m_dockInter->setWindowSize(uint(dockSize));
|
||||
@ -228,7 +254,7 @@ void MultiScreenWorker::onExtralRegionMonitorChanged(int x, int y, const QString
|
||||
return;
|
||||
|
||||
// 鼠标移动到任务栏界面之外,停止计时器(延时2秒改变任务栏所在屏幕)
|
||||
m_delayTimer->stop();
|
||||
m_delayWakeTimer->stop();
|
||||
|
||||
if (m_hideMode == HideMode::KeepShowing
|
||||
|| ((m_hideMode == HideMode::KeepHidden || m_hideMode == HideMode::SmartHide) && m_hideState == HideState::Show)) {
|
||||
@ -544,6 +570,12 @@ void MultiScreenWorker::onOpacityChanged(const double value)
|
||||
emit opacityChanged(quint8(value * 255));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief onRequestUpdateRegionMonitor 更新监听区域信息
|
||||
* 触发时机:屏幕大小,屏幕坐标,屏幕数量,发生变化
|
||||
* 任务栏位置发生变化
|
||||
* 任务栏'模式'发生变化
|
||||
*/
|
||||
void MultiScreenWorker::onRequestUpdateRegionMonitor()
|
||||
{
|
||||
if (!m_registerKey.isEmpty()) {
|
||||
@ -955,13 +987,18 @@ void MultiScreenWorker::onRequestDelayShowDock(const QString &screenName)
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow *MultiScreenWorker::parent()
|
||||
{
|
||||
return static_cast<MainWindow *>(m_parent);
|
||||
}
|
||||
|
||||
void MultiScreenWorker::initMembers()
|
||||
{
|
||||
m_monitorUpdateTimer->setInterval(100);
|
||||
m_monitorUpdateTimer->setSingleShot(true);
|
||||
|
||||
m_delayTimer->setInterval(2000);
|
||||
m_delayTimer->setSingleShot(true);
|
||||
m_delayWakeTimer->setInterval(2000);
|
||||
m_delayWakeTimer->setSingleShot(true);
|
||||
|
||||
// init check
|
||||
checkDaemonDockService();
|
||||
@ -971,21 +1008,16 @@ void MultiScreenWorker::initMembers()
|
||||
|
||||
void MultiScreenWorker::initGSettingConfig()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled("com.deepin.dde.dock.mainwindow")) {
|
||||
m_monitorSetting = new QGSettings("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", this);
|
||||
if (m_monitorSetting->keys().contains(MonitorsSwitchTime)) {
|
||||
m_delayTimer->setInterval(m_monitorSetting->get(MonitorsSwitchTime).toInt());
|
||||
} else {
|
||||
qWarning() << "can not find key:" << MonitorsSwitchTime;
|
||||
}
|
||||
|
||||
if (m_monitorSetting->keys().contains(OnlyShowPrimary)) {
|
||||
m_mtrInfo.setShowInPrimary(m_monitorSetting->get(OnlyShowPrimary).toBool());
|
||||
} else {
|
||||
qWarning() << "can not find key:" << OnlyShowPrimary;
|
||||
}
|
||||
if (m_gsettings && m_gsettings->keys().contains(MonitorsSwitchTime)) {
|
||||
m_delayWakeTimer->setInterval(m_gsettings->get(MonitorsSwitchTime).toInt());
|
||||
} else {
|
||||
qWarning() << "com.deepin.dde.dock is uninstalled.";
|
||||
qWarning() << "can not find key:" << MonitorsSwitchTime;
|
||||
}
|
||||
|
||||
if (m_gsettings && m_gsettings->keys().contains(OnlyShowPrimary)) {
|
||||
m_mtrInfo.setShowInPrimary(m_gsettings->get(OnlyShowPrimary).toBool());
|
||||
} else {
|
||||
qWarning() << "can not find key:" << OnlyShowPrimary;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1027,7 +1059,7 @@ void MultiScreenWorker::initConnection()
|
||||
connect(this, &MultiScreenWorker::requestUpdateMonitorInfo, this, &MultiScreenWorker::onRequestUpdateMonitorInfo);
|
||||
connect(this, &MultiScreenWorker::requestDelayShowDock, this, &MultiScreenWorker::onRequestDelayShowDock);
|
||||
|
||||
connect(m_delayTimer, &QTimer::timeout, this, &MultiScreenWorker::delayShowDock);
|
||||
connect(m_delayWakeTimer, &QTimer::timeout, this, &MultiScreenWorker::delayShowDock);
|
||||
|
||||
// 更新任务栏内容展示
|
||||
connect(this, &MultiScreenWorker::requestUpdateLayout, this, [ = ] {
|
||||
@ -1060,7 +1092,8 @@ void MultiScreenWorker::initConnection()
|
||||
emit requestNotifyWindowManager();
|
||||
});
|
||||
|
||||
connect(m_monitorSetting, &QGSettings::changed, this, &MultiScreenWorker::onConfigChange);
|
||||
if (m_gsettings)
|
||||
connect(m_gsettings, &QGSettings::changed, this, &MultiScreenWorker::onGSettingsChange);
|
||||
}
|
||||
|
||||
void MultiScreenWorker::initUI()
|
||||
@ -1105,6 +1138,10 @@ void MultiScreenWorker::initDBus()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initDisplayData
|
||||
* 初始化任务栏的所有必要信息,并更新其位置
|
||||
*/
|
||||
void MultiScreenWorker::initDisplayData()
|
||||
{
|
||||
//1\初始化monitor信息
|
||||
@ -1120,6 +1157,10 @@ void MultiScreenWorker::initDisplayData()
|
||||
resetDockScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief reInitDisplayData
|
||||
* 重新初始化任务栏的所有必要信息,并更新其位置
|
||||
*/
|
||||
void MultiScreenWorker::reInitDisplayData()
|
||||
{
|
||||
initDBus();
|
||||
@ -1256,6 +1297,13 @@ void MultiScreenWorker::displayAnimation(const QString &screen, AniAction act)
|
||||
return displayAnimation(screen, m_position, act);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief changeDockPosition 做一个动画操作
|
||||
* @param lastScreen 上次任务栏所在的屏幕
|
||||
* @param deskScreen 任务栏要移动到的屏幕
|
||||
* @param fromPos 任务栏上次的方向
|
||||
* @param toPos 任务栏打算移动到的方向
|
||||
*/
|
||||
void MultiScreenWorker::changeDockPosition(QString fromScreen, QString toScreen, const Position &fromPos, const Position &toPos)
|
||||
{
|
||||
if (fromScreen == toScreen && fromPos == toPos) {
|
||||
@ -1360,6 +1408,10 @@ void MultiScreenWorker::changeDockPosition(QString fromScreen, QString toScreen,
|
||||
group->start(QVariantAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief updateDockScreenName 将任务栏所在屏幕信息进行更新,在任务栏切换屏幕显示后,这里应该被调用
|
||||
* @param screenName 目标屏幕
|
||||
*/
|
||||
void MultiScreenWorker::updateDockScreenName(const QString &screenName)
|
||||
{
|
||||
Q_UNUSED(screenName);
|
||||
@ -1369,6 +1421,10 @@ void MultiScreenWorker::updateDockScreenName(const QString &screenName)
|
||||
qInfo() << "update dock screen: " << m_ds.current();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief getValidScreen 获取一个当前任务栏可以停靠的屏幕,优先使用主屏
|
||||
* @return
|
||||
*/
|
||||
QString MultiScreenWorker::getValidScreen(const Position &pos)
|
||||
{
|
||||
QList<Monitor *> monitorList = m_mtrInfo.validMonitor();
|
||||
@ -1407,6 +1463,9 @@ QString MultiScreenWorker::getValidScreen(const Position &pos)
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief resetDockScreen 检查一下当前屏幕所在边缘是够允许任务栏停靠,不允许的情况需要更换下一块屏幕
|
||||
*/
|
||||
void MultiScreenWorker::resetDockScreen()
|
||||
{
|
||||
QList<Monitor *> monitorList = m_mtrInfo.validMonitor();
|
||||
@ -1437,6 +1496,10 @@ void MultiScreenWorker::resetDockScreen()
|
||||
parent()->panel()->move(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checkDaemonDockService
|
||||
* 避免com.deepin.dde.daemon.Dock服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void MultiScreenWorker::checkDaemonDockService()
|
||||
{
|
||||
auto connectionInit = [ = ](DBusDock * dockInter) {
|
||||
@ -1481,6 +1544,10 @@ void MultiScreenWorker::checkDaemonDockService()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checkDaemonDisplayService
|
||||
* 避免com.deepin.daemon.Display服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void MultiScreenWorker::checkDaemonDisplayService()
|
||||
{
|
||||
auto connectionInit = [ = ](DisplayInter *displayInter) {
|
||||
@ -1519,6 +1586,10 @@ void MultiScreenWorker::checkDaemonDisplayService()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checkDaemonXEventMonitorService
|
||||
* 避免com.deepin.api.XEventMonitor服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void MultiScreenWorker::checkXEventMonitorService()
|
||||
{
|
||||
auto connectionInit = [ = ](XEventMonitor * eventInter, XEventMonitor * extralEventInter, XEventMonitor * touchEventInter) {
|
||||
@ -1559,11 +1630,6 @@ void MultiScreenWorker::checkXEventMonitorService()
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow *MultiScreenWorker::parent()
|
||||
{
|
||||
return static_cast<MainWindow *>(m_parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取任务栏显示时的参数。目前多屏情况下缩放保持一致,如果后续缩放规则修改,这里需要重新调整
|
||||
*
|
||||
@ -1822,6 +1888,11 @@ void MultiScreenWorker::onTouchRelease(int type, int x, int y, const QString &ke
|
||||
tryToShowDock(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief tryToShowDock 根据xEvent监控区域信号的x,y坐标处理任务栏唤醒显示
|
||||
* @param eventX 监控信号x坐标
|
||||
* @param eventY 监控信号y坐标
|
||||
*/
|
||||
void MultiScreenWorker::tryToShowDock(int eventX, int eventY)
|
||||
{
|
||||
if (m_draging || m_aniStart) {
|
||||
@ -1860,9 +1931,9 @@ void MultiScreenWorker::tryToShowDock(int eventX, int eventY)
|
||||
|
||||
// 任务栏显示状态,但需要切换屏幕
|
||||
if (toScreen != m_ds.current()) {
|
||||
if (!m_delayTimer->isActive()) {
|
||||
if (!m_delayWakeTimer->isActive()) {
|
||||
m_delayScreen = toScreen;
|
||||
m_delayTimer->start();
|
||||
m_delayWakeTimer->start();
|
||||
}
|
||||
} else {
|
||||
// 任务栏隐藏状态,但需要显示
|
||||
@ -1886,12 +1957,12 @@ void MultiScreenWorker::tryToShowDock(int eventX, int eventY)
|
||||
}
|
||||
}
|
||||
|
||||
void MultiScreenWorker::onConfigChange(const QString &changeKey)
|
||||
void MultiScreenWorker::onGSettingsChange(const QString &changeKey)
|
||||
{
|
||||
if (changeKey == MonitorsSwitchTime) {
|
||||
m_delayTimer->setInterval(m_monitorSetting->get(MonitorsSwitchTime).toInt());
|
||||
m_delayWakeTimer->setInterval(m_gsettings ? m_gsettings->get(MonitorsSwitchTime).toInt() : 2000);
|
||||
} else if (changeKey == OnlyShowPrimary) {
|
||||
m_mtrInfo.setShowInPrimary(m_monitorSetting->get(OnlyShowPrimary).toBool());
|
||||
m_mtrInfo.setShowInPrimary(m_gsettings && m_gsettings->get(OnlyShowPrimary).toBool());
|
||||
// 每次切换都更新一下屏幕显示的信息
|
||||
emit requestUpdateMonitorInfo();
|
||||
}
|
||||
|
@ -222,66 +222,18 @@ public:
|
||||
|
||||
void initShow();
|
||||
|
||||
DBusDock *dockInter() {return m_dockInter;}
|
||||
DBusDock *dockInter() { return m_dockInter; }
|
||||
|
||||
inline const QString &lastScreen() { return m_ds.last(); }
|
||||
inline const QString &deskScreen() { return m_ds.current(); }
|
||||
inline const Position &position() { return m_position; }
|
||||
inline const DisplayMode &displayMode() { return m_displayMode; }
|
||||
inline const HideMode &hideMode() { return m_hideMode; }
|
||||
inline const HideState &hideState() { return m_hideState; }
|
||||
inline quint8 opacity() { return m_opacity * 255; }
|
||||
|
||||
/**
|
||||
* @brief lastScreen
|
||||
* @return 任务栏上次所在的屏幕
|
||||
*/
|
||||
inline const QString &lastScreen() {return m_ds.last();/*return m_lastScreen;*/}
|
||||
/**
|
||||
* @brief deskScreen
|
||||
* @return 任务栏目标屏幕.可以理解为任务栏当前所在屏幕
|
||||
*/
|
||||
inline const QString &deskScreen() {return m_ds.current();/*return m_currentScreen;*/}
|
||||
/**
|
||||
* @brief position
|
||||
* @return 任务栏所在方向(上下左右)
|
||||
*/
|
||||
inline const Position &position() {return m_position;}
|
||||
/**
|
||||
* @brief displayMode
|
||||
* @return 任务栏显示模式(时尚模式,高效模式)
|
||||
*/
|
||||
inline const DisplayMode &displayMode() {return m_displayMode;}
|
||||
/**
|
||||
* @brief hideMode
|
||||
* @return 任务栏状态(一直显示,一直隐藏,智能隐藏)
|
||||
*/
|
||||
inline const HideMode &hideMode() {return m_hideMode;}
|
||||
/**
|
||||
* @brief hideState
|
||||
* @return 任务栏的智能隐藏时的一个状态值(1显示,2隐藏,其他不处理)
|
||||
*/
|
||||
inline const HideState &hideState() {return m_hideState;}
|
||||
/**
|
||||
* @brief opacity
|
||||
* @return 任务栏透明度
|
||||
*/
|
||||
inline quint8 opacity() {return m_opacity * 255;}
|
||||
/**
|
||||
* @brief dockRect
|
||||
* @param screenName 屏幕名
|
||||
* @param pos 任务栏位置
|
||||
* @param hideMode 模式
|
||||
* @param displayMode 状态
|
||||
* @return 按照给定的数据计算出任务栏所在位置
|
||||
*/
|
||||
QRect dockRect(const QString &screenName, const Position &pos, const HideMode &hideMode, const DisplayMode &displayMode);
|
||||
/**
|
||||
* @brief dockRect
|
||||
* @param screenName 屏幕名
|
||||
* @return 按照当前屏幕的当前属性给出任务栏所在区域
|
||||
*/
|
||||
QRect dockRect(const QString &screenName);
|
||||
/**
|
||||
* @brief realDockRect 给出不计算缩放情况的区域信息(和后端接口保持一致)
|
||||
* @param screenName 屏幕名
|
||||
* @param pos 任务栏位置
|
||||
* @param hideMode 模式
|
||||
* @param displayMode 状态
|
||||
* @return
|
||||
*/
|
||||
QRect dockRectWithoutScale(const QString &screenName, const Position &pos, const HideMode &hideMode, const DisplayMode &displayMode);
|
||||
|
||||
signals:
|
||||
@ -305,13 +257,8 @@ signals:
|
||||
|
||||
public slots:
|
||||
void onAutoHideChanged(bool autoHide);
|
||||
/**
|
||||
* @brief updateDaemonDockSize
|
||||
* @param dockSize 这里的高度是通过qt获取的,不能使用后端的接口数据
|
||||
*/
|
||||
void updateDaemonDockSize(int dockSize);
|
||||
void onDragStateChanged(bool draging);
|
||||
|
||||
void handleDbusSignal(QDBusMessage);
|
||||
|
||||
private slots:
|
||||
@ -341,12 +288,6 @@ private slots:
|
||||
void onHideStateChanged();
|
||||
void onOpacityChanged(const double value);
|
||||
|
||||
/**
|
||||
* @brief onRequestUpdateRegionMonitor 更新监听区域信息
|
||||
* 触发时机:屏幕大小,屏幕坐标,屏幕数量,发生变化
|
||||
* 任务栏位置发生变化
|
||||
* 任务栏'模式'发生变化
|
||||
*/
|
||||
void onRequestUpdateRegionMonitor();
|
||||
|
||||
// 通知后端任务栏所在位置
|
||||
@ -368,74 +309,32 @@ private slots:
|
||||
void onTouchRelease(int type, int x, int y, const QString &key);
|
||||
|
||||
// gsetting配置改变响应槽
|
||||
void onConfigChange(const QString &changeKey);
|
||||
void onGSettingsChange(const QString &changeKey);
|
||||
|
||||
private:
|
||||
MainWindow *parent();
|
||||
// 初始化数据信息
|
||||
void initMembers();
|
||||
void initGSettingConfig();
|
||||
void initDBus();
|
||||
void initConnection();
|
||||
void initUI();
|
||||
/**
|
||||
* @brief initDisplayData
|
||||
* 初始化任务栏的所有必要信息,并更新其位置
|
||||
*/
|
||||
void initDisplayData();
|
||||
/**
|
||||
* @brief reInitDisplayData
|
||||
* 重新初始化任务栏的所有必要信息,并更新其位置
|
||||
*/
|
||||
void reInitDisplayData();
|
||||
|
||||
void displayAnimation(const QString &screen, const Position &pos, AniAction act);
|
||||
|
||||
void displayAnimation(const QString &screen, AniAction act);
|
||||
/**
|
||||
* @brief tryToShowDock 根据xEvent监控区域信号的x,y坐标处理任务栏唤醒显示
|
||||
* @param eventX 监控信号x坐标
|
||||
* @param eventY 监控信号y坐标
|
||||
*/
|
||||
void tryToShowDock(int eventX, int eventY);
|
||||
/**
|
||||
* @brief changeDockPosition 做一个动画操作
|
||||
* @param lastScreen 上次任务栏所在的屏幕
|
||||
* @param deskScreen 任务栏要移动到的屏幕
|
||||
* @param fromPos 任务栏上次的方向
|
||||
* @param toPos 任务栏打算移动到的方向
|
||||
*/
|
||||
void changeDockPosition(QString lastScreen, QString deskScreen, const Position &fromPos, const Position &toPos);
|
||||
/**
|
||||
* @brief updateDockScreenName 将任务栏所在屏幕信息进行更新,在任务栏切换屏幕显示后,这里应该被调用
|
||||
* @param screenName 目标屏幕
|
||||
*/
|
||||
void updateDockScreenName(const QString &screenName);
|
||||
/**
|
||||
* @brief getValidScreen 获取一个当前任务栏可以停靠的屏幕,优先使用主屏
|
||||
* @return
|
||||
*/
|
||||
QString getValidScreen(const Position &pos);
|
||||
/**
|
||||
* @brief resetDockScreen 检查一下当前屏幕所在边缘是够允许任务栏停靠,不允许的情况需要更换下一块屏幕
|
||||
*/
|
||||
void resetDockScreen();
|
||||
/**
|
||||
* @brief checkDaemonDockService
|
||||
* 避免com.deepin.dde.daemon.Dock服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void checkDaemonDockService();
|
||||
/**
|
||||
* @brief checkDaemonDisplayService
|
||||
* 避免com.deepin.daemon.Display服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void checkDaemonDisplayService();
|
||||
/**
|
||||
* @brief checkDaemonXEventMonitorService
|
||||
* 避免com.deepin.api.XEventMonitor服务比dock晚启动,导致dock启动后的状态错误
|
||||
*/
|
||||
void checkXEventMonitorService();
|
||||
|
||||
MainWindow *parent();
|
||||
void tryToShowDock(int eventX, int eventY);
|
||||
void changeDockPosition(QString lastScreen, QString deskScreen, const Position &fromPos, const Position &toPos);
|
||||
|
||||
void updateDockScreenName(const QString &screenName);
|
||||
QString getValidScreen(const Position &pos);
|
||||
void resetDockScreen();
|
||||
|
||||
void checkDaemonDockService();
|
||||
void checkDaemonDisplayService();
|
||||
void checkXEventMonitorService();
|
||||
|
||||
QRect getDockShowGeometry(const QString &screenName, const Position &pos, const DisplayMode &displaymode, bool withoutScale = false);
|
||||
QRect getDockHideGeometry(const QString &screenName, const Position &pos, const DisplayMode &displaymode, bool withoutScale = false);
|
||||
@ -465,14 +364,12 @@ private:
|
||||
|
||||
// update monitor info
|
||||
QTimer *m_monitorUpdateTimer;
|
||||
QTimer *m_delayTimer; // sp3需求,切换屏幕显示延时,默认2秒唤起任务栏
|
||||
QTimer *m_delayWakeTimer; // sp3需求,切换屏幕显示延时,默认2秒唤起任务栏
|
||||
|
||||
QGSettings *m_monitorSetting; // 多屏配置控制
|
||||
const QGSettings *m_gsettings; // 多屏配置控制
|
||||
|
||||
// 屏幕名称信息
|
||||
DockScreen m_ds;
|
||||
// 显示器信息
|
||||
MonitorInfo m_mtrInfo;
|
||||
DockScreen m_ds; // 屏幕名称信息
|
||||
MonitorInfo m_mtrInfo; // 显示器信息
|
||||
|
||||
// 任务栏属性
|
||||
double m_opacity;
|
||||
@ -481,10 +378,8 @@ private:
|
||||
HideState m_hideState;
|
||||
DisplayMode m_displayMode;
|
||||
|
||||
//当前屏幕的方向
|
||||
int m_monitorRotation;
|
||||
//当前屏幕的所有方向
|
||||
RotationList m_rotations; // 逆时针旋转(向下,向右,向上,向左)
|
||||
int m_monitorRotation; //当前屏幕的方向
|
||||
RotationList m_rotations; // 当前屏幕的所有方向,逆时针旋转(向下,向右,向上,向左)
|
||||
|
||||
/***************不和其他流程产生交互,尽量不要动这里的变量***************/
|
||||
int m_screenRawHeight;
|
||||
|
@ -25,16 +25,59 @@
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QGSettings>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
#define ICBC_CONF_FILE "/etc/deepin/icbc.conf"
|
||||
|
||||
// 这样命名就是为了强调这是个指针类型
|
||||
inline const QGSettings *SettingsPtr(const QString &module, QObject *parent = nullptr) {
|
||||
return QGSettings::isSchemaInstalled(QString("com.deepin.dde.dock.module." + module).toUtf8())
|
||||
? new QGSettings(QString("com.deepin.dde.dock.module." + module).toUtf8(), QByteArray(), parent) // 自动销毁
|
||||
: nullptr;
|
||||
/**
|
||||
* @brief SettingsPtr 根据给定信息返回一个QGSettings指针
|
||||
* @param schema_id The id of the schema
|
||||
* @param path If non-empty, specifies the path for a relocatable schema
|
||||
* @param parent 创建指针的付对象
|
||||
* @return
|
||||
*/
|
||||
inline const 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;
|
||||
}
|
||||
qDebug() << "Cannot find gsettings, schema_id:" << schema_id;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsPtr 根据给定信息返回一个QGSettings指针
|
||||
* @param module 传入QGSettings构造函数时,会添加"com.deepin.dde.dock.module."前缀
|
||||
* @param path If non-empty, specifies the path for a relocatable schema
|
||||
* @param parent 创建指针的付对象
|
||||
* @return
|
||||
*/
|
||||
inline const QGSettings *ModuleSettingsPtr(const QString &module, const QByteArray &path = QByteArray(), QObject *parent = nullptr) {
|
||||
return SettingsPtr("com.deepin.dde.dock.module." + module, path, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingValue 根据给定信息返回获取的值
|
||||
* @param schema_id The id of the schema
|
||||
* @param path If non-empty, specifies the path for a relocatable schema
|
||||
* @param key 对应信息的key值
|
||||
* @param fallback 如果找不到信息,返回此默认值
|
||||
* @return
|
||||
*/
|
||||
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)) {
|
||||
QVariant v = settings->get(key);
|
||||
delete settings;
|
||||
return v;
|
||||
} else{
|
||||
qDebug() << "Cannot find gsettings, schema_id:" << schema_id
|
||||
<< " path:" << path << " key:" << key
|
||||
<< "Use fallback value:" << fallback;
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
||||
@ -53,7 +96,7 @@ inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal dev
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
inline QScreen * screenAt(const QPoint &point) {
|
||||
inline QScreen *screenAt(const QPoint &point) {
|
||||
for (QScreen *screen : qApp->screens()) {
|
||||
const QRect r { screen->geometry() };
|
||||
const QRect rect { r.topLeft(), r.size() * screen->devicePixelRatio() };
|
||||
@ -66,7 +109,7 @@ inline QScreen * screenAt(const QPoint &point) {
|
||||
}
|
||||
|
||||
//!!! 注意:这里传入的QPoint是未计算缩放的
|
||||
inline QScreen * screenAtByScaled(const QPoint &point) {
|
||||
inline QScreen *screenAtByScaled(const QPoint &point) {
|
||||
for (QScreen *screen : qApp->screens()) {
|
||||
const QRect r { screen->geometry() };
|
||||
QRect rect { r.topLeft(), r.size() * screen->devicePixelRatio() };
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QX11Info>
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <QGSettings>
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xutil.h>
|
||||
@ -523,8 +522,7 @@ void MainWindow::touchRequestResizeDock()
|
||||
return;
|
||||
}
|
||||
|
||||
QGSettings settings("com.deepin.dde.dock.touch", QByteArray(), this);
|
||||
int resizeHeight = settings.get("resizeHeight").toInt();
|
||||
int resizeHeight = Utils::SettingValue("com.deepin.dde.dock.touch", QByteArray(), "resizeHeight", 7).toInt();
|
||||
|
||||
QRect touchRect;
|
||||
// 任务栏屏幕 内侧边线 内外resizeHeight距离矩形区域内长按可拖动任务栏高度
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <DDBusSender>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QGSettings>
|
||||
#include <QFile>
|
||||
|
||||
using namespace dde::network;
|
||||
|
@ -44,7 +44,7 @@ ShutdownPlugin::ShutdownPlugin(QObject *parent)
|
||||
, m_pluginLoaded(false)
|
||||
, m_tipsLabel(new TipsWidget)
|
||||
, m_powerManagerInter(new DBusPowerManager("com.deepin.daemon.PowerManager", "/com/deepin/daemon/PowerManager", QDBusConnection::systemBus(), this))
|
||||
, m_gsettings(new QGSettings("com.deepin.dde.dock.module.shutdown", QByteArray(), this))
|
||||
, m_gsettings(Utils::ModuleSettingsPtr("shutdown", QByteArray(), this))
|
||||
{
|
||||
m_tipsLabel->setVisible(false);
|
||||
m_tipsLabel->setAccessibleName("shutdown");
|
||||
@ -118,7 +118,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
items.reserve(6);
|
||||
|
||||
QMap<QString, QVariant> shutdown;
|
||||
if (m_gsettings->get(GSETTING_SHOW_SHUTDOWN).toBool()) {
|
||||
if (!m_gsettings || (m_gsettings->keys().contains(GSETTING_SHOW_SHUTDOWN) && m_gsettings->get(GSETTING_SHOW_SHUTDOWN).toBool())) {
|
||||
shutdown["itemId"] = "Shutdown";
|
||||
shutdown["itemText"] = tr("Shut down");
|
||||
shutdown["isActive"] = true;
|
||||
@ -140,7 +140,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
;
|
||||
if (can_sleep) {
|
||||
QMap<QString, QVariant> suspend;
|
||||
if (m_gsettings->get(GSETTING_SHOW_SUSPEND).toBool()) {
|
||||
if (!m_gsettings || (m_gsettings->keys().contains(GSETTING_SHOW_SUSPEND) && m_gsettings->get(GSETTING_SHOW_SUSPEND).toBool())) {
|
||||
suspend["itemId"] = "Suspend";
|
||||
suspend["itemText"] = tr("Suspend");
|
||||
suspend["isActive"] = true;
|
||||
@ -153,7 +153,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
|
||||
if (can_hibernate) {
|
||||
QMap<QString, QVariant> hibernate;
|
||||
if (m_gsettings->get(GSETTING_SHOW_HIBERNATE).toBool()) {
|
||||
if (!m_gsettings || (m_gsettings->keys().contains(GSETTING_SHOW_HIBERNATE) && m_gsettings->get(GSETTING_SHOW_HIBERNATE).toBool())) {
|
||||
hibernate["itemId"] = "Hibernate";
|
||||
hibernate["itemText"] = tr("Hibernate");
|
||||
hibernate["isActive"] = true;
|
||||
@ -164,7 +164,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
#endif
|
||||
|
||||
QMap<QString, QVariant> lock;
|
||||
if (m_gsettings->get(GSETTING_SHOW_LOCK).toBool()) {
|
||||
if (!m_gsettings || (m_gsettings->keys().contains(GSETTING_SHOW_LOCK) && m_gsettings->get(GSETTING_SHOW_LOCK).toBool())) {
|
||||
lock["itemId"] = "Lock";
|
||||
lock["itemText"] = tr("Lock");
|
||||
lock["isActive"] = true;
|
||||
|
@ -113,7 +113,7 @@ private:
|
||||
ShutdownWidget *m_shutdownWidget;
|
||||
Dock::TipsWidget *m_tipsLabel;
|
||||
DBusPowerManager* m_powerManagerInter;
|
||||
QGSettings *m_gsettings;
|
||||
const QGSettings *m_gsettings;
|
||||
};
|
||||
|
||||
#endif // SHUTDOWNPLUGIN_H
|
||||
|
@ -25,14 +25,15 @@
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "../frame/util/imageutil.h"
|
||||
#include "util/utils.h"
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
#include <DApplication>
|
||||
#include <DStandardItem>
|
||||
#include <DFontSizeManager>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QIcon>
|
||||
#include <QScrollBar>
|
||||
#include <DApplication>
|
||||
#include <DStandardItem>
|
||||
#include <DFontSizeManager>
|
||||
|
||||
#define WIDTH 260
|
||||
#define MAX_HEIGHT 300
|
||||
@ -120,7 +121,7 @@ SoundApplet::SoundApplet(QWidget *parent)
|
||||
, m_model(new QStandardItemModel(m_listView))
|
||||
, m_deviceInfo("")
|
||||
, m_lastPort(nullptr)
|
||||
, m_gsettings(new QGSettings("com.deepin.dde.dock.module.sound", QByteArray(), this))
|
||||
, m_gsettings(Utils::ModuleSettingsPtr("sound", QByteArray(), this))
|
||||
|
||||
{
|
||||
initUi();
|
||||
@ -183,7 +184,7 @@ void SoundApplet::initUi()
|
||||
m_volumeSlider->setFixedHeight(SLIDER_HIGHT);
|
||||
m_volumeSlider->setMinimum(0);
|
||||
m_volumeSlider->setMaximum(m_audioInter->maxUIVolume() * 100.0f);
|
||||
updateVolumeSliderStatus(m_gsettings->get(GSETTING_SOUND_OUTPUT_SLIDER).toString());
|
||||
updateVolumeSliderStatus(Utils::SettingValue("com.deepin.dde.dock.module.sound", QByteArray(), "Enabled").toString());
|
||||
connect(m_gsettings, &QGSettings::changed, [ = ] (const QString &key) {
|
||||
if (key == GSETTING_SOUND_OUTPUT_SLIDER) {
|
||||
updateVolumeSliderStatus(m_gsettings->get(GSETTING_SOUND_OUTPUT_SLIDER).toString());
|
||||
@ -559,7 +560,7 @@ void SoundApplet::updateCradsInfo()
|
||||
|
||||
void SoundApplet::enableDevice(bool flag)
|
||||
{
|
||||
QString status = m_gsettings->get(GSETTING_SOUND_OUTPUT_SLIDER).toString();
|
||||
QString status = m_gsettings ? m_gsettings->get(GSETTING_SOUND_OUTPUT_SLIDER).toString() : "Enabled";
|
||||
if ("Disabled" == status ) {
|
||||
m_volumeSlider->setEnabled(false);
|
||||
} else if ("Enabled" == status) {
|
||||
|
@ -156,7 +156,7 @@ private:
|
||||
QList<Port *> m_ports;
|
||||
QString m_deviceInfo;
|
||||
QPointer<Port> m_lastPort;//最后一个因为只有一个设备而被直接移除的设备
|
||||
QGSettings *m_gsettings;
|
||||
const QGSettings *m_gsettings;
|
||||
};
|
||||
|
||||
#endif // SOUNDAPPLET_H
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
#include <QMouseEvent>
|
||||
#include <QGSettings>
|
||||
#include <QApplication>
|
||||
|
||||
#include <DApplication>
|
||||
|
@ -20,12 +20,12 @@
|
||||
*/
|
||||
|
||||
#include "systemtrayitem.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <QGSettings>
|
||||
|
||||
Dock::Position SystemTrayItem::DockPosition = Dock::Position::Top;
|
||||
QPointer<DockPopupWindow> SystemTrayItem::PopupWindow = nullptr;
|
||||
@ -39,6 +39,7 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
, m_popupTipsDelayTimer(new QTimer(this))
|
||||
, m_popupAdjustDelayTimer(new QTimer(this))
|
||||
, m_itemKey(itemKey)
|
||||
, m_gsettings(Utils::ModuleSettingsPtr(pluginInter->pluginName(), QByteArray(), this))
|
||||
{
|
||||
qDebug() << "load tray plugins item: " << m_pluginInter->pluginName() << itemKey << m_centralWidget;
|
||||
|
||||
@ -77,32 +78,16 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
connect(m_popupAdjustDelayTimer, &QTimer::timeout, this, &SystemTrayItem::updatePopupPosition, Qt::QueuedConnection);
|
||||
connect(&m_contextMenu, &QMenu::triggered, this, &SystemTrayItem::menuActionClicked);
|
||||
|
||||
if (m_gsettings)
|
||||
connect(m_gsettings, &QGSettings::changed, this, &SystemTrayItem::onGSettingsChanged);
|
||||
|
||||
grabGesture(Qt::TapAndHoldGesture);
|
||||
|
||||
const QByteArray &schema{
|
||||
QString("com.deepin.dde.dock.module.%1").arg(pluginInter->pluginName()).toUtf8()
|
||||
};
|
||||
|
||||
if (QGSettings::isSchemaInstalled(schema)) {
|
||||
m_gsettings = new QGSettings(schema);
|
||||
m_gsettings->setParent(this);
|
||||
connect(m_gsettings, &QGSettings::changed, this,
|
||||
&SystemTrayItem::onGSettingsChanged);
|
||||
}
|
||||
else {
|
||||
m_gsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
SystemTrayItem::~SystemTrayItem()
|
||||
{
|
||||
if (m_popupShown)
|
||||
popupWindowAccept();
|
||||
|
||||
if(nullptr != m_gsettings){
|
||||
m_gsettings->deleteLater();
|
||||
m_gsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QString SystemTrayItem::itemKeyForConfig()
|
||||
@ -203,7 +188,7 @@ void SystemTrayItem::enterEvent(QEvent *event)
|
||||
if (checkGSettingsControl()) {
|
||||
//网络需要显示Tips,需要特殊处理。
|
||||
if (m_pluginInter->pluginName() != "network")
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// 触屏不显示hover效果
|
||||
@ -493,11 +478,11 @@ void SystemTrayItem::updatePopupPosition()
|
||||
}
|
||||
|
||||
void SystemTrayItem::onGSettingsChanged(const QString &key) {
|
||||
if (key != "enable" || !m_gsettings) {
|
||||
if (key != "enable") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gsettings->keys().contains("enable")) {
|
||||
if (m_gsettings && m_gsettings->keys().contains("enable")) {
|
||||
const bool visible = m_gsettings->get("enable").toBool();
|
||||
setVisible(visible);
|
||||
emit itemVisibleChanged(visible);
|
||||
@ -506,5 +491,5 @@ void SystemTrayItem::onGSettingsChanged(const QString &key) {
|
||||
|
||||
bool SystemTrayItem::checkGSettingsControl() const
|
||||
{
|
||||
return m_gsettings ? m_gsettings->get("control").toBool() : false;
|
||||
return (m_gsettings && m_gsettings->get("control").toBool());
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
|
||||
static Dock::Position DockPosition;
|
||||
static QPointer<DockPopupWindow> PopupWindow;
|
||||
QGSettings* m_gsettings;
|
||||
const QGSettings* m_gsettings;
|
||||
};
|
||||
|
||||
#endif // SYSTEMTRAYITEM_H
|
||||
|
@ -23,12 +23,12 @@
|
||||
#include "trayplugin.h"
|
||||
#include "fashiontray/fashiontrayitem.h"
|
||||
#include "snitraywidget.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QWindow>
|
||||
#include <QWidget>
|
||||
#include <QX11Info>
|
||||
#include <QGSettings>
|
||||
#include <QtConcurrent>
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
@ -385,10 +385,8 @@ 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()) {
|
||||
if (!Utils::SettingValue("com.deepin.dde.dock.module.systemtray", QByteArray(), "enable", false).toBool())
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractTrayWidget *trayWidget = new XEmbedTrayWidget(winId);
|
||||
if (trayWidget->isValid())
|
||||
@ -432,10 +430,8 @@ void TrayPlugin::traySNIAdded(const QString &itemKey, const QString &sniServiceP
|
||||
}
|
||||
}
|
||||
|
||||
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
||||
if (settings.keys().contains("enable") && !settings.get("enable").toBool()) {
|
||||
if (!Utils::SettingValue("com.deepin.dde.dock.module.systemtray", QByteArray(), "enable", false).toBool())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sniServicePath.startsWith("/") || !sniServicePath.contains("/")) {
|
||||
qDebug() << "SNI service path invalid";
|
||||
@ -470,10 +466,8 @@ 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()) {
|
||||
if (!Utils::SettingValue("com.deepin.dde.dock.module.systemtray", QByteArray(), "enable", false).toBool())
|
||||
return;
|
||||
}
|
||||
|
||||
IndicatorTray *indicatorTray = nullptr;
|
||||
if (!m_indicatorMap.keys().contains(indicatorName)) {
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "appdrag.h"
|
||||
#include "mock/qgsettingsmock.h"
|
||||
|
||||
class Test_AppDrag : public ::testing::Test
|
||||
{
|
||||
@ -44,10 +43,7 @@ void Test_AppDrag::TearDown()
|
||||
TEST_F(Test_AppDrag, drag_test)
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
QGSettingsMock mock;
|
||||
ON_CALL(mock, get(::testing::_)) .WillByDefault(::testing::Invoke([](const QString& key){return 1.5; }));
|
||||
|
||||
AppDrag *drag = new AppDrag(&mock, w);
|
||||
AppDrag *drag = new AppDrag(w);
|
||||
QPixmap pix(":/res/all_settings_on.png");
|
||||
drag->setPixmap(pix);
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#define private public
|
||||
#include "appdragwidget.h"
|
||||
#include "mock/qgsettingsmock.h"
|
||||
#undef private
|
||||
|
||||
class Test_AppDragWidget : public ::testing::Test
|
||||
@ -45,10 +44,7 @@ void Test_AppDragWidget::TearDown()
|
||||
|
||||
TEST_F(Test_AppDragWidget, cuntion_test)
|
||||
{
|
||||
QGSettingsMock *mock = new QGSettingsMock;
|
||||
ON_CALL(*mock, get(::testing::_)) .WillByDefault(::testing::Invoke([](const QString& key){Q_UNUSED(key); return 1.5; }));
|
||||
|
||||
AppDragWidget *dragWidget = new AppDragWidget(mock);
|
||||
AppDragWidget *dragWidget = new AppDragWidget;
|
||||
|
||||
QPixmap pix(":/res/all_settings_on.png");
|
||||
dragWidget->setAppPixmap(pix);
|
||||
|
@ -25,12 +25,11 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "utils.h"
|
||||
#define private public
|
||||
#include "appitem.h"
|
||||
#undef private
|
||||
|
||||
#include "mock/qgsettingsmock.h"
|
||||
|
||||
using namespace ::testing;
|
||||
|
||||
class Test_AppItem : public ::testing::Test
|
||||
@ -50,16 +49,14 @@ void Test_AppItem::TearDown()
|
||||
|
||||
TEST_F(Test_AppItem, coverage_test)
|
||||
{
|
||||
QGSettingsMock mock;
|
||||
const QGSettings *appSettings = Utils::ModuleSettingsPtr("app");
|
||||
const QGSettings *activeSettings = Utils::ModuleSettingsPtr("activeapp");
|
||||
const QGSettings *dockedSettings = Utils::ModuleSettingsPtr("dockapp");
|
||||
|
||||
ON_CALL(mock, type()).WillByDefault(Return(QGSettingsMock::Type::MockType));
|
||||
ON_CALL(mock, keys()).WillByDefault(Return(QStringList() << "enable" << "control"));
|
||||
ON_CALL(mock, get(_)) .WillByDefault(::testing::Invoke([](const QString& key){return true; }));
|
||||
|
||||
AppItem *appItem = new AppItem(&mock, &mock, &mock, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e0T6045b766"));
|
||||
AppItem *appItem = new AppItem(appSettings, activeSettings, dockedSettings, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e0T6045b766"));
|
||||
|
||||
// 触发信号测试
|
||||
// emit appItem->m_refershIconTimer->start(10);
|
||||
// emit appItem->m_refershIconTimer->start(10);
|
||||
QTest::qWait(20);
|
||||
|
||||
// FIXME: 测试不到?
|
||||
@ -97,12 +94,18 @@ TEST_F(Test_AppItem, coverage_test)
|
||||
QTest::mousePress(appItem, Qt::LeftButton, Qt::NoModifier);
|
||||
QTest::mouseRelease(appItem, Qt::LeftButton, Qt::NoModifier);
|
||||
QTest::qWait(400);
|
||||
// QTest::mouseClick(appItem, Qt::MiddleButton, Qt::NoModifier);
|
||||
// QTest::qWait(400);
|
||||
// QTest::mouseClick(appItem, Qt::LeftButton, Qt::NoModifier, QPoint(-1, -1));
|
||||
// QTest::qWait(400);
|
||||
// QTest::mouseMove(appItem, appItem->geometry().center());
|
||||
// QTest::mouseClick(appItem, Qt::MiddleButton, Qt::NoModifier);
|
||||
// QTest::qWait(400);
|
||||
// QTest::mouseClick(appItem, Qt::LeftButton, Qt::NoModifier, QPoint(-1, -1));
|
||||
// QTest::qWait(400);
|
||||
// QTest::mouseMove(appItem, appItem->geometry().center());
|
||||
|
||||
delete appItem;
|
||||
appItem = nullptr;
|
||||
delete appSettings;
|
||||
appSettings = nullptr;
|
||||
delete activeSettings;
|
||||
activeSettings = nullptr;
|
||||
delete dockedSettings;
|
||||
dockedSettings = nullptr;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "dockitem.h"
|
||||
#include "mock/qgsettingsmock.h"
|
||||
|
||||
class Test_DockItem : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
|
@ -31,8 +31,6 @@ using namespace ::testing;
|
||||
#include "launcheritem.h"
|
||||
#undef private
|
||||
|
||||
#include "mock/qgsettingsmock.h"
|
||||
|
||||
class Test_LauncherItem : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QGSETTINGSMOCK_H
|
||||
#define QGSETTINGSMOCK_H
|
||||
#include "qgsettingsinterface.h"
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
class QGSettingsMock : public QGSettingsInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QGSettingsMock() {}
|
||||
|
||||
MOCK_METHOD0(type, Type(void));
|
||||
MOCK_METHOD0(gsettings, QGSettings *(void));
|
||||
MOCK_CONST_METHOD1(get, QVariant(const QString &key));
|
||||
MOCK_METHOD2(set, void(const QString &key, const QVariant &value));
|
||||
MOCK_METHOD2(trySet, bool (const QString &key, const QVariant &value));
|
||||
MOCK_CONST_METHOD0(keys, QStringList(void));
|
||||
MOCK_CONST_METHOD1(choices, QVariantList(const QString &key));
|
||||
MOCK_METHOD1(reset, void(const QString &key));
|
||||
|
||||
static bool isSchemaInstalled(const QByteArray &schema_id) {Q_UNUSED(schema_id); return true;}
|
||||
};
|
||||
#endif // QGSETTINGSMOCK_H
|
Loading…
x
Reference in New Issue
Block a user