┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/topbar.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/topbar.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/topbar.h')
-rw-r--r--src/selectionmode/topbar.h27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/selectionmode/topbar.h b/src/selectionmode/topbar.h
index 028fc4985..1f9cfdb18 100644
--- a/src/selectionmode/topbar.h
+++ b/src/selectionmode/topbar.h
@@ -8,17 +8,11 @@
#ifndef SELECTIONMODETOPBAR_H
#define SELECTIONMODETOPBAR_H
-#include "global.h"
+#include "animatedheightwidget.h"
-#include <QPointer>
-#include <QPropertyAnimation>
-#include <QWidget>
-
-class QHideEvent;
class QLabel;
class QPushButton;
class QResizeEvent;
-class QShowEvent;
namespace SelectionMode
{
@@ -26,20 +20,13 @@ namespace SelectionMode
/**
* @brief A bar appearing at the top of the view when in selection mode to make users aware of the selection mode state of the application.
*/
-class TopBar : public QWidget
+class TopBar : public AnimatedHeightWidget
{
Q_OBJECT
public:
TopBar(QWidget *parent);
- /**
- * Plays a show or hide animation while changing visibility.
- * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
- * @see QWidget::setVisible()
- */
- void setVisible(bool visible, Animated animated);
-
Q_SIGNALS:
void selectionModeLeavingRequested();
@@ -48,11 +35,15 @@ 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.
-
/** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
void updateLabelString();
+ /** @see AnimatedHeightWidget::preferredHeight() */
+ inline int preferredHeight() const override
+ {
+ return m_preferredHeight;
+ };
+
private:
QLabel *m_label;
QPushButton *m_closeButton;
@@ -63,8 +54,6 @@ private:
QString m_shortLabelString;
int m_preferredHeight;
-
- QPointer<QPropertyAnimation> m_heightAnimation;
};
}