/*****************************************************************************
* 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 <QSettings>
#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 );
- w->setPalette( plt );
- }
-#endif
- }
-
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 QVLCDialog : public QDialog
+{
+public:
+ 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 )
+ {
+ 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()
{
- QVLCFrame::fixStyle( this );
+ if( isVisible() ) hide();
+ else show();
}
- virtual ~QVLCMW() {};
protected:
intf_thread_t *p_intf;
QSize mainSize;
void readSettings( QString name, QSize defSize )
{
- QSettings settings( "VideoLAN", "VLC" );
+ QSettings settings( "vlc", "vlc-qt-interface" );
settings.beginGroup( name );
- mainSize = settings.value( "size", defSize ).toSize();
- QPoint npos = settings.value( "pos", QPoint( 0,0 ) ).toPoint();
- if( npos.x() > 0 )
- move( npos );
+ 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();
}