File: floatingtoolbar.h

package info (click to toggle)
krdc 4%3A22.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,240 kB
  • sloc: cpp: 6,392; xml: 135; makefile: 8; sh: 5
file content (64 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download
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
/*
    SPDX-FileCopyrightText: 2007-2008 Urs Wolfer <uwolfer@kde.org>
    Parts of this file have been take from okular:
    SPDX-FileCopyrightText: 2004-2005 Enrico Ros <eros.kde@email.it>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef FLOATINGTOOLBAR_H
#define FLOATINGTOOLBAR_H

#include <QToolBar>

/**
 * @short A toolbar widget that slides in from a side.
 *
 * This is a shaped widget that slides in from a side of the 'anchor widget'
 * it's attached to. It can be dragged and docked on {left,top,right,bottom}
 * sides and contains actions.
 */
class FloatingToolBar : public QToolBar
{
    Q_OBJECT
public:
    FloatingToolBar(QWidget *parent, QWidget *anchorWidget);
    ~FloatingToolBar() override;

    enum Side { Left = 0, Top = 1, Right = 2, Bottom = 3 };
    Q_ENUM(Side)

    void addAction(QAction *action);
    void setSide(Side side);

Q_SIGNALS:
    void orientationChanged(int side);

public Q_SLOTS:
    void setSticky(bool sticky);
    void showAndAnimate();
    void hideAndDestroy();

protected:
    bool eventFilter(QObject *o, QEvent *e) override;
    void paintEvent(QPaintEvent *) override;
    void mousePressEvent(QMouseEvent *e) override;
    void mouseMoveEvent(QMouseEvent *e) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    void enterEvent(QEnterEvent *event) override;
#else
    void enterEvent(QEvent*) override;
#endif
    void leaveEvent(QEvent *e) override;
    void mouseReleaseEvent(QMouseEvent *e) override;
    void wheelEvent(QWheelEvent *e) override;

private:
    class FloatingToolBarPrivate *d;

private Q_SLOTS:
    void animate();
    void hide();
};

#endif