From b235e6cc96fddc8d80541d111eeb0271984f1344 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 12 Apr 2021 12:24:22 +0300 Subject: [PATCH] update view alignment to new architecture --view alignment can now be updated either by editdock window or through views dialog in settings window --- app/layout/genericlayout.cpp | 2 +- app/view/positioner.cpp | 12 +++++++ app/view/view.cpp | 1 + .../package/contents/ui/VisibilityManager.qml | 2 +- .../ui/abilities/privates/MyViewPrivate.qml | 1 - .../contents/ui/layouts/LayoutsContainer.qml | 2 +- containment/package/contents/ui/main.qml | 34 +++++++++---------- .../configuration/pages/BehaviorConfig.qml | 8 ++--- 8 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index f32de4b4f..ba6aa3ab3 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -1499,7 +1499,7 @@ void GenericLayout::updateView(const Latte::Data::View &viewData) } view->setName(viewData.name); - view->positioner()->setNextLocation("", scrName, viewData.edge, Latte::Types::NoneAlignment); + view->positioner()->setNextLocation("", scrName, viewData.edge, viewData.alignment); } } diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index bcacb4416..f09c34391 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -971,6 +971,12 @@ void Positioner::initSignalingForLocationChangeSliding() if (m_nextScreenEdge != Plasma::Types::Floating) { m_view->setLocation(m_nextScreenEdge); } + + //! ALIGNMENT + if (m_nextAlignment != Latte::Types::NoneAlignment && m_nextAlignment != m_view->alignment()) { + m_view->setAlignment(m_nextAlignment); + m_nextAlignment = Latte::Types::NoneAlignment; + } }); } @@ -1120,6 +1126,12 @@ void Positioner::setNextLocation(const QString layoutName, const QString screenN } } + //! ALIGNMENT + if (alignment != Latte::Types::NoneAlignment && m_view->alignment() != alignment) { + m_nextAlignment = static_cast(alignment); + haschanges = true; + } + m_repositionIsAnimated = isanimated; m_repositionFromViewSettingsWindow = m_view->settingsWindowIsShown(); diff --git a/app/view/view.cpp b/app/view/view.cpp index c609dee6b..1fa387ffb 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -1654,6 +1654,7 @@ void View::restoreConfig() auto config = this->containment()->config(); m_onPrimary = config.readEntry("onPrimary", true); + m_alignment = static_cast(config.group("General").readEntry("alignment", (int)Latte::Types::Center)); m_byPassWM = config.readEntry("byPassWM", false); m_isPreferredForShortcuts = config.readEntry("isPreferredForShortcuts", false); m_name = config.readEntry("name", QString()); diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index fde2d67fd..6e7197982 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -398,7 +398,7 @@ Item{ onXChanged: updateMaskArea(); onYChanged: updateMaskArea() onWidthChanged: updateMaskArea(); - onHeightChanged: updateMaskArea(); + onHeightChanged: updateMaskArea(); } Connections{ diff --git a/containment/package/contents/ui/abilities/privates/MyViewPrivate.qml b/containment/package/contents/ui/abilities/privates/MyViewPrivate.qml index 89c867ffb..d5abd5428 100644 --- a/containment/package/contents/ui/abilities/privates/MyViewPrivate.qml +++ b/containment/package/contents/ui/abilities/privates/MyViewPrivate.qml @@ -92,7 +92,6 @@ AbilityHost.MyView { } } - function decimalToHex(d, padding) { var hex = Number(d).toString(16); padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding; diff --git a/containment/package/contents/ui/layouts/LayoutsContainer.qml b/containment/package/contents/ui/layouts/LayoutsContainer.qml index df139be89..9b07a1c97 100644 --- a/containment/package/contents/ui/layouts/LayoutsContainer.qml +++ b/containment/package/contents/ui/layouts/LayoutsContainer.qml @@ -334,7 +334,7 @@ Item{ } transitions: Transition { - enabled: root.editMode + enabled: !visibilityManager.inRelocationAnimation && !root.inStartup AnchorAnimation { duration: 0.8 * animations.duration.proposed easing.type: Easing.OutCubic diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index a216f4d02..b87a78162 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -451,30 +451,30 @@ Item { updateIndexes(); } - //! It is used only when the user chooses different alignment types - //! and not during startup + //! It is used only when the user chooses different alignment types and not during startup Connections { - target: myView + target: latteView ? latteView : null onAlignmentChanged: { - if (!root.editMode) { + if (latteView.alignment === LatteCore.Types.NoneAlignment) { return; } - if (root.editMode){ - if (root.myView.alignment===LatteCore.Types.Justify) { - layouter.appletsInParentChange = true; - fastLayoutManager.addJustifySplittersInMainLayout(); - console.log("LAYOUTS: Moving applets from MAIN to THREE Layouts mode..."); - fastLayoutManager.moveAppletsBasedOnJustifyAlignment(); - layouter.appletsInParentChange = false; - } else { - layouter.appletsInParentChange = true; - console.log("LAYOUTS: Moving applets from THREE to MAIN Layout mode..."); - fastLayoutManager.joinLayoutsToMainLayout(); - layouter.appletsInParentChange = false; - } + var previousalignment = plasmoid.configuration.alignment; + + if (latteView.alignment===LatteCore.Types.Justify && previousalignment!==LatteCore.Types.Justify) { // main -> justify + layouter.appletsInParentChange = true; + fastLayoutManager.addJustifySplittersInMainLayout(); + console.log("LAYOUTS: Moving applets from MAIN to THREE Layouts mode..."); + fastLayoutManager.moveAppletsBasedOnJustifyAlignment(); + layouter.appletsInParentChange = false; + } else if (latteView.alignment!==LatteCore.Types.Justify && previousalignment===LatteCore.Types.Justify ) { // justify ->main + layouter.appletsInParentChange = true; + console.log("LAYOUTS: Moving applets from THREE to MAIN Layout mode..."); + fastLayoutManager.joinLayoutsToMainLayout(); + layouter.appletsInParentChange = false; } + plasmoid.configuration.alignment = latteView.alignment; fastLayoutManager.save(); } } diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index 383eaeb7d..2a770e2ac 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -300,7 +300,7 @@ PlasmaComponents.Page { onPressedChanged: { if (pressed) { - plasmoid.configuration.alignment = alignment + latteView.positioner.setNextLocation("", "", PlasmaCore.Types.Floating, alignment); } } } @@ -317,7 +317,7 @@ PlasmaComponents.Page { onPressedChanged: { if (pressed) { - plasmoid.configuration.alignment = alignment + latteView.positioner.setNextLocation("", "", PlasmaCore.Types.Floating, alignment); } } } @@ -334,7 +334,7 @@ PlasmaComponents.Page { onPressedChanged: { if (pressed) { - plasmoid.configuration.alignment = alignment + latteView.positioner.setNextLocation("", "", PlasmaCore.Types.Floating, alignment); } } } @@ -352,7 +352,7 @@ PlasmaComponents.Page { onPressedChanged: { if (pressed) { - plasmoid.configuration.alignment = alignment + latteView.positioner.setNextLocation("", "", PlasmaCore.Types.Floating, alignment); } } }