]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/settings/servicessettingspage.cpp
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / settings / servicessettingspage.cpp
index 57e91e5dd55288a88f1a08b6cf80c46bb86884e2..a58df2096afb025f9f9b3215c264377d782a685e 100644 (file)
@@ -70,6 +70,8 @@ void ServicesSettingsPage::applySettings()
         const QString service = item->data(Qt::UserRole).toString();
         showGroup.writeEntry(service, show);
     }
+
+    showGroup.sync();
 }
 
 void ServicesSettingsPage::restoreDefaults()
@@ -102,11 +104,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 +121,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"