[neon/kde/dolphin/Neon/unstable] debian/patches: add dolphin mobile form factor patch for testing in unstable

Carlos De Maine null at kde.org
Thu Sep 26 01:37:45 BST 2024


Git commit 847a320d29203ffddfba62e64194786f53bb9cac by Carlos De Maine.
Committed on 26/09/2024 at 00:37.
Pushed by carlosdem into branch 'Neon/unstable'.

add dolphin mobile form factor patch for testing in unstable

A  +350  -0    debian/patches/dolphin_mobile_form_factor
A  +1    -0    debian/patches/series

https://invent.kde.org/neon/kde/dolphin/-/commit/847a320d29203ffddfba62e64194786f53bb9cac

diff --git a/debian/patches/dolphin_mobile_form_factor b/debian/patches/dolphin_mobile_form_factor
new file mode 100644
index 0000000..c1cf80c
--- /dev/null
+++ b/debian/patches/dolphin_mobile_form_factor
@@ -0,0 +1,350 @@
+diff --git a/src/dolphin.qrc b/src/dolphin.qrc
+index 55cae54b95645a29f6067a2e8a4905f87140e39a..bd32ef73445309d8ee80a41deeac6acb2efecb07 100644
+--- a/src/dolphin.qrc
++++ b/src/dolphin.qrc
+@@ -1,5 +1,6 @@
+ <RCC>
+ <qresource prefix="/kxmlgui5/dolphin">
+ <file>dolphinui.rc</file>
++<file>dolphinuiforphones.rc</file>
+ </qresource>
+ </RCC>
+diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
+index 54cd3bf71b974d6fa66ad340302d12f31321d8a6..054a48aec21a7e0939d9a61ef5e10c9f141ed46e 100644
+--- a/src/dolphinmainwindow.cpp
++++ b/src/dolphinmainwindow.cpp
+@@ -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,15 @@ DolphinMainWindow::DolphinMainWindow()
+ 
+     if (firstRun) {
+         menuBar()->setVisible(false);
++
++        if (usePhoneUi) {
++            Q_ASSERT(qobject_cast<QDockWidget *>(m_placesPanel->parent()));
++            m_placesPanel->parentWidget()->hide();
++            auto settings = GeneralSettings::self();
++            settings->setShowZoomSlider(false); // Zooming can be done with pinch gestures instead and we are short on horizontal space.
++            settings->setRenameInline(false); // This works around inline renaming currently not working well with virtual keyboards.
++            settings->save(); // Otherwise the RenameInline setting is not picked up for the first time Dolphin is used.
++        }
+     }
+ 
+     const bool showMenu = !menuBar()->isHidden();
+diff --git a/src/dolphinuiforphones.rc b/src/dolphinuiforphones.rc
+new file mode 100644
+index 0000000000000000000000000000000000000000..ba5945cc36e81815f8fe79df05b7bb05052c2708
+--- /dev/null
++++ b/src/dolphinuiforphones.rc
+@@ -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>
+diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp
+index 782a03ae9132494e4f32f9099565573c069f7bfb..d9184759e70a3517e7d66495dfad707e438af8b5 100644
+--- a/src/settings/dolphinsettingsdialog.cpp
++++ b/src/settings/dolphinsettingsdialog.cpp
+@@ -21,6 +21,7 @@
+ #include <KAuthorized>
+ #include <KLocalizedString>
+ #include <KMessageBox>
++#include <KRuntimePlatform>
+ #include <KWindowConfig>
+ 
+ #include <kwidgetsaddons_version.h>
+@@ -37,7 +38,7 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K
+     const QSize minSize = minimumSize();
+     setMinimumSize(QSize(540, minSize.height()));
+ 
+-    setFaceType(List);
++    setFaceType(KRuntimePlatform::runtimePlatform().contains(QLatin1String("phone")) ? Tabbed : List);
+     setWindowTitle(i18nc("@title:window", "Configure"));
+ 
+     // Interface
+diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
+index 94e6d5be4486c3d282a02de72a4e12350754c26f..61a72ad51b055d92e2f00ceb9b520031d196c02f 100644
+--- a/src/tests/dolphinmainwindowtest.cpp
++++ b/src/tests/dolphinmainwindowtest.cpp
+@@ -20,6 +20,7 @@
+ #include <KConfigGui>
+ 
+ #include <QAccessible>
++#include <QDomDocument>
+ #include <QFileSystemWatcher>
+ #include <QScopedPointer>
+ #include <QSignalSpy>
+@@ -27,6 +28,7 @@
+ #include <QTest>
+ 
+ #include <set>
++#include <unordered_set>
+ 
+ class DolphinMainWindowTest : public QObject
+ {
+@@ -35,6 +37,7 @@ class DolphinMainWindowTest : public QObject
+ private Q_SLOTS:
+     void initTestCase();
+     void init();
++    void testSyncDesktopAndPhoneUi();
+     void testClosingTabsWithSearchBoxVisible();
+     void testActiveViewAfterClosingSplitView_data();
+     void testActiveViewAfterClosingSplitView();
+@@ -67,6 +70,109 @@ void DolphinMainWindowTest::init()
+     m_mainWindow.reset(new DolphinMainWindow());
+ }
+ 
++/**
++ * It is too easy to forget that most changes in dolphinui.rc should be mirrored in dolphinuiforphones.rc. This test makes sure that these two files stay
++ * mostly identical. Differences between those files need to be explicitly added as exceptions to this test. So if you land here after changing either
++ * dolphinui.rc or dolphinuiforphones.rc, then resolve this test failure either by making the exact same change to the other ui.rc file, or by adding the
++ * changed object to the `exceptions` variable below.
++ */
++void DolphinMainWindowTest::testSyncDesktopAndPhoneUi()
++{
++    std::unordered_set<QString> exceptions{{QStringLiteral("version"), QStringLiteral("ToolBar")}};
++
++    QDomDocument desktopUi;
++    QFile desktopUiXmlFile(":/kxmlgui5/dolphin/dolphinui.rc");
++    desktopUiXmlFile.open(QIODevice::ReadOnly);
++    desktopUi.setContent(&desktopUiXmlFile);
++    desktopUiXmlFile.close();
++
++    QDomDocument phoneUi;
++    QFile phoneUiXmlFile(":/kxmlgui5/dolphin/dolphinuiforphones.rc");
++    phoneUiXmlFile.open(QIODevice::ReadOnly);
++    phoneUi.setContent(&phoneUiXmlFile);
++    phoneUiXmlFile.close();
++
++    QDomElement desktopUiElement = desktopUi.documentElement();
++    QDomElement phoneUiElement = phoneUi.documentElement();
++
++    auto nextUiElement = [&exceptions](QDomElement uiElement) -> QDomElement {
++        QDomNode nextUiNode{uiElement};
++        do {
++            // If the current node is an exception, we skip its children as well.
++            if (exceptions.count(nextUiNode.nodeName()) == 0) {
++                auto firstChild{nextUiNode.firstChild()};
++                if (!firstChild.isNull()) {
++                    nextUiNode = firstChild;
++                    continue;
++                }
++            }
++            auto nextSibling{nextUiNode.nextSibling()};
++            if (!nextSibling.isNull()) {
++                nextUiNode = nextSibling;
++                continue;
++            }
++            auto parent{nextUiNode.parentNode()};
++            while (true) {
++                if (parent.isNull()) {
++                    return QDomElement();
++                }
++                auto nextParentSibling{parent.nextSibling()};
++                if (!nextParentSibling.isNull()) {
++                    nextUiNode = nextParentSibling;
++                    break;
++                }
++                parent = parent.parentNode();
++            }
++        } while (
++            !nextUiNode.isNull()
++            && (nextUiNode.toElement().isNull() || exceptions.count(nextUiNode.nodeName()))); // We loop until we either give up finding an element or find one.
++        if (nextUiNode.isNull()) {
++            return QDomElement();
++        }
++        return nextUiNode.toElement();
++    };
++
++    int totalComparisonsCount{0};
++    do {
++        QVERIFY2(desktopUiElement.tagName() == phoneUiElement.tagName(),
++                 qPrintable(QStringLiteral("Node mismatch: dolphinui.rc/%1::%2 and dolphinuiforphones.rc/%3::%4")
++                                .arg(desktopUiElement.parentNode().toElement().tagName())
++                                .arg(desktopUiElement.tagName())
++                                .arg(phoneUiElement.parentNode().toElement().tagName())
++                                .arg(phoneUiElement.tagName())));
++        QCOMPARE(desktopUiElement.text(), phoneUiElement.text());
++        const auto desktopUiElementAttributes = desktopUiElement.attributes();
++        const auto phoneUiElementAttributes = phoneUiElement.attributes();
++        for (int i = 0; i < desktopUiElementAttributes.count(); i++) {
++            QVERIFY2(phoneUiElementAttributes.count() >= i,
++                     qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has more attributes than dolphinuiforphones.rc/%3::%4")
++                                    .arg(desktopUiElement.parentNode().toElement().tagName())
++                                    .arg(desktopUiElement.tagName())
++                                    .arg(phoneUiElement.parentNode().toElement().tagName())
++                                    .arg(phoneUiElement.tagName())));
++            if (exceptions.count(desktopUiElementAttributes.item(i).nodeName())) {
++                continue;
++            }
++            QCOMPARE(desktopUiElementAttributes.item(i).nodeName(), phoneUiElementAttributes.item(i).nodeName());
++            QCOMPARE(desktopUiElementAttributes.item(i).nodeValue(), phoneUiElementAttributes.item(i).nodeValue());
++            totalComparisonsCount++;
++        }
++        QVERIFY2(desktopUiElementAttributes.count() == phoneUiElementAttributes.count(),
++                 qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has fewer attributes than dolphinuiforphones.rc/%3::%4. %5 < %6")
++                                .arg(desktopUiElement.parentNode().toElement().tagName())
++                                .arg(desktopUiElement.tagName())
++                                .arg(phoneUiElement.parentNode().toElement().tagName())
++                                .arg(phoneUiElement.tagName())
++                                .arg(phoneUiElementAttributes.count())
++                                .arg(desktopUiElementAttributes.count())));
++
++        desktopUiElement = nextUiElement(desktopUiElement);
++        phoneUiElement = nextUiElement(phoneUiElement);
++        totalComparisonsCount++;
++    } while (!desktopUiElement.isNull() || !phoneUiElement.isNull());
++    QVERIFY2(totalComparisonsCount > 200, qPrintable(QStringLiteral("There were only %1 comparisons. Did the test run correctly?").arg(totalComparisonsCount)));
++}
++
+ // See https://bugs.kde.org/show_bug.cgi?id=379135
+ void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible()
+ {
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..e423061
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+dolphin_mobile_form_factor


More information about the Neon-commits mailing list