1 /*****************************************************************************
2 * main_inteface.cpp : Main interface
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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. *****************************************************************************/
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>
33 DialogsProvider* DialogsProvider::instance = NULL;
35 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
36 QObject( NULL ), p_intf( _p_intf )
38 // idle_timer = new QTimer( this );
39 // idle_timer->start( 0 );
41 fixed_timer = new QTimer( this );
42 fixed_timer->start( 150 /* milliseconds */ );
44 menusMapper = new QSignalMapper();
45 connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
46 SLOT(menuAction( QObject *)) );
50 DialogsProvider::~DialogsProvider()
53 void DialogsProvider::customEvent( QEvent *event )
55 if( event->type() == DialogEvent_Type )
57 DialogEvent *de = dynamic_cast<DialogEvent*>(event);
58 switch( de->i_dialog )
60 case INTF_DIALOG_FILE:
61 case INTF_DIALOG_DISC:
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:
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;
81 case INTF_DIALOG_BOOKMARKS:
82 case INTF_DIALOG_WIZARD:
84 msg_Warn( p_intf, "unimplemented dialog\n" );
89 void DialogsProvider::playlistDialog()
91 PlaylistDialog::getInstance( p_intf )->toggleVisible();
94 void DialogsProvider::openDialog()
98 void DialogsProvider::openDialog( int i_dialog )
102 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
104 InteractionDialog *qdialog;
105 interaction_dialog_t *p_dialog = p_arg->p_dialog;
106 switch( p_dialog->i_action )
109 qdialog = new InteractionDialog( p_intf, p_dialog );
110 p_dialog->p_private = (void*)qdialog;
113 case INTERACT_UPDATE:
114 qdialog = (InteractionDialog*)(p_dialog->p_private);
119 qdialog = (InteractionDialog*)(p_dialog->p_private);
122 p_dialog->i_status = HIDDEN_DIALOG;
124 case INTERACT_DESTROY:
125 qdialog = (InteractionDialog*)(p_dialog->p_private);
127 p_dialog->i_status = DESTROYED_DIALOG;
132 void DialogsProvider::streaminfoDialog()
134 StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
137 void DialogsProvider::streamingDialog()
141 void DialogsProvider::prefsDialog()
143 PrefsDialog::getInstance( p_intf )->toggleVisible();
146 void DialogsProvider::messagesDialog()
150 void DialogsProvider::menuAction( QObject *data )
152 QVLCMenu::DoAction( p_intf, data );
155 void DialogsProvider::simpleOpenDialog()
159 void DialogsProvider::popupMenu( int i_dialog )