From a034c72c62d7d91ee179b4017c93972e2b7201b9ce513a2347f6a4ebb96632a4 Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Tue, 26 Jan 2021 15:53:28 +0000 Subject: [PATCH] Accepting request 866684 from home:luca_b:branches:KDE:Applications - Add upstream patch to properly show the network button in the URL navigator (kde#431626): - 0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch - Refreshed patches: - 0001-Update-cached-viewContainer-geometry-every-time-they.patch OBS-URL: https://build.opensuse.org/request/show/866684 OBS-URL: https://build.opensuse.org/package/show/KDE:Applications/dolphin?expand=0&rev=241 --- ...pen-knetattach-inline-with-URL-nav-o.patch | 193 ++++++++++++++++++ ...ewContainer-geometry-every-time-they.patch | 59 +++--- dolphin.changes | 9 + dolphin.spec | 4 +- 4 files changed, 233 insertions(+), 32 deletions(-) create mode 100644 0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch diff --git a/0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch b/0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch new file mode 100644 index 0000000..13980a9 --- /dev/null +++ b/0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch @@ -0,0 +1,193 @@ +From 33270dd4423eea329b8f20db17f8d70ab7b108da Mon Sep 17 00:00:00 2001 +From: Norbert Preining +Date: Tue, 19 Jan 2021 06:43:14 +0900 +Subject: [PATCH] Show button to open knetattach inline with URL nav on + remove:// view + +This is a backport of b1cadeba939155282a9fadf7d7b025d6529c489e + + From b1cadeba939155282a9fadf7d7b025d6529c489e Mon Sep 17 00:00:00 2001 + From: Nate Graham + Date: Tue, 15 Dec 2020 23:03:00 -0700 + Subject: [PATCH] Show button to open knetattach inline with URL nav on + Remote:// view + + In conjunction with + https://invent.kde.org/frameworks/kio/-/merge_requests/260, + the net result is to hide the knetattach launcher in the view, and show + it inline with Dolphin's URL navigator toolbar when viewing the + remote:// view, just like how we add an "Empty Trash" button when + viewing trash://. + +The backport ensures that even with frameworks << 5.78 only one network +button is shown. + +BUG: 431626 +--- + src/dolphinnavigatorswidgetaction.cpp | 61 +++++++++++++++++++++++++++ + src/dolphinnavigatorswidgetaction.h | 20 ++++++++- + 2 files changed, 80 insertions(+), 1 deletion(-) + +diff --git a/src/dolphinnavigatorswidgetaction.cpp b/src/dolphinnavigatorswidgetaction.cpp +index b8c77c69b..b25c60d0c 100644 +--- a/src/dolphinnavigatorswidgetaction.cpp ++++ b/src/dolphinnavigatorswidgetaction.cpp +@@ -10,9 +10,13 @@ + #include "trash/dolphintrash.h" + + #include ++#include ++#include + #include + #include + ++#include ++ + #include + #include + #include +@@ -154,7 +158,13 @@ void DolphinNavigatorsWidgetAction::adjustSpacing() + } + int trailingSpacing = (m_globalXOfSplitter + m_splitter->width()) + - (m_globalXOfPrimary + m_widthOfPrimary); ++#if KIO_VERSION < QT_VERSION_CHECK(5, 78, 0) + if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible()) { ++#else ++ if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible() ++ || networkFolderButton(Primary)->isVisible() ++ ) { ++#endif + trailingSpacing = 0; + } + const int widthLeftForUrlNavigator = m_splitter->widget(0)->width() - leadingSpacing - trailingSpacing; +@@ -181,7 +191,13 @@ void DolphinNavigatorsWidgetAction::adjustSpacing() + + trailingSpacing = (m_globalXOfSplitter + m_splitter->width()) + - (m_globalXOfSecondary + m_widthOfSecondary); ++#if KIO_VERSION < QT_VERSION_CHECK(5, 78, 0) + if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible()) { ++#else ++ if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible() ++ || networkFolderButton(Secondary)->isVisible() ++ ) { ++#endif + trailingSpacing = 0; + } else { + const int widthLeftForUrlNavigator2 = m_splitter->widget(1)->width() - trailingSpacing; +@@ -212,6 +228,11 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const + auto emptyTrashButton = newEmptyTrashButton(urlNavigator, navigatorWidget); + layout->addWidget(emptyTrashButton); + ++#if !(KIO_VERSION < QT_VERSION_CHECK(5, 78, 0)) ++ auto networkFolderButton = newNetworkFolderButton(urlNavigator, navigatorWidget); ++ layout->addWidget(networkFolderButton); ++#endif ++ + connect(urlNavigator, &KUrlNavigator::urlChanged, this, [this]() { + // We have to wait for DolphinUrlNavigator::sizeHint() to update which + // happens a little bit later than when urlChanged is emitted. +@@ -249,6 +270,38 @@ QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrl + return emptyTrashButton; + } + ++#if !(KIO_VERSION < QT_VERSION_CHECK(5, 78, 0)) ++QPushButton *DolphinNavigatorsWidgetAction::networkFolderButton(DolphinNavigatorsWidgetAction::Side side) ++{ ++ int sideIndex = (side == Primary ? 0 : 1); ++ if (side == Primary) { ++ return static_cast(m_splitter->widget(sideIndex)->layout()->itemAt(3)->widget()); ++ } ++ return static_cast(m_splitter->widget(sideIndex)->layout()->itemAt(2)->widget()); ++} ++ ++QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const ++{ ++ auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")), ++ i18nc("@action:button", "Add Network Folder"), parent); ++ networkFolderButton->setFlat(true); ++ connect(networkFolderButton, &QPushButton::clicked, ++ this, [networkFolderButton]() { ++ KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach")); ++ auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton); ++ auto *delegate = new KNotificationJobUiDelegate; ++ delegate->setAutoErrorHandlingEnabled(true); ++ job->setUiDelegate(delegate); ++ job->start(); ++ }); ++ networkFolderButton->hide(); ++ connect(urlNavigator, &KUrlNavigator::urlChanged, this, [networkFolderButton, urlNavigator]() { ++ networkFolderButton->setVisible(urlNavigator->locationUrl().scheme() == QLatin1String("remote")); ++ }); ++ return networkFolderButton; ++} ++#endif ++ + QWidget *DolphinNavigatorsWidgetAction::spacing(Side side, Position position) const + { + int sideIndex = (side == Primary ? 0 : 1); +@@ -257,9 +310,17 @@ QWidget *DolphinNavigatorsWidgetAction::spacing(Side side, Position position) co + return m_splitter->widget(sideIndex)->layout()->itemAt(0)->widget(); + } + if (side == Primary) { ++#if KIO_VERSION < QT_VERSION_CHECK(5, 78, 0) + return m_splitter->widget(sideIndex)->layout()->itemAt(3)->widget(); ++#else ++ return m_splitter->widget(sideIndex)->layout()->itemAt(4)->widget(); ++#endif + } ++#if KIO_VERSION < QT_VERSION_CHECK(5, 78, 0) + return m_splitter->widget(sideIndex)->layout()->itemAt(2)->widget(); ++#else ++ return m_splitter->widget(sideIndex)->layout()->itemAt(3)->widget(); ++#endif + } + + void DolphinNavigatorsWidgetAction::updateText() +diff --git a/src/dolphinnavigatorswidgetaction.h b/src/dolphinnavigatorswidgetaction.h +index bbd8cf127..ce199b3f0 100644 +--- a/src/dolphinnavigatorswidgetaction.h ++++ b/src/dolphinnavigatorswidgetaction.h +@@ -10,6 +10,7 @@ + + #include "dolphinurlnavigator.h" + ++#include + #include + #include + #include +@@ -30,7 +31,8 @@ class QPushButton; + * The secondary side only exists for split view and is created by + * createSecondaryUrlNavigator() when necessary. + * - Each side is a QWidget which I call NavigatorWidget with a QHBoxLayout. +- * - Each NavigatorWidget consists an UrlNavigator, an emptyTrashButton and spacing. ++ * - Each NavigatorWidget consists an UrlNavigator, an emptyTrashButton, a ++ * networkFolderButton (for frameworks >= 5.78), and spacing. + * - Only the primary navigatorWidget has leading spacing. Both have trailing spacing. + * The spacing is there to align the UrlNavigator with its DolphinViewContainer. + */ +@@ -131,6 +133,22 @@ private: + */ + QPushButton *newEmptyTrashButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const; + ++#if !(KIO_VERSION < QT_VERSION_CHECK(5, 78, 0)) ++ /** ++ * Used to retrieve the networkFolderButtons for the navigatorWidgets on ++ * both sides. ++ */ ++ QPushButton *networkFolderButton(Side side); ++ ++ /** ++ * Creates a new add "network folder" button. ++ * @param urlNavigator Only when this UrlNavigator shows the remote directory ++ * will the button be visible. ++ * @param parent The object that should be the button's parent. ++ */ ++ QPushButton *newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const; ++#endif ++ + enum Position { + Leading, + Trailing +-- +2.30.0 + diff --git a/0001-Update-cached-viewContainer-geometry-every-time-they.patch b/0001-Update-cached-viewContainer-geometry-every-time-they.patch index cf2481f..f83c3df 100644 --- a/0001-Update-cached-viewContainer-geometry-every-time-they.patch +++ b/0001-Update-cached-viewContainer-geometry-every-time-they.patch @@ -9,11 +9,11 @@ Subject: [PATCH] Update cached viewContainer geometry every time they are used src/dolphintabpage.cpp | 26 ++++------- 3 files changed, 57 insertions(+), 49 deletions(-) -diff --git a/src/dolphinnavigatorswidgetaction.cpp b/src/dolphinnavigatorswidgetaction.cpp -index b8c77c69b..e534b9bb4 100644 ---- a/src/dolphinnavigatorswidgetaction.cpp -+++ b/src/dolphinnavigatorswidgetaction.cpp -@@ -53,31 +53,12 @@ void DolphinNavigatorsWidgetAction::createSecondaryUrlNavigator() +Index: dolphin-20.12.1/src/dolphinnavigatorswidgetaction.cpp +=================================================================== +--- dolphin-20.12.1.orig/src/dolphinnavigatorswidgetaction.cpp 2021-01-25 23:18:02.080476301 +0100 ++++ dolphin-20.12.1/src/dolphinnavigatorswidgetaction.cpp 2021-01-25 23:18:14.684426507 +0100 +@@ -57,31 +57,12 @@ updateText(); } @@ -50,7 +50,7 @@ index b8c77c69b..e534b9bb4 100644 adjustSpacing(); } -@@ -139,6 +120,7 @@ void DolphinNavigatorsWidgetAction::deleteWidget(QWidget *widget) +@@ -143,6 +124,7 @@ void DolphinNavigatorsWidgetAction::adjustSpacing() { @@ -58,8 +58,8 @@ index b8c77c69b..e534b9bb4 100644 Q_ASSERT(m_globalXOfSplitter != INT_MIN); Q_ASSERT(m_globalXOfPrimary != INT_MIN); Q_ASSERT(m_widthOfPrimary != INT_MIN); -@@ -262,6 +244,38 @@ QWidget *DolphinNavigatorsWidgetAction::spacing(Side side, Position position) co - return m_splitter->widget(sideIndex)->layout()->itemAt(2)->widget(); +@@ -323,6 +305,38 @@ + #endif } +void DolphinNavigatorsWidgetAction::updateCachedViewGeometry() @@ -97,28 +97,27 @@ index b8c77c69b..e534b9bb4 100644 void DolphinNavigatorsWidgetAction::updateText() { const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ? -diff --git a/src/dolphinnavigatorswidgetaction.h b/src/dolphinnavigatorswidgetaction.h -index bbd8cf127..32d52e5d1 100644 ---- a/src/dolphinnavigatorswidgetaction.h -+++ b/src/dolphinnavigatorswidgetaction.h -@@ -10,6 +10,7 @@ - +Index: dolphin-20.12.1/src/dolphinnavigatorswidgetaction.h +=================================================================== +--- dolphin-20.12.1.orig/src/dolphinnavigatorswidgetaction.h 2021-01-25 23:18:02.080476301 +0100 ++++ dolphin-20.12.1/src/dolphinnavigatorswidgetaction.h 2021-01-25 23:18:46.064299606 +0100 +@@ -11,6 +11,7 @@ #include "dolphinurlnavigator.h" + #include +#include #include #include #include -@@ -52,17 +53,12 @@ public: - */ +@@ -55,16 +56,11 @@ void createSecondaryUrlNavigator(); -- /** + /** - * Notify the primary UrlNavigator of changes in geometry of the ViewContainer it tries to be - * aligned with. Only call this method if there is no secondary UrlNavigator. - */ - void followViewContainerGeometry(int globalXOfPrimary, int widthOfPrimary); - /** +- /** * Notify this widget of changes in geometry of the ViewContainers it tries to be * aligned with. */ @@ -129,7 +128,7 @@ index bbd8cf127..32d52e5d1 100644 bool isInToolbar() const; -@@ -141,11 +137,19 @@ private: +@@ -159,12 +155,20 @@ */ QWidget *spacing(Side side, Position position) const; @@ -140,20 +139,21 @@ index bbd8cf127..32d52e5d1 100644 */ void updateText(); -+ /** + /** + * The viewContainers are only remembered for the adjustSpacing calculations. + */ + QPointer m_primaryViewContainer; + QPointer m_secondaryViewContainer; + - /** ++ /** * The defaultWidget() of this QWidgetAction. */ -diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp -index 138822cfd..d64c87d75 100644 ---- a/src/dolphintabpage.cpp -+++ b/src/dolphintabpage.cpp -@@ -167,7 +167,8 @@ void DolphinTabPage::connectNavigators(DolphinNavigatorsWidgetAction *navigators + std::unique_ptr m_splitter; +Index: dolphin-20.12.1/src/dolphintabpage.cpp +=================================================================== +--- dolphin-20.12.1.orig/src/dolphintabpage.cpp 2021-01-02 14:42:54.000000000 +0100 ++++ dolphin-20.12.1/src/dolphintabpage.cpp 2021-01-25 23:18:14.684426507 +0100 +@@ -167,7 +167,8 @@ auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator(); m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator); } @@ -163,7 +163,7 @@ index 138822cfd..d64c87d75 100644 } void DolphinTabPage::disconnectNavigators() -@@ -182,7 +183,12 @@ void DolphinTabPage::disconnectNavigators() +@@ -182,7 +183,12 @@ bool DolphinTabPage::eventFilter(QObject *watched, QEvent *event) { if (event->type() == QEvent::Resize && m_navigatorsWidget) { @@ -177,7 +177,7 @@ index 138822cfd..d64c87d75 100644 return false; } return QWidget::eventFilter(watched, event); -@@ -201,22 +207,6 @@ void DolphinTabPage::insertNavigatorsWidget(DolphinNavigatorsWidgetAction* navig +@@ -201,22 +207,6 @@ } } @@ -200,6 +200,3 @@ index 138822cfd..d64c87d75 100644 void DolphinTabPage::markUrlsAsSelected(const QList& urls) { m_primaryViewContainer->view()->markUrlsAsSelected(urls); --- -2.25.1 - diff --git a/dolphin.changes b/dolphin.changes index aa11ca1..c4bafad 100644 --- a/dolphin.changes +++ b/dolphin.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Jan 25 22:14:27 UTC 2021 - Luca Beltrame + +- Add upstream patch to properly show the network button in the + URL navigator (kde#431626): + - 0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch +- Refreshed patches: + - 0001-Update-cached-viewContainer-geometry-every-time-they.patch + ------------------------------------------------------------------- Tue Jan 5 12:24:43 UTC 2021 - Luca Beltrame diff --git a/dolphin.spec b/dolphin.spec index da49d19..7c1a987 100644 --- a/dolphin.spec +++ b/dolphin.spec @@ -31,7 +31,9 @@ Source: https://download.kde.org/stable/release-service/%{version}/src/% Source3: dolphinsu.desktop Patch0: dolphin-go_up.diff # PATCH-FIX-UPSTREAM -Patch1: 0001-Update-cached-viewContainer-geometry-every-time-they.patch +Patch1: 0001-Show-button-to-open-knetattach-inline-with-URL-nav-o.patch +# PATCH-FIX-UPSTREAM +Patch2: 0001-Update-cached-viewContainer-geometry-every-time-they.patch # PATCH-FIX-OPENSUSE Patch100: 0001-Revert-Disallow-executing-Dolphin-as-root-on-Linux.patch BuildRequires: extra-cmake-modules >= 1.6.0