]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/plugins.cpp
Merge branch 'master' into lpcm_encoder
[vlc] / modules / gui / qt4 / dialogs / plugins.cpp
index cac958a5d8e336d74f7a9f9408c84651d5b90933..c29bd2d7fee43dfd8a8317ca38b13523061529a8 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <assert.h>
 
-//#include <vlc_modules.h>
+#include <vlc_modules.h>
 
 #include <QTreeWidget>
 #include <QStringList>
@@ -44,7 +44,6 @@
 #include <QLabel>
 #include <QVBoxLayout>
 #include <QComboBox>
-#include <QTextBrowser>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QSpacerItem>
@@ -72,10 +71,12 @@ PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     box->addButton( okButton, QDialogButtonBox::AcceptRole );
     layout->addWidget( box );
     BUTTONACT( okButton, close() );
+    readSettings( "PluginsDialog", QSize( 435, 280 ) );
 }
 
 PluginDialog::~PluginDialog()
 {
+    writeSettings( "PluginsDialog" );
 }
 
 /* Plugins tab */
@@ -141,6 +142,7 @@ inline void PluginTab::FillTree()
         QTreeWidgetItem *item = new PluginTreeItem( qs_item );
         treePlugins->addTopLevelItem( item );
     }
+    module_list_free( p_list );
 }
 
 void PluginTab::search( const QString& qs )
@@ -180,6 +182,8 @@ ExtensionTab::ExtensionTab( intf_thread_t *p_intf )
 
     // ListView
     extList = new QListView( this );
+    CONNECT( extList, activated( const QModelIndex& ),
+             this, moreInformation() );
     layout->addWidget( extList );
 
     // List item delegate
@@ -258,6 +262,11 @@ public:
     {
         name = qfu( p_ext->psz_name );
         description = qfu( p_ext->psz_description );
+        shortdesc = qfu( p_ext->psz_shortdescription );
+        if( description.isEmpty() )
+            description = shortdesc;
+        if( shortdesc.isEmpty() && !description.isEmpty() )
+            shortdesc = description;
         title = qfu( p_ext->psz_title );
         author = qfu( p_ext->psz_author );
         version = qfu( p_ext->psz_version );
@@ -265,7 +274,7 @@ public:
     }
     ~ExtensionCopy() {}
 
-    QString name, title, description, author, version, url;
+    QString name, title, description, shortdesc, author, version, url;
 };
 
 /* Extensions list model for the QListView */
@@ -283,6 +292,9 @@ ExtensionListModel::ExtensionListModel( QListView *view, intf_thread_t *intf )
 
 ExtensionListModel::~ExtensionListModel()
 {
+    // Clear extensions list
+    while( !extensions.isEmpty() )
+        delete extensions.takeLast();
 }
 
 void ExtensionListModel::updateList()
@@ -403,24 +415,22 @@ void ExtensionItemDelegate::paint( QPainter *painter,
         pen.setBrush( option.palette.text() );
     }
     pixpaint->setPen( pen );
+    QFontMetrics metrics = option.fontMetrics;
+
+    /// @todo Add extension's icon
 
     // Title: bold
     font.setBold( true );
     pixpaint->setFont( font );
-    pixpaint->drawText( QRect( 10, 5, width - 70, 20 ),
+    pixpaint->drawText( QRect( 10, 7, width - 70, metrics.height() ),
                         Qt::AlignLeft, ext->title );
 
     // Short description: normal
     font.setBold( false );
     pixpaint->setFont( font );
-    pixpaint->drawText( QRect( 10, 30, width - 40, 20 ),
-                        Qt::AlignLeft, ext->description );
-
-    // Version: italic
-    font.setItalic( true );
-    pixpaint->setFont( font );
-    pixpaint->drawText( QRect( width - 50, 5, 20, 20 ),
-                        Qt::AlignLeft, ext->version );
+    pixpaint->drawText( QRect( 10, 7 + metrics.height(), width - 40,
+                               metrics.height() ),
+                        Qt::AlignLeft, ext->shortdesc );
 
     // Flush paint operations
     delete pixpaint;
@@ -435,7 +445,7 @@ QSize ExtensionItemDelegate::sizeHint( const QStyleOptionViewItem &option,
     if (index.isValid() && index.column() == 0)
     {
         QFontMetrics metrics = option.fontMetrics;
-        return QSize( 200, 20 + 2 * metrics.height() );
+        return QSize( 200, 14 + 2 * metrics.height() );
     }
     else
         return QSize();
@@ -452,14 +462,18 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
     // Let's be a modal dialog
     setWindowModality( Qt::WindowModal );
 
+    // Window title
+    setWindowTitle( qtr( "About" ) + " " + extension.title );
+
     // Layout
     QGridLayout *layout = new QGridLayout( this );
 
     // Icon
+    /// @todo Use the extension's icon, when extensions will support icons :)
     QLabel *icon = new QLabel( this );
     QPixmap pix( ":/logo/vlc48.png" );
     icon->setPixmap( pix );
-    layout->addWidget( icon, 1, 0, 2, 1, Qt::AlignLeft );
+    layout->addWidget( icon, 1, 0, 2, 1 );
 
     // Title
     QLabel *label = new QLabel( extension.title, this );
@@ -467,50 +481,59 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
     font.setBold( true );
     font.setPointSizeF( font.pointSizeF() * 1.3f );
     label->setFont( font );
-    layout->addWidget( label, 0, 0, 1, -1, Qt::AlignLeft );
+    layout->addWidget( label, 0, 0, 1, -1 );
 
     // Version
-    label = new QLabel( this );
-    QString txt = qtr( "Version:" );
-    txt += extension.version;
-    label->setText( txt );
-    layout->addWidget( label, 1, 1, 1, 1, Qt::AlignLeft | Qt::AlignBottom );
+    label = new QLabel( "<b>" + qtr( "Version" ) + ":</b>", this );
+    layout->addWidget( label, 1, 1, 1, 1, Qt::AlignBottom );
+    label = new QLabel( extension.version, this );
+    layout->addWidget( label, 1, 2, 1, 2, Qt::AlignBottom );
 
     // Author
-    label = new QLabel( this );
-    txt = qtr( "Author(s):" );
-    txt += extension.author;
-    label->setText( txt );
-    layout->addWidget( label, 2, 1, 1, 1, Qt::AlignLeft | Qt::AlignTop );
+    label = new QLabel( "<b>" + qtr( "Author" ) + ":</b>", this );
+    layout->addWidget( label, 2, 1, 1, 1, Qt::AlignTop );
+    label = new QLabel( extension.author, this );
+    layout->addWidget( label, 2, 2, 1, 2, Qt::AlignTop );
+
 
     // Description
-    // FIXME: if( !extension.full_description.isEmpty() ) ...
-    QTextBrowser *text = new QTextBrowser( this );
-    text->setHtml( extension.description );
-    layout->addWidget( text, 4, 0, 1, -1, Qt::AlignJustify );
+    label = new QLabel( this );
+    label->setText( extension.description );
+    label->setWordWrap( true );
+    label->setOpenExternalLinks( true );
+    layout->addWidget( label, 4, 0, 1, -1 );
 
     // URL
-    label = new QLabel( qtr( "Website:" ), this );
-    font = label->font();
-    font.setBold( true );
-    label->setFont( font );
-    layout->addWidget( label, 5, 0, 1, 1, Qt::AlignLeft );
-    label = new QLabel( extension.url, this );
-    label->setTextInteractionFlags( Qt::TextBrowserInteraction );
-    layout->addWidget( label, 5, 1, 1, 1, Qt::AlignLeft );
+    label = new QLabel( "<b>" + qtr( "Website" ) + ":</b>", this );
+    layout->addWidget( label, 5, 0, 1, 2 );
+    QString txt = "<a href=\"";
+    txt += extension.url;
+    txt += "\">";
+    txt += extension.url;
+    txt += "</a>";
+    label = new QLabel( txt, this );
+    label->setText( txt );
+    label->setOpenExternalLinks( true );
+    layout->addWidget( label, 5, 2, 1, -1 );
 
     // Script file
-    label = new QLabel( qtr( "File:" ), this );
-    label->setFont( font );
-    layout->addWidget( label, 6, 0, 1, 1, Qt::AlignLeft );
+    label = new QLabel( "<b>" + qtr( "File" ) + ":</b>", this );
+    layout->addWidget( label, 6, 0, 1, 2 );
     QLineEdit *line = new QLineEdit( extension.name, this );
-    layout->addWidget( line, 6, 1, 1, 1, Qt::AlignLeft );
+    layout->addWidget( line, 6, 2, 1, -1 );
 
     // Close button
-    QDialogButtonBox *group = new QDialogButtonBox( QDialogButtonBox::Close,
-                                                    Qt::Horizontal, this );
+    QDialogButtonBox *group = new QDialogButtonBox( this );
+    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
+    group->addButton( closeButton, QDialogButtonBox::AcceptRole );
+    BUTTONACT( closeButton, close() );
+
     layout->addWidget( group, 7, 0, 1, -1 );
-    connect( group, SIGNAL(accepted()), this, SLOT(close()) );
+
+    // Fix layout
+    layout->setColumnStretch( 2, 1 );
+    layout->setRowStretch( 4, 1 );
+    setMinimumSize( 450, 350 );
 }
 
 ExtensionInfoDialog::~ExtensionInfoDialog()