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
This commit is contained in:
Marco Martin 2014-02-24 20:47:34 +01:00
parent 9976c47ad9
commit b8b913c930
3 changed files with 39 additions and 16 deletions

View File

@ -97,18 +97,18 @@ void PanelConfigView::syncGeometry()
resize(rootObject()->implicitWidth(), screen()->size().height()); resize(rootObject()->implicitWidth(), screen()->size().height());
if (m_containment->location() == Plasma::Types::LeftEdge) { 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) { } 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 { } else {
resize(screen()->size().width(), rootObject()->implicitHeight()); resize(screen()->size().width(), rootObject()->implicitHeight());
if (m_containment->location() == Plasma::Types::TopEdge) { 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) { } 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());
} }
} }
} }

View File

@ -41,6 +41,7 @@ PanelView::PanelView(ShellCorona *corona, QWindow *parent)
m_offset(0), m_offset(0),
m_maxLength(0), m_maxLength(0),
m_minLength(0), m_minLength(0),
m_distance(0),
m_alignment(Qt::AlignLeft), m_alignment(Qt::AlignLeft),
m_corona(corona), m_corona(corona),
m_strutsTimer(new QTimer(this)), m_strutsTimer(new QTimer(this)),
@ -287,6 +288,22 @@ void PanelView::setMinimumLength(int length)
m_corona->requestApplicationConfigSync(); 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) void PanelView::setVisibilityMode(PanelView::VisibilityMode mode)
{ {
m_visibilityMode = mode; m_visibilityMode = mode;
@ -337,14 +354,14 @@ void PanelView::positionPanel()
switch (m_alignment) { switch (m_alignment) {
case Qt::AlignCenter: 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; break;
case Qt::AlignRight: 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; break;
case Qt::AlignLeft: case Qt::AlignLeft:
default: default:
setPosition(s->geometry().topLeft() + QPoint(m_offset, 0)); setPosition(s->geometry().topLeft() + QPoint(m_offset, m_distance));
} }
break; break;
@ -353,14 +370,14 @@ void PanelView::positionPanel()
switch (m_alignment) { switch (m_alignment) {
case Qt::AlignCenter: 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; break;
case Qt::AlignRight: 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; break;
case Qt::AlignLeft: case Qt::AlignLeft:
default: default:
setPosition(s->geometry().topLeft() + QPoint(0, m_offset)); setPosition(s->geometry().topLeft() + QPoint(m_distance, m_offset));
} }
break; break;
@ -369,14 +386,14 @@ void PanelView::positionPanel()
switch (m_alignment) { switch (m_alignment) {
case Qt::AlignCenter: 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; break;
case Qt::AlignRight: 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; break;
case Qt::AlignLeft: case Qt::AlignLeft:
default: 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; break;
@ -386,14 +403,14 @@ void PanelView::positionPanel()
switch (m_alignment) { switch (m_alignment) {
case Qt::AlignCenter: 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; break;
case Qt::AlignRight: 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; break;
case Qt::AlignLeft: case Qt::AlignLeft:
default: 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(); m_strutsTimer->stop();

View File

@ -37,6 +37,7 @@ class PanelView : public PlasmaQuick::View
Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged) Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged)
Q_PROPERTY(int maximumLength READ maximumLength WRITE setMaximumLength NOTIFY maximumLengthChanged) Q_PROPERTY(int maximumLength READ maximumLength WRITE setMaximumLength NOTIFY maximumLengthChanged)
Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged) 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(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(VisibilityMode visibilityMode READ visibilityMode WRITE setVisibilityMode NOTIFY visibilityModeChanged) Q_PROPERTY(VisibilityMode visibilityMode READ visibilityMode WRITE setVisibilityMode NOTIFY visibilityModeChanged)
@ -75,6 +76,9 @@ public:
int minimumLength() const; int minimumLength() const;
void setMinimumLength(int length); void setMinimumLength(int length);
int distance() const;
void setDistance(int dist);
VisibilityMode visibilityMode() const; VisibilityMode visibilityMode() const;
void setVisibilityMode(PanelView::VisibilityMode mode); void setVisibilityMode(PanelView::VisibilityMode mode);
@ -90,6 +94,7 @@ Q_SIGNALS:
void lengthChanged(); void lengthChanged();
void maximumLengthChanged(); void maximumLengthChanged();
void minimumLengthChanged(); void minimumLengthChanged();
void distanceChanged();
void screenChanged(QScreen *screen); void screenChanged(QScreen *screen);
void visibilityModeChanged(); void visibilityModeChanged();
@ -109,6 +114,7 @@ private:
int m_offset; int m_offset;
int m_maxLength; int m_maxLength;
int m_minLength; int m_minLength;
int m_distance;
Qt::Alignment m_alignment; Qt::Alignment m_alignment;
QPointer<PlasmaQuick::ConfigView> m_panelConfigView; QPointer<PlasmaQuick::ConfigView> m_panelConfigView;
ShellCorona *m_corona; ShellCorona *m_corona;