2020-12-10 21:30:32 +00:00
|
|
|
From 5c5198981e64a7ed5c60e24b43a043bac18d8a93 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Felix Ernst <fe.a.ernst@gmail.com>
|
|
|
|
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(-)
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
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 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -143,6 +124,7 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
|
|
|
|
void DolphinNavigatorsWidgetAction::adjustSpacing()
|
|
|
|
{
|
|
|
|
+ updateCachedViewGeometry();
|
|
|
|
Q_ASSERT(m_globalXOfSplitter != INT_MIN);
|
|
|
|
Q_ASSERT(m_globalXOfPrimary != INT_MIN);
|
|
|
|
Q_ASSERT(m_widthOfPrimary != INT_MIN);
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -323,6 +305,38 @@
|
|
|
|
#endif
|
2020-12-10 21:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+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() ?
|
2021-01-26 15:53:28 +00:00
|
|
|
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 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
#include "dolphinurlnavigator.h"
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
#include <kio_version.h>
|
2020-12-10 21:30:32 +00:00
|
|
|
+#include <QPointer>
|
|
|
|
#include <QSplitter>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidgetAction>
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -55,16 +56,11 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
void createSecondaryUrlNavigator();
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
/**
|
2020-12-10 21:30:32 +00:00
|
|
|
- * 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);
|
2021-01-26 15:53:28 +00:00
|
|
|
- /**
|
2020-12-10 21:30:32 +00:00
|
|
|
* 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;
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -159,12 +155,20 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
*/
|
|
|
|
QWidget *spacing(Side side, Position position) const;
|
|
|
|
|
|
|
|
+ void updateCachedViewGeometry();
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* Sets this action's text depending on the amount of visible UrlNavigators.
|
|
|
|
*/
|
|
|
|
void updateText();
|
|
|
|
|
2021-01-26 15:53:28 +00:00
|
|
|
/**
|
2020-12-10 21:30:32 +00:00
|
|
|
+ * The viewContainers are only remembered for the adjustSpacing calculations.
|
|
|
|
+ */
|
|
|
|
+ QPointer<const QWidget> m_primaryViewContainer;
|
|
|
|
+ QPointer<const QWidget> m_secondaryViewContainer;
|
|
|
|
+
|
2021-01-26 15:53:28 +00:00
|
|
|
+ /**
|
2020-12-10 21:30:32 +00:00
|
|
|
* The defaultWidget() of this QWidgetAction.
|
|
|
|
*/
|
2021-01-26 15:53:28 +00:00
|
|
|
std::unique_ptr<QSplitter> 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 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator();
|
|
|
|
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
|
|
|
|
}
|
|
|
|
- resizeNavigators();
|
|
|
|
+ m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer,
|
|
|
|
+ m_secondaryViewContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinTabPage::disconnectNavigators()
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -182,7 +183,12 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
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);
|
2021-01-26 15:53:28 +00:00
|
|
|
@@ -201,22 +207,6 @@
|
2020-12-10 21:30:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
-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<QUrl>& urls)
|
|
|
|
{
|
|
|
|
m_primaryViewContainer->view()->markUrlsAsSelected(urls);
|