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, QSize defSize, QPoint defPos )
58 QSettings settings( "vlc", "vlc-qt-interface" );
59 settings.beginGroup( name );
60 /* never trust any saved size ;-) */
61 QSize newSize = settings.value( "size", defSize ).toSize();
62 if( newSize.isValid() )
64 move( settings.value( "pos", defPos ).toPoint() );
67 void writeSettings( QString name )
69 QSettings settings( "vlc", "vlc-qt-interface" );
70 settings.beginGroup( name );
71 /* only save valid sizes ... */
72 QSize currentsize = size();
73 if( currentsize.isValid() )
74 settings.setValue ("size", currentsize );
75 settings.setValue( "pos", pos() );
86 virtual void keyPressEvent( QKeyEvent *keyEvent )
88 if( keyEvent->key() == Qt::Key_Escape )
90 msg_Dbg( p_intf, "Escp Key pressed" );
93 else if( keyEvent->key() == Qt::Key_Return )
95 msg_Dbg( p_intf, "Enter Key pressed" );
101 class QVLCDialog : public QDialog
104 QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
105 QDialog( parent ), p_intf( _p_intf )
107 virtual ~QVLCDialog() {};
110 if( isVisible() ) hide();
115 intf_thread_t *p_intf;
117 virtual void cancel()
125 virtual void keyPressEvent( QKeyEvent *keyEvent )
127 if( keyEvent->key() == Qt::Key_Escape )
129 msg_Dbg( p_intf, "Escp Key pressed" );
132 else if( keyEvent->key() == Qt::Key_Return )
134 msg_Dbg( p_intf, "Enter Key pressed" );
140 class QVLCMW : public QMainWindow
143 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
145 virtual ~QVLCMW() {};
148 if( isVisible() ) hide();
152 intf_thread_t *p_intf;
155 void readSettings( QString name, QSize defSize )
157 QSettings settings( "vlc", "vlc-qt-interface" );
158 settings.beginGroup( name );
159 QSize s = settings.value( "size", defSize ).toSize() ;
160 fprintf( stderr, "%i %i ", s.width(), s.height() );
161 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
165 void readSettings( QString name )
167 QSettings settings( "vlc", "vlc-qt-interface" );
168 settings.beginGroup( name );
169 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
170 if( !mainSize.isValid() )
172 mainSize = QSize(0,0);
177 void writeSettings( QString name )
179 QSettings settings( "vlc", "vlc-qt-interface" );
180 settings.beginGroup( name );
181 /* only save valid sizes ... */
182 QSize currentsize = size();
183 if( currentsize.isValid() )
184 settings.setValue ("size", currentsize );
185 settings.setValue( "pos", pos() );