qvlcframe.hpp 4.68 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
/*****************************************************************************
 * qvlcframe.hpp : A few helpers
3
4
 *****************************************************************************
 * Copyright (C) 2006-2007 the VideoLAN team
5
 * $Id$
zorglub's avatar
zorglub committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * 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
21
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
zorglub's avatar
zorglub committed
23
24
25
26
27

#ifndef _QVLCFRAME_H_
#define _QVLCFRAME_H_

#include <QWidget>
zorglub's avatar
zorglub committed
28
#include <QDialog>
zorglub's avatar
zorglub committed
29
30
#include <QSpacerItem>
#include <QHBoxLayout>
zorglub's avatar
zorglub committed
31
#include <QApplication>
zorglub's avatar
zorglub committed
32
33
#include <QSettings>
#include <QMainWindow>
zorglub's avatar
zorglub committed
34
#include <QPlastiqueStyle>
zorglub's avatar
zorglub committed
35
#include <QPushButton>
36
#include <QKeyEvent>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
37

zorglub's avatar
zorglub committed
38
#include "qt4.hpp"
zorglub's avatar
zorglub committed
39
#include <vlc/vlc.h>
zorglub's avatar
zorglub committed
40
#include <vlc_charset.h>
zorglub's avatar
zorglub committed
41
42
43
44

class QVLCFrame : public QWidget
{
public:
45
    QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
zorglub's avatar
zorglub committed
46
    {    };
zorglub's avatar
zorglub committed
47
48
49
50
51
52
53
54
55
    virtual ~QVLCFrame()   {};

    void toggleVisible()
    {
        if( isVisible() ) hide();
        else show();
    }
protected:
    intf_thread_t *p_intf;
zorglub's avatar
zorglub committed
56

57
    void readSettings( QString name, QSize defSize, QPoint defPos )
zorglub's avatar
zorglub committed
58
    {
59
        QSettings settings( "vlc", "vlc-qt-interface" );
zorglub's avatar
zorglub committed
60
61
        settings.beginGroup( name );
        resize( settings.value( "size", defSize ).toSize() );
62
        move( settings.value( "pos", defPos ).toPoint() );
zorglub's avatar
zorglub committed
63
64
65
66
        settings.endGroup();
    }
    void writeSettings( QString name )
    {
67
        QSettings settings( "vlc", "vlc-qt-interface" );
zorglub's avatar
zorglub committed
68
69
70
71
72
        settings.beginGroup( name );
        settings.setValue ("size", size() );
        settings.setValue( "pos", pos() );
        settings.endGroup();
    }
73
    virtual void cancel()
74
75
76
    {
        hide();
    }
77
    virtual void close()
78
79
80
    {
        hide();
    }
81
    virtual void keyPressEvent( QKeyEvent *keyEvent )
82
83
84
    {
        if( keyEvent->key() == Qt::Key_Escape )
        {
85
            msg_Dbg( p_intf, "Escp Key pressed" );
86
87
            cancel();
        }
88
        else if( keyEvent->key() == Qt::Key_Return )
89
        {
90
91
92
             msg_Dbg( p_intf, "Enter Key pressed" );
             close();
         }
93
    }
zorglub's avatar
zorglub committed
94
};
zorglub's avatar
zorglub committed
95

zorglub's avatar
zorglub committed
96
class QVLCDialog : public QDialog
zorglub's avatar
zorglub committed
97
98
{
public:
zorglub's avatar
zorglub committed
99
100
101
102
103
    QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
                                    QDialog( parent ), p_intf( _p_intf )
    {}
    virtual ~QVLCDialog() {};
    void toggleVisible()
zorglub's avatar
zorglub committed
104
    {
zorglub's avatar
zorglub committed
105
106
        if( isVisible() ) hide();
        else show();
zorglub's avatar
zorglub committed
107
    }
zorglub's avatar
zorglub committed
108
109
110

protected:
    intf_thread_t *p_intf;
111

112
113
114
115
116
    virtual void cancel()
    {
        hide();
    }
    virtual void close()
117
118
119
    {
        hide();
    }
120
    virtual void keyPressEvent( QKeyEvent *keyEvent )
121
122
123
    {
        if( keyEvent->key() == Qt::Key_Escape )
        {
124
            msg_Dbg( p_intf, "Escp Key pressed" );
125
126
            cancel();
        }
127
        else if( keyEvent->key() == Qt::Key_Return )
128
        {
129
130
             msg_Dbg( p_intf, "Enter Key pressed" );
             close();
131
        }
132
    }
zorglub's avatar
zorglub committed
133
134
135
136
137
138
139
};

class QVLCMW : public QMainWindow
{
public:
    QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
    {    }
zorglub's avatar
zorglub committed
140
    virtual ~QVLCMW() {};
zorglub's avatar
zorglub committed
141
142
143
144
145
    void toggleVisible()
    {
        if( isVisible() ) hide();
        else show();
    }
zorglub's avatar
zorglub committed
146
147
148
149
150
151
protected:
    intf_thread_t *p_intf;
    QSize mainSize;

    void readSettings( QString name, QSize defSize )
    {
152
        QSettings settings( "vlc", "vlc-qt-interface" );
zorglub's avatar
zorglub committed
153
        settings.beginGroup( name );
154
155
        QSize s =  settings.value( "size", defSize ).toSize() ;
        fprintf( stderr, "%i %i ", s.width(), s.height() );
zorglub's avatar
zorglub committed
156
        move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
zorglub's avatar
zorglub committed
157
158
159
160
        settings.endGroup();
    }
    void readSettings( QString name )
    {
161
        QSettings settings( "vlc", "vlc-qt-interface" );
zorglub's avatar
zorglub committed
162
163
        settings.beginGroup( name );
        mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
zorglub's avatar
zorglub committed
164
165
166
167
        settings.endGroup();
    }
    void writeSettings( QString name )
    {
168
        QSettings settings( "vlc", "vlc-qt-interface" );
zorglub's avatar
zorglub committed
169
170
171
172
173
174
175
        settings.beginGroup( name );
        settings.setValue ("size", size() );
        settings.setValue( "pos", pos() );
        settings.endGroup();
    }
};

zorglub's avatar
zorglub committed
176
#endif