File indexing completed on 2024-04-21 08:48:25

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Urs Wolfer <uwolfer@kde.org>
0003     Parts of this file have been take from okular:
0004     SPDX-FileCopyrightText: 2004-2005 Enrico Ros <eros.kde@email.it>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef FLOATINGTOOLBAR_H
0010 #define FLOATINGTOOLBAR_H
0011 
0012 #include <QToolBar>
0013 
0014 /**
0015  * @short A toolbar widget that slides in from a side.
0016  *
0017  * This is a shaped widget that slides in from a side of the 'anchor widget'
0018  * it's attached to. It can be dragged and docked on {left,top,right,bottom}
0019  * sides and contains actions.
0020  */
0021 class FloatingToolBar : public QToolBar
0022 {
0023     Q_OBJECT
0024 public:
0025     FloatingToolBar(QWidget *parent, QWidget *anchorWidget);
0026     ~FloatingToolBar() override;
0027 
0028     enum Side { Left = 0, Top = 1, Right = 2, Bottom = 3 };
0029     Q_ENUM(Side)
0030 
0031     void addAction(QAction *action);
0032     void setSide(Side side);
0033 
0034 Q_SIGNALS:
0035     void orientationChanged(int side);
0036 
0037 public Q_SLOTS:
0038     void setSticky(bool sticky);
0039     void showAndAnimate();
0040     void hideAndDestroy();
0041 
0042 protected:
0043     bool eventFilter(QObject *o, QEvent *e) override;
0044     void paintEvent(QPaintEvent *) override;
0045     void mousePressEvent(QMouseEvent *e) override;
0046     void mouseMoveEvent(QMouseEvent *e) override;
0047 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0048     void enterEvent(QEnterEvent *event) override;
0049 #else
0050     void enterEvent(QEvent*) override;
0051 #endif
0052     void leaveEvent(QEvent *e) override;
0053     void mouseReleaseEvent(QMouseEvent *e) override;
0054     void wheelEvent(QWheelEvent *e) override;
0055 
0056 private:
0057     class FloatingToolBarPrivate *d;
0058 
0059 private Q_SLOTS:
0060     void animate();
0061     void hide();
0062 };
0063 
0064 #endif