]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/toolbar.hpp
Qt: support for drag n dropping widget, removall and many other improvements.
[vlc] / modules / gui / qt4 / dialogs / toolbar.hpp
1 /*****************************************************************************
2  * ToolbarEdit.hpp : ToolbarEdit dialogs
3  ****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _TOOLBAREDIT_DIALOG_H_
25 #define _TOOLBAREDIT_DIALOG_H_
26
27 #include "util/qvlcframe.hpp"
28 #include "components/controller.hpp"
29
30 #include <QRubberBand>
31 #include <QListWidget>
32 #include <QCheckBox>
33
34 class ToolbarEditDialog;
35 class DroppingController;
36 class QCheckBox;
37
38 class WidgetListing : public QListWidget
39 {
40     Q_OBJECT;
41 public:
42     WidgetListing( intf_thread_t *, QWidget *_parent = 0 );
43 protected:
44     virtual void startDrag( Qt::DropActions /*supportedActions*/ );
45 private:
46     ToolbarEditDialog *parent;
47 };
48
49 class ToolbarEditDialog : public QVLCFrame
50 {
51     Q_OBJECT;
52 public:
53     static ToolbarEditDialog * getInstance( intf_thread_t *p_intf )
54     {
55         if( !instance)
56             instance = new ToolbarEditDialog( p_intf );
57         return instance;
58     }
59     virtual ~ToolbarEditDialog();
60     int getOptions() { return flatBox->isChecked() * WIDGET_FLAT +
61                         bigBox->isChecked() * WIDGET_BIG +
62                         shinyBox->isChecked() * WIDGET_SHINY; }
63 private:
64     ToolbarEditDialog( intf_thread_t * );
65     static ToolbarEditDialog *instance;
66
67     QCheckBox *flatBox, *bigBox, *shinyBox;
68
69     WidgetListing *widgetListing;
70     DroppingController *controller1, *controller2, *controllerA;
71     DroppingController *controllerFSC, *controller;
72
73 private slots:
74     void cancel();
75     void close();
76 };
77
78 class DroppingController: public AbstractController
79 {
80     Q_OBJECT;
81 public:
82     DroppingController( intf_thread_t *, QString line, QWidget *parent = 0 );
83     QString getValue();
84     virtual ~DroppingController();
85
86 protected:
87     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
88             buttonType_e i_type, int i_option );
89     virtual void dragEnterEvent ( QDragEnterEvent * event );
90     virtual void dragMoveEvent(QDragMoveEvent *event);
91     virtual void dropEvent ( QDropEvent * event );
92     virtual void dragLeaveEvent ( QDragLeaveEvent * event );
93
94     virtual void doAction( int );
95
96     bool eventFilter( QObject *, QEvent * );
97 private:
98     struct doubleInt
99     {
100         int i_type;
101         int i_option;
102     };
103     QRubberBand *rubberband;
104     QList <doubleInt *> widgetList;
105
106     int getParentPosInLayout( QPoint point);
107
108     bool b_draging;
109
110 };
111
112 #endif
113