]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/qvlcframe.hpp
85ad2a2e97f956ba4bc77c92f706fa744f6358da
[vlc] / modules / gui / qt4 / util / qvlcframe.hpp
1 /*****************************************************************************
2  * qvlcframe.hpp : A few helpers
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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
23 #ifndef _QVLCFRAME_H_
24 #define _QVLCFRAME_H_
25
26 #include <QWidget>
27 #include <QApplication>
28 #include <QSettings>
29 #include <QMainWindow>
30 #include <QPlastiqueStyle>
31 #include <vlc/vlc.h>
32
33 class QVLCFrame : public QWidget
34 {
35 public:
36     static void fixStyle( QWidget *w)
37     {
38          QStyle *style = qApp->style();
39         // Plastique is too dark.
40         /// theming ? getting KDE data ? ?
41         if( qobject_cast<QPlastiqueStyle *>(style) )
42         {
43             QPalette plt( w->palette() );
44             plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
45             QColor vlg = (Qt::lightGray);
46             vlg = vlg.toHsv();
47             vlg.setHsv( vlg.hue(), vlg.saturation(), 235  );
48             plt.setColor( QPalette::Active, QPalette::Window, vlg );
49             plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
50             w->setPalette( plt );
51         }
52     }
53
54     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
55     {
56         fixStyle( this );
57     };
58     virtual ~QVLCFrame()   {};
59
60     void toggleVisible()
61     {
62         if( isVisible() ) hide();
63         else show();
64     }
65 protected:
66     intf_thread_t *p_intf;
67
68     void readSettings( QString name, QSize defSize )
69     {
70         QSettings settings( "VideoLAN", "VLC" );
71         settings.beginGroup( name );
72         resize( settings.value( "size", defSize ).toSize() );
73         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
74         settings.endGroup();
75     }
76     void writeSettings( QString name )
77     {
78         fprintf( stderr, "save\n" );
79         QSettings settings( "VideoLAN", "VLC" );
80         settings.beginGroup( name );
81         settings.setValue ("size", size() );
82         settings.setValue( "pos", pos() );
83         settings.endGroup();
84     }
85 };
86
87 class QVLCMW : public QMainWindow
88 {
89 public:
90     QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
91     {
92         QVLCFrame::fixStyle( this );
93     }
94     virtual ~QVLCMW() {};
95 protected:
96     intf_thread_t *p_intf;
97     QSize mainSize;
98
99     void readSettings( QString name, QSize defSize )
100     {
101         QSettings settings( "VideoLAN", "VLC" );
102         settings.beginGroup( name );
103         mainSize = settings.value( "size", defSize ).toSize();
104         QPoint npos = settings.value( "pos", QPoint( 0,0 ) ).toPoint();
105         if( npos.x() > 0 )
106             move( npos );
107         settings.endGroup();
108     }
109     void readSettings( QString name )
110     {
111         QSettings settings( "VideoLAN", "VLC" );
112         settings.beginGroup( name );
113         mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
114         settings.endGroup();
115     }
116     void writeSettings( QString name )
117     {
118         QSettings settings( "VideoLAN", "VLC" );
119         settings.beginGroup( name );
120         settings.setValue ("size", size() );
121         settings.setValue( "pos", pos() );
122         settings.endGroup();
123     }
124 };
125
126 #endif