┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/selectionmodetopbar.h
blob: eb26a5c26ad03f3c4c4ea08b4e38dc76b7924b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
    This file is part of the KDE project
    SPDX-FileCopyrightText: 2022 Felix Ernst <[email protected]>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#ifndef SELECTIONMODETOPBAR_H
#define SELECTIONMODETOPBAR_H

#include "global.h"

#include <QPointer>
#include <QPropertyAnimation>
#include <QStyle>
#include <QWidget>

class QHideEvent;
class QLabel;
class QPushButton;
class QResizeEvent;
class QShowEvent;

/**
 * @todo write docs
 */
class SelectionModeTopBar : public QWidget
{
    Q_OBJECT

public:
    SelectionModeTopBar(QWidget *parent);

    /**
     * Plays a show or hide animation while changing visibility.
     * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
     * @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.

Q_SIGNALS:
    void leaveSelectionModeRequested();

protected:
    void resizeEvent(QResizeEvent */* resizeEvent */) override;

private:
    /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
    void updateLabelString();

private:
    QLabel *m_label;
    QPushButton *m_closeButton;

    /** @see updateLabelString() */
    QString m_fullLabelString;
    /** @see updateLabelString() */
    QString m_shortLabelString;

    int m_preferredHeight;

    QPointer<QPropertyAnimation> m_heightAnimation;
};

#endif // SELECTIONMODETOPBAR_H