From 518445027d551d6b9dfd8e89e123e9be9c990ed3 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 5 May 2021 22:27:30 +0300 Subject: [PATCH] containment:enable startUp flag from layout manager --- .../package/contents/ui/VisibilityManager.qml | 12 ++++-------- containment/package/contents/ui/main.qml | 16 +++++----------- containment/plugin/layoutmanager.cpp | 14 ++++++++++++++ containment/plugin/layoutmanager.h | 9 +++++++++ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 3448d4bd5..818103bcd 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -81,7 +81,7 @@ Item{ target: latteView property:"maxThickness" //! prevents updating window geometry during closing window in wayland and such fixes a crash - when: latteView && !inRelocationHiding && !inClientSideScreenEdgeSliding && !inStartup + when: latteView && !inRelocationHiding && !inClientSideScreenEdgeSliding //&& !inStartup value: root.behaveAsPlasmaPanel ? thicknessAsPanel : metrics.mask.thickness.maxZoomed } @@ -256,7 +256,7 @@ Item{ Binding{ target: latteView && latteView.effects ? latteView.effects : null property: "drawEffects" - when: latteView && latteView.effects + when: latteView && latteView.effects && !root.inStartup value: LatteCore.WindowSystem.compositingActive && (((root.blurEnabled && root.useThemePanel) || (root.blurEnabled && root.forceSolidPanel && LatteCore.WindowSystem.compositingActive)) @@ -570,11 +570,6 @@ Item{ return; } - //! prevent sliding-in on startup if the dodge modes have sent a hide signal - if (inStartupTimer.running && root.inStartup) { - root.inStartup = false; - } - //! Normal Dodge/AutoHide case if (!slidingAnimationAutoHiddenOut.running && !latteView.visibility.blockHiding @@ -853,7 +848,8 @@ Item{ ScriptAction{ script: { - root.inStartup = false; + // deprecated + // root.inStartup = false; } } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 40bc4cef1..027d60ab6 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -193,7 +193,8 @@ Item { property bool dragActiveWindowEnabled: plasmoid.configuration.dragActiveWindowEnabled property bool immutable: plasmoid.immutable property bool inFullJustify: (plasmoid.configuration.alignment === LatteCore.Types.Justify) && (maxLengthPerCentage===100) - property bool inStartup: true + property bool inStartup: !fastLayoutManager.hasRestoredApplets + property bool isHorizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal property bool isVertical: !isHorizontal @@ -543,8 +544,6 @@ Item { fastLayoutManager.restore(); plasmoid.action("configure").visible = !plasmoid.immutable; plasmoid.action("configure").enabled = !plasmoid.immutable; - - inStartupTimer.start(); } Component.onDestruction: { @@ -1064,14 +1063,9 @@ Item { ///////////////BEGIN TIMER elements //! It is used in order to slide-in the latteView on startup - Timer{ - id: inStartupTimer - interval: 1500 - repeat: false - onTriggered: { - if (inStartup) { - visibilityManager.slotMustBeShown(); - } + onInStartupChanged: { + if (!inStartup) { + visibilityManager.slotMustBeShown(); } } diff --git a/containment/plugin/layoutmanager.cpp b/containment/plugin/layoutmanager.cpp index 25955e354..75c916e64 100644 --- a/containment/plugin/layoutmanager.cpp +++ b/containment/plugin/layoutmanager.cpp @@ -43,6 +43,18 @@ LayoutManager::LayoutManager(QObject *parent) m_option["userBlocksColorizing"] = "userBlocksColorizingApplets"; connect(this, &LayoutManager::rootItemChanged, this, &LayoutManager::onRootItemChanged); + + m_hasRestoredAppletsTimer.setInterval(2000); + m_hasRestoredAppletsTimer.setSingleShot(true); + connect(&m_hasRestoredAppletsTimer, &QTimer::timeout, this, [&]() { + m_hasRestoredApplets = true; + emit hasRestoredAppletsChanged(); + }); +} + +bool LayoutManager::hasRestoredApplets() const +{ + return m_hasRestoredApplets; } int LayoutManager::splitterPosition() const @@ -397,6 +409,8 @@ void LayoutManager::restore() restoreOptions(); save(); + + m_hasRestoredAppletsTimer.start(); } void LayoutManager::restoreOptions() diff --git a/containment/plugin/layoutmanager.h b/containment/plugin/layoutmanager.h index 516b3a65c..d80dbb795 100644 --- a/containment/plugin/layoutmanager.h +++ b/containment/plugin/layoutmanager.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace KDeclarative { class ConfigPropertyMap; @@ -48,6 +49,8 @@ class LayoutManager : public QObject Q_PROPERTY(QQuickItem *dndSpacerItem READ dndSpacer WRITE setDndSpacer NOTIFY dndSpacerChanged) Q_PROPERTY(QQuickItem *metrics READ metrics WRITE setMetrics NOTIFY metricsChanged) + Q_PROPERTY(bool hasRestoredApplets READ hasRestoredApplets NOTIFY hasRestoredAppletsChanged) + //! this is the only way I have found to write their values properly in the configuration file in Multiple mode //! if they are not used from qml side in the form of plasmoid.configuration..... then //! appletsOrder is not stored when needed and applets additions/removals are not valid on next startup @@ -60,6 +63,8 @@ class LayoutManager : public QObject public: LayoutManager(QObject *parent = nullptr); + bool hasRestoredApplets() const; + int splitterPosition() const; int splitterPosition2() const; QString appletOrder() const; @@ -104,6 +109,7 @@ public slots: signals: void appletOrderChanged(); + void hasRestoredAppletsChanged(); void plasmoidChanged(); void rootItemChanged(); void dndSpacerChanged(); @@ -166,6 +172,9 @@ private: QMetaMethod m_createAppletItemMethod; QMetaMethod m_createJustifySplitterMethod; + bool m_hasRestoredApplets{false}; + QTimer m_hasRestoredAppletsTimer; + //! first QString is the option in AppletItem //! second QString is how the option is stored in QHash m_option;