refactor:move Positioner to View:: namespace

pull/3/head
Michail Vourlakos 6 years ago
parent 47c3d6fb41
commit 825144a92e

@ -68,7 +68,7 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
: PlasmaQuick::ContainmentView(corona), : PlasmaQuick::ContainmentView(corona),
m_menuManager(new DockMenuManager(this)), m_menuManager(new DockMenuManager(this)),
m_effects(new View::Effects(this)), m_effects(new View::Effects(this)),
m_positioner(new Positioner(this)) //needs to be created after Effects becuase it catches some of its signals m_positioner(new View::Positioner(this)) //needs to be created after Effects becuase it catches some of its signals
{ {
setTitle(corona->kPackage().metadata().name()); setTitle(corona->kPackage().metadata().name());
setIcon(qGuiApp->windowIcon()); setIcon(qGuiApp->windowIcon());
@ -187,8 +187,9 @@ void DockView::init()
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged); connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged);
connect(m_positioner, &Positioner::currentScreenChanged, this, &DockView::currentScreenChanged); connect(m_positioner, &View::Positioner::currentScreenChanged, this, &DockView::currentScreenChanged);
connect(m_positioner, &Positioner::screenGeometryChanged, this, &DockView::screenGeometryChanged); connect(m_positioner, &View::Positioner::onHideWindowsForSlidingOut, this, &DockView::hideWindowsForSlidingOut);
connect(m_positioner, &View::Positioner::screenGeometryChanged, this, &DockView::screenGeometryChanged);
connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig); connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig);
@ -534,27 +535,6 @@ int DockView::docksWithTasks()
return m_managedLayout->noDocksWithTasks(); return m_managedLayout->noDocksWithTasks();
} }
void DockView::updateFormFactor()
{
if (!this->containment())
return;
switch (location()) {
case Plasma::Types::TopEdge:
case Plasma::Types::BottomEdge:
this->containment()->setFormFactor(Plasma::Types::Horizontal);
break;
case Plasma::Types::LeftEdge:
case Plasma::Types::RightEdge:
this->containment()->setFormFactor(Plasma::Types::Vertical);
break;
default:
qWarning() << "wrong location, couldn't update the panel position" << location();
}
}
bool DockView::dockWinBehavior() const bool DockView::dockWinBehavior() const
{ {
return m_dockWinBehavior; return m_dockWinBehavior;
@ -952,6 +932,19 @@ void DockView::setBlockHiding(bool block)
} }
} }
void DockView::hideWindowsForSlidingOut()
{
setBlockHiding(false);
if (m_configView) {
auto configDialog = qobject_cast<DockConfigView *>(m_configView);
if (configDialog) {
configDialog->hideConfigWindow();
}
}
}
//! remove latte tasks plasmoid //! remove latte tasks plasmoid
void DockView::removeTasksPlasmoid() void DockView::removeTasksPlasmoid()
{ {
@ -1037,7 +1030,7 @@ View::Effects *DockView::effects() const
return m_effects; return m_effects;
} }
Positioner *DockView::positioner() const View::Positioner *DockView::positioner() const
{ {
return m_positioner; return m_positioner;
} }

@ -23,6 +23,7 @@
#include "dockconfigview.h" #include "dockconfigview.h"
#include "effects.h" #include "effects.h"
#include "positioner.h"
#include "visibilitymanager.h" #include "visibilitymanager.h"
#include "../layout.h" #include "../layout.h"
#include "../plasmaquick/containmentview.h" #include "../plasmaquick/containmentview.h"
@ -56,7 +57,6 @@ class PlasmaShellSurface;
namespace Latte { namespace Latte {
class DockMenuManager; class DockMenuManager;
class Layout; class Layout;
class Positioner;
} }
namespace Latte { namespace Latte {
@ -97,7 +97,7 @@ class DockView : public PlasmaQuick::ContainmentView
Q_PROPERTY(Latte::View::Effects *effects READ effects NOTIFY effectsChanged) Q_PROPERTY(Latte::View::Effects *effects READ effects NOTIFY effectsChanged)
Q_PROPERTY(Layout *managedLayout READ managedLayout WRITE setManagedLayout NOTIFY managedLayoutChanged) Q_PROPERTY(Layout *managedLayout READ managedLayout WRITE setManagedLayout NOTIFY managedLayoutChanged)
Q_PROPERTY(Positioner *positioner READ positioner NOTIFY positionerChanged) Q_PROPERTY(Latte::View::Positioner *positioner READ positioner NOTIFY positionerChanged)
Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged) Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged)
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens) Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
@ -183,7 +183,7 @@ public:
void showSettingsWindow(); void showSettingsWindow();
View::Effects *effects() const; View::Effects *effects() const;
Positioner *positioner() const; View::Positioner *positioner() const;
VisibilityManager *visibility() const; VisibilityManager *visibility() const;
Layout *managedLayout() const; Layout *managedLayout() const;
@ -278,6 +278,7 @@ signals:
private slots: private slots:
void availableScreenRectChanged(); void availableScreenRectChanged();
void hideWindowsForSlidingOut();
void preferredViewForShortcutsChangedSlot(DockView *view); void preferredViewForShortcutsChangedSlot(DockView *view);
void statusChanged(Plasma::Types::ItemStatus); void statusChanged(Plasma::Types::ItemStatus);
@ -288,7 +289,6 @@ private:
void applyActivitiesToWindows(); void applyActivitiesToWindows();
void initSignalingForLocationChangeSliding(); void initSignalingForLocationChangeSliding();
void setupWaylandIntegration(); void setupWaylandIntegration();
void updateFormFactor();
void updateAppletContainsMethod(); void updateAppletContainsMethod();
private: private:
@ -321,7 +321,7 @@ private:
QPointer<DockMenuManager> m_menuManager; QPointer<DockMenuManager> m_menuManager;
QPointer<View::Effects> m_effects; QPointer<View::Effects> m_effects;
QPointer<Positioner> m_positioner; QPointer<View::Positioner> m_positioner;
QPointer<VisibilityManager> m_visibility; QPointer<VisibilityManager> m_visibility;
//! Connections to release and bound for the managed layout //! Connections to release and bound for the managed layout
@ -330,8 +330,6 @@ private:
Plasma::Theme m_theme; Plasma::Theme m_theme;
KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr}; KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};
friend class Positioner;
}; };
} }

@ -34,8 +34,9 @@
#include <KWayland/Client/surface.h> #include <KWayland/Client/surface.h>
namespace Latte { namespace Latte {
namespace View {
Positioner::Positioner(DockView *parent) Positioner::Positioner(Latte::DockView *parent)
: QObject(parent), : QObject(parent),
m_view(parent) m_view(parent)
{ {
@ -89,35 +90,36 @@ void Positioner::init()
connect(m_view, &QQuickWindow::widthChanged, this, &Positioner::validateDockGeometry); connect(m_view, &QQuickWindow::widthChanged, this, &Positioner::validateDockGeometry);
connect(m_view, &QQuickWindow::heightChanged, this, &Positioner::validateDockGeometry); connect(m_view, &QQuickWindow::heightChanged, this, &Positioner::validateDockGeometry);
connect(m_view, &QQuickWindow::screenChanged, this, &Positioner::screenChanged); connect(m_view, &QQuickWindow::screenChanged, this, &Positioner::screenChanged);
connect(m_view, &DockView::absGeometryChanged, this, &Positioner::syncGeometry);
connect(m_view, &DockView::behaveAsPlasmaPanelChanged, this, &Positioner::syncGeometry);
connect(m_view, &DockView::maxThicknessChanged, this, &Positioner::syncGeometry);
connect(m_view, &DockView::maxLengthChanged, this, &Positioner::syncGeometry);
connect(m_view, &DockView::offsetChanged, this, &Positioner::syncGeometry);
connect(m_view->effects(), &Latte::View::Effects::drawShadowsChanged, this, [&]() { connect(m_view, &Latte::DockView::absGeometryChanged, this, &Positioner::syncGeometry);
if (!m_view->behaveAsPlasmaPanel()) { connect(m_view, &Latte::DockView::behaveAsPlasmaPanelChanged, this, &Positioner::syncGeometry);
syncGeometry(); connect(m_view, &Latte::DockView::maxThicknessChanged, this, &Positioner::syncGeometry);
} connect(m_view, &Latte::DockView::maxLengthChanged, this, &Positioner::syncGeometry);
}); connect(m_view, &Latte::DockView::offsetChanged, this, &Positioner::syncGeometry);
connect(m_view, &DockView::locationChanged, this, [&]() { connect(m_view, &Latte::DockView::locationChanged, this, [&]() {
m_view->updateFormFactor(); updateFormFactor();
syncGeometry(); syncGeometry();
}); });
connect(m_view, &DockView::normalThicknessChanged, this, [&]() { connect(m_view, &Latte::DockView::normalThicknessChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) { if (m_view->behaveAsPlasmaPanel()) {
syncGeometry(); syncGeometry();
} }
}); });
connect(m_view, &DockView::shadowChanged, this, [&]() { connect(m_view, &Latte::DockView::shadowChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) { if (m_view->behaveAsPlasmaPanel()) {
syncGeometry(); syncGeometry();
} }
}); });
connect(m_view->effects(), &Latte::View::Effects::drawShadowsChanged, this, [&]() {
if (!m_view->behaveAsPlasmaPanel()) {
syncGeometry();
}
});
connect(qGuiApp, &QGuiApplication::screenAdded, this, &Positioner::screenChanged); connect(qGuiApp, &QGuiApplication::screenAdded, this, &Positioner::screenChanged);
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &Positioner::screenChanged); connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &Positioner::screenChanged);
@ -540,25 +542,31 @@ void Positioner::resizeWindow(QRect availableScreenRect)
} }
} }
void Positioner::hideWindowsForSlidingOut() void Positioner::updateFormFactor()
{ {
m_view->setBlockHiding(false); if (!m_view->containment())
return;
if (m_view->m_configView) { switch (m_view->location()) {
auto configDialog = qobject_cast<DockConfigView *>(m_view->m_configView); case Plasma::Types::TopEdge:
case Plasma::Types::BottomEdge:
m_view->containment()->setFormFactor(Plasma::Types::Horizontal);
break;
if (configDialog) { case Plasma::Types::LeftEdge:
configDialog->hideConfigWindow(); case Plasma::Types::RightEdge:
} m_view->containment()->setFormFactor(Plasma::Types::Vertical);
break;
default:
qWarning() << "wrong location, couldn't update the panel position" << m_view->location();
} }
} }
void Positioner::initSignalingForLocationChangeSliding() void Positioner::initSignalingForLocationChangeSliding()
{ {
//! signals to handle the sliding-in/out during location changes //! signals to handle the sliding-in/out during location changes
connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, [&]() { connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
hideWindowsForSlidingOut();
});
connect(m_view, &DockView::locationChanged, this, [&]() { connect(m_view, &DockView::locationChanged, this, [&]() {
if (m_goToLocation != Plasma::Types::Floating) { if (m_goToLocation != Plasma::Types::Floating) {
@ -576,9 +584,7 @@ void Positioner::initSignalingForLocationChangeSliding()
}); });
//! signals to handle the sliding-in/out during screen changes //! signals to handle the sliding-in/out during screen changes
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, [&]() { connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
hideWindowsForSlidingOut();
});
connect(m_view, &DockView::currentScreenChanged, this, [&]() { connect(m_view, &DockView::currentScreenChanged, this, [&]() {
if (m_goToScreen) { if (m_goToScreen) {
@ -596,9 +602,7 @@ void Positioner::initSignalingForLocationChangeSliding()
}); });
//! signals to handle the sliding-in/out during moving to another layout //! signals to handle the sliding-in/out during moving to another layout
connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, [&]() { connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, &Positioner::onHideWindowsForSlidingOut);
hideWindowsForSlidingOut();
});
connect(m_view, &DockView::managedLayoutChanged, this, [&]() { connect(m_view, &DockView::managedLayoutChanged, this, [&]() {
if (!m_moveToLayout.isEmpty() && m_view->managedLayout()) { if (!m_moveToLayout.isEmpty() && m_view->managedLayout()) {
@ -645,3 +649,4 @@ void Positioner::hideDockDuringMovingToLayout(QString layoutName)
} }
} }
}

@ -36,6 +36,7 @@ class DockView;
} }
namespace Latte { namespace Latte {
namespace View {
class Positioner: public QObject class Positioner: public QObject
{ {
@ -73,6 +74,7 @@ signals:
void hideDockDuringScreenChangeFinished(); void hideDockDuringScreenChangeFinished();
void hideDockDuringMovingToLayoutStarted(); void hideDockDuringMovingToLayoutStarted();
void hideDockDuringMovingToLayoutFinished(); void hideDockDuringMovingToLayoutFinished();
void onHideWindowsForSlidingOut();
void showDockAfterLocationChangeFinished(); void showDockAfterLocationChangeFinished();
void showDockAfterScreenChangeFinished(); void showDockAfterScreenChangeFinished();
void showDockAfterMovingToLayoutFinished(); void showDockAfterMovingToLayoutFinished();
@ -84,9 +86,9 @@ private slots:
private: private:
void init(); void init();
void initSignalingForLocationChangeSliding(); void initSignalingForLocationChangeSliding();
void hideWindowsForSlidingOut();
void resizeWindow(QRect availableScreenRect = QRect()); void resizeWindow(QRect availableScreenRect = QRect());
void updateFormFactor();
void updatePosition(QRect availableScreenRect = QRect()); void updatePosition(QRect availableScreenRect = QRect());
QRect maximumNormalGeometry(); QRect maximumNormalGeometry();
@ -97,7 +99,7 @@ private:
//! it is used in order to enforce X11 to never miss window geometry //! it is used in order to enforce X11 to never miss window geometry
QRect m_validGeometry; QRect m_validGeometry;
QPointer<DockView> m_view; QPointer<Latte::DockView> m_view;
QString m_screenToFollowId; QString m_screenToFollowId;
QPointer<QScreen> m_screenToFollow; QPointer<QScreen> m_screenToFollow;
@ -111,6 +113,7 @@ private:
QScreen *m_goToScreen{nullptr}; QScreen *m_goToScreen{nullptr};
}; };
}
} }
#endif #endif

Loading…
Cancel
Save