2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@kde.org>
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
11 #include "animatedheightwidget.h"
17 class KActionCollection
;
23 namespace SelectionMode
25 class BottomBarContentsContainer
;
28 * @brief A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
30 * The Contents enum below gives a rough idea about the different states this bar might have.
31 * The bar is notified of various changes that make changing or updating the content worthwhile.
33 * The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
35 class BottomBar
: public AnimatedHeightWidget
40 /** The different contents this bar can have. */
44 CopyToOtherViewContents
,
49 MoveToOtherViewContents
,
56 * @param actionCollection the collection this bar retrieves its actions from
57 * @param parent the parent widget. Typically a DolphinViewContainer
59 explicit BottomBar(KActionCollection
*actionCollection
, QWidget
*parent
);
62 * Plays a show or hide animation while changing visibility.
63 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
65 * This bar might also not show itself when setVisible(true), when context menu actions are supposed to be shown
66 * for the selected items but no items have been selected yet. In that case it will only show itself once items were selected.
68 * This bar might also ignore a setVisible(false) call, if it has PasteContents because that bar is supposed to stay visible
69 * even outside of selection mode.
71 * @param visible Whether this bar is supposed to be visible long term
72 * @param animated Whether this should be animated. The animation is skipped if the users' settings are configured that way.
74 * @see AnimatedHeightWidget::setVisible()
75 * @see QWidget::setVisible()
77 void setVisible(bool visible
, Animated animated
);
80 * Changes the contents of the bar to @p contents.
82 void resetContents(Contents contents
);
83 Contents
contents() const;
86 /** Adapts the contents based on the selection in the related view. */
87 void slotSelectionChanged(const KFileItemList
&selection
, const QUrl
&baseUrl
);
89 /** Used to notify the m_selectionModeBottomBar that there is no other ViewContainer in the tab. */
90 void slotSplitTabDisabled();
94 * Forwards the errors from the KFileItemAction::error() used for contextual actions.
96 void error(const QString
&errorMessage
);
98 void selectionModeLeavingRequested();
101 /** Is installed on an internal widget to make sure that the height of the bar is adjusted to its contents. */
102 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
104 /** Adapts the way the contents of this bar are displayed based on the available width. */
105 void resizeEvent(QResizeEvent
*resizeEvent
) override
;
109 * Identical to SelectionModeBottomBar::setVisible() but doesn't change m_allowedToBeVisible.
110 * @see SelectionModeBottomBar::setVisible()
111 * @see m_allowedToBeVisible
113 void setVisibleInternal(bool visible
, Animated animated
);
115 /** @see AnimatedHeightWidget::preferredHeight() */
116 int preferredHeight() const override
;
119 /** The only direct grandchild of this bar. */
120 BottomBarContentsContainer
*m_contentsContainer
;
122 /** Remembers if this bar was setVisible(true) or setVisible(false) the last time.
123 * 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.
124 * @see SelectionModeBottomBar::setVisible() */
125 bool m_allowedToBeVisible
= false;
130 #endif // BOTTOMBAR_H