1/*
2 SPDX-FileCopyrightText: 2014 Montel Laurent <montel@kde.org>
3 based on code:
4 SPDX-FileCopyrightText: 2009 Aurélien Gâteau <agateau@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8#ifndef KSPLITTERCOLLAPSERBUTTON_H
9#define KSPLITTERCOLLAPSERBUTTON_H
10
11// Qt
12#include <QToolButton>
13#include <kwidgetsaddons_export.h>
14#include <memory>
15
16class QSplitter;
17
18/*!
19 * \class KSplitterCollapserButton
20 * \inmodule KWidgetsAddons
21 *
22 * \brief A button which appears on the side of a splitter handle and allows easy
23 * collapsing of the widget on the opposite side
24 * \since 5.5
25 */
26class KWIDGETSADDONS_EXPORT KSplitterCollapserButton : public QToolButton
27{
28 Q_OBJECT
29public:
30 /*!
31 * KSplitterCollapserButton create a splitter collapser
32 *
33 * \a childWidget the widget, child of the splitter, whose size is controlled by this collapser
34 *
35 * \a splitter the splitter which this collapser should be associated with.
36 */
37 explicit KSplitterCollapserButton(QWidget *childWidget, QSplitter *splitter);
38
39 ~KSplitterCollapserButton() override;
40
41 /*!
42 * Returns \c true if splitter is collapsed.
43 */
44 bool isWidgetCollapsed() const;
45
46 QSize sizeHint() const override;
47
48public Q_SLOTS:
49 /*!
50 * This function collapses the splitter if splitter is not collapsed.
51 */
52 void collapse();
53 /*!
54 * Call this function to restore previous splitter position.
55 */
56 void restore();
57 /*!
58 * This function allows to collapse or not the splitter.
59 *
60 * \a collapsed if the splitter should be collapsed
61 */
62 void setCollapsed(bool collapsed);
63
64private Q_SLOTS:
65 KWIDGETSADDONS_NO_EXPORT void slotClicked();
66
67protected:
68 bool eventFilter(QObject *, QEvent *) override;
69 void paintEvent(QPaintEvent *) override;
70 void enterEvent(QEnterEvent *event) override;
71 void leaveEvent(QEvent *event) override;
72 void showEvent(QShowEvent *event) override;
73
74private:
75 std::unique_ptr<class KSplitterCollapserButtonPrivate> const d;
76};
77
78#endif /* KSPLITTERCOLLAPSERBUTTON_H */
79

source code of kwidgetsaddons/src/ksplittercollapserbutton.h