]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
bbdfc83c0a9554c68ba2d650e90f64250da91c86
[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
31 DialogsProvider* DialogsProvider::instance = NULL;
32
33 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
34                                       QObject( NULL ), p_intf( _p_intf )
35 {
36 //    idle_timer = new QTimer( this );
37 //    idle_timer->start( 0 );
38
39     fixed_timer = new QTimer( this );
40     fixed_timer->start( 150 /* milliseconds */ );
41 }
42
43 DialogsProvider::~DialogsProvider()
44 {
45 }
46
47 void DialogsProvider::customEvent( QEvent *event )
48 {
49     if( event->type() == DialogEvent_Type )
50     {
51         DialogEvent *de = dynamic_cast<DialogEvent*>(event);
52         switch( de->i_dialog )
53         {
54             case INTF_DIALOG_FILE:
55             case INTF_DIALOG_DISC:
56             case INTF_DIALOG_NET:
57             case INTF_DIALOG_CAPTURE:
58                 openDialog( de->i_dialog ); break;
59             case INTF_DIALOG_PLAYLIST:
60                 playlistDialog(); break;
61             case INTF_DIALOG_MESSAGES:
62                 messagesDialog(); break;
63             case INTF_DIALOG_PREFS:
64                prefsDialog(); break;
65             case INTF_DIALOG_POPUPMENU:
66             case INTF_DIALOG_AUDIOPOPUPMENU:
67             case INTF_DIALOG_VIDEOPOPUPMENU:
68             case INTF_DIALOG_MISCPOPUPMENU:
69                popupMenu( de->i_dialog ); break;
70             case INTF_DIALOG_FILEINFO:
71                streaminfoDialog(); break;
72             case INTF_DIALOG_INTERACTION:
73                doInteraction( de->p_arg ); break;
74             case INTF_DIALOG_VLM:
75             case INTF_DIALOG_BOOKMARKS:
76             case INTF_DIALOG_WIZARD:
77             default:
78                msg_Warn( p_intf, "unimplemented dialog\n" );
79         }
80     }
81 }
82
83 void DialogsProvider::playlistDialog()
84 {
85     PlaylistDialog::getInstance( p_intf )->toggleVisible();
86 }
87
88 void DialogsProvider::openDialog( int i_dialog )
89 {
90 }
91
92 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
93 {
94     InteractionDialog *qdialog;
95     interaction_dialog_t *p_dialog = p_arg->p_dialog;
96     switch( p_dialog->i_action )
97     {
98     case INTERACT_NEW:
99         qdialog = new InteractionDialog( p_intf, p_dialog );
100         p_dialog->p_private = (void*)qdialog;
101         qdialog->show();
102         break;
103     case INTERACT_UPDATE:
104         qdialog = (InteractionDialog*)(p_dialog->p_private);
105         if( qdialog)
106             qdialog->Update();
107         break;
108     case INTERACT_HIDE:
109         qdialog = (InteractionDialog*)(p_dialog->p_private);
110         if( qdialog )
111             qdialog->hide();
112         p_dialog->i_status = HIDDEN_DIALOG;
113         break;
114     case INTERACT_DESTROY:
115         qdialog = (InteractionDialog*)(p_dialog->p_private);
116         delete qdialog; 
117         p_dialog->i_status = DESTROYED_DIALOG;
118         break;
119     }
120 }
121
122 void DialogsProvider::streaminfoDialog()
123 {
124     StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
125 }
126
127 void DialogsProvider::prefsDialog()
128 {
129     PrefsDialog::getInstance( p_intf )->toggleVisible();
130 }
131
132 void DialogsProvider::messagesDialog()
133 {
134 }
135
136 void DialogsProvider::popupMenu( int i_dialog )
137 {
138
139 }