]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/help.cpp
Qt(Dialog provider): Add support for key accelerators
[vlc] / modules / gui / qt4 / dialogs / help.cpp
index 229601ede8f94c7c48d0468283e5d1a99169b07b..453753b28a4b397fb5afed3a3f626a243a4b381c 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Help.cpp : Help and About dialogs
+ * help.cpp : Help and About dialogs
  ****************************************************************************
  * Copyright (C) 2007 the VideoLAN team
  * $Id$
@@ -43,7 +43,6 @@
 #include <QString>
 #include <QDialogButtonBox>
 #include <QEvent>
-#include <QFileDialog>
 #include <QDate>
 #include <QPushButton>
 
@@ -57,89 +56,129 @@ HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     setMinimumSize( 350, 300 );
 
     QVBoxLayout *layout = new QVBoxLayout( this );
+
     QTextBrowser *helpBrowser = new QTextBrowser( this );
     helpBrowser->setOpenExternalLinks( true );
     helpBrowser->setHtml( qtr(I_LONGHELP) );
-    QDialogButtonBox *closeButtonBox = new QDialogButtonBox( Qt::Horizontal, this );
+
+    QDialogButtonBox *closeButtonBox = new QDialogButtonBox( this );
     closeButtonBox->addButton(
-        new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
+        new QPushButton( qtr("&Close") ), QDialogButtonBox::RejectRole );
     closeButtonBox->setFocus();
 
     layout->addWidget( helpBrowser );
     layout->addWidget( closeButtonBox );
 
     CONNECT( closeButtonBox, rejected(), this, close() );
-    readSettings( "Help", QSize( 500, 450 ) );
+    restoreWidgetPosition( "Help", QSize( 500, 450 ) );
 }
 
 HelpDialog::~HelpDialog()
 {
-    writeSettings( "Help" );
-}
-
-void HelpDialog::close()
-{
-    toggleVisible();
+    saveWidgetPosition( "Help" );
 }
 
 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" );
-    resize( 600, 500 );
-    setMinimumSize( 600, 500 );
     setWindowModality( Qt::WindowModal );
 
-    CONNECT( ui.closeButtonBox, rejected(), this, close() );
-    ui.closeButtonBox->setFocus();
+    ui.version->setText(qfu( " " VERSION_MESSAGE ) );
+    ui.title->setText("<html><head/><body><p><span style=\" font-size:26pt; color:#353535;\"> " + qtr( "VLC media player" ) + " </span></p></body></html>");
 
-    ui.introduction->setText(
-            qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
+    ui.MainBlabla->setText("<html><head/><body>" +
+    qtr( "<p>VLC media player is a free and open source media player, encoder, and streamer made by the volunteers of the <a href=\"http://www.videolan.org/\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</span></a> community.</p><p>VLC uses its internal codecs, works on essentially every popular platform, and can read almost all files, CDs, DVDs, network streams, capture cards and other media formats!</p><p><a href=\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: underline; color:#0057ae;\">Help and join us!</span></a>" ) +
+    "</p></body> </html>");
 
+#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 Qt4 Interface.\n\n" )
-            + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
-            + qtr( " by the VideoLAN Team.\n" )
-            + "vlc@videolan.org, http://www.videolan.org" );
+#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->setText( "<html><head/><body><p><span style=\" text-decoration: underline; color:#0057ae;\">"+qtr( "License" )+"</span></p></body></html>");
+    ui.licenseButton->installEventFilter( this );
+
+    ui.authorsButton->setText( "<html><head/><body><p><span style=\" text-decoration: underline; color:#0057ae;\">"+qtr( "Authors" )+"</span></p></body></html>");
+    ui.authorsButton->installEventFilter( this );
+
+    ui.creditsButton->setText( "<html><head/><body><p><span style=\" text-decoration: underline; color:#0057ae;\">"+qtr( "Credits" )+"</span></p></body></html>");
+    ui.creditsButton->installEventFilter( this );
+
+    ui.version->installEventFilter( this );
+}
+
+void AboutDialog::showLicense()
+{
+    ui.stackedWidget->setCurrentWidget( ui.licensePage );
 }
 
-AboutDialog::~AboutDialog()
+void AboutDialog::showAuthors()
 {
+    ui.stackedWidget->setCurrentWidget( ui.authorsPage );
 }
 
-void AboutDialog::close()
+void AboutDialog::showCredit()
 {
-    toggleVisible();
+    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
@@ -154,13 +193,18 @@ static void UpdateCallback( void *data, bool b_ret )
     QEvent* event;
 
     if( b_ret )
-        event = new QEvent( (QEvent::Type)UDOkEvent );
+        event = new QEvent( UpdateDialog::UDOkEvent );
     else
-        event = new QEvent( (QEvent::Type)UDErrorEvent );
+        event = new QEvent( UpdateDialog::UDErrorEvent );
 
     QApplication::postEvent( UDialog, event );
 }
 
+const QEvent::Type UpdateDialog::UDOkEvent =
+        (QEvent::Type)QEvent::registerEventType();
+const QEvent::Type UpdateDialog::UDErrorEvent =
+        (QEvent::Type)QEvent::registerEventType();
+
 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
 {
     /* build Ui */
@@ -189,9 +233,9 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     b_checked = false;
 
     setMinimumSize( 300, 300 );
-    setMaximumSize( 400, 300 );
+    setMaximumSize( 500, 300 );
 
-    readSettings( "Update", QSize( 300, 250 ) );
+    restoreWidgetPosition( "Update", maximumSize() );
 
     /* Check for updates */
     UpdateOrDownload();
@@ -200,12 +244,7 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
 UpdateDialog::~UpdateDialog()
 {
     update_Delete( p_update );
-    writeSettings( "Update" );
-}
-
-void UpdateDialog::close()
-{
-    toggleVisible();
+    saveWidgetPosition( "Update" );
 }
 
 /* Check for updates */
@@ -218,10 +257,7 @@ void UpdateDialog::UpdateOrDownload()
     }
     else
     {
-        QString dest_dir = QFileDialog::getExistingDirectory( this,
-                                 qtr( I_OP_SEL_DIR ),
-                                 QVLCUserDir( VLC_DOWNLOAD_DIR ) );
-
+        QString dest_dir = QDir::tempPath();
         if( !dest_dir.isEmpty() )
         {
             dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
@@ -259,10 +295,19 @@ void UpdateDialog::updateNotify( bool b_result )
                 .arg( QString::number( p_release->i_major ) )
                 .arg( QString::number( p_release->i_minor ) )
                 .arg( QString::number( p_release->i_revision ) )
-                .arg( ( p_release->extra )?QString( p_release->extra ):"" );
+                .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();
@@ -283,4 +328,3 @@ void UpdateDialog::updateNotify( bool b_result )
 }
 
 #endif
-