1 /*****************************************************************************
2 * qvlcframe.hpp : A few helpers
3 ****************************************************************************
4 * Copyright (C) 2006 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. *****************************************************************************/
27 #include <QSpacerItem>
28 #include <QHBoxLayout>
29 #include <QApplication>
31 #include <QMainWindow>
32 #include <QPlastiqueStyle>
33 #include <QPushButton>
38 class QVLCFrame : public QWidget
41 static void fixStyle( QWidget *w)
43 QStyle *style = qApp->style();
45 // Plastique is too dark.
46 /// theming ? getting KDE data ? ?
47 if( qobject_cast<QPlastiqueStyle *>(style) )
49 QPalette plt( w->palette() );
50 plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
51 QColor vlg = (Qt::lightGray);
53 vlg.setHsv( vlg.hue(), vlg.saturation(), 235 );
54 plt.setColor( QPalette::Active, QPalette::Window, vlg );
55 plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
56 plt.setColor( QPalette::Inactive, QPalette::Button, vlg );
57 plt.setColor( QPalette::Active, QPalette::Button, vlg );
58 plt.setColor( QPalette::Active, QPalette::Text, Qt::yellow );
63 static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
64 QPushButton **defaul, char *psz_default,
65 QPushButton **alt, char *psz_alt,
66 QPushButton **other, char *psz_other )
70 QHBoxLayout *buttons_layout = new QHBoxLayout;
71 QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
72 QSizePolicy::Expanding, QSizePolicy::Minimum);
73 buttons_layout->addItem( spacerItem );
77 *defaul = new QPushButton(0);
78 (*defaul)->setFocus();
79 buttons_layout->addWidget( *defaul );
80 (*defaul)->setText( qfu( psz_default ) );
84 *alt = new QPushButton(0);
85 buttons_layout->addWidget( *alt );
86 (*alt)->setText( qfu( psz_alt ) );
90 *other = new QPushButton( 0 );
91 buttons_layout->addWidget( *other );
92 (*other)->setText( qfu( psz_other ) );
95 l->addLayout( buttons_layout );
97 return buttons_layout;
100 QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
104 virtual ~QVLCFrame() {};
108 if( isVisible() ) hide();
112 intf_thread_t *p_intf;
114 void readSettings( QString name, QSize defSize )
116 QSettings settings( "VideoLAN", "VLC" );
117 settings.beginGroup( name );
118 resize( settings.value( "size", defSize ).toSize() );
119 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
122 void writeSettings( QString name )
124 QSettings settings( "VideoLAN", "VLC" );
125 settings.beginGroup( name );
126 settings.setValue ("size", size() );
127 settings.setValue( "pos", pos() );
132 class QVLCMW : public QMainWindow
135 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
137 QVLCFrame::fixStyle( this );
139 virtual ~QVLCMW() {};
142 if( isVisible() ) hide();
146 intf_thread_t *p_intf;
149 void readSettings( QString name, QSize defSize )
151 QSettings settings( "VideoLAN", "VLC" );
152 settings.beginGroup( name );
153 QSize s = settings.value( "size", defSize ).toSize() ;
154 fprintf( stderr, "%i %i ", s.width(), s.height() );
155 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
158 void readSettings( QString name )
160 QSettings settings( "VideoLAN", "VLC" );
161 settings.beginGroup( name );
162 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
165 void writeSettings( QString name )
167 QSettings settings( "VideoLAN", "VLC" );
168 settings.beginGroup( name );
169 settings.setValue ("size", size() );
170 settings.setValue( "pos", pos() );