From f46848e0398a48b3d95922d90ce726c5014dfe2e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 26 Feb 2017 15:49:50 +0200 Subject: [PATCH] add screen information into debug window --- app/dockview.cpp | 26 +++++++++++++++++++------ app/dockview.h | 10 ++++++++++ containment/contents/ui/DebugWindow.qml | 24 +++++++++++++++++++---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/app/dockview.cpp b/app/dockview.cpp index 39e85f17a..ce54acfbf 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -116,11 +116,14 @@ void DockView::init() { connect(this, &QQuickWindow::screenChanged, this, &DockView::screenChanged); - connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::reconsiderScreen); - connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::reconsiderScreen); + connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::screenChanged); + connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged); connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry); + connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged); + connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged); connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged); connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged); + connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() { if (formFactor() == Plasma::Types::Vertical) syncGeometry(); @@ -207,6 +210,7 @@ void DockView::reconsiderScreen() foreach(auto scr, qGuiApp->screens()){ if (scr && scr->name() == m_screenToFollowId){ + connect(scr, &QScreen::geometryChanged, this, &DockView::screenGeometryChanged); setScreenToFollow(scr); syncGeometry(); } @@ -217,11 +221,11 @@ void DockView::reconsiderScreen() void DockView::screenChanged(QScreen *scr) { - if (!scr || m_screenToFollow == scr) { - return; - } + // if (!scr || m_screenToFollow == scr) { + // return; + // } - qDebug() << "Screen inconsistency!!! :" << scr->name() << " - " <name(); + // qDebug() << "Screen inconsistency!!! :" << scr->name() << " - " <name(); QTimer::singleShot(2500, this, &DockView::reconsiderScreen); /*bool found{false}; @@ -650,6 +654,16 @@ QRect DockView::absGeometry() const return m_absGeometry; } +QRect DockView::screenGeometry() const +{ + if (this->screen()) { + QRect geom = this->screen()->geometry(); + return geom; + } + + return QRect(); +} + int DockView::shadow() const { return m_shadow; diff --git a/app/dockview.h b/app/dockview.h index 9ff752bed..b5d086b99 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -47,6 +47,8 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) Q_PROPERTY(int docksCount READ docksCount NOTIFY docksCountChanged) + Q_PROPERTY(int x READ x NOTIFY xChanged) + Q_PROPERTY(int y READ y NOTIFY yChanged) Q_PROPERTY(int width READ width NOTIFY widthChanged) Q_PROPERTY(int height READ height NOTIFY heightChanged) Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged) @@ -63,6 +65,9 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged) Q_PROPERTY(QQmlListProperty screens READ screens) + Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) + + public: DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr); virtual ~DockView(); @@ -103,6 +108,8 @@ public: void updateAbsDockGeometry(const QRect &localDockGeometry); QRect absGeometry() const; + QRect screenGeometry() const; + Plasma::FrameSvg::EnabledBorders enabledBorders() const; QString currentScreen() const; @@ -153,7 +160,10 @@ signals: void normalThicknessChanged(); void visibilityChanged(); void maskAreaChanged(); + void screenGeometryChanged(); void shadowChanged(); + void xChanged(); + void yChanged(); void absGeometryChanged(const QRect &geometry); diff --git a/containment/contents/ui/DebugWindow.qml b/containment/contents/ui/DebugWindow.qml index f9aff63ab..abd627d86 100644 --- a/containment/contents/ui/DebugWindow.qml +++ b/containment/contents/ui/DebugWindow.qml @@ -37,19 +37,35 @@ Window{ columns: 2 Text{ - text: "Window Width"+space + text: "Screen id"+space } Text{ - text: dock.width + text: dock.currentScreen } Text{ - text: "Window Height"+space + text: "Screen Geometry"+space } Text{ - text: dock.height + text: dock.screenGeometry.x+","+dock.screenGeometry.y+ " "+dock.screenGeometry.width+"x"+dock.screenGeometry.height + } + + Text{ + text: "Window Geometry"+space + } + + Text{ + text: dock.x + "," + dock.y + " "+dock.width+ "x"+dock.height + } + + Text{ + text: " ----------- " + } + + Text{ + text: " ----------- " } Text{