/*
This file is part of the KDE project
- SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@zohomail.eu>
+ SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef BOTTOMBAR_H
#define BOTTOMBAR_H
+#include "animatedheightwidget.h"
#include "global.h"
#include <QAction>
#include <QPointer>
-#include <QPropertyAnimation>
-#include <QWidget>
-
-#include <memory>
class KActionCollection;
class KFileItemList;
-class QAction;
class QPushButton;
class QResizeEvent;
-class QScrollArea;
class QUrl;
namespace SelectionMode
{
- class BottomBarContentsContainer;
+class BottomBarContentsContainer;
/**
- * A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
+ * @brief A bar used in selection mode that serves various purposes depending on what the user is currently trying to do.
*
* The Contents enum below gives a rough idea about the different states this bar might have.
* The bar is notified of various changes that make changing or updating the content worthwhile.
*
* The visible contents of the bar are managed in BottomBarContentsContainer. This class serves as a wrapper around it.
*/
-class BottomBar : public QWidget
+class BottomBar : public AnimatedHeightWidget
{
Q_OBJECT
public:
/** The different contents this bar can have. */
- enum Contents{
+ enum Contents {
CopyContents,
CopyLocationContents,
CopyToOtherViewContents,
*
* This bar might also not show itself when setVisible(true), when context menu actions are supposed to be shown
* for the selected items but no items have been selected yet. In that case it will only show itself once items were selected.
+ *
+ * This bar might also ignore a setVisible(false) call, if it has PasteContents because that bar is supposed to stay visible
+ * even outside of selection mode.
+ *
+ * @param visible Whether this bar is supposed to be visible long term
+ * @param animated Whether this should be animated. The animation is skipped if the users' settings are configured that way.
+ *
+ * @see AnimatedHeightWidget::setVisible()
* @see QWidget::setVisible()
*/
void setVisible(bool visible, Animated animated);
- using QWidget::setVisible; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget.
+ /**
+ * Changes the contents of the bar to @p contents.
+ */
void resetContents(Contents contents);
Contents contents() const;
- /** @returns a width of 1 to make sure that this bar never causes side panels to shrink. */
- QSize sizeHint() const override;
-
public Q_SLOTS:
+ /** Adapts the contents based on the selection in the related view. */
void slotSelectionChanged(const KFileItemList &selection, const QUrl &baseUrl);
/** Used to notify the m_selectionModeBottomBar that there is no other ViewContainer in the tab. */
*/
void error(const QString &errorMessage);
- void leaveSelectionModeRequested();
+ void selectionModeLeavingRequested();
protected:
/** Is installed on an internal widget to make sure that the height of the bar is adjusted to its contents. */
*/
void setVisibleInternal(bool visible, Animated animated);
+ /** @see AnimatedHeightWidget::preferredHeight() */
+ int preferredHeight() const override;
+
private:
- /** The only direct child widget of this bar. */
- QScrollArea *m_scrollArea;
/** The only direct grandchild of this bar. */
BottomBarContentsContainer *m_contentsContainer;
* 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.
* @see SelectionModeBottomBar::setVisible() */
bool m_allowedToBeVisible = false;
- /// @see SelectionModeBottomBar::setVisible()
- QPointer<QPropertyAnimation> m_heightAnimation;
};
}