]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add phone UI
authorFelix Ernst <felixernst@zohomail.eu>
Sun, 15 Sep 2024 16:52:49 +0000 (18:52 +0200)
committerFelix Ernst <felixernst@kde.org>
Thu, 17 Oct 2024 15:52:31 +0000 (15:52 +0000)
Previous to this commit launching Dolphin on phones (e.g. those
running Plasma Mobile) would show Dolphin with its default user
interface optimised for desktop usage. This commit changes this so
instead a phone form factor optimised user interface is used.

The differences to the default UI configuration are:
-Toolbar at bottom
-Icon-only toolbar
-Different actions on the toolbar
-Places panel hidden
-Location bar at the top with a button to show places
-Zoom slider hidden (pinch gestures to zoom still work)

Through these changes Dolphin actually has a good user experience
on phones by default. All the features were already there.
Especially Steffen Hartleib's work to trigger selection mode on
long press leads to great UX when dealing with multiple files.

Still, this might be considered just a start towards making Dolphin
great on phone form factors. Secondary windows that Dolphin might
spawn are not yet adapted, but are usable on Plasma Mobile as they
are anyway.

src/dolphin.qrc
src/dolphinmainwindow.cpp
src/dolphinuiforphones.rc [new file with mode: 0644]

index 55cae54b95645a29f6067a2e8a4905f87140e39a..bd32ef73445309d8ee80a41deeac6acb2efecb07 100644 (file)
@@ -1,5 +1,6 @@
 <RCC>
 <qresource prefix="/kxmlgui5/dolphin">
 <file>dolphinui.rc</file>
+<file>dolphinuiforphones.rc</file>
 </qresource>
 </RCC>
index 7d62f52edf17bd79d7bcbef0488254409f9cedc6..36f0316c6a43165ad4eebad7f28fc4990f586295 100644 (file)
@@ -54,6 +54,7 @@
 #include <KProtocolInfo>
 #include <KProtocolManager>
 #include <KRecentFilesAction>
+#include <KRuntimePlatform>
 #include <KShell>
 #include <KShortcutsDialog>
 #include <KStandardAction>
@@ -190,7 +191,8 @@ DolphinMainWindow::DolphinMainWindow()
 
     setupDockWidgets();
 
-    setupGUI(Save | Create | ToolBar);
+    const bool usePhoneUi{KRuntimePlatform::runtimePlatform().contains(QLatin1String("phone"))};
+    setupGUI(Save | Create | ToolBar, usePhoneUi ? QStringLiteral("dolphinuiforphones.rc") : QString() /* load the default dolphinui.rc file */);
     stateChanged(QStringLiteral("new_file"));
 
     QClipboard *clipboard = QApplication::clipboard();
@@ -201,6 +203,12 @@ DolphinMainWindow::DolphinMainWindow()
 
     if (firstRun) {
         menuBar()->setVisible(false);
+
+        if (usePhoneUi) {
+            Q_ASSERT(qobject_cast<QDockWidget *>(m_placesPanel->parent()));
+            m_placesPanel->parentWidget()->hide();
+            GeneralSettings::setShowZoomSlider(false);
+        }
     }
 
     const bool showMenu = !menuBar()->isHidden();
diff --git a/src/dolphinuiforphones.rc b/src/dolphinuiforphones.rc
new file mode 100644 (file)
index 0000000..ba5945c
--- /dev/null
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<!DOCTYPE gui SYSTEM "kpartgui.dtd">
+<gui name="dolphin" version="1">
+    <MenuBar>
+        <Menu name="file">
+            <Action name="new_menu" />
+            <Action name="file_new" />
+            <Action name="new_tab" />
+            <Action name="file_close" />
+            <Action name="undo_close_tab" />
+            <Separator/>
+            <Action name="add_to_places" />
+            <Separator/>
+            <Action name="renamefile" />
+            <Action name="duplicate" />
+            <Action name="movetotrash" />
+            <Action name="deletefile" />
+            <Separator/>
+            <Action name="show_target" />
+            <Separator/>
+            <Action name="properties" />
+        </Menu>
+        <Menu name="edit">
+            <Action name="edit_undo" />
+            <Separator />
+            <Action name="edit_cut" />
+            <Action name="edit_copy" />
+            <Action name="copy_location" />
+            <Action name="edit_paste" />
+            <Separator />
+            <Action name="show_filter_bar" />
+            <Action name="edit_find" />
+            <Separator />
+            <Action name="toggle_selection_mode" />
+            <Action name="copy_to_inactive_split_view" />
+            <Action name="move_to_inactive_split_view" />
+            <Action name="edit_select_all" />
+            <Action name="invert_selection" />
+        </Menu>
+        <Menu name="view">
+            <Action name="view_zoom_in"/>
+            <Action name="view_zoom_reset"/>
+            <Action name="view_zoom_out"/>
+            <Separator/>
+            <Action name="sort" />
+            <Action name="view_mode" />
+            <Action name="additional_info" />
+            <Action name="show_preview" />
+            <Action name="show_in_groups" />
+            <Action name="show_hidden_files" />
+            <Action name="act_as_admin" />
+            <Separator/>
+            <Action name="split_view_menu" />
+            <Action name="popout_split_view" />
+            <Action name="split_stash" />
+            <Action name="redisplay" />
+            <Action name="stop" />
+            <Separator/>
+            <Action name="panels" />
+            <Menu name="location_bar" icon="edit-select-text">
+                <text context="@title:menu">Location Bar</text>
+                <Action name="editable_location" />
+                <Action name="replace_location" />
+            </Menu>
+            <Separator/>
+            <Action name="view_properties" />
+        </Menu>
+        <Menu name="go">
+            <Action name="bookmarks" />
+            <Action name="closed_tabs" />
+        </Menu>
+        <Menu name="tools">
+            <Action name="open_preferred_search_tool" />
+            <Action name="open_terminal" />
+            <Action name="open_terminal_here" />
+            <Action name="compare_files" />
+            <Action name="change_remote_encoding" />
+        </Menu>
+    </MenuBar>
+    <State name="new_file" >
+        <disable>
+            <Action name="edit_undo" />
+            <Action name="edit_redo" />
+            <Action name="edit_cut" />
+            <Action name="renamefile" />
+            <Action name="movetotrash" />
+            <Action name="deletefile" />
+            <Action name="invert_selection" />
+            <Separator/>
+            <Action name="go_back" />
+            <Action name="go_forward" />
+        </disable>
+    </State>
+    <State name="has_selection" >
+        <enable>
+            <Action name="invert_selection" />
+        </enable>
+    </State>
+    <State name="has_no_selection" >
+        <disable>
+            <Action name="delete_shortcut" />
+            <Action name="invert_selection" />
+        </disable>
+    </State>
+    <ToolBar noMerge="1" position="Bottom" ToolButtonStyle="icononly" name="mainToolBar" >
+        <text context="@title:menu">Main Toolbar</text>
+        <Action name="go_back" />
+        <Action name="go_forward" />
+        <Spacer name="spacer_1" />
+        <Action name="new_menu" />
+        <Action name="edit_copy" />
+        <Action name="renamefile" />
+        <Action name="movetotrash" />
+        <Spacer name="spacer_2" />
+        <Action name="toggle_search" />
+        <Action name="hamburger_menu" />
+    </ToolBar>
+    <ActionProperties scheme="Default">
+        <Action priority="0" name="go_back"/>
+        <Action priority="0" name="go_forward"/>
+        <Action priority="0" name="go_up"/>
+        <Action priority="0" name="go_home"/>
+        <Action priority="0" name="stop"/>
+        <Action priority="0" name="icons"/>
+        <Action priority="0" name="compact"/>
+        <Action priority="0" name="details"/>
+        <Action priority="0" name="view_zoom_in"/>
+        <Action priority="0" name="view_zoom_reset"/>
+        <Action priority="0" name="view_zoom_out"/>
+        <Action priority="0" name="edit_cut"/>
+        <Action priority="0" name="edit_copy"/>
+        <Action priority="0" name="edit_paste"/>
+        <Action priority="0" name="toggle_search"/>
+        <Action priority="0" name="toggle_filter"/>
+    </ActionProperties>
+</gui>