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

List:       kde-core-devel
Subject:    KPluginSelector about plugin dialogs
From:       Rafael =?iso-8859-1?q?Fern=E1ndez_L=F3pez?= <ereslibre () kde ! org>
Date:       2008-06-08 0:47:54
Message-ID: 200806080247.57875.ereslibre () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi there,

Some days ago I was suggested by Pino to use KAboutApplicationDialog for 
showing the info messages of the plugins on the KPluginSelector, instead of 
KMessageBox.

This gives a much better look, as well as consistency for what this is meant.

I have given to it two approaches, 1st one, try to take the aboutData of the 
component, and if that fails (because the plugin does not set that 
information), go and fetch the info from the desktop file (KPluginInfo).

There is only one remaining thing: when reading the license information from 
the desktop file, set it correctly on the about dialog.

I would like to know, if you think that when I finish the license thing, I can 
commit this into 4.1 yet...

 
Regards,
Rafael Fernández López.

["kdelibs-kutils.diff" (text/x-patch)]

diff --git a/kutils/kpluginselector.cpp b/kutils/kpluginselector.cpp
index e9f04b8..28a9ebe 100644
--- a/kutils/kpluginselector.cpp
+++ b/kutils/kpluginselector.cpp
@@ -43,6 +43,7 @@
 #include <kcategorydrawer.h>
 #include <kcategorizedview.h>
 #include <kcategorizedsortfilterproxymodel.h>
+#include <kaboutapplicationdialog.h>
 
 #define MARGIN 5
 
@@ -722,33 +723,40 @@ void \
KPluginSelector::Private::PluginDelegate::slotAboutClicked()  const QString version = \
model->data(index, VersionRole).toString();  const QString license = \
model->data(index, LicenseRole).toString();  
-    QString message = i18n("Name:\n%1", name);
-
-    if (!comment.isEmpty()) {
-        message += i18n("\n\nComment:\n%1", comment);
-    }
-
-    if (!author.isEmpty()) {
-        message += i18n("\n\nAuthor:\n%1", author);
-    }
-
-    if (!email.isEmpty()) {
-        message += i18n("\n\nE-Mail:\n%1", email);
-    }
-
-    if (!website.isEmpty()) {
-        message += i18n("\n\nWebsite:\n%1", website);
-    }
-
-    if (!version.isEmpty()) {
-        message += i18n("\n\nVersion:\n%1", version);
+    // Try to retrieve the plugin information from the KComponentData object of the \
plugin. +    // If there is no valid information, go and fetch it from the service \
itself (the .desktop +    // file).
+
+    PluginEntry *entry = index.model()->data(index, \
PluginEntryRole).value<PluginEntry*>(); +    KService::Ptr entryService = \
entry->pluginInfo.service(); +    if (entryService) {
+        KPluginLoader loader(*entryService);
+        KPluginFactory *factory = loader.factory();
+        if (factory) {
+            const KAboutData *aboutData = factory->componentData().aboutData();
+            if (!aboutData->programName().isEmpty()) { // Be sure the about data is \
not completely empty +                KAboutApplicationDialog aboutPlugin(aboutData, \
itemView()); +                aboutPlugin.exec();
+                return;
+            }
+        }
     }
 
-    if (!license.isEmpty()) {
-        message += i18n("\n\nLicense:\n%1", license);
+    KAboutData aboutData(name.toUtf8(), name.toUtf8(), ki18n(name.toUtf8()), \
version.toUtf8(), ki18n(comment.toUtf8()), KAboutData::License_Unknown, \
ki18n(QByteArray()), ki18n(QByteArray()), website.toLatin1()); +    \
aboutData.setProgramIconName(index.model()->data(index, \
Qt::DecorationRole).toString()); +    QStringList authors = author.split(',');
+    QStringList emails = email.split(',');
+    int i = 0;
+    if (authors.count() == emails.count()) {
+        foreach (const QString &author, authors) {
+            if (!author.isEmpty()) {
+                aboutData.addAuthor(ki18n(author.toUtf8()), ki18n(QByteArray()), \
emails[i].toUtf8(), 0); +            }
+            i++;
+        }
     }
-
-    KMessageBox::information(itemView(), message, i18n("About Plugin \"%1\"", \
name)); +    KAboutApplicationDialog aboutPlugin(&aboutData, itemView());
+    aboutPlugin.exec();
 }
 
 void KPluginSelector::Private::PluginDelegate::slotConfigureClicked()


["signature.asc" (application/pgp-signature)]

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

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