]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/qvlcframe.hpp
[Untested] Save interface position
[vlc] / modules / gui / qt4 / util / qvlcframe.hpp
1 /*****************************************************************************
2  * qvlcframe.hpp : A few helpers
3  ****************************************************************************
4  * Copyright (C) 2000-2006 the VideoLAN team
5  * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
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         QSettings settings( "VideoLAN", "VLC" );
79         settings.beginGroup( name );
80         settings.setValue ("size", size() );
81         settings.setValue( "pos", pos() );
82         settings.endGroup();
83     }
84 };
85
86 class QVLCMW : public QMainWindow
87 {
88 public:
89     QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
90     {
91         QVLCFrame::fixStyle( this );
92     }
93     virtual ~QVLCMW() {};
94 protected:
95     intf_thread_t *p_intf;
96     QSize mainSize;
97
98     void readSettings( QString name, QSize defSize )
99     {
100         QSettings settings( "VideoLAN", "VLC" );
101         settings.beginGroup( name );
102         mainSize = settings.value( "size", defSize ).toSize();
103         resize( mainSize );
104         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
105         settings.endGroup();
106     }
107     void writeSettings( QString name )
108     {
109         QSettings settings( "VideoLAN", "VLC" );
110         settings.beginGroup( name );
111         settings.setValue ("size", size() );
112         settings.setValue( "pos", pos() );
113         settings.endGroup();
114     }
115 };
116
117 #endif