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>
37 class QVLCFrame : public QWidget
40 static void fixStyle( QWidget *w)
42 QStyle *style = qApp->style();
44 // Plastique is too dark.
45 /// theming ? getting KDE data ? ?
46 if( qobject_cast<QPlastiqueStyle *>(style) )
48 QPalette plt( w->palette() );
49 plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
50 QColor vlg = (Qt::lightGray);
52 vlg.setHsv( vlg.hue(), vlg.saturation(), 235 );
53 plt.setColor( QPalette::Active, QPalette::Window, vlg );
54 plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
55 plt.setColor( QPalette::Inactive, QPalette::Button, vlg );
56 plt.setColor( QPalette::Active, QPalette::Button, vlg );
57 plt.setColor( QPalette::Active, QPalette::Text, Qt::yellow );
62 static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
63 QPushButton **defaul, char *psz_default,
64 QPushButton **alt, char *psz_alt,
65 QPushButton **other, char *psz_other )
69 QHBoxLayout *buttons_layout = new QHBoxLayout;
70 QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
71 QSizePolicy::Expanding, QSizePolicy::Minimum);
72 buttons_layout->addItem( spacerItem );
76 fprintf( stderr, "Creating default button %s\n", psz_default );
77 *defaul = new QPushButton(0);
78 buttons_layout->addWidget( *defaul );
79 (*defaul)->setText( qfu( psz_default ) );
83 *alt = new QPushButton(0);
84 buttons_layout->addWidget( *alt );
85 (*alt)->setText( qfu( psz_alt ) );
89 *other = new QPushButton( 0 );
90 buttons_layout->addWidget( *other );
91 (*other)->setText( qfu( psz_other ) );
94 l->addLayout( buttons_layout );
96 return buttons_layout;
99 QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
103 virtual ~QVLCFrame() {};
107 if( isVisible() ) hide();
111 intf_thread_t *p_intf;
113 void readSettings( QString name, QSize defSize )
115 QSettings settings( "VideoLAN", "VLC" );
116 settings.beginGroup( name );
117 resize( settings.value( "size", defSize ).toSize() );
118 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
121 void writeSettings( QString name )
123 QSettings settings( "VideoLAN", "VLC" );
124 settings.beginGroup( name );
125 settings.setValue ("size", size() );
126 settings.setValue( "pos", pos() );
131 class QVLCMW : public QMainWindow
134 QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
136 QVLCFrame::fixStyle( this );
138 virtual ~QVLCMW() {};
141 if( isVisible() ) hide();
145 intf_thread_t *p_intf;
148 void readSettings( QString name, QSize defSize )
150 QSettings settings( "VideoLAN", "VLC" );
151 settings.beginGroup( name );
152 QSize s = settings.value( "size", defSize ).toSize() ;
153 fprintf( stderr, "%i %i ", s.width(), s.height() );
154 move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
157 void readSettings( QString name )
159 QSettings settings( "VideoLAN", "VLC" );
160 settings.beginGroup( name );
161 mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
164 void writeSettings( QString name )
166 QSettings settings( "VideoLAN", "VLC" );
167 settings.beginGroup( name );
168 settings.setValue ("size", size() );
169 settings.setValue( "pos", pos() );