From 5796ed1527867e1c078f2d0c7bb23203d0a1e9f1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Mar 2013 16:13:12 +0100 Subject: [PATCH] expose thickness --- src/shell/panelconfigview.cpp | 10 +++++--- src/shell/panelview.cpp | 25 +++++++++++++++++++ src/shell/panelview.h | 5 ++++ .../components/PanelConfiguration.qml | 21 +++++----------- src/shell/view.cpp | 4 +-- src/shell/view.h | 2 +- 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/shell/panelconfigview.cpp b/src/shell/panelconfigview.cpp index 4613ab522..caf9c641c 100644 --- a/src/shell/panelconfigview.cpp +++ b/src/shell/panelconfigview.cpp @@ -57,6 +57,8 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa engine()->rootContext()->setContextProperty("configDialog", this); setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui"))); syncGeometry(); + connect(containment, &Plasma::Containment::formFactorChanged, + this, &PanelConfigView::syncGeometry); } PanelConfigView::~PanelConfigView() @@ -73,18 +75,18 @@ void PanelConfigView::syncGeometry() resize(128, screen()->size().height()); if (m_containment->location() == Plasma::LeftEdge) { - setPosition(m_panelView->width(), 0); + setPosition(screen()->geometry().left() + m_panelView->thickness(), 0); } else if (m_containment->location() == Plasma::RightEdge) { - setPosition(screen()->size().width() - m_panelView->width(), 0); + setPosition(screen()->geometry().right() - 128 - m_panelView->thickness(), 0); } } else { resize(screen()->size().width(), 128); if (m_containment->location() == Plasma::TopEdge) { - setPosition(0, m_panelView->height()); + setPosition(0, screen()->geometry().top() + m_panelView->thickness()); } else if (m_containment->location() == Plasma::BottomEdge) { - setPosition(0, screen()->size().width() - m_panelView->height()); + setPosition(0, screen()->geometry().bottom() - 128 - m_panelView->thickness()); } } } diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index e4800425c..c408b922f 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -136,6 +136,27 @@ void PanelView::setOffset(int offset) emit offsetChanged(); } +int PanelView::thickness() const +{ + return config().readEntry("thickness", 30); +} + +void PanelView::setThickness(int value) +{ + if (value == thickness()) { + value; + } + + if (formFactor() == Plasma::Vertical) { + return setWidth(value); + } else { + return setHeight(value); + } + config().writeEntry("thickness", value); + emit thicknessChanged(); +} + + void PanelView::manageNewContainment() { connect(containment()->actions()->action("configure"), &QAction::triggered, @@ -157,6 +178,7 @@ void PanelView::positionPanel() } QScreen *s = screen(); + const int oldThickness = thickness(); switch (containment()->location()) { case Plasma::TopEdge: @@ -223,6 +245,9 @@ void PanelView::positionPanel() setPosition(s->virtualGeometry().bottomLeft() - QPoint(0, height()) + QPoint(m_offset, 0)); } } + if (thickness() != oldThickness) { + emit thicknessChanged(); + } } void PanelView::restore() diff --git a/src/shell/panelview.h b/src/shell/panelview.h index 2b81882b4..29898dcd1 100644 --- a/src/shell/panelview.h +++ b/src/shell/panelview.h @@ -30,6 +30,7 @@ class PanelView : public View Q_OBJECT Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) + Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged) public: explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0); @@ -45,10 +46,14 @@ public: int offset() const; void setOffset(int offset); + int thickness() const; + void setThickness(int thickness); + Q_SIGNALS: void alignmentChanged(); void offsetChanged(); void screenGeometryChanged(); + void thicknessChanged(); private Q_SLOTS: void manageNewContainment(); diff --git a/src/shell/qmlpackages/desktop/contents/components/PanelConfiguration.qml b/src/shell/qmlpackages/desktop/contents/components/PanelConfiguration.qml index 0d7d9a84e..37a263a40 100644 --- a/src/shell/qmlpackages/desktop/contents/components/PanelConfiguration.qml +++ b/src/shell/qmlpackages/desktop/contents/components/PanelConfiguration.qml @@ -129,21 +129,12 @@ Rectangle { newLocation = 5; //FIXME: Plasma::LeftEdge; } } else if(panel.location == 4) { - return; + return; } else { newLocation = 4; //FIXME: Plasma::BottomEdge; } } panel.location = newLocation - if (panel.location == 5 || panel.location == 6) { - configDialog.y = panel.screenGeometry.y - root.width = 100 - root.height = panel.screenGeometry.height - } else { - configDialog.x = panel.screenGeometry.x - root.height = 100 - root.width = panel.screenGeometry.width - } print("New Location: " + newLocation); } onReleased: panelResetAnimation.running = true @@ -166,19 +157,19 @@ Rectangle { break; //RightEdge case 6: - return panel.screenGeometry.y + panel.screenGeometry.height - panel.height + return panel.screenGeometry.x + panel.screenGeometry.width - panel.width break; //BottomEdge case 4: default: - return panel.screenGeometry.x + panel.screenGeometry.width - panel.width + return panel.screenGeometry.y + panel.screenGeometry.height - panel.height } } duration: 150 } NumberAnimation { target: configDialog - properties: "y" + properties: (panel.location == 5 || panel.location == 6) ? "x" : "y" to: { panel.height switch (panel.location) { @@ -192,12 +183,12 @@ Rectangle { break; //RightEdge case 6: - return panel.x - configDialog.width + return panel.screenGeometry.x + panel.screenGeometry.width - panel.width - configDialog.width break; //BottomEdge case 4: default: - return panel.y - configDialog.height + return panel.screenGeometry.y + panel.screenGeometry.height - panel.height - configDialog.height } } duration: 150 diff --git a/src/shell/view.cpp b/src/shell/view.cpp index 2578f9557..81e359d45 100644 --- a/src/shell/view.cpp +++ b/src/shell/view.cpp @@ -127,7 +127,7 @@ Plasma::Containment *View::containment() const //FIXME: wrong types void View::setLocation(int location) { - return m_containment.data()->setLocation((Plasma::Location)location); + m_containment.data()->setLocation((Plasma::Location)location); } //FIXME: wrong types @@ -139,7 +139,7 @@ int View::location() const return m_containment.data()->location(); } -Plasma::FormFactor View::formFactor() +Plasma::FormFactor View::formFactor() const { if (!m_containment) { return Plasma::Planar; diff --git a/src/shell/view.h b/src/shell/view.h index 6e09ed933..d01a889e7 100644 --- a/src/shell/view.h +++ b/src/shell/view.h @@ -50,7 +50,7 @@ public: int location() const; void setLocation(int location); - Plasma::FormFactor formFactor(); + Plasma::FormFactor formFactor() const; QRectF screenGeometry();