]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/qvlcframe.hpp
Icons support
[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 #if 0
40         // Plastique is too dark.
41         /// theming ? getting KDE data ? ?
42         if( qobject_cast<QPlastiqueStyle *>(style) )
43         {
44             QPalette plt( w->palette() );
45             plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
46             QColor vlg = (Qt::lightGray);
47             vlg = vlg.toHsv();
48             vlg.setHsv( vlg.hue(), vlg.saturation(), 235  );
49             plt.setColor( QPalette::Active, QPalette::Window, vlg );
50             plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
51             w->setPalette( plt );
52         }
53 #endif
54     }
55
56     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
57     {
58         fixStyle( this );
59     };
60     virtual ~QVLCFrame()   {};
61
62     void toggleVisible()
63     {
64         if( isVisible() ) hide();
65         else show();
66     }
67 protected:
68     intf_thread_t *p_intf;
69
70     void readSettings( QString name, QSize defSize )
71     {
72         QSettings settings( "VideoLAN", "VLC" );
73         settings.beginGroup( name );
74         resize( settings.value( "size", defSize ).toSize() );
75         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
76         settings.endGroup();
77     }
78     void writeSettings( QString name )
79     {
80         QSettings settings( "VideoLAN", "VLC" );
81         settings.beginGroup( name );
82         settings.setValue ("size", size() );
83         settings.setValue( "pos", pos() );
84         settings.endGroup();
85     }
86 };
87
88 class QVLCMW : public QMainWindow
89 {
90 public:
91     QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
92     {
93         QVLCFrame::fixStyle( this );
94     }
95     virtual ~QVLCMW() {};
96 protected:
97     intf_thread_t *p_intf;
98     QSize mainSize;
99
100     void readSettings( QString name, QSize defSize )
101     {
102         QSettings settings( "VideoLAN", "VLC" );
103         settings.beginGroup( name );
104         mainSize = settings.value( "size", defSize ).toSize();
105         QPoint npos = settings.value( "pos", QPoint( 0,0 ) ).toPoint();
106         if( npos.x() > 0 )
107             move( npos );
108         settings.endGroup();
109     }
110     void readSettings( QString name )
111     {
112         QSettings settings( "VideoLAN", "VLC" );
113         settings.beginGroup( name );
114         mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
115         settings.endGroup();
116     }
117     void writeSettings( QString name )
118     {
119         QSettings settings( "VideoLAN", "VLC" );
120         settings.beginGroup( name );
121         settings.setValue ("size", size() );
122         settings.setValue( "pos", pos() );
123         settings.endGroup();
124     }
125 };
126
127 #endif