From a32f5721789776ced7d9a925defca953bdb6d3550dca1ccf4129a95763580ede Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Thu, 10 Dec 2020 21:30:32 +0000 Subject: [PATCH] Accepting request 854652 from home:Vogtinator:branches:KDE:Applications - Add patch to fix appearance on the first start (kde#429447): * 0001-Update-cached-viewContainer-geometry-every-time-they.patch OBS-URL: https://build.opensuse.org/request/show/854652 OBS-URL: https://build.opensuse.org/package/show/KDE:Applications/dolphin?expand=0&rev=234 --- ...ewContainer-geometry-every-time-they.patch | 205 ++++++++++++++++++ dolphin.changes | 6 + dolphin.spec | 4 +- 3 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 0001-Update-cached-viewContainer-geometry-every-time-they.patch diff --git a/0001-Update-cached-viewContainer-geometry-every-time-they.patch b/0001-Update-cached-viewContainer-geometry-every-time-they.patch new file mode 100644 index 0000000..cf2481f --- /dev/null +++ b/0001-Update-cached-viewContainer-geometry-every-time-they.patch @@ -0,0 +1,205 @@ +From 5c5198981e64a7ed5c60e24b43a043bac18d8a93 Mon Sep 17 00:00:00 2001 +From: Felix Ernst +Date: Fri, 27 Nov 2020 18:44:48 +0100 +Subject: [PATCH] Update cached viewContainer geometry every time they are used + +--- + src/dolphinnavigatorswidgetaction.cpp | 62 ++++++++++++++++----------- + src/dolphinnavigatorswidgetaction.h | 18 +++++--- + 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() + updateText(); + } + +-void DolphinNavigatorsWidgetAction::followViewContainerGeometry( +- int globalXOfPrimary, int widthOfPrimary) ++void DolphinNavigatorsWidgetAction::followViewContainersGeometry(QWidget *primaryViewContainer, ++ QWidget *secondaryViewContainer) + { +- followViewContainersGeometry(globalXOfPrimary, widthOfPrimary, INT_MIN, INT_MIN); +-} +- +-void DolphinNavigatorsWidgetAction::followViewContainersGeometry( +- int globalXOfPrimary, int widthOfPrimary, +- int globalXOfSecondary, int widthOfSecondary) +-{ +- if (QApplication::layoutDirection() == Qt::LeftToRight) { +- m_globalXOfSplitter = m_splitter->mapToGlobal(QPoint(0,0)).x(); +- m_globalXOfPrimary = globalXOfPrimary; +- m_globalXOfSecondary = globalXOfSecondary; +- } else { +- // When the direction is reversed, globalX does not change. +- // For the adjustSpacing() code to work we need globalX to measure from right to left +- // and to measure up to the rightmost point of a widget instead of the leftmost. +- m_globalXOfSplitter = (-1) * (m_splitter->mapToGlobal(QPoint(0,0)).x() + m_splitter->width()); +- m_globalXOfPrimary = (-1) * (globalXOfPrimary + widthOfPrimary); +- m_globalXOfSecondary = (globalXOfSecondary == INT_MIN) ? INT_MIN : +- (-1) * (globalXOfSecondary + widthOfSecondary); +- } +- m_widthOfPrimary = widthOfPrimary; +- m_widthOfSecondary = widthOfSecondary; ++ Q_CHECK_PTR(primaryViewContainer); ++ m_primaryViewContainer = primaryViewContainer; ++ m_secondaryViewContainer = secondaryViewContainer; + adjustSpacing(); + } + +@@ -139,6 +120,7 @@ void DolphinNavigatorsWidgetAction::deleteWidget(QWidget *widget) + + void DolphinNavigatorsWidgetAction::adjustSpacing() + { ++ updateCachedViewGeometry(); + 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(); + } + ++void DolphinNavigatorsWidgetAction::updateCachedViewGeometry() ++{ ++ Q_ASSERT(m_primaryViewContainer); ++ m_widthOfPrimary = m_primaryViewContainer->width(); ++ if (m_secondaryViewContainer) { ++ m_widthOfSecondary = m_secondaryViewContainer->width(); ++ } else { ++ m_widthOfSecondary = INT_MIN; ++ } ++ ++ const int globalXOfSplitter = m_splitter->mapToGlobal(QPoint(0,0)).x(); ++ const int globalXOfPrimary = m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x(); ++ int globalXOfSecondary = INT_MIN; ++ if (m_secondaryViewContainer) { ++ globalXOfSecondary = m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x(); ++ } ++ ++ if (QApplication::layoutDirection() == Qt::LeftToRight) { ++ m_globalXOfSplitter = globalXOfSplitter; ++ m_globalXOfPrimary = globalXOfPrimary; ++ m_globalXOfSecondary = globalXOfSecondary; ++ } else { ++ // When the direction is reversed, globalX does not change. ++ // For the adjustSpacing() code to work we need globalX to measure from right to left ++ // and to measure up to the rightmost point of a widget instead of the leftmost. ++ m_globalXOfSplitter = (-1) * (globalXOfSplitter + m_splitter->width()); ++ m_globalXOfPrimary = (-1) * (globalXOfPrimary + m_widthOfPrimary); ++ m_globalXOfSecondary = (globalXOfSecondary == INT_MIN) ? INT_MIN : ++ (-1) * (globalXOfSecondary + m_widthOfSecondary); ++ } ++} ++ + 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 @@ + + #include "dolphinurlnavigator.h" + ++#include + #include + #include + #include +@@ -52,17 +53,12 @@ public: + */ + 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. + */ +- void followViewContainersGeometry(int globalXOfPrimary, int widthOfPrimary, +- int globalXOfSecondary, int widthOfSecondary); ++ void followViewContainersGeometry(QWidget *primaryViewContainer, ++ QWidget *secondaryViewContainer = nullptr); + + bool isInToolbar() const; + +@@ -141,11 +137,19 @@ private: + */ + QWidget *spacing(Side side, Position position) const; + ++ void updateCachedViewGeometry(); ++ + /** + * Sets this action's text depending on the amount of visible UrlNavigators. + */ + 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 + auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator(); + m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator); + } +- resizeNavigators(); ++ m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, ++ m_secondaryViewContainer); + } + + void DolphinTabPage::disconnectNavigators() +@@ -182,7 +183,12 @@ void DolphinTabPage::disconnectNavigators() + bool DolphinTabPage::eventFilter(QObject *watched, QEvent *event) + { + if (event->type() == QEvent::Resize && m_navigatorsWidget) { +- resizeNavigators(); ++ if (!m_splitViewEnabled) { ++ m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer); ++ } else { ++ m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, ++ m_secondaryViewContainer); ++ } + return false; + } + return QWidget::eventFilter(watched, event); +@@ -201,22 +207,6 @@ void DolphinTabPage::insertNavigatorsWidget(DolphinNavigatorsWidgetAction* navig + } + } + +- +-void DolphinTabPage::resizeNavigators() const +-{ +- if (!m_splitViewEnabled) { +- m_navigatorsWidget->followViewContainerGeometry( +- m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x(), +- m_primaryViewContainer->width()); +- } else { +- m_navigatorsWidget->followViewContainersGeometry( +- m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x(), +- m_primaryViewContainer->width(), +- m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x(), +- m_secondaryViewContainer->width()); +- } +-} +- + void DolphinTabPage::markUrlsAsSelected(const QList& urls) + { + m_primaryViewContainer->view()->markUrlsAsSelected(urls); +-- +2.25.1 + diff --git a/dolphin.changes b/dolphin.changes index 4dd7f99..22b6323 100644 --- a/dolphin.changes +++ b/dolphin.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Dec 10 19:14:25 UTC 2020 - Fabian Vogt + +- Add patch to fix appearance on the first start (kde#429447): + * 0001-Update-cached-viewContainer-geometry-every-time-they.patch + ------------------------------------------------------------------- Sat Dec 5 23:15:24 UTC 2020 - Luca Beltrame diff --git a/dolphin.spec b/dolphin.spec index c319196..8154fa3 100644 --- a/dolphin.spec +++ b/dolphin.spec @@ -30,8 +30,10 @@ URL: https://www.kde.org Source: https://download.kde.org/stable/release-service/%{version}/src/%{name}-%{version}.tar.xz Source3: dolphinsu.desktop Patch0: dolphin-go_up.diff +# PATCH-FIX-UPSTREAM +Patch1: 0001-Update-cached-viewContainer-geometry-every-time-they.patch # PATCH-FIX-OPENSUSE -Patch1: 0001-Revert-Disallow-executing-Dolphin-as-root-on-Linux.patch +Patch100: 0001-Revert-Disallow-executing-Dolphin-as-root-on-Linux.patch BuildRequires: extra-cmake-modules >= 1.6.0 BuildRequires: systemd-rpm-macros BuildRequires: update-desktop-files