2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
2020-05-28 20:45:02 +08:00
|
|
|
* zhaolong <zhaolong@uniontech.com>
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2016-06-06 10:59:29 +08:00
|
|
|
#ifndef DOCKSETTINGS_H
|
|
|
|
#define DOCKSETTINGS_H
|
|
|
|
|
2016-06-16 16:56:21 +08:00
|
|
|
#include "constants.h"
|
2020-04-21 17:47:35 +08:00
|
|
|
#include "monitor.h"
|
2019-01-07 14:09:25 +08:00
|
|
|
|
|
|
|
#include <com_deepin_dde_daemon_dock.h>
|
2020-06-05 16:16:59 +08:00
|
|
|
#include <com_deepin_daemon_display.h>
|
2016-06-16 16:56:21 +08:00
|
|
|
|
2016-12-12 10:58:48 +08:00
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
2016-06-21 14:02:51 +08:00
|
|
|
|
2016-06-06 10:59:29 +08:00
|
|
|
#include <QObject>
|
2016-06-13 09:20:01 +08:00
|
|
|
#include <QSize>
|
2016-06-06 10:59:29 +08:00
|
|
|
|
2016-06-21 10:12:43 +08:00
|
|
|
using namespace Dock;
|
2019-01-07 14:09:25 +08:00
|
|
|
using DBusDock = com::deepin::dde::daemon::Dock;
|
2020-06-05 16:16:59 +08:00
|
|
|
using DisplayInter = com::deepin::daemon::Display;
|
2016-06-21 10:12:43 +08:00
|
|
|
|
2020-06-05 16:16:59 +08:00
|
|
|
class DockItemManager;
|
2016-06-06 10:59:29 +08:00
|
|
|
class DockSettings : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-08-17 18:01:32 +08:00
|
|
|
static DockSettings &Instance();
|
2016-06-06 10:59:29 +08:00
|
|
|
|
2017-12-26 11:54:31 +08:00
|
|
|
inline DisplayMode displayMode() const { return m_displayMode; }
|
|
|
|
inline HideMode hideMode() const { return m_hideMode; }
|
|
|
|
inline HideState hideState() const { return m_hideState; }
|
|
|
|
inline Position position() const { return m_position; }
|
|
|
|
inline int screenRawHeight() const { return m_screenRawHeight; }
|
|
|
|
inline int screenRawWidth() const { return m_screenRawWidth; }
|
|
|
|
inline int expandTimeout() const { return m_dockInter->showTimeout(); }
|
2018-01-02 16:48:01 +08:00
|
|
|
inline int narrowTimeout() const { return 100; }
|
2017-12-26 11:54:31 +08:00
|
|
|
inline bool autoHide() const { return m_autoHide; }
|
2019-03-29 14:38:12 +08:00
|
|
|
const QRect primaryRect() const;
|
2020-05-28 20:45:02 +08:00
|
|
|
const QRect currentRect();
|
2020-04-21 17:47:35 +08:00
|
|
|
const QList<QRect> monitorsRect() const;
|
2017-12-26 11:54:31 +08:00
|
|
|
inline const QRect primaryRawRect() const { return m_primaryRawRect; }
|
2020-06-05 16:16:59 +08:00
|
|
|
inline const QRect currentRawRect() const { return m_currentRawRect; }
|
2017-12-26 11:54:31 +08:00
|
|
|
inline const QRect frontendWindowRect() const { return m_frontendRect; }
|
|
|
|
inline const QSize windowSize() const { return m_mainWindowSize; }
|
2018-10-08 15:11:42 +08:00
|
|
|
inline const quint8 Opacity() const { return m_opacity * 255; }
|
2019-08-23 16:58:13 +08:00
|
|
|
const int dockMargin() const;
|
2017-12-26 11:54:31 +08:00
|
|
|
|
|
|
|
const QSize panelSize() const;
|
2020-05-28 20:45:02 +08:00
|
|
|
const QRect windowRect(const Position position, const bool hide = false);
|
2019-04-23 14:28:09 +08:00
|
|
|
qreal dockRatio() const;
|
2016-06-13 09:20:01 +08:00
|
|
|
|
2016-06-21 14:02:51 +08:00
|
|
|
void showDockSettingsMenu();
|
2019-09-20 16:05:22 +08:00
|
|
|
void updateFrontendGeometry();
|
2020-05-28 20:45:02 +08:00
|
|
|
|
2020-06-11 18:17:40 +08:00
|
|
|
bool setDockScreen(const QString &scrName);
|
2020-05-28 20:45:02 +08:00
|
|
|
QString ¤tDockScreen() { return m_currentScreen; }
|
2019-09-20 16:05:22 +08:00
|
|
|
|
2020-06-10 21:24:38 +08:00
|
|
|
void posChangedUpdateSettings();
|
2020-06-15 16:38:30 +08:00
|
|
|
void calculateWindowConfig();
|
2020-06-10 21:24:38 +08:00
|
|
|
|
2019-08-26 16:15:50 +08:00
|
|
|
QSize m_mainWindowSize;
|
2019-09-03 13:26:42 +08:00
|
|
|
DBusDock *m_dockInter;
|
2020-01-19 18:21:26 +08:00
|
|
|
bool m_menuVisible;
|
2016-06-21 14:02:51 +08:00
|
|
|
|
2016-06-21 10:12:43 +08:00
|
|
|
signals:
|
|
|
|
void dataChanged() const;
|
2020-06-10 21:24:38 +08:00
|
|
|
void positionChanged() const;
|
2016-06-30 14:44:55 +08:00
|
|
|
void autoHideChanged(const bool autoHide) const;
|
2018-01-04 17:22:37 +08:00
|
|
|
void displayModeChanegd() const;
|
2017-02-07 00:18:00 +08:00
|
|
|
void windowVisibleChanged() const;
|
2016-06-29 16:53:37 +08:00
|
|
|
void windowHideModeChanged() const;
|
2016-06-22 10:28:47 +08:00
|
|
|
void windowGeometryChanged() const;
|
2018-10-08 15:11:42 +08:00
|
|
|
void opacityChanged(const quint8 value) const;
|
2020-02-12 17:32:46 +08:00
|
|
|
void trayCountChanged() const;
|
2016-06-21 10:12:43 +08:00
|
|
|
|
2016-06-13 09:20:01 +08:00
|
|
|
public slots:
|
|
|
|
void updateGeometry();
|
2016-06-30 14:44:55 +08:00
|
|
|
void setAutoHide(const bool autoHide);
|
2016-06-06 10:59:29 +08:00
|
|
|
|
2016-06-21 10:12:43 +08:00
|
|
|
private slots:
|
2016-12-12 10:58:48 +08:00
|
|
|
void menuActionClicked(QAction *action);
|
2020-01-19 18:21:26 +08:00
|
|
|
void onGSettingsChanged(const QString &key);
|
2016-08-12 14:28:35 +08:00
|
|
|
void onPositionChanged();
|
2018-01-04 17:22:37 +08:00
|
|
|
void onDisplayModeChanged();
|
2016-06-27 16:36:51 +08:00
|
|
|
void hideModeChanged();
|
2017-02-07 00:18:00 +08:00
|
|
|
void hideStateChanged();
|
2016-06-22 10:28:47 +08:00
|
|
|
void dockItemCountChanged();
|
2016-06-29 14:37:24 +08:00
|
|
|
void primaryScreenChanged();
|
2016-06-30 15:46:20 +08:00
|
|
|
void resetFrontendGeometry();
|
2018-10-08 15:11:42 +08:00
|
|
|
void onOpacityChanged(const double value);
|
2019-10-29 14:53:35 +08:00
|
|
|
void trayVisableCountChanged(const int &count);
|
2019-10-08 13:57:35 +08:00
|
|
|
void onWindowSizeChanged();
|
2020-02-24 17:39:14 +08:00
|
|
|
void onTrashGSettingsChanged(const QString &key);
|
2020-06-05 16:16:59 +08:00
|
|
|
void onMonitorListChanged(const QList<QDBusObjectPath> &mons);
|
2016-06-30 09:53:50 +08:00
|
|
|
|
2016-06-21 15:11:32 +08:00
|
|
|
private:
|
2020-06-05 16:16:59 +08:00
|
|
|
DockSettings(QWidget *parent = nullptr);
|
2018-07-30 15:12:51 +08:00
|
|
|
DockSettings(DockSettings const &) = delete;
|
|
|
|
DockSettings operator =(DockSettings const &) = delete;
|
|
|
|
|
2017-02-15 17:10:32 +08:00
|
|
|
void gtkIconThemeChanged();
|
2019-12-02 15:01:38 +08:00
|
|
|
void checkService();
|
2016-06-13 09:20:01 +08:00
|
|
|
|
2020-06-05 16:16:59 +08:00
|
|
|
void calculateMultiScreensPos();
|
|
|
|
void monitorAdded(const QString &path);
|
|
|
|
void monitorRemoved(const QString &path);
|
|
|
|
void twoScreensCalPos();
|
|
|
|
void treeScreensCalPos();
|
|
|
|
void combination(QList<Monitor*> &screens);
|
|
|
|
void calculateRelativePos(Monitor *s1, Monitor *s2);
|
|
|
|
|
2016-06-13 09:20:01 +08:00
|
|
|
private:
|
2019-09-03 13:26:42 +08:00
|
|
|
int m_dockWindowSize;
|
2016-06-30 14:44:55 +08:00
|
|
|
bool m_autoHide;
|
2017-12-13 11:53:03 +08:00
|
|
|
int m_screenRawHeight;
|
|
|
|
int m_screenRawWidth;
|
2018-10-08 15:11:42 +08:00
|
|
|
double m_opacity;
|
2019-08-23 16:58:13 +08:00
|
|
|
int m_dockMargin;
|
2017-12-13 11:53:03 +08:00
|
|
|
QSet<Position> m_forbidPositions;
|
2016-06-21 10:12:43 +08:00
|
|
|
Position m_position;
|
2016-06-21 14:02:51 +08:00
|
|
|
HideMode m_hideMode;
|
2016-06-29 18:30:25 +08:00
|
|
|
HideState m_hideState;
|
2016-06-21 14:02:51 +08:00
|
|
|
DisplayMode m_displayMode;
|
2017-11-13 21:17:56 +08:00
|
|
|
QRect m_primaryRawRect;
|
2020-05-28 20:45:02 +08:00
|
|
|
QRect m_currentRawRect;
|
2017-12-13 11:53:03 +08:00
|
|
|
QRect m_frontendRect;
|
2016-06-21 10:12:43 +08:00
|
|
|
|
2019-11-12 18:55:27 +08:00
|
|
|
QMenu m_settingsMenu;
|
|
|
|
QMenu *m_hideSubMenu;
|
2016-12-12 10:58:48 +08:00
|
|
|
QAction m_fashionModeAct;
|
|
|
|
QAction m_efficientModeAct;
|
|
|
|
QAction m_topPosAct;
|
|
|
|
QAction m_bottomPosAct;
|
|
|
|
QAction m_leftPosAct;
|
|
|
|
QAction m_rightPosAct;
|
|
|
|
QAction m_keepShownAct;
|
|
|
|
QAction m_keepHiddenAct;
|
|
|
|
QAction m_smartHideAct;
|
2016-06-21 14:02:51 +08:00
|
|
|
|
2020-06-05 16:16:59 +08:00
|
|
|
DisplayInter *m_displayInter;
|
2019-08-17 18:01:32 +08:00
|
|
|
DockItemManager *m_itemManager;
|
2020-02-24 17:39:14 +08:00
|
|
|
bool m_trashPluginShow;
|
2020-04-21 17:47:35 +08:00
|
|
|
|
|
|
|
QMap<Monitor *, MonitorInter *> m_monitors;
|
2020-05-28 20:45:02 +08:00
|
|
|
bool m_isMouseMoveCause;
|
|
|
|
Monitor *m_mouseCauseDockScreen;
|
|
|
|
QString m_currentScreen;
|
2016-06-06 10:59:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOCKSETTINGS_H
|