From 4dcb1d9c4f46b48c204e2c76720792d2b1c9957f Mon Sep 17 00:00:00 2001 From: haruyukilxz Date: Mon, 30 Jul 2018 15:12:51 +0800 Subject: [PATCH] feat: add dock settings instance Change-Id: I8d09c2d0e986de1493ad9dc43a2eeaffe3014746 --- frame/util/docksettings.cpp | 6 ++++++ frame/util/docksettings.h | 6 +++++- frame/window/mainwindow.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frame/util/docksettings.cpp b/frame/util/docksettings.cpp index 288fb19a1..ab9166c69 100644 --- a/frame/util/docksettings.cpp +++ b/frame/util/docksettings.cpp @@ -152,6 +152,12 @@ DockSettings::DockSettings(QWidget *parent) resetFrontendGeometry(); } +DockSettings &DockSettings::Instance() +{ + static DockSettings settings; + return settings; +} + const QSize DockSettings::panelSize() const { switch (m_position) diff --git a/frame/util/docksettings.h b/frame/util/docksettings.h index c5d8e9edc..9f310561f 100644 --- a/frame/util/docksettings.h +++ b/frame/util/docksettings.h @@ -57,7 +57,7 @@ class DockSettings : public QObject Q_OBJECT public: - explicit DockSettings(QWidget *parent = 0); + static DockSettings& Instance(); inline DisplayMode displayMode() const { return m_displayMode; } inline HideMode hideMode() const { return m_hideMode; } @@ -106,6 +106,10 @@ private slots: void updateForbidPostions(); private: + DockSettings(QWidget *parent = 0); + DockSettings(DockSettings const &) = delete; + DockSettings operator =(DockSettings const &) = delete; + bool test(const Position pos, const QList &otherScreens) const; void calculateWindowConfig(); void gtkIconThemeChanged(); diff --git a/frame/window/mainwindow.cpp b/frame/window/mainwindow.cpp index f9482bcc2..ccb1780bd 100644 --- a/frame/window/mainwindow.cpp +++ b/frame/window/mainwindow.cpp @@ -103,7 +103,7 @@ MainWindow::MainWindow(QWidget *parent) m_platformWindowHandle.setShadowOffset(QPoint(0, 0)); m_platformWindowHandle.setShadowRadius(0); - m_settings = new DockSettings(this); + m_settings = &DockSettings::Instance(); m_xcbMisc->set_window_type(winId(), XcbMisc::Dock); initComponents();