+ /**
+ * Extracts the geometry information needed by adjustSpacing() from
+ * ViewContainers. They are also monitored for size changes which
+ * will lead to adjustSpacing() calls.
+ */
+ class ViewGeometriesHelper : public QObject
+ {
+ public:
+ /**
+ * @param navigatorsWidget The QWidget of the navigatorsWidgetAction.
+ * @param navigatorsWidgetAction is only used to call adjustSpacing() whenever that is
+ * deemed necessary.
+ */
+ ViewGeometriesHelper(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction);
+
+ /**
+ * Calls m_navigatorsWidgetAction::adjustSpacing() when a watched object is resized.
+ */
+ bool eventFilter(QObject *watched, QEvent *event) override;
+
+ /**
+ * Sets the ViewContainers whose geometry is obtained when viewGeometries() is called.
+ */
+ void setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer = nullptr);
+
+ struct Geometries {
+ int globalXOfNavigatorsWidget;
+ int globalXOfPrimary;
+ int widthOfPrimary;
+ int globalXOfSecondary;
+ int widthOfSecondary;
+ };
+ /**
+ * @return a Geometries struct that contains values adjustSpacing() requires.
+ */
+ Geometries viewGeometries();
+
+ private:
+ QWidget *m_navigatorsWidget;
+ /** Is only used to call adjustSpacing() whenever that is deemed necessary. */
+ DolphinNavigatorsWidgetAction *m_navigatorsWidgetAction;
+
+ QPointer<QWidget> m_primaryViewContainer;
+ QPointer<QWidget> m_secondaryViewContainer;
+ };
+
+ ViewGeometriesHelper m_viewGeometriesHelper;
+
+ /**
+ * Used to check if the window has been resized.
+ * @see ViewGeometriesHelper::eventFilter() for why this is needed.
+ */
+ int m_previousWindowWidth = -1;