1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-22 06:03:55 +03:00

refactor:move Positioner to View:: namespace

This commit is contained in:
Michail Vourlakos 2018-12-01 00:13:11 +02:00
parent 47c3d6fb41
commit 825144a92e
4 changed files with 64 additions and 65 deletions

View File

@ -68,7 +68,7 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
: PlasmaQuick::ContainmentView(corona),
m_menuManager(new DockMenuManager(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());
setIcon(qGuiApp->windowIcon());
@ -187,8 +187,9 @@ void DockView::init()
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged);
connect(m_positioner, &Positioner::currentScreenChanged, this, &DockView::currentScreenChanged);
connect(m_positioner, &Positioner::screenGeometryChanged, this, &DockView::screenGeometryChanged);
connect(m_positioner, &View::Positioner::currentScreenChanged, this, &DockView::currentScreenChanged);
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::onPrimaryChanged, this, &DockView::saveConfig);
@ -534,27 +535,6 @@ int DockView::docksWithTasks()
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
{
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
void DockView::removeTasksPlasmoid()
{
@ -1037,7 +1030,7 @@ View::Effects *DockView::effects() const
return m_effects;
}
Positioner *DockView::positioner() const
View::Positioner *DockView::positioner() const
{
return m_positioner;
}

View File

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

View File

@ -34,8 +34,9 @@
#include <KWayland/Client/surface.h>
namespace Latte {
namespace View {
Positioner::Positioner(DockView *parent)
Positioner::Positioner(Latte::DockView *parent)
: QObject(parent),
m_view(parent)
{
@ -89,35 +90,36 @@ void Positioner::init()
connect(m_view, &QQuickWindow::widthChanged, this, &Positioner::validateDockGeometry);
connect(m_view, &QQuickWindow::heightChanged, this, &Positioner::validateDockGeometry);
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, [&]() {
if (!m_view->behaveAsPlasmaPanel()) {
syncGeometry();
}
});
connect(m_view, &Latte::DockView::absGeometryChanged, this, &Positioner::syncGeometry);
connect(m_view, &Latte::DockView::behaveAsPlasmaPanelChanged, this, &Positioner::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, [&]() {
m_view->updateFormFactor();
connect(m_view, &Latte::DockView::locationChanged, this, [&]() {
updateFormFactor();
syncGeometry();
});
connect(m_view, &DockView::normalThicknessChanged, this, [&]() {
connect(m_view, &Latte::DockView::normalThicknessChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) {
syncGeometry();
}
});
connect(m_view, &DockView::shadowChanged, this, [&]() {
connect(m_view, &Latte::DockView::shadowChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) {
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::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) {
auto configDialog = qobject_cast<DockConfigView *>(m_view->m_configView);
switch (m_view->location()) {
case Plasma::Types::TopEdge:
case Plasma::Types::BottomEdge:
m_view->containment()->setFormFactor(Plasma::Types::Horizontal);
break;
if (configDialog) {
configDialog->hideConfigWindow();
}
case Plasma::Types::LeftEdge:
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()
{
//! signals to handle the sliding-in/out during location changes
connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, [&]() {
hideWindowsForSlidingOut();
});
connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
connect(m_view, &DockView::locationChanged, this, [&]() {
if (m_goToLocation != Plasma::Types::Floating) {
@ -576,9 +584,7 @@ void Positioner::initSignalingForLocationChangeSliding()
});
//! signals to handle the sliding-in/out during screen changes
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, [&]() {
hideWindowsForSlidingOut();
});
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
connect(m_view, &DockView::currentScreenChanged, this, [&]() {
if (m_goToScreen) {
@ -596,9 +602,7 @@ void Positioner::initSignalingForLocationChangeSliding()
});
//! signals to handle the sliding-in/out during moving to another layout
connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, [&]() {
hideWindowsForSlidingOut();
});
connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, &Positioner::onHideWindowsForSlidingOut);
connect(m_view, &DockView::managedLayoutChanged, this, [&]() {
if (!m_moveToLayout.isEmpty() && m_view->managedLayout()) {
@ -645,3 +649,4 @@ void Positioner::hideDockDuringMovingToLayout(QString layoutName)
}
}
}

View File

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