]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/qvlcframe.hpp
* Made open and sout QDialogs
[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 <QDialog>
28 #include <QSpacerItem>
29 #include <QHBoxLayout>
30 #include <QApplication>
31 #include <QSettings>
32 #include <QMainWindow>
33 #include <QPlastiqueStyle>
34 #include <QPushButton>
35 #include "qt4.hpp"
36 #include <vlc/vlc.h>
37 #include <vlc_charset.h>
38
39 class QVLCFrame : public QWidget
40 {
41 public:
42     static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
43                                QPushButton **defaul, char *psz_default,
44                                QPushButton **alt, char *psz_alt,
45                                QPushButton **other, char *psz_other )
46     {
47 #ifdef QT42
48 #else
49         QHBoxLayout *buttons_layout = new QHBoxLayout;
50         QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
51                                QSizePolicy::Expanding, QSizePolicy::Minimum);
52         buttons_layout->addItem( spacerItem );
53
54         if( psz_default )
55         {
56             *defaul = new QPushButton(0);
57             (*defaul)->setFocus();
58             buttons_layout->addWidget( *defaul );
59             (*defaul)->setText( qfu( psz_default ) );
60         }
61         if( psz_alt )
62         {
63             *alt = new QPushButton(0);
64             buttons_layout->addWidget( *alt );
65             (*alt)->setText( qfu( psz_alt ) );
66         }
67         if( psz_other )
68         {
69             *other = new QPushButton( 0 );
70             buttons_layout->addWidget( *other );
71             (*other)->setText( qfu( psz_other ) );
72         }
73         if( l )
74             l->addLayout( buttons_layout );
75 #endif
76         return buttons_layout;
77     };
78
79     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
80     {    };
81     virtual ~QVLCFrame()   {};
82
83     void toggleVisible()
84     {
85         if( isVisible() ) hide();
86         else show();
87     }
88 protected:
89     intf_thread_t *p_intf;
90
91     void readSettings( QString name, QSize defSize )
92     {
93         QSettings settings( "VideoLAN", "VLC" );
94         settings.beginGroup( name );
95         resize( settings.value( "size", defSize ).toSize() );
96         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
97         settings.endGroup();
98     }
99     void writeSettings( QString name )
100     {
101         QSettings settings( "VideoLAN", "VLC" );
102         settings.beginGroup( name );
103         settings.setValue ("size", size() );
104         settings.setValue( "pos", pos() );
105         settings.endGroup();
106     }
107 };
108
109 class QVLCDialog : public QDialog
110 {
111 public:
112     QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
113                                     QDialog( parent ), p_intf( _p_intf )
114     {}
115     virtual ~QVLCDialog() {};
116     void toggleVisible()
117     {
118         if( isVisible() ) hide();
119         else show();
120     }
121
122 protected:
123     intf_thread_t *p_intf;
124 };
125
126 class QVLCMW : public QMainWindow
127 {
128 public:
129     QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
130     {    }
131     virtual ~QVLCMW() {};
132     void toggleVisible()
133     {
134         if( isVisible() ) hide();
135         else show();
136     }
137 protected:
138     intf_thread_t *p_intf;
139     QSize mainSize;
140
141     void readSettings( QString name, QSize defSize )
142     {
143         QSettings settings( "VideoLAN", "VLC" );
144         settings.beginGroup( name );
145       QSize s =  settings.value( "size", defSize ).toSize() ;
146       fprintf( stderr, "%i %i ", s.width(), s.height() );
147         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
148         settings.endGroup();
149     }
150     void readSettings( QString name )
151     {
152         QSettings settings( "VideoLAN", "VLC" );
153         settings.beginGroup( name );
154         mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
155         settings.endGroup();
156     }
157     void writeSettings( QString name )
158     {
159         QSettings settings( "VideoLAN", "VLC" );
160         settings.beginGroup( name );
161         settings.setValue ("size", size() );
162         settings.setValue( "pos", pos() );
163         settings.endGroup();
164     }
165 };
166
167 #endif