]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/settings/servicessettingspage.cpp
Start font requester with previously set custom font
[dolphin.git] / src / settings / servicessettingspage.cpp
index 57e91e5dd55288a88f1a08b6cf80c46bb86884e2..a5e19725a51046261d33594940978214480b83dd 100644 (file)
@@ -24,6 +24,7 @@
 #include <kdesktopfileactions.h>
 #include <kicon.h>
 #include <klocale.h>
+#include <knewstuff3/knewstuffbutton.h>
 #include <kservice.h>
 #include <kservicetypetrader.h>
 #include <kstandarddirs.h>
@@ -31,6 +32,7 @@
 #include <QEvent>
 #include <QLabel>
 #include <QListWidget>
+#include <QPushButton>
 #include <QVBoxLayout>
 
 ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
@@ -43,6 +45,7 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
     QLabel* label = new QLabel(i18nc("@label:textbox",
                                      "Configure which services should "
                                      "be shown in the context menu."), this);
+    label->setWordWrap(true);
 
     m_servicesList = new QListWidget(this);
     m_servicesList->setSortingEnabled(true);
@@ -50,8 +53,14 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
     connect(m_servicesList, SIGNAL(itemClicked(QListWidgetItem*)),
             this, SIGNAL(changed()));
 
+    KNS3::Button* downloadButton = new KNS3::Button(i18nc("@action:button", "Download New Services..."),
+                                                    "servicemenu.knsrc",
+                                                    this);
+    connect(downloadButton, SIGNAL(dialogFinished(const Entry::List&)), this, SLOT(loadServices()));
+
     topLayout->addWidget(label);
     topLayout->addWidget(m_servicesList);
+    topLayout->addWidget(downloadButton);
 }
 
 ServicesSettingsPage::~ServicesSettingsPage()
@@ -70,6 +79,8 @@ void ServicesSettingsPage::applySettings()
         const QString service = item->data(Qt::UserRole).toString();
         showGroup.writeEntry(service, show);
     }
+
+    showGroup.sync();
 }
 
 void ServicesSettingsPage::restoreDefaults()
@@ -102,11 +113,15 @@ void ServicesSettingsPage::loadServices()
                                     KDesktopFileActions::userDefinedServices(file, true);
 
         foreach (const KServiceAction& action, serviceActions) {
-            if (!action.noDisplay() && !action.isSeparator()) {
+            const QString service = action.name();
+            const bool addService = !action.noDisplay()
+                                    && !action.isSeparator()
+                                    && !isInServicesList(service);
+
+            if (addService) {
                 QListWidgetItem* item = new QListWidgetItem(KIcon(action.icon()),
                                                             action.text(),
                                                             m_servicesList);
-                const QString service = action.name();
                 item->setData(Qt::UserRole, service);
                 const bool show = showGroup.readEntry(service, true);
                 item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
@@ -115,4 +130,16 @@ void ServicesSettingsPage::loadServices()
     }
 }
 
+bool ServicesSettingsPage::isInServicesList(const QString& service) const
+{
+    const int count = m_servicesList->count();
+    for (int i = 0; i < count; ++i) {
+        QListWidgetItem* item = m_servicesList->item(i);
+        if (item->data(Qt::UserRole).toString() == service) {
+            return true;
+        }
+    }
+    return false;
+}
+
 #include "servicessettingspage.moc"