]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
6fe6c5199ea76ee7dc530f13a617a719921c2850
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
1 /*****************************************************************************
2  * main_inteface.cpp : Main interface
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@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 #include "qt4.hpp"
24 #include <QEvent>
25 #include "dialogs_provider.hpp"
26 #include "dialogs/playlist.hpp"
27 #include "dialogs/prefs_dialog.hpp"
28 #include "dialogs/streaminfo.hpp"
29 #include <QApplication>
30 #include <QSignalMapper>
31 #include "menus.hpp"
32
33 DialogsProvider* DialogsProvider::instance = NULL;
34
35 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
36                                       QObject( NULL ), p_intf( _p_intf )
37 {
38 //    idle_timer = new QTimer( this );
39 //    idle_timer->start( 0 );
40
41     fixed_timer = new QTimer( this );
42     fixed_timer->start( 150 /* milliseconds */ );
43
44     menusMapper = new QSignalMapper();
45     connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
46             SLOT(menuAction( QObject *)) );
47
48     menusUpdateMapper = new QSignalMapper();
49     connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
50             SLOT(menuUpdateAction( QObject *)) );
51 }
52
53 DialogsProvider::~DialogsProvider()
54 {
55 }
56 void DialogsProvider::customEvent( QEvent *event )
57 {
58     if( event->type() == DialogEvent_Type )
59     {
60         DialogEvent *de = dynamic_cast<DialogEvent*>(event);
61         switch( de->i_dialog )
62         {
63             case INTF_DIALOG_FILE:
64             case INTF_DIALOG_DISC:
65             case INTF_DIALOG_NET:
66             case INTF_DIALOG_CAPTURE:
67                 openDialog( de->i_dialog ); break;
68             case INTF_DIALOG_PLAYLIST:
69                 playlistDialog(); break;
70             case INTF_DIALOG_MESSAGES:
71                 messagesDialog(); break;
72             case INTF_DIALOG_PREFS:
73                prefsDialog(); break;
74             case INTF_DIALOG_POPUPMENU:
75             case INTF_DIALOG_AUDIOPOPUPMENU:
76             case INTF_DIALOG_VIDEOPOPUPMENU:
77             case INTF_DIALOG_MISCPOPUPMENU:
78                popupMenu( de->i_dialog ); break;
79             case INTF_DIALOG_FILEINFO:
80                streaminfoDialog(); break;
81             case INTF_DIALOG_INTERACTION:
82                doInteraction( de->p_arg ); break;
83             case INTF_DIALOG_VLM:
84             case INTF_DIALOG_BOOKMARKS:
85             case INTF_DIALOG_WIZARD:
86             default:
87                msg_Warn( p_intf, "unimplemented dialog\n" );
88         }
89     }
90 }
91
92 void DialogsProvider::playlistDialog()
93 {
94     PlaylistDialog::getInstance( p_intf )->toggleVisible();
95 }
96
97 void DialogsProvider::openDialog()
98 {
99     openDialog( 0 );
100 }
101 void DialogsProvider::openDialog( int i_dialog )
102 {
103 }
104
105 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
106 {
107     InteractionDialog *qdialog;
108     interaction_dialog_t *p_dialog = p_arg->p_dialog;
109     switch( p_dialog->i_action )
110     {
111     case INTERACT_NEW:
112         qdialog = new InteractionDialog( p_intf, p_dialog );
113         p_dialog->p_private = (void*)qdialog;
114         qdialog->show();
115         break;
116     case INTERACT_UPDATE:
117         qdialog = (InteractionDialog*)(p_dialog->p_private);
118         if( qdialog)
119             qdialog->Update();
120         break;
121     case INTERACT_HIDE:
122         qdialog = (InteractionDialog*)(p_dialog->p_private);
123         if( qdialog )
124             qdialog->hide();
125         p_dialog->i_status = HIDDEN_DIALOG;
126         break;
127     case INTERACT_DESTROY:
128         qdialog = (InteractionDialog*)(p_dialog->p_private);
129         delete qdialog; 
130         p_dialog->i_status = DESTROYED_DIALOG;
131         break;
132     }
133 }
134
135 void DialogsProvider::streaminfoDialog()
136 {
137     StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
138 }
139
140 void DialogsProvider::streamingDialog()
141 {
142 }
143
144 void DialogsProvider::prefsDialog()
145 {
146     PrefsDialog::getInstance( p_intf )->toggleVisible();
147 }
148
149 void DialogsProvider::messagesDialog()
150 {
151 }
152
153 void DialogsProvider::menuAction( QObject *data )
154 {
155     QVLCMenu::DoAction( p_intf, data );
156 }
157
158 void DialogsProvider::menuUpdateAction( QObject *data )
159 {
160     MenuFunc * f = qobject_cast<MenuFunc *>(data);
161     f->doFunc( p_intf );
162 }
163
164 void DialogsProvider::simpleOpenDialog()
165 {
166 }
167
168 void DialogsProvider::popupMenu( int i_dialog )
169 {
170
171 }