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>
20 class KActionCollection
;
28 namespace SelectionMode
30 class BottomBarContentsContainer
;
33 * A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
35 * The Contents enum below gives a rough idea about the different states this bar might have.
36 * The bar is notified of various changes that make changing or updating the content worthwhile.
38 * The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
40 class BottomBar
: public QWidget
45 /** The different contents this bar can have. */
49 CopyToOtherViewContents
,
54 MoveToOtherViewContents
,
61 * @param actionCollection the collection this bar retrieves its actions from
62 * @param parent the parent widget. Typically a DolphinViewContainer
64 explicit BottomBar(KActionCollection
*actionCollection
, QWidget
*parent
);
67 * Plays a show or hide animation while changing visibility.
68 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
70 * This bar might also not show itself when setVisible(true), when context menu actions are supposed to be shown
71 * for the selected items but no items have been selected yet. In that case it will only show itself once items were selected.
72 * @see QWidget::setVisible()
74 void setVisible(bool visible
, Animated animated
);
75 using QWidget::setVisible
; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget.
77 void resetContents(Contents contents
);
78 Contents
contents() const;
80 /** @returns a width of 1 to make sure that this bar never causes side panels to shrink. */
81 QSize
sizeHint() const override
;
84 void slotSelectionChanged(const KFileItemList
&selection
, const QUrl
&baseUrl
);
86 /** Used to notify the m_selectionModeBottomBar that there is no other ViewContainer in the tab. */
87 void slotSplitTabDisabled();
91 * Forwards the errors from the KFileItemAction::error() used for contextual actions.
93 void error(const QString
&errorMessage
);
95 void leaveSelectionModeRequested();
98 /** Is installed on an internal widget to make sure that the height of the bar is adjusted to its contents. */
99 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
101 /** Adapts the way the contents of this bar are displayed based on the available width. */
102 void resizeEvent(QResizeEvent
*resizeEvent
) override
;
106 * Identical to SelectionModeBottomBar::setVisible() but doesn't change m_allowedToBeVisible.
107 * @see SelectionModeBottomBar::setVisible()
108 * @see m_allowedToBeVisible
110 void setVisibleInternal(bool visible
, Animated animated
);
113 /** The only direct child widget of this bar. */
114 QScrollArea
*m_scrollArea
;
115 /** The only direct grandchild of this bar. */
116 BottomBarContentsContainer
*m_contentsContainer
;
118 /** Remembers if this bar was setVisible(true) or setVisible(false) the last time.
119 * 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.
120 * @see SelectionModeBottomBar::setVisible() */
121 bool m_allowedToBeVisible
= false;
122 /// @see SelectionModeBottomBar::setVisible()
123 QPointer
<QPropertyAnimation
> m_heightAnimation
;
128 #endif // BOTTOMBAR_H