]> git.sesse.net Git - vlc/commitdiff
Qt4 - New Simple Preferences look'n feel. Should work without too many segfaults...
authorJean-Baptiste Kempf <jb@videolan.org>
Wed, 4 Apr 2007 00:05:33 +0000 (00:05 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 4 Apr 2007 00:05:33 +0000 (00:05 +0000)
Some look has still to be done, especially for size/margin/padding.
I don't know yet if the look of the button will be like that ( flat, rounded onMouseOver, darked onCliked)

modules/gui/qt4/components/open.hpp
modules/gui/qt4/components/simple_preferences.cpp
modules/gui/qt4/components/simple_preferences.hpp
modules/gui/qt4/dialogs/preferences.cpp
modules/gui/qt4/dialogs/preferences.hpp

index 83ed6e9035a0c89b87012a4c7a099878a8c39394..7cf2bb1f70d0b7e6b7eee90eae60eb7ed6fe4d5e 100644 (file)
@@ -51,7 +51,7 @@ protected:
 public slots:
     virtual void updateMRL() = 0;
 signals:
-    void mrlUpdated(QString);
+    void mrlUpdated( QString );
     void methodChanged( QString method );
 };
 
index 80635be0e35738d98cfbb154494411494edf0a72..4272970bed17db5c959f5119f3dce2ab6f489d5c 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <QListWidget>
-#include <QListWidgetItem>
 #include <QString>
 #include <QFont>
+#include <QToolButton>
+#include <QButtonGroup>
 
 #include "components/simple_preferences.hpp"
 #include "components/preferences_widgets.hpp"
 
 #include <vlc_config_cat.h>
 
-#include "pixmaps/hotkeys_50x50.xpm"
-#include "pixmaps/audio_50x50.xpm"
-#include "pixmaps/input_and_codecs_50x50.xpm"
-#include "pixmaps/interface_50x50.xpm"
-#include "pixmaps/subtitles_50x50.xpm"
-#include "pixmaps/video_50x50.xpm"
-
 #include "ui/sprefs_audio.h"
 #include "ui/sprefs_input.h"
 #include "ui/sprefs_video.h"
 #include "ui/sprefs_hotkeys.h"
 #include "ui/sprefs_interface.h"
 
-#define ITEM_HEIGHT 64
+#define ICON_HEIGHT 64
+#define BUTTON_HEIGHT 76
 
 /*********************************************************************
  * The List of categories
  *********************************************************************/
 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
-                                  QListWidget( _parent ), p_intf( _p_intf )
+                                  QWidget( _parent ), p_intf( _p_intf )
 {
-    setIconSize( QSize( ITEM_HEIGHT, ITEM_HEIGHT ) );
-    setViewMode(QListView::ListMode);
-    setMovement(QListView::Static);
-    setMaximumWidth(200);
-    setSpacing(0);
-//  setWordWrap(true);
-    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
-    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    setAlternatingRowColors( true );
-
-#define ADD_CATEGORY( id, label, icon )                                  \
-    addItem( label );                                                    \
-    item( id )->setIcon( QIcon( ":/pixmaps/" #icon ) )  ;   \
-    item( id )->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter );      \
-    item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) );   \
-    item( id )->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+    QVBoxLayout *layout = new QVBoxLayout();
+
+    QButtonGroup *buttonGroup = new QButtonGroup( this );
+    buttonGroup->setExclusive ( true );
+    CONNECT( buttonGroup, buttonClicked ( int ),
+            this, switchPanel( int ) );
+
+#define ADD_CATEGORY( button, label, icon, numb )                           \
+    QToolButton * button = new QToolButton( this );                         \
+    button->setIcon( QIcon( ":/pixmaps/" #icon ) );                         \
+    button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) );              \
+    button->setText( label );                                               \
+    button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );              \
+    button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT);                         \
+    button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ;  \
+    button->setAutoRaise( true );                                           \
+    button->setCheckable( true );                                           \
+    buttonGroup->addButton( button, numb );                                 \
+    layout->addWidget( button );
 
     ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
-                  spref_cone_Interface_64.png );
-    ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png );
-    ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png );
+                  spref_cone_Interface_64.png, 0 );
+    ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
+    ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
     ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"),
-                  spref_cone_Subtitles_64.png );
+                  spref_cone_Subtitles_64.png, 3 );
     ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
-                  spref_cone_Input_64.png );
-    ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png );
+                  spref_cone_Input_64.png, 4 );
+    ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
 
-    setCurrentRow( SPrefsInterface );
+    this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
+    setLayout( layout );
+}
+
+void SPrefsCatList::switchPanel( int i )
+{
+    emit currentItemChanged( i );
 }
 
 /*********************************************************************
@@ -304,3 +307,4 @@ void SPrefsPanel::apply()
 
 void SPrefsPanel::clean()
 {}
+
index 99d6892652482e2269b4fc20974ef59c57703bb2..39d5756c9b8710fe9a5e51de839165ab4337e5ed 100644 (file)
@@ -25,6 +25,7 @@
 #define _SIMPLEPREFS_H_
 
 #include <QListWidget>
+#include <QVBoxLayout>
 #include <vlc/vlc.h>
 #include <vlc_interface.h>
 
@@ -41,7 +42,7 @@ enum {
 
 class ConfigControl;
 
-class SPrefsCatList : public QListWidget
+class SPrefsCatList : public QWidget
 {
     Q_OBJECT;
 public:
@@ -49,6 +50,10 @@ public:
     virtual ~SPrefsCatList() {};
 private:
     intf_thread_t *p_intf;
+signals:
+    void currentItemChanged( int );
+public slots:
+    void switchPanel( int );
 };
 
 class SPrefsPanel : public QWidget
index d404a687e334003e1cbca30bdce09fae60200d71..83ca1f7240bce641a02539c80825357e825f48c5 100644 (file)
@@ -143,8 +143,8 @@ void PrefsDialog::setSmall()
     {
          simple_tree = new SPrefsCatList( p_intf, tree_panel );
          CONNECT( simple_tree,
-                  currentItemChanged( QListWidgetItem *, QListWidgetItem *),
-                  this,  changeSimplePanel( QListWidgetItem * ) );
+                  currentItemChanged( int ),
+                  this,  changeSimplePanel( int ) );
     }
     tree_panel_l->addWidget( simple_tree );
     simple_tree->show();
@@ -160,9 +160,8 @@ void PrefsDialog::setSmall()
     simple_panel->show();
 }
 
-void PrefsDialog::changeSimplePanel( QListWidgetItem *item )
+void PrefsDialog::changeSimplePanel( int number )
 {
-    int number = item->data( Qt::UserRole ).toInt();
     if( simple_panel )
     {
         main_panel_l->removeWidget( simple_panel );
@@ -176,7 +175,6 @@ void PrefsDialog::changeSimplePanel( QListWidgetItem *item )
     }
     main_panel_l->addWidget( simple_panel );
     simple_panel->show();
-//    panel_label->setText(qtr("Test")); //FIXME
 }
 
 void PrefsDialog::changePanel( QTreeWidgetItem *item )
index 55e409b10007edb7429b9c0d560a93a61be2de81..e43256dfcb73324398d1f7cc932e31d7160331a6 100644 (file)
@@ -80,7 +80,7 @@ private:
     static PrefsDialog *instance;
 private slots:
      void changePanel( QTreeWidgetItem * );
-     void changeSimplePanel( QListWidgetItem * );
+     void changeSimplePanel( int );
      void setAll();
      void setSmall();
      void save();