void removeBuildDirConfig( KDevelop::IProject* project ) { int buildDirIndex = currentBuildDirIndex( project ); if ( !buildDirGroupExists( project, buildDirIndex ) ) { qWarning() << "build directory config" << buildDirIndex << "to be removed but does not exist"; return; } int bdCount = buildDirCount(project); setBuildDirCount( project, bdCount - 1 ); removeOverrideBuildDirIndex( project ); setCurrentBuildDirIndex( project, -1 ); // move (rename) the upper config groups to keep the numbering // if there's nothing to move, just delete the group physically if (buildDirIndex + 1 == bdCount) buildDirGroup( project, buildDirIndex ).deleteGroup(); else for (int i = buildDirIndex + 1; i < bdCount; ++i) { KConfigGroup src = buildDirGroup( project, i ); KConfigGroup dest = buildDirGroup( project, i - 1 ); dest.deleteGroup(); src.copyTo(&dest); src.deleteGroup(); } }
bool AvatarManager::remove(Kopete::AvatarManager::AvatarEntry entryToRemove) { // We need name and path to remove an avatar from the storage. if( entryToRemove.name.isEmpty() && entryToRemove.path.isEmpty() ) return false; // We don't allow removing avatars from Contact category if( entryToRemove.category & Kopete::AvatarManager::Contact ) return false; // Delete the image file first, file delete is more likely to fail than config group remove. if( KIO::NetAccess::del(KUrl(entryToRemove.path),0) ) { kDebug(14010) << "Removing avatar from config."; KUrl configUrl(d->baseDir); configUrl.addPath( UserDir ); configUrl.addPath( AvatarConfig ); KConfigGroup avatarConfig ( KSharedConfig::openConfig( configUrl.toLocalFile(), KConfig::SimpleConfig ), entryToRemove.name ); avatarConfig.deleteGroup(); avatarConfig.sync(); emit avatarRemoved(entryToRemove); return true; } return false; }
void CustomBuildSystemConfigWidget::saveTo( KConfig* cfg, KDevelop::IProject* /*project*/ ) { KConfigGroup subgrp = cfg->group( ConfigConstants::customBuildSystemGroup ); subgrp.deleteGroup(); for( int i = 0; i < ui->currentConfig->count(); i++ ) { configs[i].title = ui->currentConfig->itemText(i); saveConfig( subgrp, configs[i], i ); } cfg->sync(); }
ProviderPtr ImporterManager::createProvider( QVariantMap config ) { Controller *controller = Amarok::Components::statSyncingController(); // First, get rid of the old provider instance. Note: the StatSyncing::Config // remembers the provider by the id, even when it's unregistered. After this // block, old instance should be destroyed, its destructor called. if( config.contains( "uid" ) ) { const QString providerId = config.value( "uid" ).toString(); if( m_providers.contains( providerId ) ) { ProviderPtr oldProvider = m_providers.take( providerId ); if( controller ) controller->unregisterProvider( oldProvider ); } } // Create a concrete provider using the config. The QueuedConnection in connect() // is important, because on reconfigure we *destroy* the old provider instance ImporterProviderPtr provider = newInstance( config ); if( !provider ) { warning() << __PRETTY_FUNCTION__ << "created provider is null!"; return provider; } connect( provider.data(), SIGNAL(reconfigurationRequested(QVariantMap)), SLOT(createProvider(QVariantMap)), Qt::QueuedConnection); m_providers.insert( provider->id(), provider ); // Register the provider if( controller ) { controller->registerProvider( provider ); // Set provider to offline if( Config *config = controller->config() ) { config->updateProvider( provider->id(), provider->prettyName(), provider->icon(), /*online*/ false ); config->save(); } } // Save the settings KConfigGroup group = providerConfig( provider ); group.deleteGroup(); foreach( const QString &key, provider->m_config.keys() ) group.writeEntry( key, provider->m_config.value( key ) ); group.sync(); return provider; }
foreach(const QString& dev, devices) { const DeviceType* deviceType = DeviceType::find(dev); assert(deviceType != NULL); KConfigGroup devconfig = KConfigGroup(&config, dev); DeviceProfile devprofile = d->profile->getDevice(*deviceType); DeviceProfileConfigAdaptor devadaptor(devprofile); devconfig.deleteGroup(); devadaptor.saveConfig(devconfig); }
void FlickrWindow::slotRemoveAccount() { KConfig config("kipirc"); KConfigGroup grp = config.group(QString("%1%2Export Settings").arg(m_serviceName).arg(m_username)); if(grp.exists()) { kDebug()<<"Removing Account having group"<<QString("%1%2Export Settings").arg(m_serviceName); grp.deleteGroup(); } m_username = QString(); kDebug() << "SlotTokenObtained invoked setting user Display name to " << m_username; m_userNameDisplayLabel->setText(QString("<b>%1</b>").arg(m_username)); }
// Reconstructs configGroup from configData and mIncomingMetaData void rebuildConfig() { configGroup->deleteGroup(KConfigGroup::WriteConfigFlags()); // mIncomingMetaData cascades over config, so we write config first, // to let it be overwritten MetaData::ConstIterator end = configData.constEnd(); for (MetaData::ConstIterator it = configData.constBegin(); it != end; ++it) configGroup->writeEntry(it.key(), it->toUtf8(), KConfigGroup::WriteConfigFlags()); end = q->mIncomingMetaData.constEnd(); for (MetaData::ConstIterator it = q->mIncomingMetaData.constBegin(); it != end; ++it) configGroup->writeEntry(it.key(), it->toUtf8(), KConfigGroup::WriteConfigFlags()); }
void ImporterManager::slotProviderForgotten( const QString &providerId ) { // Check if the provider is managed by this ImporterManager if( !m_providers.contains( providerId ) ) return; ProviderPtr provider = m_providers.take( providerId ); if( Controller *controller = Amarok::Components::statSyncingController() ) controller->unregisterProvider( provider ); // Remove configuration KConfigGroup group = providerConfig( providerId ); group.deleteGroup(); group.sync(); }
void saveEntries( const KConfigGroup &grp) { KConfigGroup cg = grp; if (cg.name().isEmpty()) { cg = KConfigGroup(cg.config(),"RecentFiles"); } cg.deleteGroup(); // write file list for (int i = 1; i <= recentFilesIndex.size(); ++i) { // i - 1 because we started from 1 cg.writePathEntry(QString("File%1").arg(i), recentFiles[i - 1]); cg.writePathEntry(QString("Name%1").arg(i), recentFilesIndex[i - 1]); } }
void KonfUpdate::gotRemoveGroup(const QString &_group) { m_oldGroup = parseGroupString(_group); if (!m_oldConfig1) { logFileError() << "RemoveGroup without previous File specification" << endl; return; } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, m_oldGroup); if (!cg.exists()) { return; } // Delete group. cg.deleteGroup(); log() << m_currentFilename << ": RemoveGroup removes group " << m_oldFile << ":" << m_oldGroup << endl; }
void CustomBuildSystemConfigWidget::saveConfig( KConfigGroup& grp, CustomBuildSystemConfig& c, int index ) { // Generate group name, access and clear it KConfigGroup subgrp = grp.group( ConfigConstants::buildConfigPrefix + QString::number(index) ); subgrp.deleteGroup(); // Write current configuration key, if our group is current if( ui->currentConfig->currentIndex() == index ) grp.writeEntry( ConfigConstants::currentConfigKey, subgrp.name() ); subgrp.writeEntry( ConfigConstants::configTitleKey, c.title ); subgrp.writeEntry<QUrl>( ConfigConstants::buildDirKey, c.buildDir ); foreach( const CustomBuildSystemTool& tool, c.tools ) { KConfigGroup toolgrp = subgrp.group( generateToolGroupName( tool.type ) ); toolgrp.writeEntry( ConfigConstants::toolType, int(tool.type) ); toolgrp.writeEntry( ConfigConstants::toolEnvironment , tool.envGrp ); toolgrp.writeEntry( ConfigConstants::toolEnabled, tool.enabled ); toolgrp.writeEntry<QUrl>( ConfigConstants::toolExecutable, tool.executable ); toolgrp.writeEntry( ConfigConstants::toolArguments, tool.arguments ); } }
void UserAgentDlg::save() { Q_ASSERT (m_config); // Put all the groups except the default into the delete list. QStringList deleteList = m_config->groupList(); //Remove all the groups that DO NOT contain a "UserAgent" entry... QStringList::ConstIterator endIt = deleteList.constEnd(); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { if ( (*it) == QLatin1String ("<default>")) continue; KConfigGroup cg (m_config, *it); if (!cg.hasKey ("UserAgent")) deleteList.removeAll (*it); } QString domain; QTreeWidgetItem* item; int itemCount = ui.sitePolicyTreeWidget->topLevelItemCount(); // Save and remove from the delete list all the groups that were // not deleted by the end user. for (int i = 0; i < itemCount; i++) { item = ui.sitePolicyTreeWidget->topLevelItem (i); domain = item->text (0); KConfigGroup cg (m_config, domain); cg.writeEntry ("UserAgent", item->text (2)); deleteList.removeAll (domain); qDebug ("UserAgentDlg::save: Removed [%s] from delete list", domain.toLatin1().constData()); } // Write the global configuration information... KConfigGroup cg (m_config, QString()); cg.writeEntry ("SendUserAgent", ui.sendUACheckBox->isChecked()); cg.writeEntry ("UserAgentKeys", m_ua_keys); // Sync up all the changes so far... m_config->sync(); // If delete list is not empty, delete the specified domains. if (!deleteList.isEmpty()) { // Remove entries from local file. endIt = deleteList.constEnd(); KConfig cfg (QStringLiteral("kio_httprc"), KConfig::SimpleConfig); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { KConfigGroup cg (&cfg, *it); cg.deleteEntry ("UserAgent"); qDebug ("UserAgentDlg::save: Deleting UserAgent of group [%s]", (*it).toLatin1().constData()); if (cg.keyList().count() < 1) cg.deleteGroup(); } // Sync up the configuration... cfg.sync(); // Check everything is gone, reset to blank otherwise. m_config->reparseConfiguration(); endIt = deleteList.constEnd(); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { KConfigGroup cg (m_config, *it); if (cg.hasKey ("UserAgent")) cg.writeEntry ("UserAgent", QString()); } // Sync up the configuration... m_config->sync(); } KSaveIOConfig::updateRunningIOSlaves (this); configChanged (false); }
void process(Mode mode, KConfigGroup &grp, QString key, QString value) { switch (mode) { case Read: if (IS_A_TTY(1)) std::cout << CHAR(key) << ": " << CHAR(grp.readEntry(key, "does not exist")) << " (" << CHAR(path(grp)) << ")" << std::endl; else std::cout << CHAR(grp.readEntry(key, "")); break; case Write: { if (grp.isImmutable()) { std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl; exit(1); } bool added = !grp.hasKey(key); QString oldv; if (!added) oldv = grp.readEntry(key); grp.writeEntry(key, QString(value)); grp.sync(); if (added) std::cout << "New " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl; else std::cout << CHAR(key) << ": " << CHAR(oldv) << " -> " << CHAR(grp.readEntry(key)) << std::endl; break; } case Delete: { if (grp.isImmutable()) { std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl; exit(1); } if (grp.hasKey(key)) { std::cout << "Removed " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl; grp.deleteEntry(key); grp.sync(); } else if (grp.hasGroup(key)) { std::cout << "There's a group, but no key: " << CHAR(key) << "\nPlease explicitly use deletegroup" << std::endl; exit(1); } else { std::cout << "There's no key " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl; exit(1); } break; } case DeleteGroup: { if (grp.hasGroup(key)) { grp = grp.group(key); if (grp.isImmutable()) { std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl; exit(1); } QMap<QString, QString> map = grp.entryMap(); std::cout << "Removed " << CHAR(key) << gs_separator << std::endl; for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) { std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl; } grp.deleteGroup(); grp.sync(); } else { std::cout << "There's no group " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl; exit(1); } break; } case List: case ListKeys: { if (!grp.exists()) { // could be parent group if (mode == ListKeys) exit(1); QStringList groups = grp.parent().exists() ? grp.parent().groupList() : grp.config()->groupList(); if (groups.isEmpty()) { std::cout << "The component/group " << CHAR(path(grp)) << " does not exist" << std::endl; exit(1); } std::cout << "Groups in " << CHAR(path(grp)) << gs_separator << std::endl; foreach (const QString &s, groups) if (key.isEmpty() || s.contains(key, Qt::CaseInsensitive)) std::cout << CHAR(s) << std::endl; exit(0); } QMap<QString, QString> map = grp.entryMap(); if (map.isEmpty()) { std::cout << "The group " << CHAR(path(grp)) << " is empty" << std::endl; break; } if (mode == List) { bool matchFound = false; for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) { if (key.isEmpty() || it.key().contains(key, Qt::CaseInsensitive)) { if (!matchFound) std::cout << std::endl << CHAR(path(grp)) << gs_separator << std::endl; matchFound = true; std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl; } } if (!matchFound) std::cout << "No present key matches \"" << CHAR(key) << "\" in " << CHAR(path(grp)); std::cout << std::endl; } else { for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) { if (key.isEmpty() || it.key().contains(key, Qt::CaseInsensitive)) { std::cout << CHAR(it.key()) << std::endl; } } } break; } case ListGroups: { QStringList groups = grp.parent().exists() ? grp.parent().groupList() : grp.config()->groupList(); foreach (const QString &s, groups) if (key.isEmpty() || s.contains(key, Qt::CaseInsensitive)) std::cout << CHAR(s) << std::endl; exit(0); } case Replace: { if (grp.isImmutable()) { std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl; exit(1); } QStringList match = key.split("="); if (match.count() != 2) { std::cout << "The match sequence must be of the form <key regexp>=<value regexp>" << std::endl; exit(1); } QRegExp keyMatch(match.at(0), Qt::CaseInsensitive); QRegExp valueMatch(match.at(1), Qt::CaseInsensitive); QStringList replace = value.split("="); if (replace.count() != 2) { std::cout << "The replace sequence must be of the form <key string>=<value string>" << std::endl; exit(1); } QMap<QString, QString> map = grp.entryMap(); QStringList keys; for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) { if (keyMatch.exactMatch(it.key()) && valueMatch.exactMatch(it.value())) { keys << it.key(); } } foreach (const QString &key, keys) { QString newKey = key; newKey.replace(keyMatch, replace.at(0)); QString newValue = grp.readEntry(key); const QString oldValue = newValue; newValue.replace(valueMatch, replace.at(1)); if (key != newKey) grp.deleteEntry(key); grp.writeEntry(newKey, newValue); std::cout << CHAR(key) << ": " << CHAR(oldValue) << " -> " << CHAR(newKey) << ": " << CHAR(grp.readEntry(newKey)) << std::endl; grp.sync(); } break; } Invalid: default: break; }
void SettingsCore::saveSettings() { #ifdef ABAKUS_QTONLY //TODO #else KConfigGroup config = KGlobal::config()->group("Settings"); config.writeEntry("Trigonometric mode", trigMode() == Abakus::Degrees ? "Degrees" : "Radians"); config.writeEntry("Decimal Precision", Abakus::m_prec); config.writeEntry("History Limit", m_historyLimit); config = KGlobal::config()->group("GUI"); config.writeEntry("InCompactMode", m_compactMode); config.writeEntry("ShowMathematicalSidebar", m_mathematicalSidebarVisible); config.writeEntry("MathematicalSidebarActiveTab", m_mathematicalSidebarActiveView); config.writeEntry("MathematicalSidebarWidth", m_mathematicalSidebarWidth); config.writeEntry("Size", m_windowSize); config = KGlobal::config()->group("Variables"); config.deleteGroup(); QStringList saveList; QStringList::ConstIterator it; int fieldWidth; int numberOfEntries; // Set precision to max for most accuracy Abakus::m_prec = 75; QStringList values = NumeralModel::instance()->valueNames(); for(it = values.begin(), numberOfEntries = 0; it != values.end(); ++it) { if(NumeralModel::instance()->isValueReadOnly(*it)) continue; ++numberOfEntries; } fieldWidth = QString("%1").arg(numberOfEntries).length(); int j = 0; for(it = values.begin(); it != values.end(); ++it) { if(NumeralModel::instance()->isValueReadOnly(*it)) continue; saveList.clear(); saveList << *it; saveList << NumeralModel::instance()->value(*it).toString(Abakus::DEC); saveList << QString("%1").arg(NumeralModel::instance()->value(*it).numeralSystem()); config.writeEntry(QString("%1").arg(j, fieldWidth, 10, QLatin1Char('0')), saveList); ++j; } config = KGlobal::config()->group("Functions"); config.deleteGroup(); FunctionModel *manager = FunctionModel::instance(); UnaryFunction *fn; QString variable; QString expression; QString saveString; QStringList userFunctions = manager->functionList(FunctionModel::UserDefined); fieldWidth = QString("%1").arg(userFunctions.count()).length(); j = 0; foreach(QString functionName, userFunctions) { fn = dynamic_cast<UnaryFunction *>(manager->function(functionName)->userFn->fn); variable = manager->function(functionName)->userFn->varName; expression = fn->operand()->infixString(); saveString = QString("%1(%2) = %3").arg(functionName).arg(variable).arg(expression); config.writeEntry(QString("%1").arg(j, fieldWidth, 10, QLatin1Char('0')), saveString); ++j; }
int PlasmaApp::newInstance() { KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); if (args->count() == 0) { KCmdLineArgs::usage(); return 0; } QString pluginName; if (args->count() > 0) { pluginName = args->arg(0); } //is the applet already running? if (m_viewForPlugin.contains(pluginName)) { m_viewForPlugin.value(pluginName)->activateWindow(); m_viewForPlugin.value(pluginName)->raise(); return 0; } QVariantList appletArgs; for (int i = 1; i < args->count(); ++i) { appletArgs << args->arg(i); } int appletId; Plasma::Containment *containment = m_corona->addContainment("null"); containment->setFormFactor(Plasma::Planar); containment->setLocation(Plasma::Floating); appletId = ++m_maxId; if (m_storedApplets.contains(pluginName)) { int storedAppletId = m_storedApplets.values(pluginName).first(); KConfigGroup config = storedConfig(storedAppletId); KConfigGroup actualConfig(containment->config()); actualConfig = KConfigGroup(&actualConfig, "Applets"); actualConfig = KConfigGroup(&actualConfig, QString::number(appletId)); config.copyTo(&actualConfig); config.deleteGroup(); m_storedApplets.remove(pluginName, storedAppletId); } SingleView *view = new SingleView(m_corona, containment, pluginName, appletId, appletArgs); if (!view->applet()) { delete view; return 0; } connect(view, SIGNAL(storeApplet(Plasma::Applet*)), this, SLOT(storeApplet(Plasma::Applet*))); connect(view, SIGNAL(destroyed(QObject*)), this, SLOT(viewDestroyed(QObject*))); if (args->isSet("border")) { view->setBackgroundBrush(KColorUtils::mix(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor), Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor), 0.15)); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(themeChanged())); view->applet()->setBackgroundHints(Plasma::Applet::NoBackground); } else { view->setWindowFlags(Qt::FramelessWindowHint); view->setAttribute(Qt::WA_TranslucentBackground); view->setAutoFillBackground(false); view->viewport()->setAutoFillBackground(false); view->setAttribute(Qt::WA_NoSystemBackground); view->viewport()->setAttribute(Qt::WA_NoSystemBackground); Plasma::WindowEffects::overrideShadow(view->winId(), true); } if (args->isSet("fullscreen")) { view->setWindowState(Qt::WindowFullScreen); } args->clear(); m_viewForPlugin[pluginName] = view; m_pluginForView[view] = pluginName; KWindowSystem::setOnDesktop(view->winId(), KWindowSystem::currentDesktop()); view->show(); view->raise(); return 0; }
void SetupCamera::applySettings() { // Save camera devices ----------------------------------- CameraList* const clist = CameraList::defaultList(); if (clist) { clist->clear(); QTreeWidgetItemIterator it(d->listView); while (*it) { SetupCameraItem* const item = dynamic_cast<SetupCameraItem*>(*it); if (item) { CameraType* const ctype = item->cameraType(); if (ctype) { clist->insert(new CameraType(*ctype)); } } ++it; } clist->save(); } // ------------------------------------------------------- KSharedConfig::Ptr config = KSharedConfig::openConfig(); KConfigGroup group = config->group(d->configGroupName); group.writeEntry(d->configUseFileMetadata, d->useFileMetadata->isChecked()); group.writeEntry(d->configTrunHighQualityThumbs, d->turnHighQualityThumbs->isChecked()); group.writeEntry(d->configUseDefaultTargetAlbum, d->useDefaultTargetAlbum->isChecked()); PAlbum* const album = d->target1AlbumSelector->currentAlbum(); group.writeEntry(d->configDefaultTargetAlbumId, album ? album->id() : 0); d->fullScreenSettings->saveSettings(group); group.sync(); // ------------------------------------------------------- KConfigGroup importGroup = config->group(d->importFiltersConfigGroupName); importGroup.deleteGroup(); for (int i = 0; i < d->filters.count(); ++i) { importGroup.writeEntry(QString::fromUtf8("Filter%1").arg(i), d->filters[i]->toString()); } importGroup.writeEntry(QLatin1String("IgnoreNames"), d->ignoreNamesEdit->text()); importGroup.writeEntry(QLatin1String("IgnoreExtensions"), d->ignoreExtensionsEdit->text()); importGroup.sync(); ImportSettings* const settings = ImportSettings::instance(); if (!settings) { return; } settings->setIconShowName(d->iconShowNameBox->isChecked()); settings->setIconShowTags(d->iconShowTagsBox->isChecked()); settings->setIconShowSize(d->iconShowSizeBox->isChecked()); settings->setIconShowDate(d->iconShowDateBox->isChecked()); //TODO: settings->setIconShowResolution(d->iconShowResolutionBox->isChecked()); settings->setIconShowOverlays(d->iconShowOverlaysBox->isChecked()); settings->setIconShowRating(d->iconShowRatingBox->isChecked()); settings->setIconShowImageFormat(d->iconShowFormatBox->isChecked()); settings->setIconShowCoordinates(d->iconShowCoordinatesBox->isChecked()); settings->setIconViewFont(d->iconViewFontSelect->font()); settings->setItemLeftClickAction((ImportSettings::ItemLeftClickAction) d->leftClickActionComboBox->currentIndex()); settings->setPreviewLoadFullImageSize(d->previewLoadFullImageSize->isChecked()); settings->setPreviewItemsWhileDownload(d->previewItemsWhileDownload->isChecked()); settings->setPreviewShowIcons(d->previewShowIcons->isChecked()); settings->saveSettings(); }
void TestPlaylistFileProvider::removeConfigPlaylistEntries() { KConfigGroup config = Amarok::config( "Loaded Playlist Files" ); config.deleteGroup(); }
void Configuration::save() { KConfigGroup configuration = m_applet->config(); QStringList arrangement; closeActionEditors(); for (int i = 0; i < m_arrangementUi.currentEntriesListWidget->count(); ++i) { QListWidgetItem *item = m_arrangementUi.currentEntriesListWidget->item(i); if (!item->toolTip().isEmpty()) { if (arrangement.contains(item->toolTip())) { continue; } arrangement.append(item->toolTip()); const KUrl url(item->toolTip()); Launcher *launcher = new Launcher(url, m_applet); if (m_rules.contains(item->toolTip()) && !launcher->isMenu()) { launcher->setRules(m_rules[item->toolTip()].first); launcher->setExcluded(m_rules[item->toolTip()].second); } m_applet->changeLauncher(launcher, url, true); launcher->deleteLater(); } else if (item->text() == i18n("--- tasks area ---")) { arrangement.append("tasks"); } else if (item->text() == i18n("--- jobs area ---")) { arrangement.append("jobs"); } else { arrangement.append("separator"); } } configuration.deleteGroup("Actions"); KConfigGroup actionsConfiguration = configuration.group("Actions"); for (int i = 0; i < m_actionsUi.actionsTableWidget->rowCount(); ++i) { QTableWidgetItem *actionItem = m_actionsUi.actionsTableWidget->item(i, 0); QTableWidgetItem *triggerItem = m_actionsUi.actionsTableWidget->item(i, 1); if (triggerItem->data(Qt::EditRole).toString().isEmpty() || actionItem->data(Qt::EditRole).toInt() == 0) { continue; } actionsConfiguration.writeEntry(triggerItem->data(Qt::EditRole).toString(), actionItem->data(Qt::EditRole).toInt()); } configuration.writeEntry("moveAnimation", m_appearanceUi.moveAnimation->itemData(m_appearanceUi.moveAnimation->currentIndex()).toInt()); configuration.writeEntry("parabolicMoveAnimation", m_appearanceUi.parabolicMoveAnimation->isChecked()); configuration.writeEntry("demandsAttentionAnimation", m_appearanceUi.demandsAttentionAnimation->itemData(m_appearanceUi.demandsAttentionAnimation->currentIndex()).toInt()); configuration.writeEntry("startupAnimation", m_appearanceUi.startupAnimation->itemData(m_appearanceUi.startupAnimation->currentIndex()).toInt()); configuration.writeEntry("activeIconIndication", m_appearanceUi.activeIconIndication->itemData(m_appearanceUi.activeIconIndication->currentIndex()).toInt()); configuration.writeEntry("titleLabelMode", m_appearanceUi.titleLabelMode->itemData(m_appearanceUi.titleLabelMode->currentIndex()).toInt()); configuration.writeEntry("customBackgroundImage", (m_appearanceUi.customBackgroundImage->url().isValid()?m_appearanceUi.customBackgroundImage->url().path():QString())); configuration.writeEntry("showOnlyCurrentDesktop", m_generalUi.showOnlyCurrentDesktop->isChecked()); configuration.writeEntry("showOnlyCurrentActivity", m_generalUi.showOnlyCurrentActivity->isChecked()); configuration.writeEntry("showOnlyCurrentScreen", m_generalUi.showOnlyCurrentScreen->isChecked()); configuration.writeEntry("showOnlyMinimized", m_generalUi.showOnlyMinimized->isChecked()); configuration.writeEntry("showOnlyTasksWithLaunchers", m_generalUi.showOnlyTasksWithLaunchers->isChecked()); configuration.writeEntry("connectJobsWithTasks", m_generalUi.connectJobsWithTasks->isChecked()); configuration.writeEntry("groupJobs", m_generalUi.groupJobs->isChecked()); configuration.writeEntry("groupingStrategy", m_generalUi.groupingStrategy->itemData(m_generalUi.groupingStrategy->currentIndex()).toInt()); configuration.writeEntry("sortingStrategy", m_generalUi.sortingStrategy->itemData(m_generalUi.sortingStrategy->currentIndex()).toInt()); configuration.writeEntry("jobCloseMode", m_generalUi.jobCloseMode->itemData(m_generalUi.jobCloseMode->currentIndex()).toInt()); configuration.writeEntry("arrangement", arrangement); static_cast<KConfigDialog*>(parent())->enableButtonApply(false); emit accepted(); }
void KonfUpdate::gotScript(const QString &_script) { QString script, interpreter; int i = _script.indexOf(','); if (i == -1) { script = _script.trimmed(); } else { script = _script.left(i).trimmed(); interpreter = _script.mid(i + 1).trimmed(); } if (script.isEmpty()) { logFileError() << "Script fails to specify filename"; m_skip = true; return; } QString path = KStandardDirs::locate("data", "kconf_update/" + script); if (path.isEmpty()) { if (interpreter.isEmpty()) { path = KStandardDirs::locate("lib", "kconf_update_bin/" + script); } if (path.isEmpty()) { logFileError() << "Script '" << script << "' not found" << endl; m_skip = true; return; } } if (!m_arguments.isNull()) { log() << m_currentFilename << ": Running script '" << script << "' with arguments '" << m_arguments << "'" << endl; } else { log() << m_currentFilename << ": Running script '" << script << "'" << endl; } QString cmd; if (interpreter.isEmpty()) { cmd = path; } else { cmd = interpreter + ' ' + path; } if (!m_arguments.isNull()) { cmd += ' '; cmd += m_arguments; } KTemporaryFile scriptIn; scriptIn.open(); KTemporaryFile scriptOut; scriptOut.open(); KTemporaryFile scriptErr; scriptErr.open(); int result; if (m_oldConfig1) { if (m_debug) { scriptIn.setAutoRemove(false); log() << "Script input stored in " << scriptIn.fileName() << endl; } KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); if (m_oldGroup.isEmpty()) { // Write all entries to tmpFile; const QStringList grpList = m_oldConfig1->groupList(); for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) { copyGroup(m_oldConfig1, *it, &cfg, *it); } } else { KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); KConfigGroup cg2(&cfg, QString()); copyGroup(cg1, cg2); } cfg.sync(); #ifndef _WIN32_WCE result = system(QFile::encodeName(QString("%1 < %2 > %3 2> %4").arg(cmd, scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()))); #else QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() ); QString file_ = QFileInfo ( cmd ).fileName(); SHELLEXECUTEINFO execInfo; memset ( &execInfo,0,sizeof ( execInfo ) ); execInfo.cbSize = sizeof ( execInfo ); execInfo.fMask = SEE_MASK_FLAG_NO_UI; execInfo.lpVerb = L"open"; execInfo.lpFile = (LPCWSTR) path_.utf16(); execInfo.lpDirectory = (LPCWSTR) file_.utf16(); execInfo.lpParameters = (LPCWSTR) QString(" < %1 > %2 2> %3").arg( scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()).utf16(); result = ShellExecuteEx ( &execInfo ); if (result != 0) { result = 0; } else { result = -1; } #endif } else { // No config file #ifndef _WIN32_WCE result = system(QFile::encodeName(QString("%1 2> %2").arg(cmd, scriptErr.fileName()))); #else QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() ); QString file_ = QFileInfo ( cmd ).fileName(); SHELLEXECUTEINFO execInfo; memset ( &execInfo,0,sizeof ( execInfo ) ); execInfo.cbSize = sizeof ( execInfo ); execInfo.fMask = SEE_MASK_FLAG_NO_UI; execInfo.lpVerb = L"open"; execInfo.lpFile = (LPCWSTR) path_.utf16(); execInfo.lpDirectory = (LPCWSTR) file_.utf16(); execInfo.lpParameters = (LPCWSTR) QString(" 2> %1").arg( scriptErr.fileName()).utf16(); result = ShellExecuteEx ( &execInfo ); if (result != 0) { result = 0; } else { result = -1; } #endif } // Copy script stderr to log file { QFile output(scriptErr.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); ts.setCodec(QTextCodec::codecForName("UTF-8")); while (!ts.atEnd()) { QString line = ts.readLine(); log() << "[Script] " << line << endl; } } } if (result) { log() << m_currentFilename << ": !! An error occurred while running '" << cmd << "'" << endl; return; } if (!m_oldConfig1) { return; // Nothing to merge } if (m_debug) { scriptOut.setAutoRemove(false); log() << "Script output stored in " << scriptOut.fileName() << endl; } // Deleting old entries { QStringList group = m_oldGroup; QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); ts.setCodec(QTextCodec::codecForName("UTF-8")); while (!ts.atEnd()) { QString line = ts.readLine(); if (line.startsWith('[')) { group = parseGroupString(line); } else if (line.startsWith(QLatin1String("# DELETE "))) { QString key = line.mid(9); if (key[0] == '[') { int j = key.lastIndexOf(']') + 1; if (j > 0) { group = parseGroupString(key.left(j)); key = key.mid(j); } } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); cg.deleteEntry(key); log() << m_currentFilename << ": Script removes " << m_oldFile << ":" << group << ":" << key << endl; /*if (m_oldConfig2->deleteGroup(group, KConfig::Normal)) { // Delete group if empty. log() << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group << endl; } (this should be automatic)*/ } else if (line.startsWith(QLatin1String("# DELETEGROUP"))) { QString str = line.mid(13).trimmed(); if (!str.isEmpty()) { group = parseGroupString(str); } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); cg.deleteGroup(); log() << m_currentFilename << ": Script removes group " << m_oldFile << ":" << group << endl; } } } } // Merging in new entries. KConfig scriptOutConfig(scriptOut.fileName(), KConfig::NoGlobals); if (m_newGroup.isEmpty()) { // Copy "default" keys as members of "default" keys copyGroup(&scriptOutConfig, QString(), m_newConfig, QString()); } else { // Copy default keys as members of m_newGroup KConfigGroup srcCg = KConfigUtils::openGroup(&scriptOutConfig, QStringList()); KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, m_newGroup); copyGroup(srcCg, dstCg); } Q_FOREACH(const QString &group, scriptOutConfig.groupList()) { copyGroup(&scriptOutConfig, group, m_newConfig, group); } }