2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@zohomail.eu>
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
15 #include <QPropertyAnimation>
18 class KActionCollection
;
25 namespace SelectionMode
27 class BottomBarContentsContainer
;
30 * @brief A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
32 * The Contents enum below gives a rough idea about the different states this bar might have.
33 * The bar is notified of various changes that make changing or updating the content worthwhile.
35 * The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
37 class BottomBar
: public QWidget
42 /** The different contents this bar can have. */
46 CopyToOtherViewContents
,
51 MoveToOtherViewContents
,
58 * @param actionCollection the collection this bar retrieves its actions from
59 * @param parent the parent widget. Typically a DolphinViewContainer
61 explicit BottomBar(KActionCollection
*actionCollection
, QWidget
*parent
);
64 * Plays a show or hide animation while changing visibility.
65 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
67 * This bar might also not show itself when setVisible(true), when context menu actions are supposed to be shown
68 * for the selected items but no items have been selected yet. In that case it will only show itself once items were selected.
70 * This bar might also ignore a setVisible(false) call, if it has PasteContents because that bar is supposed to stay visible
71 * even outside of selection mode.
73 * @param visible Whether this bar is supposed to be visible long term
74 * @param animated Whether this should be animated. The animation is skipped if the users' settings are configured that way.
76 * @see QWidget::setVisible()
78 void setVisible(bool visible
, Animated animated
);
81 * Changes the contents of the bar to @p contents.
83 void resetContents(Contents contents
);
84 Contents
contents() const;
86 /** @returns a width of 1 to make sure that this bar never causes side panels to shrink. */
87 QSize
sizeHint() const override
;
90 /** Adapts the contents based on the selection in the related view. */
91 void slotSelectionChanged(const KFileItemList
&selection
, const QUrl
&baseUrl
);
93 /** Used to notify the m_selectionModeBottomBar that there is no other ViewContainer in the tab. */
94 void slotSplitTabDisabled();
98 * Forwards the errors from the KFileItemAction::error() used for contextual actions.
100 void error(const QString
&errorMessage
);
102 void selectionModeLeavingRequested();
105 /** Is installed on an internal widget to make sure that the height of the bar is adjusted to its contents. */
106 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
108 /** Adapts the way the contents of this bar are displayed based on the available width. */
109 void resizeEvent(QResizeEvent
*resizeEvent
) override
;
112 using QWidget::setVisible
; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget so we can still use it privately.
115 * Identical to SelectionModeBottomBar::setVisible() but doesn't change m_allowedToBeVisible.
116 * @see SelectionModeBottomBar::setVisible()
117 * @see m_allowedToBeVisible
119 void setVisibleInternal(bool visible
, Animated animated
);
122 /** The only direct child widget of this bar. */
123 QScrollArea
*m_scrollArea
;
124 /** The only direct grandchild of this bar. */
125 BottomBarContentsContainer
*m_contentsContainer
;
127 /** Remembers if this bar was setVisible(true) or setVisible(false) the last time.
128 * 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.
129 * @see SelectionModeBottomBar::setVisible() */
130 bool m_allowedToBeVisible
= false;
131 /** @see SelectionModeBottomBar::setVisible() */
132 QPointer
<QPropertyAnimation
> m_heightAnimation
;
137 #endif // BOTTOMBAR_H