]> git.sesse.net Git - vlc/commitdiff
[Untested] Save interface position
authorClément Stenac <zorglub@videolan.org>
Wed, 5 Jul 2006 18:12:55 +0000 (18:12 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 5 Jul 2006 18:12:55 +0000 (18:12 +0000)
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/util/qvlcframe.hpp

index 371e8bd559e3673c6744bfd810c2580fe2bcdf38..18c93fdf622c39ee0512dff680c3e8dd10b42fb0 100644 (file)
@@ -32,8 +32,10 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
                                      VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
     new StandardPLPanel( this, p_intf, p_playlist, p_playlist->p_root_category );
+    readSettings( "playlist", QSize( 500,500 ) );
 }
 
 PlaylistDialog::~PlaylistDialog()
 {
+    writeSettings( "playlist" );
 }
index 6fd5e9d08e9acab7e62455e163a8bfde257c91bb..5efd4c1db85b5c79256358dd9c4e73d0e57fdede 100644 (file)
 #include <assert.h>
 #include <QPushButton>
 
-MainInterface::MainInterface( intf_thread_t *_p_intf ) : QMainWindow(),
-                                                         p_intf( _p_intf )
+MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     /* All UI stuff */
-    QVLCFrame::fixStyle( this );
     QWidget *main = new QWidget( this );
     setCentralWidget( main );
     setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
@@ -56,16 +54,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QMainWindow(),
     ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
     ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
 
-
 //    if( config_GetInt( p_intf, "embedded" ) )
     {
         videoWidget = new VideoWidget( p_intf );
         videoWidget->resize( 1,1 );
         ui.vboxLayout->insertWidget( 0, videoWidget );
     }
-    resize( QSize( 500, 121 ) );
-    i_saved_width = width();
-    i_saved_height = height();
+
+    readSettings( "MainWindow" , QSize( 500, 131) );
 
     //QVLCMenu::createMenuBar();
 
index f71b54dd86b1bc117fa3ca3092e45f24e7853bd9..99fe72b88ccf29483c5667ca259d8790e0cd6665 100644 (file)
 #include <vlc/intf.h>
 #include "ui/main_interface.h"
 #include "util/qvlcframe.hpp"
-#include <QMainWindow>
 
 class InputManager;
 class QCloseEvent;
 class InputSlider;
 class VideoWidget;
 
-class MainInterface : public QMainWindow
+class MainInterface : public QVLCMW
 {
     Q_OBJECT;
 public:
index 83b40c5400d181b32add067176b5c4a770a6e02c..04d9d56b3f4925f05df5b2d4d1a419adbbaf1778 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <QWidget>
 #include <QApplication>
+#include <QSettings>
+#include <QMainWindow>
 #include <QPlastiqueStyle>
 #include <vlc/vlc.h>
 
@@ -52,7 +54,7 @@ public:
     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
     {
         fixStyle( this );
-   };
+    };
     virtual ~QVLCFrame()   {};
 
     void toggleVisible()
@@ -62,5 +64,54 @@ public:
     }
 protected:
     intf_thread_t *p_intf;
+
+    void readSettings( QString name, QSize defSize )
+    {
+        QSettings settings( "VideoLAN", "VLC" );
+        settings.beginGroup( name );
+        resize( settings.value( "size", defSize ).toSize() );
+        move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
+        settings.endGroup();
+    }
+    void writeSettings( QString name )
+    {
+        QSettings settings( "VideoLAN", "VLC" );
+        settings.beginGroup( name );
+        settings.setValue ("size", size() );
+        settings.setValue( "pos", pos() );
+        settings.endGroup();
+    }
 };
+
+class QVLCMW : public QMainWindow
+{
+public:
+    QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
+    {
+        QVLCFrame::fixStyle( this );
+    }
+    virtual ~QVLCMW() {};
+protected:
+    intf_thread_t *p_intf;
+    QSize mainSize;
+
+    void readSettings( QString name, QSize defSize )
+    {
+        QSettings settings( "VideoLAN", "VLC" );
+        settings.beginGroup( name );
+        mainSize = settings.value( "size", defSize ).toSize();
+        resize( mainSize );
+        move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
+        settings.endGroup();
+    }
+    void writeSettings( QString name )
+    {
+        QSettings settings( "VideoLAN", "VLC" );
+        settings.beginGroup( name );
+        settings.setValue ("size", size() );
+        settings.setValue( "pos", pos() );
+        settings.endGroup();
+    }
+};
+
 #endif