/*****************************************************************************
* qvlcframe.hpp : A few helpers
- ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ *****************************************************************************
+ * Copyright (C) 2006-2007 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
#ifndef _QVLCFRAME_H_
#define _QVLCFRAME_H_
#include <QWidget>
+#include <QDialog>
#include <QSpacerItem>
#include <QHBoxLayout>
#include <QApplication>
#include <QMainWindow>
#include <QPlastiqueStyle>
#include <QPushButton>
+#include <QKeyEvent>
+
#include "qt4.hpp"
#include <vlc/vlc.h>
+#include <vlc_charset.h>
class QVLCFrame : public QWidget
{
public:
- static void fixStyle( QWidget *w)
- {
- QStyle *style = qApp->style();
-#if 0
- // Plastique is too dark.
- /// theming ? getting KDE data ? ?
- if( qobject_cast<QPlastiqueStyle *>(style) )
- {
- QPalette plt( w->palette() );
- plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
- QColor vlg = (Qt::lightGray);
- vlg = vlg.toHsv();
- vlg.setHsv( vlg.hue(), vlg.saturation(), 235 );
- plt.setColor( QPalette::Active, QPalette::Window, vlg );
- plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
- plt.setColor( QPalette::Inactive, QPalette::Button, vlg );
- plt.setColor( QPalette::Active, QPalette::Button, vlg );
- plt.setColor( QPalette::Active, QPalette::Text, Qt::yellow );
- w->setPalette( plt );
- }
-#endif
- }
- static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
- QPushButton **defaul, char *psz_default,
- QPushButton **alt, char *psz_alt,
- QPushButton **other, char *psz_other )
- {
-#ifdef QT42
- fprintf( stderr, "Gra\n" );
-#else
- QHBoxLayout *buttons_layout = new QHBoxLayout;
- QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
- QSizePolicy::Expanding, QSizePolicy::Minimum);
- buttons_layout->addItem( spacerItem );
-
- if( psz_default )
- {
- fprintf( stderr, "Creating default button %s\n", psz_default );
- *defaul = new QPushButton(0);
- (*defaul)->setFocus();
- buttons_layout->addWidget( *defaul );
- (*defaul)->setText( qfu( psz_default ) );
- }
- if( psz_alt )
- {
- *alt = new QPushButton(0);
- buttons_layout->addWidget( *alt );
- (*alt)->setText( qfu( psz_alt ) );
- }
- if( psz_other )
- {
- *other = new QPushButton( 0 );
- buttons_layout->addWidget( *other );
- (*other)->setText( qfu( psz_other ) );
- }
- if( l )
- l->addLayout( buttons_layout );
-#endif
- return buttons_layout;
- };
-
QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
- {
- fixStyle( this );
- };
+ { };
virtual ~QVLCFrame() {};
void toggleVisible()
protected:
intf_thread_t *p_intf;
- void readSettings( QString name, QSize defSize )
+ void readSettings( QString name, QSize defSize, QPoint defPos )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
- resize( settings.value( "size", defSize ).toSize() );
- move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
+ /* never trust any saved size ;-) */
+ QSize newSize = settings.value( "size", defSize ).toSize();
+ if( newSize.isValid() )
+ resize( newSize );
+ move( settings.value( "pos", defPos ).toPoint() );
settings.endGroup();
}
void writeSettings( QString name )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
- settings.setValue ("size", size() );
+ /* only save valid sizes ... */
+ QSize currentsize = size();
+ if( currentsize.isValid() )
+ settings.setValue ("size", currentsize );
settings.setValue( "pos", pos() );
settings.endGroup();
}
+ virtual void cancel()
+ {
+ hide();
+ }
+ virtual void close()
+ {
+ hide();
+ }
+ virtual void keyPressEvent( QKeyEvent *keyEvent )
+ {
+ if( keyEvent->key() == Qt::Key_Escape )
+ {
+ msg_Dbg( p_intf, "Escp Key pressed" );
+ cancel();
+ }
+ else if( keyEvent->key() == Qt::Key_Return )
+ {
+ msg_Dbg( p_intf, "Enter Key pressed" );
+ close();
+ }
+ }
};
-class QVLCMW : public QMainWindow
+class QVLCDialog : public QDialog
{
public:
- QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
+ QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
+ QDialog( parent ), p_intf( _p_intf )
+ {}
+ virtual ~QVLCDialog() {};
+ void toggleVisible()
+ {
+ if( isVisible() ) hide();
+ else show();
+ }
+
+protected:
+ intf_thread_t *p_intf;
+
+ virtual void cancel()
+ {
+ hide();
+ }
+ virtual void close()
+ {
+ hide();
+ }
+ virtual void keyPressEvent( QKeyEvent *keyEvent )
{
- QVLCFrame::fixStyle( this );
+ if( keyEvent->key() == Qt::Key_Escape )
+ {
+ msg_Dbg( p_intf, "Escp Key pressed" );
+ cancel();
+ }
+ else if( keyEvent->key() == Qt::Key_Return )
+ {
+ msg_Dbg( p_intf, "Enter Key pressed" );
+ close();
+ }
}
+};
+
+class QVLCMW : public QMainWindow
+{
+public:
+ QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
+ { }
virtual ~QVLCMW() {};
void toggleVisible()
{
void readSettings( QString name, QSize defSize )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
- QSize s = settings.value( "size", defSize ).toSize() ;
- fprintf( stderr, "%i %i ", s.width(), s.height() );
+ QSize s = settings.value( "size", defSize ).toSize() ;
+ fprintf( stderr, "%i %i ", s.width(), s.height() );
move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
settings.endGroup();
}
+
void readSettings( QString name )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
+ if( !mainSize.isValid() )
+ {
+ mainSize = QSize(0,0);
+ }
settings.endGroup();
}
+
void writeSettings( QString name )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
- settings.setValue ("size", size() );
+ /* only save valid sizes ... */
+ QSize currentsize = size();
+ if( currentsize.isValid() )
+ settings.setValue ("size", currentsize );
settings.setValue( "pos", pos() );
settings.endGroup();
}