From 37248789f6fd9c91d4e44a6951778c6405311c08 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 6 Jul 2020 14:35:03 +0300 Subject: [PATCH] improvements to view config windows abstraction --- app/view/settings/primaryconfigview.cpp | 17 +++++- app/view/settings/primaryconfigview.h | 3 +- app/view/settings/subconfigview.h | 2 +- app/view/settings/viewsettingsfactory.cpp | 2 +- app/view/settings/viewsettingsfactory.h | 2 +- app/view/view.cpp | 65 ++++++----------------- app/view/view.h | 2 +- 7 files changed, 38 insertions(+), 55 deletions(-) diff --git a/app/view/settings/primaryconfigview.cpp b/app/view/settings/primaryconfigview.cpp index b2b56c6a8..462c60a89 100644 --- a/app/view/settings/primaryconfigview.cpp +++ b/app/view/settings/primaryconfigview.cpp @@ -108,9 +108,22 @@ void PrimaryConfigView::init() syncSlideEffect(); } -QQuickView *PrimaryConfigView::secondaryWindow() +void PrimaryConfigView::setOnActivities(QStringList activities) { - return m_secConfigView; + m_corona->wm()->setWindowOnActivities(*this, activities); + + if (m_secConfigView) { + m_corona->wm()->setWindowOnActivities(*m_secConfigView.data(), activities); + } +} + +void PrimaryConfigView::requestActivate() +{ + if (m_secConfigView) { + m_secConfigView->requestActivate(); + } + + SubConfigView::requestActivate(); } void PrimaryConfigView::showSecondaryWindow() diff --git a/app/view/settings/primaryconfigview.h b/app/view/settings/primaryconfigview.h index 9451721e4..e4d0f9c2e 100644 --- a/app/view/settings/primaryconfigview.h +++ b/app/view/settings/primaryconfigview.h @@ -96,8 +96,9 @@ public: QRect geometryWhenVisible() const; void setParentView(Latte::View *view) override; + void setOnActivities(QStringList activities); - QQuickView *secondaryWindow(); + void requestActivate() override; public slots: Q_INVOKABLE void syncGeometry() override; diff --git a/app/view/settings/subconfigview.h b/app/view/settings/subconfigview.h index 73d7a493a..28b9d0454 100644 --- a/app/view/settings/subconfigview.h +++ b/app/view/settings/subconfigview.h @@ -56,7 +56,7 @@ public: SubConfigView(Latte::View *view, const QString &title); ~SubConfigView() override; - void requestActivate(); + virtual void requestActivate(); QString validTitle() const; diff --git a/app/view/settings/viewsettingsfactory.cpp b/app/view/settings/viewsettingsfactory.cpp index 537918404..3a7431679 100644 --- a/app/view/settings/viewsettingsfactory.cpp +++ b/app/view/settings/viewsettingsfactory.cpp @@ -36,7 +36,7 @@ ViewSettingsFactory::~ViewSettingsFactory() } } -ViewPart::PrimaryConfigView *ViewSettingsFactory::primary(Latte::View *view) +ViewPart::PrimaryConfigView *ViewSettingsFactory::primaryConfigView(Latte::View *view) { if (!m_primaryConfigView) { m_primaryConfigView = new ViewPart::PrimaryConfigView(view); diff --git a/app/view/settings/viewsettingsfactory.h b/app/view/settings/viewsettingsfactory.h index 1a77d2691..7c204b13c 100644 --- a/app/view/settings/viewsettingsfactory.h +++ b/app/view/settings/viewsettingsfactory.h @@ -43,7 +43,7 @@ public: ViewSettingsFactory(QObject *parent); ~ViewSettingsFactory() override; - ViewPart::PrimaryConfigView *primary(Latte::View *view); + ViewPart::PrimaryConfigView *primaryConfigView(Latte::View *view); private: QPointer m_primaryConfigView; diff --git a/app/view/view.cpp b/app/view/view.cpp index 5447f693f..65aec73f3 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -201,9 +201,9 @@ View::~View() //! windows. //! this->disconnect(); - if (m_containmentConfigView && m_corona->inQuit()) { + if (m_primaryConfigView && m_corona->inQuit()) { //! delete only when application is quitting - delete m_containmentConfigView; + delete m_primaryConfigView; } if (m_appletConfigView) { @@ -428,9 +428,7 @@ void View::removeView() bool View::settingsWindowIsShown() { - auto cview = qobject_cast(m_containmentConfigView); - - return cview && (cview->parentView()==this) && cview->isVisible(); + return m_primaryConfigView && (m_primaryConfigView->parentView()==this) && m_primaryConfigView->isVisible(); } void View::showSettingsWindow() @@ -444,7 +442,7 @@ void View::showSettingsWindow() QQuickView *View::configView() { - return m_containmentConfigView.data(); + return m_primaryConfigView.data(); } void View::showConfigurationInterface(Plasma::Applet *applet) @@ -454,11 +452,11 @@ void View::showConfigurationInterface(Plasma::Applet *applet) Plasma::Containment *c = qobject_cast(applet); - if (m_containmentConfigView && c && c->isContainment() && c == this->containment()) { - if (m_containmentConfigView->isVisible()) { - m_containmentConfigView->hide(); + if (m_primaryConfigView && c && c->isContainment() && c == this->containment()) { + if (m_primaryConfigView->isVisible()) { + m_primaryConfigView->hide(); } else { - m_containmentConfigView->show(); + m_primaryConfigView->show(); applyActivitiesToWindows(); } @@ -479,7 +477,7 @@ void View::showConfigurationInterface(Plasma::Applet *applet) bool delayConfigView = false; if (c && containment() && c->isContainment() && c->id() == containment()->id()) { - m_containmentConfigView = m_corona->viewSettingsFactory()->primary(this); + m_primaryConfigView = m_corona->viewSettingsFactory()->primaryConfigView(this); applyActivitiesToWindows(); } else { m_appletConfigView = new PlasmaQuick::ConfigView(applet); @@ -794,15 +792,7 @@ void View::setIsPreferredForShortcuts(bool preferred) bool View::inSettingsAdvancedMode() const { - if (m_containmentConfigView) { - auto configView = qobject_cast(m_containmentConfigView); - - if (configView) { - return configView->inAdvancedMode(); - } - } - - return false; + return m_primaryConfigView && m_primaryConfigView->inAdvancedMode(); } bool View::isTouchingBottomViewAndIsBusy() const @@ -1039,14 +1029,8 @@ void View::applyActivitiesToWindows() m_windowsTracker->setWindowOnActivities(*this, runningActivities); //! config windows - if (m_containmentConfigView) { - m_windowsTracker->setWindowOnActivities(*m_containmentConfigView, runningActivities); - - auto configView = qobject_cast(m_containmentConfigView); - - if (configView && configView->secondaryWindow()) { - m_windowsTracker->setWindowOnActivities(*configView->secondaryWindow(), runningActivities); - } + if (m_primaryConfigView) { + m_primaryConfigView->setOnActivities(runningActivities); } if (m_appletConfigView) { @@ -1210,12 +1194,8 @@ void View::moveToLayout(QString layoutName) void View::hideWindowsForSlidingOut() { - if (m_containmentConfigView) { - auto configDialog = qobject_cast(m_containmentConfigView); - - if (configDialog) { - configDialog->hideConfigWindow(); - } + if (m_primaryConfigView) { + m_primaryConfigView->hideConfigWindow(); } } @@ -1302,19 +1282,8 @@ bool View::event(QEvent *e) case QEvent::Enter: m_containsMouse = true; - if (m_containmentConfigView) { - ViewPart::PrimaryConfigView *primaryConfigView = qobject_cast(m_containmentConfigView); - - if (primaryConfigView) { - if (primaryConfigView->secondaryWindow()) { - ViewPart::SecondaryConfigView *secConfigView = qobject_cast(primaryConfigView->secondaryWindow()); - if (secConfigView) { - secConfigView->requestActivate(); - } - } - - primaryConfigView->requestActivate(); - } + if (m_primaryConfigView) { + m_primaryConfigView->requestActivate(); } break; @@ -1399,7 +1368,7 @@ bool View::event(QEvent *e) void View::releaseConfigView() { - m_containmentConfigView = nullptr; + m_primaryConfigView = nullptr; } //! release grab and restore mouse state diff --git a/app/view/view.h b/app/view/view.h index 6fa2891d8..888e24ea6 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -411,7 +411,7 @@ private: Layout::GenericLayout *m_layout{nullptr}; QPointer m_appletConfigView; - QPointer m_containmentConfigView; + QPointer m_primaryConfigView; QPointer m_contextMenu; QPointer m_effects;