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 )
69 fprintf( stderr, "Gra\n" );
71 QHBoxLayout *buttons_layout = new QHBoxLayout;
72 QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
73 QSizePolicy::Expanding, QSizePolicy::Minimum);
74 buttons_layout->addItem( spacerItem );
78 utf8_fprintf( stderr, "Creating default button %s\n", psz_default );
79 *defaul = new QPushButton(0);
80 (*defaul)->setFocus();
81 buttons_layout->addWidget( *defaul );
82 (*defaul)->setText( qfu( psz_default ) );
86 *alt = new QPushButton(0);
87 buttons_layout->addWidget( *alt );
88 (*alt)->setText( qfu( psz_alt ) );
92 *other = new QPushButton( 0 );
93 buttons_layout->addWidget( *other );
94 (*other)->setText( qfu( psz_other ) );
97 l->addLayout( buttons_layout );
99 return buttons_layout;
102 QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
106 virtual ~QVLCFrame() {};
110 if( isVisible() ) hide();
114 intf_thread_t *p_intf;
116 void readSettings( QString name, QSize defSize )
118 QSettings settings( "VideoLAN", "VLC" );
119 settings.beginGroup( name );
120 resize( settings.value( "size", defSize ).toSize() );
121 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
124 void writeSettings( QString name )
126 QSettings settings( "VideoLAN", "VLC" );
127 settings.beginGroup( name );
128 settings.setValue ("size", size() );
129 settings.setValue( "pos", pos() );
134 class QVLCMW : public QMainWindow
137 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
139 QVLCFrame::fixStyle( this );
141 virtual ~QVLCMW() {};
144 if( isVisible() ) hide();
148 intf_thread_t *p_intf;
151 void readSettings( QString name, QSize defSize )
153 QSettings settings( "VideoLAN", "VLC" );
154 settings.beginGroup( name );
155 QSize s = settings.value( "size", defSize ).toSize() ;
156 fprintf( stderr, "%i %i ", s.width(), s.height() );
157 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
160 void readSettings( QString name )
162 QSettings settings( "VideoLAN", "VLC" );
163 settings.beginGroup( name );
164 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
167 void writeSettings( QString name )
169 QSettings settings( "VideoLAN", "VLC" );
170 settings.beginGroup( name );
171 settings.setValue ("size", size() );
172 settings.setValue( "pos", pos() );