Qt: simplify previewWidgets creation.
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 12 Oct 2009 13:00:44 +0000 (15:00 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 16 Oct 2009 09:21:16 +0000 (11:21 +0200)
Btw, you really shouldn't use C cast on QObjects

modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.hpp
modules/gui/qt4/components/simple_preferences.cpp
modules/gui/qt4/ui/sprefs_interface.ui

index 7e09a0e..396da64 100644 (file)
@@ -200,8 +200,7 @@ void ConfigControl::doApply( intf_thread_t *p_intf )
 /*******************************************************
  * Simple widgets
  *******************************************************/
-InterfacePreviewWidget::InterfacePreviewWidget
-        ( QWidget *parent ) : QLabel( parent, 0 )
+InterfacePreviewWidget::InterfacePreviewWidget ( QWidget *parent ) : QLabel( parent )
 {
     setGeometry( 0, 0, 128, 100 );
     setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
index 1b235e8..420f835 100644 (file)
@@ -64,6 +64,10 @@ class InterfacePreviewWidget : public QLabel
 public:
     InterfacePreviewWidget( QWidget * );
 public slots:
+    /* 0: sample_classic, aka VLC 0.8.6
+       1: sample_complete, aka MPC
+       2: sample_minimal, aka WMP12 minimal
+       3: sample_skins */
     void setPreview( int );
 };
 
index f0e5647..3ffe3b3 100644 (file)
@@ -542,15 +542,9 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             ui.native_zone->setEnabled( ui.qt4->isChecked() );
             CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
 
-            InterfacePreviewWidget *preview = new InterfacePreviewWidget( this );
-            ( (QGridLayout *) ui.LooknfeelBox->layout() )->
-                    addWidget( preview, 1, 0, 1, 2 );
             CONNECT( ui.displayModeBox, currentIndexChanged( int ),
-                     preview, setPreview( int ) );
-            InterfacePreviewWidget *skinspreview = new InterfacePreviewWidget( this );
-            skinspreview->setPreview(3); /* skins_preview resource index */
-            ( (QGridLayout *) ui.LooknfeelBox->layout() )->
-                    addWidget( skinspreview, 7, 0, 1, 2 );
+                     ui.mainPreview, setPreview( int ) );
+            ui.skinsPreview->setPreview( 3 ); /* skins_preview resource index */
 
             CONFIG_GENERIC( "qt-display-mode", IntegerList, ui.displayLabel,
                             displayModeBox );
index 6a4d576..b279c84 100644 (file)
@@ -61,6 +61,9 @@
         <property name="text">
          <string>Album art download policy:</string>
         </property>
+        <property name="buddy">
+         <cstring>artFetcher</cstring>
+        </property>
        </widget>
       </item>
       <item row="0" column="2" colspan="2">
         <property name="margin">
          <number>5</number>
         </property>
+        <property name="buddy">
+         <cstring>recentlyPlayedFilters</cstring>
+        </property>
        </widget>
       </item>
       <item row="2" column="2" colspan="2">
         <property name="alignment">
          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
         </property>
+        <property name="buddy">
+         <cstring>language</cstring>
+        </property>
        </widget>
       </item>
       <item>
            <property name="text">
             <string>Force window style:</string>
            </property>
+           <property name="buddy">
+            <cstring>stylesCombo</cstring>
+           </property>
           </widget>
          </item>
         </layout>
         </property>
        </widget>
       </item>
+      <item row="1" column="0" colspan="2">
+       <widget class="InterfacePreviewWidget" name="mainPreview">
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="buddy">
+         <cstring>displayModeBox</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="7" column="0" colspan="2">
+       <widget class="InterfacePreviewWidget" name="skinsPreview"/>
+      </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>InterfacePreviewWidget</class>
+   <extends>QLabel</extends>
+   <header>components/preferences_widgets.hpp</header>
+  </customwidget>
+ </customwidgets>
  <tabstops>
   <tabstop>OneInterfaceMode</tabstop>
   <tabstop>artFetcher</tabstop>