]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
f8208014748162bbee7a1a232918a77a2255978d
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
1 /*****************************************************************************
2  * main_inteface.cpp : Main interface
3  ****************************************************************************
4  * Copyright (C) 2000-2005 the VideoLAN team
5  * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
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 }
49
50 DialogsProvider::~DialogsProvider()
51 {
52 }
53 void DialogsProvider::customEvent( QEvent *event )
54 {
55     if( event->type() == DialogEvent_Type )
56     {
57         DialogEvent *de = dynamic_cast<DialogEvent*>(event);
58         switch( de->i_dialog )
59         {
60             case INTF_DIALOG_FILE:
61             case INTF_DIALOG_DISC:
62             case INTF_DIALOG_NET:
63             case INTF_DIALOG_CAPTURE:
64                 openDialog( de->i_dialog ); break;
65             case INTF_DIALOG_PLAYLIST:
66                 playlistDialog(); break;
67             case INTF_DIALOG_MESSAGES:
68                 messagesDialog(); break;
69             case INTF_DIALOG_PREFS:
70                prefsDialog(); break;
71             case INTF_DIALOG_POPUPMENU:
72             case INTF_DIALOG_AUDIOPOPUPMENU:
73             case INTF_DIALOG_VIDEOPOPUPMENU:
74             case INTF_DIALOG_MISCPOPUPMENU:
75                popupMenu( de->i_dialog ); break;
76             case INTF_DIALOG_FILEINFO:
77                streaminfoDialog(); break;
78             case INTF_DIALOG_INTERACTION:
79                doInteraction( de->p_arg ); break;
80             case INTF_DIALOG_VLM:
81             case INTF_DIALOG_BOOKMARKS:
82             case INTF_DIALOG_WIZARD:
83             default:
84                msg_Warn( p_intf, "unimplemented dialog\n" );
85         }
86     }
87 }
88
89 void DialogsProvider::playlistDialog()
90 {
91     PlaylistDialog::getInstance( p_intf )->toggleVisible();
92 }
93
94 void DialogsProvider::openDialog()
95 {
96     openDialog( 0 );
97 }
98 void DialogsProvider::openDialog( int i_dialog )
99 {
100 }
101
102 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
103 {
104     InteractionDialog *qdialog;
105     interaction_dialog_t *p_dialog = p_arg->p_dialog;
106     switch( p_dialog->i_action )
107     {
108     case INTERACT_NEW:
109         qdialog = new InteractionDialog( p_intf, p_dialog );
110         p_dialog->p_private = (void*)qdialog;
111         qdialog->show();
112         break;
113     case INTERACT_UPDATE:
114         qdialog = (InteractionDialog*)(p_dialog->p_private);
115         if( qdialog)
116             qdialog->Update();
117         break;
118     case INTERACT_HIDE:
119         qdialog = (InteractionDialog*)(p_dialog->p_private);
120         if( qdialog )
121             qdialog->hide();
122         p_dialog->i_status = HIDDEN_DIALOG;
123         break;
124     case INTERACT_DESTROY:
125         qdialog = (InteractionDialog*)(p_dialog->p_private);
126         delete qdialog; 
127         p_dialog->i_status = DESTROYED_DIALOG;
128         break;
129     }
130 }
131
132 void DialogsProvider::streaminfoDialog()
133 {
134     StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
135 }
136
137 void DialogsProvider::streamingDialog()
138 {
139 }
140
141 void DialogsProvider::prefsDialog()
142 {
143     PrefsDialog::getInstance( p_intf )->toggleVisible();
144 }
145
146 void DialogsProvider::messagesDialog()
147 {
148 }
149
150 void DialogsProvider::menuAction( QObject *data )
151 {
152     QVLCMenu::DoAction( p_intf, data );
153 }
154
155 void DialogsProvider::simpleOpenDialog()
156 {
157 }
158
159 void DialogsProvider::popupMenu( int i_dialog )
160 {
161
162 }