┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/bottombar.h
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2024-03-13 15:39:00 +0000
committerFelix Ernst <[email protected]>2024-03-13 15:39:00 +0000
commitf588a7d48b7cef5351d8b0f030a6ec5e76229976 (patch)
tree086c0743d3dd63e5ca11cd84e55b527f58cbe5ea /src/selectionmode/bottombar.h
parent73ea5fd8450cdd097a47ede9d740cbbcf9f9df10 (diff)
Animate most of the bars
When a bar is toggled visible this usually happens because the user might want to use its functionality now. However, if bars appear without animation or at a location the user is not currently looking at, they might not notice that they have appeared at all. An animation makes it more likely that the user notices the change and can then use the newly made visible component. Another reason for animations for showing or hiding of components is that it can be disorienting for users when panels or bars suddenly appear or disappear without animation. There is no visible movement then, so the user might not know what happened if they didn't concentrate or blink at that moment. The newly appearing or disappearing component might also displace other components which can make it difficult to find what one was just looking at. These bars animate now after this change: - Search panel - Filter bar - Status bar This is implemented by extracting the animation code from SelectionMode::TopBar into a new abstract base class AnimatedHeightWidget. This class is now also used in SelectionMode::BottomBar and the animating code there was removed. These bars are left in Dolphin that stay without animation: - Menu bar (Would probably need to be implemented in KXmlGui) - Tool bar (Would probably need to be implemented in KXmlGui) - Tab bar (Needs a different appraoch because it already inherits QTabBar and therefore can not inherit AnimatedHeightWidget)
Diffstat (limited to 'src/selectionmode/bottombar.h')
-rw-r--r--src/selectionmode/bottombar.h19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/selectionmode/bottombar.h b/src/selectionmode/bottombar.h
index fd6eaebd9..73515b0bd 100644
--- a/src/selectionmode/bottombar.h
+++ b/src/selectionmode/bottombar.h
@@ -8,18 +8,16 @@
#ifndef BOTTOMBAR_H
#define BOTTOMBAR_H
+#include "animatedheightwidget.h"
#include "global.h"
#include <QAction>
#include <QPointer>
-#include <QPropertyAnimation>
-#include <QWidget>
class KActionCollection;
class KFileItemList;
class QPushButton;
class QResizeEvent;
-class QScrollArea;
class QUrl;
namespace SelectionMode
@@ -34,7 +32,7 @@ class BottomBarContentsContainer;
*
* The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
*/
-class BottomBar : public QWidget
+class BottomBar : public AnimatedHeightWidget
{
Q_OBJECT
@@ -73,6 +71,7 @@ public:
* @param visible Whether this bar is supposed to be visible long term
* @param animated Whether this should be animated. The animation is skipped if the users' settings are configured that way.
*
+ * @see AnimatedHeightWidget::setVisible()
* @see QWidget::setVisible()
*/
void setVisible(bool visible, Animated animated);
@@ -83,9 +82,6 @@ public:
void resetContents(Contents contents);
Contents contents() const;
- /** @returns a width of 1 to make sure that this bar never causes side panels to shrink. */
- QSize sizeHint() const override;
-
public Q_SLOTS:
/** Adapts the contents based on the selection in the related view. */
void slotSelectionChanged(const KFileItemList &selection, const QUrl &baseUrl);
@@ -109,8 +105,6 @@ protected:
void resizeEvent(QResizeEvent *resizeEvent) override;
private:
- using QWidget::setVisible; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget so we can still use it privately.
-
/**
* Identical to SelectionModeBottomBar::setVisible() but doesn't change m_allowedToBeVisible.
* @see SelectionModeBottomBar::setVisible()
@@ -118,9 +112,10 @@ private:
*/
void setVisibleInternal(bool visible, Animated animated);
+ /** @see AnimatedHeightWidget::preferredHeight() */
+ int preferredHeight() const override;
+
private:
- /** The only direct child widget of this bar. */
- QScrollArea *m_scrollArea;
/** The only direct grandchild of this bar. */
BottomBarContentsContainer *m_contentsContainer;
@@ -128,8 +123,6 @@ private:
* This is necessary because this bar might have been setVisible(true) but there is no reason to show the bar currently so it was kept hidden.
* @see SelectionModeBottomBar::setVisible() */
bool m_allowedToBeVisible = false;
- /** @see SelectionModeBottomBar::setVisible() */
- QPointer<QPropertyAnimation> m_heightAnimation;
};
}