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 <QPlastiqueStyle>
35 #include <QPushButton>
39 #include <vlc_charset.h>
41 class QVLCFrame : public QWidget
44 static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
45 QPushButton **defaul, char *psz_default,
46 QPushButton **alt, char *psz_alt,
47 QPushButton **other, char *psz_other )
51 QHBoxLayout *buttons_layout = new QHBoxLayout;
52 QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
53 QSizePolicy::Expanding, QSizePolicy::Minimum);
54 buttons_layout->addItem( spacerItem );
58 *defaul = new QPushButton(0);
59 (*defaul)->setFocus();
60 buttons_layout->addWidget( *defaul );
61 (*defaul)->setText( qfu( psz_default ) );
65 *alt = new QPushButton(0);
66 buttons_layout->addWidget( *alt );
67 (*alt)->setText( qfu( psz_alt ) );
71 *other = new QPushButton( 0 );
72 buttons_layout->addWidget( *other );
73 (*other)->setText( qfu( psz_other ) );
76 l->addLayout( buttons_layout );
78 return buttons_layout;
81 QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
83 virtual ~QVLCFrame() {};
87 if( isVisible() ) hide();
91 intf_thread_t *p_intf;
93 void readSettings( QString name, QSize defSize )
95 QSettings settings( "VideoLAN", "VLC" );
96 settings.beginGroup( name );
97 resize( settings.value( "size", defSize ).toSize() );
98 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
101 void writeSettings( QString name )
103 QSettings settings( "VideoLAN", "VLC" );
104 settings.beginGroup( name );
105 settings.setValue ("size", size() );
106 settings.setValue( "pos", pos() );
113 void keyPressEvent( QKeyEvent *keyEvent )
115 if( keyEvent->key() == Qt::Key_Escape )
122 class QVLCDialog : public QDialog
125 QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
126 QDialog( parent ), p_intf( _p_intf )
128 virtual ~QVLCDialog() {};
131 if( isVisible() ) hide();
136 intf_thread_t *p_intf;
142 void keyPressEvent( QKeyEvent *keyEvent )
144 if( keyEvent->key() == Qt::Key_Escape )
151 class QVLCMW : public QMainWindow
154 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
156 virtual ~QVLCMW() {};
159 if( isVisible() ) hide();
163 intf_thread_t *p_intf;
166 void readSettings( QString name, QSize defSize )
168 QSettings settings( "VideoLAN", "VLC" );
169 settings.beginGroup( name );
170 QSize s = settings.value( "size", defSize ).toSize() ;
171 fprintf( stderr, "%i %i ", s.width(), s.height() );
172 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
175 void readSettings( QString name )
177 QSettings settings( "VideoLAN", "VLC" );
178 settings.beginGroup( name );
179 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
182 void writeSettings( QString name )
184 QSettings settings( "VideoLAN", "VLC" );
185 settings.beginGroup( name );
186 settings.setValue ("size", size() );
187 settings.setValue( "pos", pos() );