blob: 029d2716e25e5afaf53ae2dcf6b3a242843f9cd8 (
plain)
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
|
//===========================================
// Lumina-DE source code
// Copyright (c) 2012-2016, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#ifndef _LUMINA_LIBRARY_RESIZE_MENU_H
#define _LUMINA_LIBRARY_RESIZE_MENU_H
#include <QMenu>
#include <QWidget>
#include <QMouseEvent>
#include <QAction>
#include <QWidgetAction>
#include <QRect>
#include <QCursor>
#include <QPoint>
//Special subclass for a menu which the user can grab the edges and resize as necessary
// Note: Make sure that you don't set 0pixel contents margins on this menu
// - it needs at least 1 pixel margins for the user to be able to grab it
class ResizeMenu : public QMenu{
Q_OBJECT
public:
ResizeMenu(QWidget *parent = 0);
virtual ~ResizeMenu();
void setContents(QWidget *con);
void resyncSize();
private:
enum SideFlag{NONE, TOP, BOTTOM, LEFT, RIGHT};
SideFlag resizeSide;
QWidget *contents;
QWidgetAction *cAct;
private slots:
void clearFlags(){
resizeSide=NONE;
}
protected:
virtual void mouseMoveEvent(QMouseEvent *ev);
virtual void mousePressEvent(QMouseEvent *ev);
virtual void mouseReleaseEvent(QMouseEvent *ev);
signals:
void MenuResized(QSize); //Emitted when the menu is manually resized by the user
};
#endif
|