dialogs_provider.cpp 5.17 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
/*****************************************************************************
 * main_inteface.cpp : Main interface
 ****************************************************************************
4
5
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
zorglub's avatar
zorglub committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/

#include "qt4.hpp"
#include <QEvent>
zorglub's avatar
zorglub committed
25
#include "dialogs_provider.hpp"
zorglub's avatar
zorglub committed
26
#include "dialogs/playlist.hpp"
zorglub's avatar
zorglub committed
27
#include "dialogs/prefs_dialog.hpp"
zorglub's avatar
zorglub committed
28
#include "dialogs/streaminfo.hpp"
29
#include "dialogs/messages.hpp"
zorglub's avatar
zorglub committed
30
#include <QApplication>
zorglub's avatar
zorglub committed
31
32
#include <QSignalMapper>
#include "menus.hpp"
zorglub's avatar
zorglub committed
33
34
35

DialogsProvider* DialogsProvider::instance = NULL;

zorglub's avatar
zorglub committed
36
37
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
                                      QObject( NULL ), p_intf( _p_intf )
zorglub's avatar
zorglub committed
38
{
zorglub's avatar
zorglub committed
39
40
//    idle_timer = new QTimer( this );
//    idle_timer->start( 0 );
zorglub's avatar
zorglub committed
41
42

    fixed_timer = new QTimer( this );
43
    fixed_timer->start( 150 /* milliseconds */ );
zorglub's avatar
zorglub committed
44
45
46
47
48

    menusMapper = new QSignalMapper();
    connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
            SLOT(menuAction( QObject *)) );

49
    menusUpdateMapper = new QSignalMapper();
zorglub's avatar
zorglub committed
50
    connect( menusUpdateMapper, SIGNAL( mapped(QObject *) ), this,
51
            SLOT(menuUpdateAction( QObject *)) );
zorglub's avatar
zorglub committed
52
}
zorglub's avatar
zorglub committed
53

zorglub's avatar
zorglub committed
54
55
56
57
58
59
60
DialogsProvider::~DialogsProvider()
{
}
void DialogsProvider::customEvent( QEvent *event )
{
    if( event->type() == DialogEvent_Type )
    {
zorglub's avatar
zorglub committed
61
        DialogEvent *de = static_cast<DialogEvent*>(event);
zorglub's avatar
zorglub committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
        switch( de->i_dialog )
        {
            case INTF_DIALOG_FILE:
            case INTF_DIALOG_DISC:
            case INTF_DIALOG_NET:
            case INTF_DIALOG_CAPTURE:
                openDialog( de->i_dialog ); break;
            case INTF_DIALOG_PLAYLIST:
                playlistDialog(); break;
            case INTF_DIALOG_MESSAGES:
                messagesDialog(); break;
            case INTF_DIALOG_PREFS:
               prefsDialog(); break;
            case INTF_DIALOG_POPUPMENU:
            case INTF_DIALOG_AUDIOPOPUPMENU:
            case INTF_DIALOG_VIDEOPOPUPMENU:
            case INTF_DIALOG_MISCPOPUPMENU:
               popupMenu( de->i_dialog ); break;
zorglub's avatar
zorglub committed
80
81
            case INTF_DIALOG_FILEINFO:
               streaminfoDialog(); break;
zorglub's avatar
zorglub committed
82
            case INTF_DIALOG_INTERACTION:
zorglub's avatar
zorglub committed
83
84
               doInteraction( de->p_arg ); break;
            case INTF_DIALOG_VLM:
zorglub's avatar
zorglub committed
85
            case INTF_DIALOG_BOOKMARKS:
zorglub's avatar
zorglub committed
86
               bookmarksDialog(); break;
zorglub's avatar
zorglub committed
87
88
            case INTF_DIALOG_WIZARD:
            default:
zorglub's avatar
zorglub committed
89
               msg_Warn( p_intf, "unimplemented dialog\n" );
zorglub's avatar
zorglub committed
90
91
92
93
94
95
96
97
98
        }
    }
}

void DialogsProvider::playlistDialog()
{
    PlaylistDialog::getInstance( p_intf )->toggleVisible();
}

zorglub's avatar
zorglub committed
99
100
101
102
void DialogsProvider::openDialog()
{
    openDialog( 0 );
}
zorglub's avatar
zorglub committed
103
104
105
106
void DialogsProvider::openDialog( int i_dialog )
{
}

zorglub's avatar
zorglub committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
{
    InteractionDialog *qdialog;
    interaction_dialog_t *p_dialog = p_arg->p_dialog;
    switch( p_dialog->i_action )
    {
    case INTERACT_NEW:
        qdialog = new InteractionDialog( p_intf, p_dialog );
        p_dialog->p_private = (void*)qdialog;
        qdialog->show();
        break;
    case INTERACT_UPDATE:
        qdialog = (InteractionDialog*)(p_dialog->p_private);
        if( qdialog)
            qdialog->Update();
        break;
    case INTERACT_HIDE:
        qdialog = (InteractionDialog*)(p_dialog->p_private);
        if( qdialog )
            qdialog->hide();
        p_dialog->i_status = HIDDEN_DIALOG;
        break;
    case INTERACT_DESTROY:
        qdialog = (InteractionDialog*)(p_dialog->p_private);
        delete qdialog; 
        p_dialog->i_status = DESTROYED_DIALOG;
        break;
    }
}

zorglub's avatar
zorglub committed
137
138
139
140
141
142
void DialogsProvider::quit()
{
    p_intf->b_die = VLC_TRUE;
    QApplication::quit();
}

zorglub's avatar
zorglub committed
143
144
void DialogsProvider::streaminfoDialog()
{
145
    StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
zorglub's avatar
zorglub committed
146
147
}

zorglub's avatar
zorglub committed
148
149
150
151
void DialogsProvider::streamingDialog()
{
}

zorglub's avatar
zorglub committed
152
153
void DialogsProvider::prefsDialog()
{
zorglub's avatar
zorglub committed
154
    PrefsDialog::getInstance( p_intf )->toggleVisible();
zorglub's avatar
zorglub committed
155
156
157
158
}

void DialogsProvider::messagesDialog()
{
159
    MessagesDialog::getInstance( p_intf, true )->toggleVisible();
zorglub's avatar
zorglub committed
160
161
}

zorglub's avatar
zorglub committed
162
163
164
165
166
void DialogsProvider::menuAction( QObject *data )
{
    QVLCMenu::DoAction( p_intf, data );
}

167
168
169
170
171
172
void DialogsProvider::menuUpdateAction( QObject *data )
{
    MenuFunc * f = qobject_cast<MenuFunc *>(data);
    f->doFunc( p_intf );
}

zorglub's avatar
zorglub committed
173
174
175
void DialogsProvider::simpleOpenDialog()
{
}
zorglub's avatar
zorglub committed
176
177
178
179
180
void DialogsProvider::bookmarksDialog()
{
}


zorglub's avatar
zorglub committed
181

zorglub's avatar
zorglub committed
182
183
184
185
void DialogsProvider::popupMenu( int i_dialog )
{

}