dialogs_provider.cpp 4.61 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
29
#include "dialogs/streaminfo.hpp"
#include <QApplication>
zorglub's avatar
zorglub committed
30
31
#include <QSignalMapper>
#include "menus.hpp"
zorglub's avatar
zorglub committed
32
33
34

DialogsProvider* DialogsProvider::instance = NULL;

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

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

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

zorglub's avatar
zorglub committed
48
}
zorglub's avatar
zorglub committed
49

zorglub's avatar
zorglub committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
DialogsProvider::~DialogsProvider()
{
}
void DialogsProvider::customEvent( QEvent *event )
{
    if( event->type() == DialogEvent_Type )
    {
        DialogEvent *de = dynamic_cast<DialogEvent*>(event);
        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
76
77
            case INTF_DIALOG_FILEINFO:
               streaminfoDialog(); break;
zorglub's avatar
zorglub committed
78
            case INTF_DIALOG_INTERACTION:
zorglub's avatar
zorglub committed
79
80
               doInteraction( de->p_arg ); break;
            case INTF_DIALOG_VLM:
zorglub's avatar
zorglub committed
81
82
83
            case INTF_DIALOG_BOOKMARKS:
            case INTF_DIALOG_WIZARD:
            default:
zorglub's avatar
zorglub committed
84
               msg_Warn( p_intf, "unimplemented dialog\n" );
zorglub's avatar
zorglub committed
85
86
87
88
89
90
91
92
93
        }
    }
}

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

zorglub's avatar
zorglub committed
94
95
96
97
void DialogsProvider::openDialog()
{
    openDialog( 0 );
}
zorglub's avatar
zorglub committed
98
99
100
101
void DialogsProvider::openDialog( int i_dialog )
{
}

zorglub's avatar
zorglub committed
102
103
104
105
106
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
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
132
133
void DialogsProvider::streaminfoDialog()
{
134
    StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
zorglub's avatar
zorglub committed
135
136
}

zorglub's avatar
zorglub committed
137
138
139
140
void DialogsProvider::streamingDialog()
{
}

zorglub's avatar
zorglub committed
141
142
void DialogsProvider::prefsDialog()
{
zorglub's avatar
zorglub committed
143
    PrefsDialog::getInstance( p_intf )->toggleVisible();
zorglub's avatar
zorglub committed
144
145
146
147
148
149
}

void DialogsProvider::messagesDialog()
{
}

zorglub's avatar
zorglub committed
150
151
152
153
154
155
156
157
158
void DialogsProvider::menuAction( QObject *data )
{
    QVLCMenu::DoAction( p_intf, data );
}

void DialogsProvider::simpleOpenDialog()
{
}

zorglub's avatar
zorglub committed
159
160
161
162
void DialogsProvider::popupMenu( int i_dialog )
{

}