]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/complete_preferences.cpp
Qt4 - Prefs; cleaning, disabling unused code, general comments, class renaming, in...
[vlc] / modules / gui / qt4 / components / complete_preferences.cpp
index 6a85fe9da4fca4bb5c07607218a7514f586589e6..c2d7d47319f21b6206366c63230c3fc7f17028f0 100644 (file)
 
 #include "components/complete_preferences.hpp"
 #include "components/preferences_widgets.hpp"
-#include "qt4.hpp"
 
 #include <vlc_config_cat.h>
 #include <vlc_intf_strings.h>
 #include <assert.h>
 
-#include "pixmaps/audio.xpm"
-#include "pixmaps/video.xpm"
-#include "pixmaps/type_net.xpm"
-#include "pixmaps/type_playlist.xpm"
-#include "pixmaps/advanced.xpm"
-#include "pixmaps/codec.xpm"
-#include "pixmaps/intf.xpm"
-
 #define ITEM_HEIGHT 25
 
 /*********************************************************************
@@ -68,14 +59,14 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
     setTextElideMode( Qt::ElideNone );
     setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOn );
 
-#define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b##_xpm ))
-    BI( audio, audio );
-    BI( video, video );
-    BI( input, codec );
-    BI( sout, type_net );
-    BI( advanced, advanced );
-    BI( playlist, type_playlist );
-    BI( interface, intf );
+#define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b ))
+    BI( audio, ":/pixmaps/vlc_advprefs_audio.png" );
+    BI( video, ":/pixmaps/vlc_advprefs_video.png" );
+    BI( input, ":/pixmaps/vlc_advprefs_codec.png" );
+    BI( sout, ":/pixmaps/vlc_advprefs_sout.png" );
+    BI( advanced, ":/pixmaps/vlc_advprefs_extended.png" );
+    BI( playlist, ":/pixmaps/vlc_advprefs_playlist.png" );
+    BI( interface, ":/pixmaps/vlc_advprefs_intf.png" );
 #undef BI
 
     /* Build the tree for the main module */
@@ -88,7 +79,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
         assert (i < (unsigned)p_list->i_count);
 
         const module_t *p_main = (module_t *)p_list->p_values[i].p_object;
-        if( strcmp( p_main->psz_object_name, "main" ) == 0 )
+        if( strcmp( module_GetObjName( p_main ), "main" ) == 0 )
             p_module = p_main;
     }
 
@@ -97,18 +88,18 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
     for (size_t i = 0; i < p_module->confsize; i++)
     {
         const module_config_t *p_item = p_module->p_config + i;
-        char *psz_help;
+        const char *psz_help;
         QIcon icon;
         switch( p_item->i_type )
         {
         case CONFIG_CATEGORY:
             if( p_item->value.i == -1 ) break;
             data = new PrefsItemData();
-            data->name = QString( qfu( config_CategoryNameGet
+            data->name = QString( qtr( config_CategoryNameGet
                                            ( p_item->value.i ) ) );
             psz_help = config_CategoryHelpGet( p_item->value.i );
             if( psz_help )
-                data->help = QString( qfu(psz_help) );
+                data->help = QString( qtr(psz_help) );
             else
                 data->help.clear();
             data->i_type = TYPE_CATEGORY;
@@ -149,11 +140,11 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
                 // Data still contains the correct thing
                 data->i_type = TYPE_CATSUBCAT;
                 data->i_subcat_id = p_item->value.i;
-                data->name = QString( qfu( config_CategoryNameGet(
+                data->name = QString( qtr( config_CategoryNameGet(
                                             p_item->value.i )) );
                 psz_help = config_CategoryHelpGet( p_item->value.i );
                 if( psz_help )
-                    data->help = QString( qfu(psz_help) );
+                    data->help = QString( qtr(psz_help) );
                 else
                     data->help.clear();
                 current_item->setData( 0, Qt::UserRole,
@@ -161,11 +152,11 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
                 continue;
             }
             data = new PrefsItemData();
-            data->name = QString( qfu( config_CategoryNameGet(
+            data->name = QString( qtr( config_CategoryNameGet(
                                                         p_item->value.i)) );
             psz_help = config_CategoryHelpGet( p_item->value.i );
             if( psz_help )
-                data->help = QString( qfu(psz_help) );
+                data->help = QString( qtr(psz_help) );
             else
                 data->help.clear();
             data->i_type = TYPE_SUBCATEGORY;
@@ -191,7 +182,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
         p_module = (module_t *)p_list->p_values[i_index].p_object;
 
         // Main module excluded
-        if( !strcmp( p_module->psz_object_name, "main" ) ) continue;
+        if( !strcmp( module_GetObjName( p_module ), "main" ) ) continue;
 
         /* Exclude submodules; they have no config options of their own */
         if( p_module->b_submodule ) continue;
@@ -252,15 +243,14 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
         PrefsItemData *module_data = new PrefsItemData();
         module_data->b_submodule = p_module->b_submodule;
         module_data->i_type = TYPE_MODULE;
-        module_data->psz_name = strdup( p_module->psz_object_name );
+        module_data->psz_name = strdup( module_GetObjName( p_module ) );
         module_data->i_object_id = p_module->b_submodule ?
                          ((module_t *)p_module->p_parent)->i_object_id :
                          p_module->i_object_id;
         module_data->help.clear();
         // TODO image
         QTreeWidgetItem *module_item = new QTreeWidgetItem();
-        module_item->setText( 0, qfu( p_module->psz_shortname ?
-                      p_module->psz_shortname : p_module->psz_object_name) );
+        module_item->setText( 0, qtr( module_GetName( p_module, VLC_FALSE ) ) );
         //item->setIcon( 0 , XXX );
         module_item->setData( 0, Qt::UserRole,
                               QVariant::fromValue( module_data) );
@@ -334,10 +324,10 @@ void PrefsTree::doAll( bool doclean )
 /*********************************************************************
  * The Panel
  *********************************************************************/
-PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent )
+AdvPrefsPanel::AdvPrefsPanel( QWidget *_parent ) : QWidget( _parent )
 {}
 
-PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
+AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                         PrefsItemData * data ) :
                         QWidget( _parent ), p_intf( _p_intf )
 {
@@ -375,9 +365,14 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
         }
     }
 
+    /* Widgets now */
     global_layout = new QVBoxLayout();
     global_layout->setMargin( 2 );
     QString head;
+    QString help;
+
+    help = QString( data->help );
+
     if( data->i_type == TYPE_SUBCATEGORY || data->i_type ==  TYPE_CATSUBCAT )
     {
         head = QString( data->name );
@@ -385,24 +380,31 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     }
     else
     {
-        head = QString( qfu(p_module->psz_longname) );
+        head = QString( qtr( module_GetLongName( p_module ) ) );
         if( p_module->psz_help )
         {
-            head.append( "\n" );
-            head.append( qfu( p_module->psz_help ) );
+            help.append( "\n" );
+            help.append( qtr( module_GetHelp( p_module ) ) );
         }
     }
 
-    QLabel *label = new QLabel( head );
-    global_layout->addWidget( label );
-    QFont myFont = QApplication::font( static_cast<QWidget*>(0) );
-    myFont.setPointSize( myFont.pointSize() + 3 ); myFont.setBold( true );
+    QLabel *titleLabel = new QLabel( head );
+    QFont titleFont = QApplication::font( static_cast<QWidget*>(0) );
+    titleFont.setPointSize( titleFont.pointSize() + 6 );
+    titleFont.setFamily( "Verdana" );
+    titleLabel->setFont( titleFont );
+
+    // Title <hr>
+    QFrame *title_line = new QFrame;
+    title_line->setFrameShape(QFrame::HLine);
+    title_line->setFrameShadow(QFrame::Sunken);
 
-    label->setFont( myFont );
-    QLabel *help = new QLabel( data->help, this );
-    help->setWordWrap( true );
+    QLabel *helpLabel = new QLabel( help, this );
+    helpLabel->setWordWrap( true );
 
-    global_layout->addWidget( help );
+    global_layout->addWidget( titleLabel );
+    global_layout->addWidget( title_line );
+    global_layout->addWidget( helpLabel );
 
     QGroupBox *box = NULL;
     QGridLayout *boxlayout = NULL;
@@ -434,7 +436,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                 layout->addWidget( box, i_line, 0, 1, 2 );
                 i_line++;
             }
-            box = new QGroupBox( qfu(p_item->psz_text) );
+            box = new QGroupBox( qtr(p_item->psz_text) );
             boxlayout = new QGridLayout();
         }
         /* Only one hotkey control */
@@ -488,7 +490,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     setLayout( global_layout );
 }
 
-void PrefsPanel::apply()
+void AdvPrefsPanel::apply()
 {
     QList<ConfigControl *>::Iterator i;
     for( i = controls.begin() ; i != controls.end() ; i++ )
@@ -497,5 +499,5 @@ void PrefsPanel::apply()
         c->doApply( p_intf );
     }
 }
-void PrefsPanel::clean()
+void AdvPrefsPanel::clean()
 {}