1 /*****************************************************************************
2 * qvlcframe.hpp : A few helpers
3 *****************************************************************************
4 * Copyright (C) 2006-2007 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.
22 *****************************************************************************/
29 #include <QSpacerItem>
30 #include <QHBoxLayout>
31 #include <QApplication>
33 #include <QMainWindow>
34 #include <QPushButton>
39 #include <vlc_charset.h>
41 class QVLCFrame : public QWidget
44 QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
46 virtual ~QVLCFrame() {};
50 if( isVisible() ) hide();
54 intf_thread_t *p_intf;
56 void readSettings( QString name,
57 QSize defSize = QSize( 0, 0 ),
58 QPoint defPos = QPoint( 0, 0 ) )
60 QSettings settings( "vlc", "vlc-qt-interface" );
61 settings.beginGroup( name );
62 /* never trust any saved size ;-) */
63 QSize newSize = settings.value( "size", defSize ).toSize();
64 if( newSize.isValid() )
66 move( settings.value( "pos", defPos ).toPoint() );
69 void writeSettings( QString name )
71 QSettings settings( "vlc", "vlc-qt-interface" );
72 settings.beginGroup( name );
73 /* only save valid sizes ... */
74 QSize currentsize = size();
75 if( currentsize.isValid() )
76 settings.setValue ("size", currentsize );
77 settings.setValue( "pos", pos() );
88 virtual void keyPressEvent( QKeyEvent *keyEvent )
90 if( keyEvent->key() == Qt::Key_Escape )
92 msg_Dbg( p_intf, "Escp Key pressed" );
95 else if( keyEvent->key() == Qt::Key_Return )
97 msg_Dbg( p_intf, "Enter Key pressed" );
103 class QVLCDialog : public QDialog
106 QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
107 QDialog( parent ), p_intf( _p_intf )
109 virtual ~QVLCDialog() {};
112 if( isVisible() ) hide();
117 intf_thread_t *p_intf;
119 virtual void cancel()
127 virtual void keyPressEvent( QKeyEvent *keyEvent )
129 if( keyEvent->key() == Qt::Key_Escape )
131 msg_Dbg( p_intf, "Escp Key pressed" );
134 else if( keyEvent->key() == Qt::Key_Return )
136 msg_Dbg( p_intf, "Enter Key pressed" );
142 class QVLCMW : public QMainWindow
145 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
147 virtual ~QVLCMW() {};
150 if( isVisible() ) hide();
154 intf_thread_t *p_intf;
157 void readSettings( QString name, QSize defSize )
159 QSettings settings( "vlc", "vlc-qt-interface" );
160 settings.beginGroup( name );
161 QSize s = settings.value( "size", defSize ).toSize() ;
162 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
166 void readSettings( QString name )
168 QSettings settings( "vlc", "vlc-qt-interface" );
169 settings.beginGroup( name );
170 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
171 if( !mainSize.isValid() )
173 mainSize = QSize(0,0);
178 void writeSettings( QString name )
180 QSettings settings( "vlc", "vlc-qt-interface" );
181 settings.beginGroup( name );
182 /* only save valid sizes ... */
183 QSize currentsize = size();
184 if( currentsize.isValid() )
185 settings.setValue ("size", currentsize );
186 settings.setValue( "pos", pos() );