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
;
26 namespace SelectionMode
28 class BottomBarContentsContainer
;
31 * @brief A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
33 * The Contents enum below gives a rough idea about the different states this bar might have.
34 * The bar is notified of various changes that make changing or updating the content worthwhile.
36 * The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
38 class BottomBar
: public QWidget
43 /** The different contents this bar can have. */
47 CopyToOtherViewContents
,
52 MoveToOtherViewContents
,
59 * @param actionCollection the collection this bar retrieves its actions from
60 * @param parent the parent widget. Typically a DolphinViewContainer
62 explicit BottomBar(KActionCollection
*actionCollection
, QWidget
*parent
);
65 * Plays a show or hide animation while changing visibility.
66 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
68 * This bar might also not show itself when setVisible(true), when context menu actions are supposed to be shown
69 * for the selected items but no items have been selected yet. In that case it will only show itself once items were selected.
71 * This bar might also ignore a setVisible(false) call, if it has PasteContents because that bar is supposed to stay visible
72 * even outside of selection mode.
74 * @param visible Whether this bar is supposed to be visible long term
75 * @param animated Whether this should be animated. The animation is skipped if the users' settings are configured that way.
77 * @see QWidget::setVisible()
79 void setVisible(bool visible
, Animated animated
);
82 * Changes the contents of the bar to @p contents.
84 void resetContents(Contents contents
);
85 Contents
contents() const;
87 /** @returns a width of 1 to make sure that this bar never causes side panels to shrink. */
88 QSize
sizeHint() const override
;
91 /** Adapts the contents based on the selection in the related view. */
92 void slotSelectionChanged(const KFileItemList
&selection
, const QUrl
&baseUrl
);
94 /** Used to notify the m_selectionModeBottomBar that there is no other ViewContainer in the tab. */
95 void slotSplitTabDisabled();
99 * Forwards the errors from the KFileItemAction::error() used for contextual actions.
101 void error(const QString
&errorMessage
);
103 void leaveSelectionModeRequested();
106 /** Is installed on an internal widget to make sure that the height of the bar is adjusted to its contents. */
107 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
109 /** Adapts the way the contents of this bar are displayed based on the available width. */
110 void resizeEvent(QResizeEvent
*resizeEvent
) override
;
113 using QWidget::setVisible
; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget so we can still use it privately.
116 * Identical to SelectionModeBottomBar::setVisible() but doesn't change m_allowedToBeVisible.
117 * @see SelectionModeBottomBar::setVisible()
118 * @see m_allowedToBeVisible
120 void setVisibleInternal(bool visible
, Animated animated
);
123 /** The only direct child widget of this bar. */
124 QScrollArea
*m_scrollArea
;
125 /** The only direct grandchild of this bar. */
126 BottomBarContentsContainer
*m_contentsContainer
;
128 /** Remembers if this bar was setVisible(true) or setVisible(false) the last time.
129 * 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.
130 * @see SelectionModeBottomBar::setVisible() */
131 bool m_allowedToBeVisible
= false;
132 /** @see SelectionModeBottomBar::setVisible() */
133 QPointer
<QPropertyAnimation
> m_heightAnimation
;
138 #endif // BOTTOMBAR_H