summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/widgetresizer.h
blob: 29e380b8d89c8ad9e81644b804289ba124dde16d (plain) (blame)
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
#ifndef WIDGETRESIZER_H
#define WIDGETRESIZER_H

#include "guiSQLiteStudio_global.h"
#include <QWidget>

class GUI_API_EXPORT WidgetResizer : public QWidget
{
        Q_OBJECT
    public:
        explicit WidgetResizer(const Qt::Orientation& orientation, QWidget *parent = 0);
        explicit WidgetResizer(QWidget *parent = 0);
        ~WidgetResizer();

        Qt::Orientation getOrientation() const;
        void setOrientation(const Qt::Orientation& value);

        int getWidth() const;
        void setWidth(int value);

        QWidget* getWidget() const;
        void setWidget(QWidget* value);

        QSize getWidgetMinimumSize() const;
        void setWidgetMinimumSize(const QSize& value);
        void setWidgetMinimumSize(int width, int height);

    protected:
        void mouseMoveEvent(QMouseEvent* event);
        void mousePressEvent(QMouseEvent* event);

    private:
        void init();
        void updateCursor();
        void updateWidth();
        void handleHorizontalMove(int position);
        void handleVerticalMove(int position);

        Qt::Orientation orientation = Qt::Vertical;
        int width = 4;
        QWidget* widget = nullptr;
        QPoint dragStartPosition;
        QSize dragStartSize;
        QSize widgetMinimumSize;
};

#endif // WIDGETRESIZER_H