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 "dialogs/messages.hpp"
30 #include <QApplication>
31 #include <QSignalMapper>
33 #include <vlc_intf_strings.h>
35 DialogsProvider* DialogsProvider::instance = NULL;
37 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
38 QObject( NULL ), p_intf( _p_intf )
40 // idle_timer = new QTimer( this );
41 // idle_timer->start( 0 );
43 fixed_timer = new QTimer( this );
44 fixed_timer->start( 150 /* milliseconds */ );
46 menusMapper = new QSignalMapper();
47 connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
48 SLOT(menuAction( QObject *)) );
50 menusUpdateMapper = new QSignalMapper();
51 connect( menusUpdateMapper, SIGNAL( mapped(QObject *) ), this,
52 SLOT(menuUpdateAction( QObject *)) );
55 DialogsProvider::~DialogsProvider()
58 void DialogsProvider::customEvent( QEvent *event )
60 if( event->type() == DialogEvent_Type )
62 DialogEvent *de = static_cast<DialogEvent*>(event);
63 switch( de->i_dialog )
65 case INTF_DIALOG_FILE:
66 case INTF_DIALOG_DISC:
68 case INTF_DIALOG_CAPTURE:
69 openDialog( de->i_dialog ); break;
70 case INTF_DIALOG_PLAYLIST:
71 playlistDialog(); break;
72 case INTF_DIALOG_MESSAGES:
73 messagesDialog(); break;
74 case INTF_DIALOG_PREFS:
76 case INTF_DIALOG_POPUPMENU:
77 case INTF_DIALOG_AUDIOPOPUPMENU:
78 case INTF_DIALOG_VIDEOPOPUPMENU:
79 case INTF_DIALOG_MISCPOPUPMENU:
80 popupMenu( de->i_dialog ); break;
81 case INTF_DIALOG_FILEINFO:
82 streaminfoDialog(); break;
83 case INTF_DIALOG_INTERACTION:
84 doInteraction( de->p_arg ); break;
86 case INTF_DIALOG_BOOKMARKS:
87 bookmarksDialog(); break;
88 case INTF_DIALOG_WIZARD:
90 msg_Warn( p_intf, "unimplemented dialog\n" );
95 void DialogsProvider::playlistDialog()
97 PlaylistDialog::getInstance( p_intf )->toggleVisible();
100 void DialogsProvider::openDialog()
104 void DialogsProvider::openDialog( int i_dialog )
108 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
110 InteractionDialog *qdialog;
111 interaction_dialog_t *p_dialog = p_arg->p_dialog;
112 switch( p_dialog->i_action )
115 qdialog = new InteractionDialog( p_intf, p_dialog );
116 p_dialog->p_private = (void*)qdialog;
119 case INTERACT_UPDATE:
120 qdialog = (InteractionDialog*)(p_dialog->p_private);
125 qdialog = (InteractionDialog*)(p_dialog->p_private);
128 p_dialog->i_status = HIDDEN_DIALOG;
130 case INTERACT_DESTROY:
131 qdialog = (InteractionDialog*)(p_dialog->p_private);
133 p_dialog->i_status = DESTROYED_DIALOG;
138 void DialogsProvider::quit()
140 p_intf->b_die = VLC_TRUE;
141 QApplication::quit();
144 void DialogsProvider::streaminfoDialog()
146 StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
149 void DialogsProvider::streamingDialog()
153 void DialogsProvider::prefsDialog()
155 PrefsDialog::getInstance( p_intf )->toggleVisible();
158 void DialogsProvider::messagesDialog()
160 MessagesDialog::getInstance( p_intf, true )->toggleVisible();
163 void DialogsProvider::menuAction( QObject *data )
165 QVLCMenu::DoAction( p_intf, data );
168 void DialogsProvider::menuUpdateAction( QObject *data )
170 MenuFunc * f = qobject_cast<MenuFunc *>(data);
174 void DialogsProvider::simpleAppendDialog()
179 void DialogsProvider::simpleOpenDialog()
181 playlist_t *p_playlist =
182 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
184 if( p_playlist == NULL )
190 FileTypes = "Video Files ( ";
191 FileTypes += EXTENSIONS_VIDEO;
192 FileTypes += ");; Sound Files ( ";
193 FileTypes += EXTENSIONS_AUDIO;
194 FileTypes += ");; PlayList Files ( ";
195 FileTypes += EXTENSIONS_PLAYLIST;
196 FileTypes += ");; Subtitles Files ( ";
197 FileTypes += EXTENSIONS_SUBTITLE;
198 FileTypes += ");; All Files (*.*) " ;
199 FileTypes.replace(QString(";*"), QString(" *"));
201 QStringList fileList = QFileDialog::getOpenFileNames(
202 NULL, qfu(I_POP_SEL_FILES ), p_intf->p_vlc->psz_homedir,
205 QStringList files = fileList;
207 for (size_t i = 0; i < files.size(); i++)
209 const char * psz_utf8 = files[i].toUtf8().data();
210 playlist_PlaylistAdd( p_playlist, psz_utf8, psz_utf8,
211 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
212 (i ? PLAYLIST_PREPARSE : 0 ),
216 vlc_object_release(p_playlist);
219 void DialogsProvider::bookmarksDialog()
223 void DialogsProvider::popupMenu( int i_dialog )