From b8b913c930b97a54b76457fe33680df44f02cfaf Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 24 Feb 2014 20:47:34 +0100 Subject: [PATCH] concept of panel distance if the shell requires the panel window to be in a different position than attached to screen edge (will be needed for active) also, fix panel and panelcontroller positioning --- src/shell/panelconfigview.cpp | 8 +++---- src/shell/panelview.cpp | 41 +++++++++++++++++++++++++---------- src/shell/panelview.h | 6 +++++ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/shell/panelconfigview.cpp b/src/shell/panelconfigview.cpp index 2d4b0ba14..ae01d07f7 100644 --- a/src/shell/panelconfigview.cpp +++ b/src/shell/panelconfigview.cpp @@ -97,18 +97,18 @@ void PanelConfigView::syncGeometry() resize(rootObject()->implicitWidth(), screen()->size().height()); if (m_containment->location() == Plasma::Types::LeftEdge) { - setPosition(screen()->geometry().left() + m_panelView->thickness(), screen()->geometry().top()); + setPosition(m_panelView->geometry().right(), screen()->geometry().top()); } else if (m_containment->location() == Plasma::Types::RightEdge) { - setPosition(screen()->geometry().right() - width() - m_panelView->thickness(), screen()->geometry().top()); + setPosition(m_panelView->geometry().left() - width(), screen()->geometry().top()); } } else { resize(screen()->size().width(), rootObject()->implicitHeight()); if (m_containment->location() == Plasma::Types::TopEdge) { - setPosition(screen()->geometry().left(), screen()->geometry().top() + m_panelView->thickness()); + setPosition(screen()->geometry().left(), m_panelView->geometry().bottom()); } else if (m_containment->location() == Plasma::Types::BottomEdge) { - setPosition(screen()->geometry().left(), screen()->geometry().bottom() - height() - m_panelView->thickness()); + setPosition(screen()->geometry().left(), m_panelView->geometry().top() - height()); } } } diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index bd8d929ff..6fb4e2c50 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -41,6 +41,7 @@ PanelView::PanelView(ShellCorona *corona, QWindow *parent) m_offset(0), m_maxLength(0), m_minLength(0), + m_distance(0), m_alignment(Qt::AlignLeft), m_corona(corona), m_strutsTimer(new QTimer(this)), @@ -287,6 +288,22 @@ void PanelView::setMinimumLength(int length) m_corona->requestApplicationConfigSync(); } +int PanelView::distance() const +{ + return m_distance; +} + +void PanelView::setDistance(int dist) +{ + if (m_distance == dist) { + return; + } + + m_distance = dist; + m_positionPaneltimer.start(); + emit distanceChanged(); +} + void PanelView::setVisibilityMode(PanelView::VisibilityMode mode) { m_visibilityMode = mode; @@ -337,14 +354,14 @@ void PanelView::positionPanel() switch (m_alignment) { case Qt::AlignCenter: - setPosition(QPoint(s->geometry().center().x(), s->geometry().top()) + QPoint(m_offset - size().width()/2, 0)); + setPosition(QPoint(s->geometry().center().x(), s->geometry().top()) + QPoint(m_offset - size().width()/2, m_distance)); break; case Qt::AlignRight: - setPosition(s->geometry().topRight() - QPoint(m_offset + size().width(), 0)); + setPosition(s->geometry().topRight() - QPoint(m_offset + size().width(), m_distance)); break; case Qt::AlignLeft: default: - setPosition(s->geometry().topLeft() + QPoint(m_offset, 0)); + setPosition(s->geometry().topLeft() + QPoint(m_offset, m_distance)); } break; @@ -353,14 +370,14 @@ void PanelView::positionPanel() switch (m_alignment) { case Qt::AlignCenter: - setPosition(QPoint(s->geometry().left(), s->geometry().center().y()) + QPoint(0, m_offset)); + setPosition(QPoint(s->geometry().left(), s->geometry().center().y()) + QPoint(m_distance, m_offset)); break; case Qt::AlignRight: - setPosition(s->geometry().bottomLeft() - QPoint(0, m_offset + size().height())); + setPosition(s->geometry().bottomLeft() - QPoint(m_distance, m_offset + size().height())); break; case Qt::AlignLeft: default: - setPosition(s->geometry().topLeft() + QPoint(0, m_offset)); + setPosition(s->geometry().topLeft() + QPoint(m_distance, m_offset)); } break; @@ -369,14 +386,14 @@ void PanelView::positionPanel() switch (m_alignment) { case Qt::AlignCenter: - setPosition(QPoint(s->geometry().right(), s->geometry().center().y()) - QPoint(width(), 0) + QPoint(0, m_offset - size().height()/2)); + setPosition(QPoint(s->geometry().right(), s->geometry().center().y()) - QPoint(width() + m_distance, 0) + QPoint(0, m_offset - size().height()/2)); break; case Qt::AlignRight: - setPosition(s->geometry().bottomRight() - QPoint(width(), 0) - QPoint(0, m_offset + size().height())); + setPosition(s->geometry().bottomRight() - QPoint(width() + m_distance, 0) - QPoint(0, m_offset + size().height())); break; case Qt::AlignLeft: default: - setPosition(s->geometry().topRight() - QPoint(width(), 0) + QPoint(0, m_offset)); + setPosition(s->geometry().topRight() - QPoint(width() + m_distance, 0) + QPoint(0, m_offset)); } break; @@ -386,14 +403,14 @@ void PanelView::positionPanel() switch (m_alignment) { case Qt::AlignCenter: - setPosition(QPoint(s->geometry().center().x(), s->geometry().bottom()) + QPoint(m_offset - size().width()/2, 1)); + setPosition(QPoint(s->geometry().center().x(), s->geometry().bottom() - height() - m_distance) + QPoint(m_offset - size().width()/2, 1)); break; case Qt::AlignRight: - setPosition(s->geometry().bottomRight() - QPoint(0, height()) - QPoint(m_offset + size().width(), 1)); + setPosition(s->geometry().bottomRight() - QPoint(0, height() + m_distance) - QPoint(m_offset + size().width(), 1)); break; case Qt::AlignLeft: default: - setPosition(s->geometry().bottomLeft() - QPoint(0, height()) + QPoint(m_offset, 1)); + setPosition(s->geometry().bottomLeft() - QPoint(0, height() + m_distance) + QPoint(m_offset, 1)); } } m_strutsTimer->stop(); diff --git a/src/shell/panelview.h b/src/shell/panelview.h index e9cec0b77..8f0e21b9f 100644 --- a/src/shell/panelview.h +++ b/src/shell/panelview.h @@ -37,6 +37,7 @@ class PanelView : public PlasmaQuick::View Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged) Q_PROPERTY(int maximumLength READ maximumLength WRITE setMaximumLength NOTIFY maximumLengthChanged) Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged) + Q_PROPERTY(int distance READ distance WRITE setDistance NOTIFY distanceChanged) Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged) Q_PROPERTY(VisibilityMode visibilityMode READ visibilityMode WRITE setVisibilityMode NOTIFY visibilityModeChanged) @@ -75,6 +76,9 @@ public: int minimumLength() const; void setMinimumLength(int length); + int distance() const; + void setDistance(int dist); + VisibilityMode visibilityMode() const; void setVisibilityMode(PanelView::VisibilityMode mode); @@ -90,6 +94,7 @@ Q_SIGNALS: void lengthChanged(); void maximumLengthChanged(); void minimumLengthChanged(); + void distanceChanged(); void screenChanged(QScreen *screen); void visibilityModeChanged(); @@ -109,6 +114,7 @@ private: int m_offset; int m_maxLength; int m_minLength; + int m_distance; Qt::Alignment m_alignment; QPointer m_panelConfigView; ShellCorona *m_corona;