From 66f8cce6d95ba2dd6d20efb16212fbeb597647a0 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 12 May 2020 17:08:09 +0300 Subject: [PATCH] introduce Layouter Debug mode --really handy and beautiful in order to confirm the calculations that are valid. Already a bug was found for ParabolicEffect. There is 1px difference between hovering Tasks and Applets --- app/main.cpp | 5 + app/view/view.cpp | 3 - .../package/contents/ui/applet/AppletItem.qml | 13 +++ .../contents/ui/{ => debug}/DebugWindow.qml | 0 containment/package/contents/ui/debug/Tag.qml | 44 +++++++++ .../contents/ui/layouts/AppletsContainer.qml | 1 + .../contents/ui/layouts/LayoutsContainer.qml | 92 +++++++++++++++++++ containment/package/contents/ui/main.qml | 4 +- 8 files changed, 158 insertions(+), 4 deletions(-) rename containment/package/contents/ui/{ => debug}/DebugWindow.qml (100%) create mode 100644 containment/package/contents/ui/debug/Tag.qml diff --git a/app/main.cpp b/app/main.cpp index b972137be..9606a74cb 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -153,6 +153,11 @@ int main(int argc, char **argv) localGeometryOption.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(localGeometryOption); + QCommandLineOption layouterOption(QStringList() << QStringLiteral("layouter")); + layouterOption.setDescription(QStringLiteral("Show visual debug tags for items sizes.")); + layouterOption.setFlags(QCommandLineOption::HiddenFromHelp); + parser.addOption(layouterOption); + QCommandLineOption filterDebugTextOption(QStringList() << QStringLiteral("debug-text")); filterDebugTextOption.setDescription(QStringLiteral("Show only debug messages that contain specific text.")); filterDebugTextOption.setFlags(QCommandLineOption::HiddenFromHelp); diff --git a/app/view/view.cpp b/app/view/view.cpp index 599c27c6e..06b6b35c3 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -1356,13 +1356,10 @@ void View::setInterfacesGraphicObj(Latte::Interfaces *ifaces) m_interfacesGraphicObj = ifaces; - qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 111"; if (containment()) { QQuickItem *containmentGraphicItem = qobject_cast(containment()->property("_plasma_graphicObject").value()); - qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 222"; if (containmentGraphicItem) { - qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 333"; containmentGraphicItem->setProperty("_latte_view_interfacesobject", QVariant::fromValue(m_interfacesGraphicObj)); } } diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index b6a1f7340..d1d0e1343 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -33,6 +33,7 @@ import org.kde.latte.components 1.0 as LatteComponents import "colorizer" as Colorizer import "communicator" as Communicator import "indicator" as Indicator +import "../debug" as Debug Item { id: appletItem @@ -1077,6 +1078,18 @@ Item { onReleased: mouse.accepted = false; } + //! Debug Elements + Loader{ + anchors.bottom: parent.bottom + anchors.left: parent.left + + active: root.debugModeLayouter + sourceComponent: Debug.Tag{ + label.text: root.isHorizontal ? appletItem.width : appletItem.height + label.color: appletItem.needsFillSpace ? "green" : "white" + } + } + //! A timer is needed in order to handle also touchpads that probably //! send too many signals very fast. This way the signals per sec are limited. //! The user needs to have a steady normal scroll in order to not diff --git a/containment/package/contents/ui/DebugWindow.qml b/containment/package/contents/ui/debug/DebugWindow.qml similarity index 100% rename from containment/package/contents/ui/DebugWindow.qml rename to containment/package/contents/ui/debug/DebugWindow.qml diff --git a/containment/package/contents/ui/debug/Tag.qml b/containment/package/contents/ui/debug/Tag.qml new file mode 100644 index 000000000..d3bdd3f32 --- /dev/null +++ b/containment/package/contents/ui/debug/Tag.qml @@ -0,0 +1,44 @@ +/* +* Copyright 2020 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.0 + +Item { + id: tag + + width: _label.width + 4 + height: _label.height + 4 + + readonly property alias background: _background + readonly property alias label: _label + + Rectangle { + id: _background + anchors.fill: parent + color: "black" + } + + Text { + id: _label + anchors.centerIn: parent + text: " --- " + color: "white" + font.pointSize: 11 + } +} diff --git a/containment/package/contents/ui/layouts/AppletsContainer.qml b/containment/package/contents/ui/layouts/AppletsContainer.qml index 0c939af66..2d1697553 100644 --- a/containment/package/contents/ui/layouts/AppletsContainer.qml +++ b/containment/package/contents/ui/layouts/AppletsContainer.qml @@ -166,6 +166,7 @@ Abilities.AbilityGrid { onShownAppletsChanged: layoutsContainer.updateSizeForAppletsInFill(); onSizeWithNoFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill(); + //////////////////////////BEGIN states //user set Panel Positions // 0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom diff --git a/containment/package/contents/ui/layouts/LayoutsContainer.qml b/containment/package/contents/ui/layouts/LayoutsContainer.qml index 38fc5b9c8..4cc6f63de 100644 --- a/containment/package/contents/ui/layouts/LayoutsContainer.qml +++ b/containment/package/contents/ui/layouts/LayoutsContainer.qml @@ -29,6 +29,7 @@ import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.private.containment 0.1 as LatteContainment import "./abilities" as AbilitiesTypes +import "../debug" as Debug import "../../code/HeuristicTools.js" as HeuristicTools Item{ @@ -310,6 +311,97 @@ Item{ } } + //! Debug Elements + Loader{ + anchors.top: debugLayout.top + anchors.horizontalCenter: debugLayout.horizontalCenter + active: root.debugModeLayouter + + readonly property Item debugLayout: _startLayout + + sourceComponent: Debug.Tag{ + background.color: "white" + label.text: tagText + label.color: "black" + label.font.pointSize: 13 + readonly property int layoutLength: root.isHorizontal ? debugLayout.width : debugLayout.height + + readonly property string tagText: { + return "no_show:" + debugLayout.shownApplets + " / no_fill:" + debugLayout.fillApplets + " / reg_len:" + debugLayout.sizeWithNoFillApplets + " / tot_len:"+layoutLength; + } + } + } + + Loader{ + anchors.top: debugLayout.top + anchors.horizontalCenter: debugLayout.horizontalCenter + active: root.debugModeLayouter + + readonly property Item debugLayout: _endLayout + + sourceComponent: Debug.Tag{ + background.color: "white" + label.text: tagText + label.color: "black" + label.font.pointSize: 13 + readonly property int layoutLength: root.isHorizontal ? debugLayout.width : debugLayout.height + + readonly property string tagText: { + return "no_show:" + debugLayout.shownApplets + " / no_fill:" + debugLayout.fillApplets + " / reg_len:" + debugLayout.sizeWithNoFillApplets + " / tot_len:"+layoutLength; + } + } + } + + Loader{ + anchors.top: debugLayout.top + anchors.horizontalCenter: debugLayout.horizontalCenter + active: root.debugModeLayouter + z:70 + + readonly property Item debugLayout: _mainLayout + + sourceComponent: Debug.Tag{ + background.color: "white" + label.text: tagText + label.color: "black" + label.font.pointSize: 13 + readonly property int layoutLength: root.isHorizontal ? debugLayout.width : debugLayout.height + + readonly property string tagText: { + return "no_show:" + debugLayout.shownApplets + " / no_fill:" + debugLayout.fillApplets + " / reg_len:" + debugLayout.sizeWithNoFillApplets + " / tot_len:"+layoutLength; + } + } + } + + Loader{ + anchors.top: _mainLayout.top + anchors.left: parent.left + active: root.debugModeLayouter + + readonly property Item debugLayout: layoutsContainer + + sourceComponent: Debug.Tag{ + background.color: "blue" + label.text: tagText + label.color: "yellow" + label.font.pointSize: 13 + label.font.bold: true + readonly property int layoutLength: root.isHorizontal ? debugLayout.width : debugLayout.height + + readonly property int layoutsLength: { + if (root.isVertical) { + return _startLayout.height + _mainLayout.height + _endLayout.height; + } + + return _startLayout.width + _mainLayout.width + _endLayout.width; + } + + readonly property string tagText: { + return "MAX:" + root.maxLength + " / TOT:"+layoutLength + " / LAYS:"+ layoutsLength; + } + } + } + //! This timer is needed in order to reduce the calls to heavy cpu function //! HeuristicTools.updateSizeForAppletsInFill() Timer{ diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 3dfa41fbb..c67810b31 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -41,6 +41,7 @@ import "editmode" as EditMode import "indicators" as Indicators import "layouts" as Layouts import "./background" as Background +import "./debug" as Debug import "../code/LayoutManager.js" as LayoutManager Item { @@ -64,6 +65,7 @@ Item { ////BEGIN properties property bool debugMode: Qt.application.arguments.indexOf("--graphics")>=0 + property bool debugModeLayouter: Qt.application.arguments.indexOf("--layouter")>=0 property bool debugModeLocalGeometry: Qt.application.arguments.indexOf("--localgeometry")>=0 property bool debugModeSpacers: Qt.application.arguments.indexOf("--spacers")>=0 property bool debugModeTimers: Qt.application.arguments.indexOf("--timers")>=0 @@ -1398,7 +1400,7 @@ Item { Loader{ active: root.debugModeWindow - sourceComponent: DebugWindow{} + sourceComponent: Debug.DebugWindow{} } EditMode.Visual{