mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 22:53:09 +00:00
navigationpanel: Delete panel when in gesture-only mode
This commit is contained in:
parent
ded2038e87
commit
ae0dc228a8
3 changed files with 47 additions and 23 deletions
|
|
@ -9,6 +9,10 @@
|
|||
#include <KIO/CommandLauncherJob>
|
||||
#include <KNotificationJobUiDelegate>
|
||||
#include <KPluginFactory>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusPendingCall>
|
||||
#include <QDebug>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <KConfigGroup>
|
||||
#include <KConfigWatcher>
|
||||
#include <KSharedConfig>
|
||||
#include <QDBusConnection>
|
||||
#include <QObject>
|
||||
|
||||
/**
|
||||
|
|
@ -179,6 +180,8 @@ Q_SIGNALS:
|
|||
void convergenceModeEnabledChanged();
|
||||
|
||||
private:
|
||||
void updateNavigationBarsInPlasma(bool navigationPanelEnabled);
|
||||
|
||||
KConfigWatcher::Ptr m_configWatcher;
|
||||
KSharedConfig::Ptr m_config;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue