From c62452c467e96756a4e5bcaddcee98caa7d27d49 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 30 Dec 2015 11:51:37 +0000 Subject: [PATCH] Don't emit signals in another object from panel Emitting objects in another object is weird. ShellCorona::availableScreenRect knows what properties of panelview we use, so tracking of property changes should be in ShellCorona. Also simplify ShellCoronaCode, if the rect changes the region has also implicitly changed. We can handle that in one connect. REVIEW: 126576 --- shell/panelview.cpp | 8 -------- shell/shellcorona.cpp | 14 +++++--------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/shell/panelview.cpp b/shell/panelview.cpp index 53a8d12c6..9c56ab476 100644 --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -93,10 +93,6 @@ PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent &m_positionPaneltimer, SLOT(start())); connect(this, SIGNAL(containmentChanged()), this, SLOT(containmentChanged())); - connect(this, &ContainmentView::locationChanged, [this] () { - emit m_corona->availableScreenRectChanged(); - emit m_corona->availableScreenRegionChanged(); - }); if (!m_corona->kPackage().isValid()) { qWarning() << "Invalid home screen package"; @@ -221,8 +217,6 @@ void PanelView::setThickness(int value) config().writeEntry("thickness", value); m_corona->requestApplicationConfigSync(); positionPanel(); - emit m_corona->availableScreenRectChanged(); - emit m_corona->availableScreenRegionChanged(); } int PanelView::length() const @@ -345,8 +339,6 @@ void PanelView::setVisibilityMode(PanelView::VisibilityMode mode) updateStruts(); emit visibilityModeChanged(); - emit corona()->availableScreenRectChanged(); - emit corona()->availableScreenRegionChanged(); restoreAutoHide(); } diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index 17ce61b57..25bc68383 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -108,6 +108,8 @@ ShellCorona::ShellCorona(QObject *parent) executeSetupPlasmoidScript(c, c); }); + connect(this, &Plasma::Corona::availableScreenRectChanged, this, &Plasma::Corona::availableScreenRegionChanged); + m_appConfigSyncTimer.setSingleShot(true); m_appConfigSyncTimer.setInterval(s_configSyncDelay); connect(&m_appConfigSyncTimer, &QTimer::timeout, this, &ShellCorona::syncAppConfig); @@ -778,7 +780,6 @@ void ShellCorona::removeView(int idx) if (panelsAltered) { emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); } } @@ -918,7 +919,6 @@ void ShellCorona::addOutput(const KScreen::OutputPtr &output) } emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); CHECK_SCREEN_INVARIANTS } @@ -1014,10 +1014,9 @@ void ShellCorona::createWaitingPanels() Q_ASSERT(qBound(0, requestedScreen, m_views.count() - 1) == requestedScreen); QScreen *screen = m_views[requestedScreen]->screen(); PanelView* panel = new PanelView(this, screen); - connect(panel, &QWindow::visibleChanged, [this]() { - emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); - }); + connect(panel, &QWindow::visibleChanged, this, &Plasma::Corona::availableScreenRectChanged); + connect(panel, &PanelView::locationChanged, this, &Plasma::Corona::availableScreenRectChanged); + connect(panel, &PanelView::visibilityModeChanged, this, &Plasma::Corona::availableScreenRectChanged); m_panelViews[cont] = panel; panel->setContainment(cont); @@ -1028,14 +1027,12 @@ void ShellCorona::createWaitingPanels() } m_waitingPanels = stillWaitingPanels; emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); } void ShellCorona::containmentDeleted(QObject *cont) { m_panelViews.remove(static_cast(cont)); emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); } void ShellCorona::handleContainmentAdded(Plasma::Containment *c) @@ -1354,7 +1351,6 @@ Plasma::Containment *ShellCorona::setContainmentTypeForScreen(int screen, const QTimer::singleShot(2500, oldContainment, &Plasma::Applet::destroy); emit availableScreenRectChanged(); - emit availableScreenRegionChanged(); return newContainment; }