]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/toolbar.hpp
Qt: profiles for the interface toolbar edition
[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 class QComboBox;
38
39 class WidgetListing : public QListWidget
40 {
41     Q_OBJECT;
42 public:
43     WidgetListing( intf_thread_t *, QWidget *_parent = 0 );
44 protected:
45     virtual void startDrag( Qt::DropActions /*supportedActions*/ );
46 private:
47     ToolbarEditDialog *parent;
48 };
49
50 class ToolbarEditDialog : public QVLCFrame
51 {
52     Q_OBJECT;
53 public:
54     static ToolbarEditDialog * getInstance( intf_thread_t *p_intf )
55     {
56         if( !instance)
57             instance = new ToolbarEditDialog( p_intf );
58         return instance;
59     }
60     static void killInstance()
61     { if( instance ) delete instance; instance = NULL;}
62     virtual ~ToolbarEditDialog();
63     int getOptions() { return flatBox->isChecked() * WIDGET_FLAT +
64                         bigBox->isChecked() * WIDGET_BIG +
65                         !shinyBox->isChecked() * WIDGET_SHINY; }
66 private:
67     ToolbarEditDialog( intf_thread_t * );
68     static ToolbarEditDialog *instance;
69
70     QCheckBox *flatBox, *bigBox, *shinyBox;
71     QComboBox *positionCombo, *profileCombo;
72
73     WidgetListing *widgetListing;
74     DroppingController *controller1, *controller2, *controllerA;
75     DroppingController *controllerFSC, *controller;
76
77 private slots:
78     void newProfile();
79     void deleteProfile();
80     void changeProfile( int );
81     void cancel();
82     void close();
83 };
84
85 class DroppingController: public AbstractController
86 {
87     Q_OBJECT;
88 public:
89     DroppingController( intf_thread_t *, QString line, QWidget *parent = 0 );
90     QString getValue();
91     virtual ~DroppingController();
92
93     void resetLine( QString );
94 protected:
95     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
96             buttonType_e i_type, int i_option );
97     virtual void dragEnterEvent ( QDragEnterEvent * event );
98     virtual void dragMoveEvent(QDragMoveEvent *event);
99     virtual void dropEvent ( QDropEvent * event );
100     virtual void dragLeaveEvent ( QDragLeaveEvent * event );
101
102     virtual void doAction( int );
103
104     bool eventFilter( QObject *, QEvent * );
105 private:
106     struct doubleInt
107     {
108         int i_type;
109         int i_option;
110     };
111     QRubberBand *rubberband;
112     QList <doubleInt *> widgetList;
113
114     int getParentPosInLayout( QPoint point);
115
116     bool b_draging;
117
118 };
119
120 #endif
121