From 41e79cf1888ee228c06ab4fce160ab7081c316fd Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 1 Feb 2017 21:19:50 +0200 Subject: [PATCH] support debug flags from the runtime --the user is able to set some additional debug flags in --debug state by just executing the application. supported flags: --with-window: provides a separate window to show metrics from each separate dock --graphics: visual indicator for the various elements --mask: additional debug messages concerning mask calculations --- app/dockcorona.cpp | 10 +- app/dockcorona.h | 5 +- app/dockview.cpp | 10 + app/dockview.h | 4 + app/main.cpp | 16 +- containment/contents/ui/DebugWindow.qml | 296 ++++++++++++++++++ containment/contents/ui/VisibilityManager.qml | 2 +- containment/contents/ui/main.qml | 7 +- 8 files changed, 344 insertions(+), 6 deletions(-) create mode 100644 containment/contents/ui/DebugWindow.qml diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 05a0fd373..29bc057c1 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -41,9 +41,10 @@ namespace Latte { -DockCorona::DockCorona(QObject *parent) +DockCorona::DockCorona(QStringList debugFlags, QObject *parent) : Plasma::Corona(parent), - m_activityConsumer(new KActivities::Consumer(this)) + m_activityConsumer(new KActivities::Consumer(this)), + m_debugFlags(debugFlags) { KPackage::Package package(new DockPackage(this)); @@ -238,6 +239,11 @@ void DockCorona::closeApplication() qGuiApp->quit(); } +QStringList DockCorona::debugFlags() const +{ + return m_debugFlags; +} + void DockCorona::aboutApplication() { if (aboutDialog) { diff --git a/app/dockcorona.h b/app/dockcorona.h index cb93188b0..3d8618a0b 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -43,7 +43,7 @@ class DockCorona : public Plasma::Corona { Q_OBJECT public: - DockCorona(QObject *parent = nullptr); + DockCorona(QStringList debugFlags = QStringList(), QObject *parent = nullptr); virtual ~DockCorona(); int numScreens() const override; @@ -53,6 +53,8 @@ public: QList freeEdges(int screen) const; + QStringList debugFlags() const; + int docksCount(int screen) const; int screenForContainment(const Plasma::Containment *containment) const override; @@ -83,6 +85,7 @@ private: bool m_activitiesStarting{true}; + QStringList m_debugFlags; QHash m_dockViews; QHash m_waitingDockViews; diff --git a/app/dockview.cpp b/app/dockview.cpp index 56475aa73..9a450aa5c 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -404,6 +404,16 @@ void DockView::setShadow(int shadow) emit shadowChanged(); } +QStringList DockView::debugFlags() const +{ + DockCorona *dockCorona = qobject_cast(this->corona()); + + if (dockCorona) + return dockCorona->debugFlags(); + + return QStringList(); +} + bool DockView::tasksPresent() { foreach (Plasma::Applet *applet, containment()->applets()) { diff --git a/app/dockview.h b/app/dockview.h index 2007c4f8a..4762836ab 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -49,6 +49,7 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged) Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged) Q_PROPERTY(int shadow READ shadow WRITE setShadow NOTIFY shadowChanged) + Q_PROPERTY(QStringList debugFlags READ debugFlags NOTIFY debugFlagsChanged) Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged) Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged) @@ -82,6 +83,8 @@ public: QRect maskArea() const; void setMaskArea(QRect area); + QStringList debugFlags() const; + VisibilityManager *visibility(); QQmlListProperty screens(); @@ -112,6 +115,7 @@ signals: void removeInternalViewSplitter(); void eventTriggered(QEvent *ev); + void debugFlagsChanged(); void dockLocationChanged(); void docksCountChanged(); void widthChanged(); diff --git a/app/main.cpp b/app/main.cpp index 811ade019..01a7b2687 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -70,11 +70,25 @@ int main(int argc, char **argv) "%{if-critical}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" CNORMAL)); // qputenv("QT_QUICK_CONTROLS_1_STYLE", "Desktop"); + QStringList debugFlags; + if (!app.arguments().contains(QLatin1String("--debug"))) { qInstallMessageHandler(noMessageOutput); + } else { + if (app.arguments().contains(QLatin1String("--with-window"))) { + debugFlags.append("--with-window"); + } + + if (app.arguments().contains(QLatin1String("--graphics"))) { + debugFlags.append("--graphics"); + } + + if (app.arguments().contains(QLatin1String("--mask"))) { + debugFlags.append("--mask"); + } } - Latte::DockCorona corona; + Latte::DockCorona corona(debugFlags); return app.exec(); } diff --git a/containment/contents/ui/DebugWindow.qml b/containment/contents/ui/DebugWindow.qml new file mode 100644 index 000000000..5e8c02f80 --- /dev/null +++ b/containment/contents/ui/DebugWindow.qml @@ -0,0 +1,296 @@ +/* +* Copyright 2016 Smith AR +* Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 + +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.latte 0.1 as Latte + +Window{ + width: 370 + height: 450 + visible: true + + property string space:" : " + + Grid{ + columns: 2 + + Text{ + text: "Window Width"+space + } + + Text{ + text: dock.width + } + + Text{ + text: "Window Height"+space + } + + Text{ + text: dock.height + } + + Text{ + text: "Contents Width"+space + } + + Text{ + text: layoutsContainer.contentsWidth + } + + Text{ + text: "Contents Height"+space + } + + Text{ + text: layoutsContainer.contentsHeight + } + + Text{ + text: "Max Length (user)"+space + } + + Text{ + text: plasmoid.configuration.maxLength +"%" + } + + Text{ + text: "Max Length (pixels)"+space + } + + Text{ + text: root.maxLength + } + + Text{ + text: "Mask"+space + } + + Text{ + text: dock.maskArea.x +", "+ dock.maskArea.y+" "+dock.maskArea.width+"x"+dock.maskArea.height + } + + Text{ + text: " ----------- " + } + + Text{ + text: " ----------- " + } + + Text{ + text: "Location"+space + } + + Text{ + text: { + switch(plasmoid.location){ + case PlasmaCore.Types.LeftEdge: + return "Left Edge"; + break; + case PlasmaCore.Types.RightEdge: + return "Right Edge"; + break; + case PlasmaCore.Types.TopEdge: + return "Top Edge"; + break; + case PlasmaCore.Types.BottomEdge: + return "Bottom Edge"; + break; + } + + return " "; + } + } + + Text{ + text: "Alignment"+space + } + + Text{ + text: { + switch(plasmoid.configuration.panelPosition){ + case Latte.Dock.Left: + return "Left"; + break; + case Latte.Dock.Right: + return "Right"; + break; + case Latte.Dock.Center: + return "Center"; + break; + case Latte.Dock.Top: + return "Top"; + break; + case Latte.Dock.Bottom: + return "Bottom"; + break; + case Latte.Dock.Justify: + return "Justify"; + break; + } + + return ""; + } + } + + Text{ + text: "Visibility"+space + } + + Text{ + text: { + switch(dock.visibility.mode){ + case Latte.Dock.AlwaysVisible: + return "Always Visible"; + break; + case Latte.Dock.AutoHide: + return "Auto Hide"; + break; + case Latte.Dock.DodgeActive: + return "Dodge Active"; + break; + case Latte.Dock.DodgeMaximized: + return "Dodge Maximized"; + break; + case Latte.Dock.DodgeAllWindows: + return "Dodge All Windows"; + break; + } + + return ""; + } + } + + Text{ + text: "Zoom Factor"+space + } + + Text{ + text: root.zoomFactor + } + + Text{ + text: " ----------- " + } + + Text{ + text: " ----------- " + } + + Text{ + text: "Icon Size (user)"+space + } + + Text{ + text: plasmoid.configuration.iconSize + } + + Text{ + text: "Icon Size (automatic)"+space + } + + Text{ + text: root.automaticIconSizeBasedSize + } + + Text{ + text: "Icon Size (current)"+space + } + + Text{ + text: root.iconSize + } + + Text{ + text: " ----------- " + } + + Text{ + text: " ----------- " + } + + Text{ + text: "Show Panel Background (user)"+space + } + + Text{ + text: { + if (plasmoid.configuration.useThemePanel) + return "Yes"; + else + return "Now"; + } + } + + Text{ + text: "Panel Background Size(user)"+space + } + + Text{ + text: plasmoid.configuration.panelSize + } + + Text{ + text: "Panel Background Size(automatic)"+space + } + + Text{ + text: root.realPanelSize + } + + Text{ + text: "Panel Background Shadow"+space + } + + Text{ + text: root.panelShadow + } + + Text{ + text: " ----------- " + } + + Text{ + text: " ----------- " + } + + Text{ + text: "Mask - Normal Thickness"+space + } + + Text{ + text: visibilityManager.thicknessNormal + } + + Text{ + text: "Thickness Uses Panel Size"+space + } + + Text{ + text: visibilityManager.panelIsBiggerFromIconSize + } + + } +} diff --git a/containment/contents/ui/VisibilityManager.qml b/containment/contents/ui/VisibilityManager.qml index 507be70db..83c75c235 100644 --- a/containment/contents/ui/VisibilityManager.qml +++ b/containment/contents/ui/VisibilityManager.qml @@ -35,7 +35,7 @@ Item{ property QtObject window - property bool debugMagager: false + property bool debugMagager: dock && dock.debugFlags.indexOf("--mask")>=0 property bool inStartup: root.inStartup property bool normalState : false // this is being set from updateMaskArea diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index 7c1f9eb49..d399c2f7f 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -42,7 +42,7 @@ DragDrop.DropArea { //// ////BEGIN properties - property bool debugMode: false + property bool debugMode: dock && dock.debugFlags.indexOf("--graphics")>=0 property bool automaticSize: plasmoid.configuration.automaticIconSize property bool confirmedDragEntered: false @@ -1026,6 +1026,11 @@ DragDrop.DropArea { ///////////////BEGIN UI elements + Loader{ + active: dock && dock.debugFlags.indexOf("--with-window")>=0 + sourceComponent: DebugWindow{} + } + /*Loader{ anchors.fill: parent active: root.editMode