]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/help.cpp
Qt: AboutDialog: reset dialog on show.
[vlc] / modules / gui / qt4 / dialogs / help.cpp
index fb6fb8d36f921c51aed89eecb2513c3e28b0b63c..a281afdf06a16bf42d2d55ec6db8d13b29ba66ea 100644 (file)
@@ -79,57 +79,95 @@ HelpDialog::~HelpDialog()
 }
 
 AboutDialog::AboutDialog( intf_thread_t *_p_intf)
-            : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
+            : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf ), b_advanced( false )
 {
     /* Build UI */
     ui.setupUi( this );
-    ui.closeButtonBox->addButton(
-        new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
-
     setWindowTitle( qtr( "About" ) );
     setWindowRole( "vlc-about" );
-    setMinimumSize( 600, 500 );
-    resize( 600, 500 );
     setWindowModality( Qt::WindowModal );
 
-    CONNECT( ui.closeButtonBox, rejected(), this, close() );
-    ui.closeButtonBox->setFocus();
-
-    ui.introduction->setText(
-            qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
-
+    ui.version->setText(qfu( " " VERSION_MESSAGE ) );
+#if 0
     if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) )
         ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128-xmas.png" ) );
     else
         ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
+#endif
 
-    /* Main Introduction */
-    ui.infoLabel->setText(
-            qtr( "VLC media player is a free media player, "
-                "encoder and streamer that can read from files, "
-                "CDs, DVDs, network streams, capture cards and even more!\n"
-                "VLC uses its internal codecs and works on essentially every "
-                "popular platform.\n\n" )
-            + qtr( "This version of VLC was compiled by:\n " )
-            + qfu( VLC_CompileBy() )+ " on " + qfu( VLC_CompileHost() ) +
-            + " ("__DATE__" "__TIME__").\n"
-            + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
-            + qtr( "You are using the Qt Interface.\n\n" )
-            + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
-            + qtr( " by the VideoLAN Team.\n" )
-            + "<a href=\"http://www.videolan.org\">http://www.videolan.org</a>" );
-
-    /* Be translators friendly: Convert to rich text */
-    ui.infoLabel->setText( ui.infoLabel->text().replace( "\n", "<br/>" ) );
+#if 0
+    ifdef UPDATE_CHECK
+#else
+    ui.update->hide();
+#endif
 
     /* GPL License */
-    ui.licenseEdit->setText( qfu( psz_license ) );
+    ui.licensePage->setText( qfu( psz_license ) );
 
     /* People who helped */
-    ui.thanksEdit->setText( qfu( psz_thanks ) );
+    ui.creditPage->setText( qfu( psz_thanks ) );
 
     /* People who wrote the software */
-    ui.authorsEdit->setText( qfu( psz_authors ) );
+    ui.authorsPage->setText( qfu( psz_authors ) );
+
+    ui.licenseButton->installEventFilter( this );
+    ui.authorsButton->installEventFilter( this );
+    ui.creditsButton->installEventFilter( this );
+
+    ui.version->installEventFilter( this );
+}
+
+void AboutDialog::showLicense()
+{
+    ui.stackedWidget->setCurrentWidget( ui.licensePage );
+}
+
+void AboutDialog::showAuthors()
+{
+    ui.stackedWidget->setCurrentWidget( ui.authorsPage );
+}
+
+void AboutDialog::showCredit()
+{
+    ui.stackedWidget->setCurrentWidget( ui.creditPage );
+}
+
+bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::MouseButtonPress )
+    {
+        if( obj == ui.version )
+        {
+            if( !b_advanced )
+            {
+                ui.version->setText(qfu( VLC_CompileBy() )+ "@" + qfu( VLC_CompileHost() )
+                    + __DATE__ + " " +__TIME__);
+                b_advanced = true;
+            }
+            else
+            {
+                ui.version->setText(qfu( " " VERSION_MESSAGE ) );
+                b_advanced = false;
+            }
+            return true;
+        }
+        else if( obj == ui.licenseButton )
+            showLicense();
+        else if( obj == ui.authorsButton )
+            showAuthors();
+        else if( obj == ui.creditsButton )
+            showCredit();
+
+        return false;
+    }
+
+    return QVLCDialog::eventFilter( obj, event);
+}
+
+void AboutDialog::showEvent( QShowEvent *event )
+{
+    ui.stackedWidget->setCurrentWidget( ui.blablaPage );
+    QVLCDialog::showEvent( event );
 }
 
 #ifdef UPDATE_CHECK
@@ -249,7 +287,16 @@ void UpdateDialog::updateNotify( bool b_result )
                 .arg( p_release->i_extra == 0 ? "" : "." + QString::number( p_release->i_extra ) );
 
             ui.updateNotifyLabel->setText( message );
-            ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) );
+            message = qfu( p_release->psz_desc ).replace( "\n", "<br/>" );
+
+            /* Try to highlight releases featuring security changes */
+            int i_index = message.indexOf( "security", Qt::CaseInsensitive );
+            if ( i_index >= 0 )
+            {
+                message.insert( i_index + 8, "</font>" );
+                message.insert( i_index, "<font style=\"color:red\">" );
+            }
+            ui.updateNotifyTextEdit->setHtml( message );
 
             /* Force the dialog to be shown */
             this->show();