[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise4/kdelibs-4.1-branch/kdeui/dialogs
From:       Marc Mutz <mutz () kde ! org>
Date:       2009-10-07 9:41:47
Message-ID: 1254908507.759673.7098.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1032206 by mutz:

KAboutApplicationDialog: add options to suppress translators tab and kde version.

This allows to use this dialog for other About Foo dialogs than just the one
for the application, as seen in the About Gpg4win dialog in Kleopatra.

 M  +35 -15    kaboutapplicationdialog.cpp  
 M  +22 -1     kaboutapplicationdialog.h  


--- branches/kdepim/enterprise4/kdelibs-4.1-branch/kdeui/dialogs/kaboutapplicationdialog.cpp \
#1032205:1032206 @@ -45,6 +45,8 @@
           aboutData(0)
     {}
 
+    void init( const KAboutData *aboutData, Options opt );
+
     void _k_showLicense( const QString &number );
 
     KAboutApplicationDialog *q;
@@ -56,26 +58,38 @@
   : KDialog(parent),
     d(new Private(this))
 {
-    if (aboutData == 0)
-        aboutData = KGlobal::mainComponent().aboutData();
+    d->init( aboutData, NoOptions );
+}
 
-    d->aboutData = aboutData;
+KAboutApplicationDialog::KAboutApplicationDialog(const KAboutData *aboutData, \
Options opt, QWidget *parent) +  : KDialog(parent),
+    d(new Private(this))
+{
+    d->init( aboutData, opt );
+}
 
+void KAboutApplicationDialog::Private::init( const KAboutData *ad, Options opt )
+{
+    if (ad == 0)
+        ad = KGlobal::mainComponent().aboutData();
+
+    aboutData = ad;
+
     if (!aboutData) {
         QLabel *errorLabel = new QLabel(i18n("<qt>No information available.<br />"
-                                             "The supplied KAboutData object does \
not exist.</qt>"), this); +                                             "The supplied \
KAboutData object does not exist.</qt>"), q);  
         errorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
-        setMainWidget(errorLabel);
+        q->setMainWidget(errorLabel);
         return;
     }
 
-    setPlainCaption(i18n("About %1", aboutData->programName()));
-    setButtons(KDialog::Close);
-    setDefaultButton(KDialog::Close);
-    setModal(false);
+    q->setPlainCaption(i18n("About %1", aboutData->programName()));
+    q->setButtons(KDialog::Close);
+    q->setDefaultButton(KDialog::Close);
+    q->setModal(false);
 
-    KTitleWidget *titleWidget = new KTitleWidget(this);
+    KTitleWidget *titleWidget = new KTitleWidget(q);
 
     QIcon windowIcon;
     if (!aboutData->programIconName().isEmpty()) {
@@ -89,8 +103,12 @@
     else if (aboutData->programLogo().canConvert<QImage>())
         titleWidget->setPixmap(QPixmap::fromImage(aboutData->programLogo().value<QImage>()), \
KTitleWidget::ImageLeft);  
-    titleWidget->setText(i18n("<html><font size=\"5\">%1</font><br /><b>Version \
                %2</b><br />Using KDE %3</html>",
-                         aboutData->programName(), aboutData->version(), \
QString(KDE_VERSION_STRING))); +    if ( opt & HideKdeVersion )
+        titleWidget->setText(i18n("<html><font size=\"5\">%1</font><br /><b>Version \
%2</b><br />&nbsp;</html>", +                                  \
aboutData->programName(), aboutData->version())); +    else
+        titleWidget->setText(i18n("<html><font size=\"5\">%1</font><br /><b>Version \
%2</b><br />Using KDE %3</html>", +                                  \
aboutData->programName(), aboutData->version(), QString(KDE_VERSION_STRING)));  
     QTabWidget *tabWidget = new QTabWidget;
     tabWidget->setUsesScrollButtons(false);
@@ -125,14 +143,14 @@
                                                                        \
                i18n("License: %1",
                                                                             \
                license.name(KAboutData::FullName))));
         showLicenseLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
-        connect(showLicenseLabel, SIGNAL(linkActivated(QString)), this, \
SLOT(_k_showLicense(QString))); +        connect(showLicenseLabel, \
SIGNAL(linkActivated(QString)), q, SLOT(_k_showLicense(QString)));  
         aboutLayout->addWidget(showLicenseLabel);
     }
 
     aboutLayout->addStretch();
 
-    QWidget *aboutWidget = new QWidget(this);
+    QWidget *aboutWidget = new QWidget(q);
     aboutWidget->setLayout(aboutLayout);
 
     tabWidget->addTab(aboutWidget, i18n("&About"));
@@ -210,6 +228,7 @@
         tabWidget->addTab(creditsTextBrowser, i18n("&Thanks To"));
     }
 
+    if ( !( opt & HideTranslators ) ) {
     const QList<KAboutPerson> translatorList = aboutData->translators();
 
     if(translatorList.count() > 0) {
@@ -231,6 +250,7 @@
         translatorTextBrowser->setHtml(translatorPageText);
         tabWidget->addTab(translatorTextBrowser, i18n("T&ranslation"));
     }
+    }
 
     QVBoxLayout *mainLayout = new QVBoxLayout;
     mainLayout->addWidget(titleWidget);
@@ -240,7 +260,7 @@
     QWidget *mainWidget = new QWidget;
     mainWidget->setLayout(mainLayout);
 
-    setMainWidget(mainWidget);
+    q->setMainWidget(mainWidget);
 }
 
 KAboutApplicationDialog::~KAboutApplicationDialog()
--- branches/kdepim/enterprise4/kdelibs-4.1-branch/kdeui/dialogs/kaboutapplicationdialog.h \
#1032205:1032206 @@ -24,6 +24,8 @@
 
 #include <kdialog.h>
 
+#include <QtCore/QFlags>
+
 class KAboutData;
 
 /**
@@ -44,8 +46,15 @@
 class KDEUI_EXPORT KAboutApplicationDialog : public KDialog
 {
     Q_OBJECT
+    Q_FLAGS( Options )
+    public:
+        enum Option {
+            NoOptions       = 0x0,
+            HideTranslators = 0x1,
+            HideKdeVersion  = 0x2
+        };
+        Q_DECLARE_FLAGS( Options, Option )
 
-    public:
         /**
          * Constructor. Creates a fully featured "About Application" dialog box.
          *
@@ -54,6 +63,16 @@
          * @param parent The parent of the dialog box. You should use the
          *        toplevel window so that the dialog becomes centered.
          */
+        explicit KAboutApplicationDialog(const KAboutData *aboutData, Options opts, \
QWidget *parent = 0); +
+        /**
+         * Constructor. Creates a fully featured "About Application" dialog box.
+         *
+         * @param aboutData A pointer to a KAboutData object which data
+         *        will be used for filling the dialog.
+         * @param parent The parent of the dialog box. You should use the
+         *        toplevel window so that the dialog becomes centered.
+         */
         explicit KAboutApplicationDialog(const KAboutData *aboutData, QWidget \
*parent = 0);  
         virtual ~KAboutApplicationDialog();
@@ -67,4 +86,6 @@
         Q_DISABLE_COPY( KAboutApplicationDialog )
 };
 
+Q_DECLARE_OPERATORS_FOR_FLAGS( KAboutApplicationDialog::Options )
+
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic