File indexing completed on 2025-04-27 04:37:42
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 { 0029 Left = 0, 0030 Top = 1, 0031 Right = 2, 0032 Bottom = 3, 0033 }; 0034 Q_ENUM(Side) 0035 0036 void addAction(QAction *action); 0037 void setSide(Side side); 0038 0039 Q_SIGNALS: 0040 void orientationChanged(int side); 0041 0042 public Q_SLOTS: 0043 void setSticky(bool sticky); 0044 void showAndAnimate(); 0045 void hideAndDestroy(); 0046 0047 protected: 0048 bool eventFilter(QObject *o, QEvent *e) override; 0049 void paintEvent(QPaintEvent *) override; 0050 void mousePressEvent(QMouseEvent *e) override; 0051 void mouseMoveEvent(QMouseEvent *e) override; 0052 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 0053 void enterEvent(QEnterEvent *event) override; 0054 #else 0055 void enterEvent(QEvent *) override; 0056 #endif 0057 void leaveEvent(QEvent *e) override; 0058 void mouseReleaseEvent(QMouseEvent *e) override; 0059 void wheelEvent(QWheelEvent *e) override; 0060 0061 private: 0062 class FloatingToolBarPrivate *d; 0063 0064 private Q_SLOTS: 0065 void animate(); 0066 void hide(); 0067 }; 0068 0069 #endif