diff --git a/components/shellsettingsplugin/mobileshellsettings.cpp b/components/shellsettingsplugin/mobileshellsettings.cpp index fa7fa20b..d12d88fe 100644 --- a/components/shellsettingsplugin/mobileshellsettings.cpp +++ b/components/shellsettingsplugin/mobileshellsettings.cpp @@ -9,6 +9,10 @@ #include #include #include + +#include +#include +#include #include const QString CONFIG_FILE = QStringLiteral("plasmamobilerc"); @@ -105,6 +109,8 @@ void MobileShellSettings::setNavigationPanelEnabled(bool navigationPanelEnabled) auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; group.writeEntry("navigationPanelEnabled", navigationPanelEnabled, KConfigGroup::Notify); m_config->sync(); + + updateNavigationBarsInPlasma(navigationPanelEnabled); } bool MobileShellSettings::taskSwitcherPreviewsEnabled() const @@ -164,3 +170,36 @@ void MobileShellSettings::setConvergenceModeEnabled(bool enabled) job->setDesktopName(QStringLiteral("org.kde.plasma-mobile-envmanager")); job->start(); } + +void MobileShellSettings::updateNavigationBarsInPlasma(bool navigationPanelEnabled) +{ + auto message = QDBusMessage::createMethodCall(QLatin1String("org.kde.plasmashell"), + QLatin1String("/PlasmaShell"), + QLatin1String("org.kde.PlasmaShell"), + QLatin1String("evaluateScript")); + + if (navigationPanelEnabled) { + QString createNavigationPanelScript = R"( + var bottomPanel = new Panel("org.kde.plasma.mobile.taskpanel") + bottomPanel.location = "bottom"; + bottomPanel.height = 2 * gridUnit; + )"; + + message << createNavigationPanelScript; + + } else { + QString deleteNavigationPanelScript = R"( + let allPanels = panels(); + for (var i = 0; i < allPanels.length; i++) { + if (allPanels[i].type === "org.kde.plasma.mobile.taskpanel") { + allPanels[i].remove(); + } + } + )"; + + message << deleteNavigationPanelScript; + } + + // TODO check for error response + QDBusConnection::sessionBus().asyncCall(message); +} diff --git a/components/shellsettingsplugin/mobileshellsettings.h b/components/shellsettingsplugin/mobileshellsettings.h index e2c9e5e3..9485b686 100644 --- a/components/shellsettingsplugin/mobileshellsettings.h +++ b/components/shellsettingsplugin/mobileshellsettings.h @@ -9,6 +9,7 @@ #include #include #include +#include #include /** @@ -179,6 +180,8 @@ Q_SIGNALS: void convergenceModeEnabledChanged(); private: + void updateNavigationBarsInPlasma(bool navigationPanelEnabled); + KConfigWatcher::Ptr m_configWatcher; KSharedConfig::Ptr m_config; }; diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index c91f97d0..e35b4673 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -28,28 +28,14 @@ ContainmentItem { Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground - // toggle visibility of navigation bar (show, or use gestures only) - Binding { - target: root.panel // assumed to be plasma-workspace "PanelView" component - property: "visibilityMode" - // 0 - VisibilityMode.NormalPanel - // 2 - VisibilityMode.LetWindowsCover HACK: TODO one day we delete the panel component instead of making it invisible in gesture-only mode - value: ShellSettings.Settings.navigationPanelEnabled ? 0 : 2 - } - - // we have the following scenarios: - // - system is in landscape orientation & nav panel is enabled (panel on right) - // - system is in landscape orientation & gesture mode is enabled (panel on bottom) - // - system is in portrait orientation (panel on bottom) readonly property bool inLandscape: Screen.width > Screen.height; - readonly property bool isInLandscapeNavPanelMode: inLandscape && ShellSettings.Settings.navigationPanelEnabled readonly property real navigationPanelHeight: Kirigami.Units.gridUnit * 2 readonly property real intendedWindowThickness: navigationPanelHeight - readonly property real intendedWindowLength: isInLandscapeNavPanelMode ? Screen.height : Screen.width - readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShell.Constants.topPanelHeight : 0; // offset for top panel - readonly property int intendedWindowLocation: isInLandscapeNavPanelMode ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge + readonly property real intendedWindowLength: inLandscape ? Screen.height : Screen.width + readonly property real intendedWindowOffset: inLandscape ? MobileShell.Constants.topPanelHeight : 0; // offset for top panel + readonly property int intendedWindowLocation: inLandscape ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen onIntendedWindowLocationChanged: locationChangeTimer.restart() @@ -121,13 +107,9 @@ ContainmentItem { Kirigami.Theme.inherit: false // load appropriate system navigation component - Loader { - id: navigationLoader - active: ShellSettings.Settings.navigationPanelEnabled + NavigationPanelComponent { anchors.fill: parent - sourceComponent: NavigationPanelComponent { - opaqueBar: root.opaqueBar - } + opaqueBar: root.opaqueBar } } }