void RecentFolders::loadConfig() { KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kio_recentfolders")); KConfigGroup group = config->group(QStringLiteral("General")); if (group.hasKey(CONFIG_BACK_DAYS)) { backDays = group.readEntry<uint>(CONFIG_BACK_DAYS, backDays); } else { group.writeEntry(CONFIG_BACK_DAYS, backDays); } }
void ColorScheme::writeColorEntry(KConfig& config , int index) const { KConfigGroup configGroup = config.group(colorNameForIndex(index)); const ColorEntry& entry = colorTable()[index]; configGroup.writeEntry("Color", entry.color); if (configGroup.hasKey("Transparent")) { configGroup.deleteEntry("Transparent"); } if (configGroup.hasKey("Transparency")) { configGroup.deleteEntry("Transparency"); } if (entry.fontWeight != ColorEntry::UseCurrentFormat) { configGroup.writeEntry("Bold", entry.fontWeight == ColorEntry::Bold); } RandomizationRange random = _randomTable != 0 ? _randomTable[index] : RandomizationRange(); // record randomization if this color has randomization or // if one of the keys already exists if (!random.isNull() || configGroup.hasKey("MaxRandomHue")) { configGroup.writeEntry("MaxRandomHue", static_cast<int>(random.hue)); configGroup.writeEntry("MaxRandomValue", static_cast<int>(random.value)); configGroup.writeEntry("MaxRandomSaturation", static_cast<int>(random.saturation)); } }
void TestUpdateKWin49::testPWEnabledTabBoxDisabled() { KConfig config(QString(), KConfig::SimpleConfig); KConfigGroup plugins = config.group("Plugins"); plugins.writeEntry("kwin4_effect_presentwindowsEnabled", true); QVERIFY(config.hasGroup("Plugins")); QVERIFY(plugins.readEntry("kwin4_effect_presentwindowsEnabled", true)); QVERIFY(!config.hasGroup("Effect-PresentWindows")); QVERIFY(!config.hasGroup("TabBox")); QVERIFY(!config.hasGroup("TabBoxAlternative")); migratePresentWindowsTabBox(config); QVERIFY(config.hasGroup("Plugins")); QVERIFY(plugins.readEntry("kwin4_effect_presentwindowsEnabled", true)); QVERIFY(!config.hasGroup("Effect-PresentWindows")); QVERIFY(!config.hasGroup("TabBox")); QVERIFY(!config.hasGroup("TabBoxAlternative")); // same with TabBox explicitly disabled KConfigGroup pw = config.group("Effect-PresentWindows"); pw.writeEntry("TabBox", false); pw.writeEntry("TabBoxAlternative", false); QVERIFY(pw.hasKey("TabBox")); QVERIFY(pw.hasKey("TabBoxAlternative")); migratePresentWindowsTabBox(config); QVERIFY(config.hasGroup("Plugins")); QVERIFY(plugins.readEntry("kwin4_effect_presentwindowsEnabled", true)); QVERIFY(!config.hasGroup("Effect-PresentWindows")); QVERIFY(!pw.hasKey("TabBox")); QVERIFY(!pw.hasKey("TabBoxAlternative")); QVERIFY(!config.hasGroup("TabBox")); QVERIFY(!config.hasGroup("TabBoxAlternative")); }
void Clock::clockConfigChanged() { KConfigGroup cg = config(); m_showTimezone = cg.readEntry("showTimezone", !isLocalTimezone()); kDebug() << "showTimezone:" << m_showTimezone; if (cg.hasKey("showDate")) { //legacy config entry as of 2011-1-4 m_dateStyle = cg.readEntry("showDate", false) ? 2 : 0; //short date : no date cg.deleteEntry("showDate"); } else { m_dateStyle = cg.readEntry("dateStyle", 0); } if (cg.hasKey("showYear")) { //legacy config entry as of 2011-1-4 if( m_dateStyle ) { m_dateStyle = cg.readEntry("showYear", false) ? 2 : 1; //short date : compact date } cg.deleteEntry("showYear"); } m_showSeconds = cg.readEntry("showSeconds", false); if (m_showSeconds) { //We don't need to cache the applet if it update every seconds setCacheMode(QGraphicsItem::NoCache); } else { setCacheMode(QGraphicsItem::DeviceCoordinateCache); } QFont f = cg.readEntry("plainClockFont", m_plainClockFont); m_isDefaultFont = f == m_plainClockFont; m_plainClockFont = f; m_useCustomColor = cg.readEntry("useCustomColor", m_useCustomColor); m_plainClockColor = cg.readEntry("plainClockColor", m_plainClockColor); m_useCustomShadowColor = cg.readEntry("useCustomShadowColor", m_useCustomShadowColor); m_plainClockShadowColor = cg.readEntry("plainClockShadowColor", m_plainClockShadowColor); m_drawShadow = cg.readEntry("plainClockDrawShadow", m_drawShadow); updateColors(); if (m_useCustomColor) { m_pixmap = QPixmap(); delete m_svg; m_svg = 0; } const QFontMetricsF metrics(KGlobalSettings::smallestReadableFont()); const QString timeString = KGlobal::locale()->formatTime(QTime(23, 59), m_showSeconds); setMinimumSize(metrics.size(Qt::TextSingleLine, timeString)); if (isUserConfiguring()) { updateSize(); } }
void TestUpdateKWin49::testPopupInfoEnabledAdditionalKeys() { KConfig config(QString(), KConfig::SimpleConfig); KConfigGroup popupInfo = config.group("PopupInfo"); popupInfo.writeEntry("ShowPopup", true); popupInfo.writeEntry("TextOnly", true); popupInfo.writeEntry("PopupHideDelay", 2000); QVERIFY(!config.hasGroup("Plugins")); QVERIFY(!config.hasGroup("Script-desktopchangeosd")); QVERIFY(popupInfo.hasKey("ShowPopup")); QVERIFY(popupInfo.hasKey("TextOnly")); QVERIFY(popupInfo.hasKey("PopupHideDelay")); migrateDesktopChangeOSD(config); QVERIFY(!config.hasGroup("PopupInfo")); QVERIFY(config.hasGroup("Plugins")); QVERIFY(config.hasGroup("Script-desktopchangeosd")); QVERIFY(!popupInfo.hasKey("ShowPopup")); QVERIFY(!popupInfo.hasKey("TextOnly")); QVERIFY(!popupInfo.hasKey("PopupHideDelay")); KConfigGroup osd = config.group("Script-desktopchangeosd"); QVERIFY(osd.hasKey("TextOnly")); QVERIFY(osd.hasKey("PopupHideDelay")); QVERIFY(osd.readEntry("TextOnly", false)); QVERIFY(osd.readEntry("PopupHideDelay", 1000) == 2000); KConfigGroup plugins = config.group("Plugins"); QVERIFY(plugins.hasKey("desktopchangeosdEnabled")); QVERIFY(plugins.readEntry("desktopchangeosdEnabled", false)); }
void TestUpdateKWin49::testPWBothEnabled() { KConfig config(QString(), KConfig::SimpleConfig); KConfigGroup pw = config.group("Effect-PresentWindows"); pw.writeEntry("TabBox", true); pw.writeEntry("TabBoxAlternative", true); QVERIFY(pw.hasKey("TabBoxAlternative")); QVERIFY(!config.hasGroup("TabBox")); QVERIFY(!config.hasGroup("TabBoxAlternative")); QVERIFY(pw.hasKey("TabBox")); migratePresentWindowsTabBox(config); QVERIFY(!config.hasGroup("Effect-PresentWindows")); QVERIFY(!pw.hasKey("TabBox")); QVERIFY(!pw.hasKey("TabBoxAlternative")); QVERIFY(config.hasGroup("TabBox")); QVERIFY(config.hasGroup("TabBoxAlternative")); KConfigGroup tabBox = config.group("TabBox"); QVERIFY(tabBox.hasKey("LayoutName")); QVERIFY(tabBox.readEntry("LayoutName", "thumbnails") == "present_windows"); KConfigGroup tabBoxAlternative = config.group("TabBoxAlternative"); QVERIFY(tabBoxAlternative.hasKey("LayoutName")); QVERIFY(tabBoxAlternative.readEntry("LayoutName", "thumbnails") == "present_windows"); // test same with an explicit layout set tabBox.writeEntry("LayoutName", "informative"); tabBoxAlternative.writeEntry("LayoutName", "informative"); pw.writeEntry("TabBox", true); pw.writeEntry("TabBoxAlternative", true); migratePresentWindowsTabBox(config); QVERIFY(!pw.hasKey("TabBox")); QVERIFY(!pw.hasKey("TabBoxAlternative")); QVERIFY(tabBox.readEntry("LayoutName", "thumbnails") == "present_windows"); QVERIFY(tabBoxAlternative.readEntry("LayoutName", "thumbnails") == "present_windows"); }
void TestUpdateKWin49::testPopupInfoDisabled() { KConfig config(QString(), KConfig::SimpleConfig); KConfigGroup popupInfo = config.group("PopupInfo"); popupInfo.writeEntry("ShowPopup", false); QVERIFY(!config.hasGroup("Plugins")); QVERIFY(!config.hasGroup("Script-desktopchangeosd")); QVERIFY(popupInfo.hasKey("ShowPopup")); migrateDesktopChangeOSD(config); QVERIFY(!config.hasGroup("Plugins")); QVERIFY(!config.hasGroup("PopupInfo")); QVERIFY(!config.hasGroup("Script-desktopchangeosd")); QVERIFY(!popupInfo.hasKey("ShowPopup")); }
void TestUpdateKWin49::testTabBoxAlreadyMigrated() { KConfig config(QString(), KConfig::SimpleConfig); KConfigGroup tabBox = config.group("TabBox"); tabBox.writeEntry("ListMode", 0); tabBox.writeEntry("DesktopMode", static_cast<int>(KWin::TabBox::TabBoxConfig::AllDesktopsClients)); tabBox.writeEntry("ShowDesktop", true); tabBox.writeEntry("ShowDesktopMode", static_cast<int>(KWin::TabBox::TabBoxConfig::DoNotShowDesktopClient)); migrateTabBoxConfig(tabBox); QVERIFY(!tabBox.hasKey("ListMode")); QVERIFY(!tabBox.hasKey("ShowDesktop")); QVERIFY(tabBox.readEntry("DesktopMode", static_cast<int>(KWin::TabBox::TabBoxConfig::defaultDesktopMode())) == KWin::TabBox::TabBoxConfig::AllDesktopsClients); QVERIFY(tabBox.readEntry("ShowDesktopMode", static_cast<int>(KWin::TabBox::TabBoxConfig::defaultShowDesktopMode())) == KWin::TabBox::TabBoxConfig::DoNotShowDesktopClient); }
bool SuspendSession::loadAction(const KConfigGroup& config) { if (config.isValid() && config.hasKey("idleTime") && config.hasKey("suspendType")) { // Add the idle timeout m_idleTime = config.readEntry<int>("idleTime", 0); if (m_idleTime) { registerIdleTimeout(m_idleTime - 5000); registerIdleTimeout(m_idleTime); } m_autoType = config.readEntry<uint>("suspendType", 0); } return true; }
void MountPointManager::handleMusicLocation() { // For users who were using QDesktopServices::MusicLocation exclusively up // to v2.2.2, which did not store the location into config. // and also for versions up to 2.7-git that did wrote the Use MusicLocation entry KConfigGroup folders = Amarok::config( "Collection Folders" ); const QString entryKey( "Use MusicLocation" ); if( !folders.hasKey( entryKey ) ) return; // good, already solved, nothing to do // write the music location as another collection folder in this case if( folders.readEntry( entryKey, false ) ) { const KUrl musicUrl = QDesktopServices::storageLocation( QDesktopServices::MusicLocation ); const QString musicDir = musicUrl.toLocalFile( KUrl::RemoveTrailingSlash ); const QDir dir( musicDir ); if( dir.exists() && dir.isReadable() ) { QStringList currentFolders = collectionFolders(); if( !currentFolders.contains( musicDir ) ) setCollectionFolders( currentFolders << musicDir ); } } folders.deleteEntry( entryKey ); // get rid of it for good }
qulonglong TrashSizeCache::currentSize( bool doLocking ) const { KInterProcessLock lock( QLatin1String( "trash" ) ); if ( doLocking ) { lock.lock(); lock.waitForLockGranted(); } KConfig config( mTrashSizeCachePath ); KConfigGroup group = config.group( mTrashSizeGroup ); if ( !group.hasKey( mTrashSizeKey ) ) { // For the first call to the trash size cache, we have to calculate // the current size. const qulonglong size = DiscSpaceUtil::sizeOfPath( mTrashPath + QString::fromLatin1( "/files/" ) ); group.writeEntry( mTrashSizeKey, size ); config.sync(); } const qulonglong value = group.readEntry( mTrashSizeKey, (qulonglong)0 ); if ( doLocking ) lock.unlock(); return value; }
void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey) { KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, dstGroupPath); if (!m_bOverwrite && dstCg.hasKey(dstKey)) { log() << m_currentFilename << ": Skipping " << m_newFileName << ":" << dstCg.name() << ":" << dstKey << ", already exists." << endl; return; } KConfigGroup srcCg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath); QString value = srcCg.readEntry(srcKey, QString()); log() << m_currentFilename << ": Updating " << m_newFileName << ":" << dstCg.name() << ":" << dstKey << " to '" << value << "'" << endl; dstCg.writeEntry(dstKey, value); if (m_bCopy) { return; // Done. } // Delete old entry if (m_oldConfig2 == m_newConfig && srcGroupPath == dstGroupPath && srcKey == dstKey) { return; // Don't delete! } KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath); srcCg2.deleteEntry(srcKey); log() << m_currentFilename << ": Removing " << m_oldFile << ":" << srcCg2.name() << ":" << srcKey << ", moved." << endl; }
foreach ( Mixer *mixer, Mixer::mixers()){ if ( mixerHasProfile.contains(mixer)) { continue; // OK, this mixer already has a profile => skip it } // No TAB YET => This should mean KMix is just started, or the user has just plugged in a card bool profileListHasKey = false; QStringList profileList; bool aProfileWasAddedSucesufully = false; if ( !mixer->isDynamic() ) { // We do not support save profiles for dynamic mixers (i.e. PulseAudio) profileListHasKey = pconfig.hasKey( mixer->id() );// <<< SHOULD be before the following line profileList = pconfig.readEntry( mixer->id(), QStringList() ); foreach ( QString profileId, profileList) { // This handles the profileList form the kmixrc kDebug() << "Now searching for profile: " << profileId; GUIProfile* guiprof = GUIProfile::find(mixer, profileId, true, false);// ### Card specific profile ### if ( guiprof != 0 ) { addMixerWidget(mixer->id(), guiprof->getId(), -1); aProfileWasAddedSucesufully = true; } else { kError() << "Cannot load profile " << profileId << " . It was removed by the user, or the KMix config file is defective."; } }
void ColorScheme::readColorEntry(const KConfig& config , int index) { KConfigGroup configGroup = config.group(colorNameForIndex(index)); ColorEntry entry; entry.color = configGroup.readEntry("Color", QColor()); // Deprecated key from KDE 4.0 which set 'Bold' to true to force // a color to be bold or false to use the current format // // TODO - Add a new tri-state key which allows for bold, normal or // current format if (configGroup.hasKey("Bold")) entry.fontWeight = configGroup.readEntry("Bold", false) ? ColorEntry::Bold : ColorEntry::UseCurrentFormat; setColorTableEntry(index , entry); const quint16 hue = configGroup.readEntry("MaxRandomHue", 0); const quint8 value = configGroup.readEntry("MaxRandomValue", 0); const quint8 saturation = configGroup.readEntry("MaxRandomSaturation", 0); if (hue != 0 || value != 0 || saturation != 0) setRandomizationRange(index , hue , saturation , value); }
void KDesktopFileTest::testActionGroup() { KTemporaryFile file; file.setPrefix("test1"); QVERIFY( file.open() ); const QString fileName = file.fileName(); QTextStream ts( &file ); ts << "[Desktop Entry]\n" "Actions=encrypt;\n" "[Desktop Action encrypt]\n" "Name=Encrypt file\n" "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); QCOMPARE(df.readType(), QString()); QCOMPARE(df.fileName(), fileName); QCOMPARE(df.readActions(), QStringList() << "encrypt"); QCOMPARE(df.hasActionGroup("encrypt"), true); QCOMPARE(df.hasActionGroup("doesnotexist"), false); KConfigGroup cg = df.actionGroup("encrypt"); QVERIFY(cg.hasKey("Name")); QCOMPARE(cg.readEntry("Name"), QString("Encrypt file")); }
void GPSSearchView::doLoadState() { KConfigGroup group = getConfigGroup(); if (group.hasKey(entryName(d->configSplitterStateEntry))) { const QByteArray splitterState = QByteArray::fromBase64(group.readEntry(entryName(d->configSplitterStateEntry), QByteArray())); if (!splitterState.isEmpty()) { d->splitter->restoreState(splitterState); } } d->sortOrderOptionsHelper->setSortOptions(GPSImageInfoSorter::SortOptions(group.readEntry(entryName(QLatin1String("Sort Order")), int(d->sortOrderOptionsHelper->getSortOptions())))); const KConfigGroup groupMapWidget = KConfigGroup(&group, entryName(QLatin1String("GPSSearch Map Widget"))); d->mapSearchWidget->readSettingsFromGroup(&groupMapWidget); d->searchTreeView->loadState(); AlbumManager::instance()->setCurrentAlbums(QList<Album*>()); d->searchTreeView->clearSelection(); }
void TypeTable::loadFromFile(const QString& fileName) { TRACE("reading file " + fileName); KConfig confFile(fileName, KConfig::SimpleConfig); /* * Read library name and properties. */ KConfigGroup cf = confFile.group(TypeTableGroup); m_displayName = cf.readEntry(LibDisplayName); if (m_displayName.isEmpty()) { // use file name instead QFileInfo fi(fileName); m_displayName = fi.completeBaseName(); } m_shlibNameRE = QRegExp(cf.readEntry(ShlibRE)); m_enabledBuiltins = cf.readEntry(EnableBuiltin, QStringList()); QString printQString = cf.readEntry(PrintQStringCmd); m_printQStringDataCmd = printQString.toAscii(); /* * Get the types. We search for entries of kind Types1, Types2, etc. * because a single entry Types could get rather long for large * libraries. */ QString typesEntry; for (int i = 1; ; i++) { // next bunch of types KConfigGroup cf = confFile.group(TypeTableGroup); typesEntry.sprintf(TypesEntryFmt, i); if (!cf.hasKey(typesEntry)) break; QStringList typeNames = cf.readEntry(typesEntry, QStringList()); // now read them QString alias; for (QStringList::iterator it = typeNames.begin(); it != typeNames.end(); ++it) { KConfigGroup cf = confFile.group(*it); // check if this is an alias alias = cf.readEntry(AliasEntry); if (alias.isEmpty()) { readType(cf, *it); } else { // look up the alias type and insert it TypeInfoMap::iterator i = m_typeDict.find(alias); if (i == m_typeDict.end()) { TRACE(*it + ": alias " + alias + " not found"); } else { m_aliasDict.insert(std::make_pair(*it, &i->second)); TRACE(*it + ": alias " + alias); } } } } // for all Types%d }
void ProductMapping::getRelatedProductsUsingInternalFile(const QString & bugzillaProduct) { //ProductGroup -> kontact=kdepim //Groups -> kdepim=kontact|kmail|korganizer|akonadi|pimlibs..etc KConfig mappingsFile(QString::fromLatin1("mappings"), KConfig::NoGlobals, QStandardPaths::DataLocation); const KConfigGroup productGroup = mappingsFile.group("ProductGroup"); //Get groups of the application QStringList groups; if (productGroup.hasKey(bugzillaProduct)) { QString group = productGroup.readEntry(bugzillaProduct); if (group.isEmpty()) { qWarning() << "Error while reading mapping entry. Entry exists but it is empty " "(or there was an error when reading)"; return; } groups = group.split('|', QString::SkipEmptyParts); } //All KDE apps use the KDE Platform (basic libs) groups << QLatin1String("kdeplatform"); //Add the product itself m_relatedBugzillaProducts = QStringList() << m_bugzillaProduct; //Get related products of each related group Q_FOREACH( const QString & group, groups ) { const KConfigGroup bzGroups = mappingsFile.group("BZGroups"); if (bzGroups.hasKey(group)) { QString bzGroup = bzGroups.readEntry(group); if (!bzGroup.isEmpty()) { QStringList relatedGroups = bzGroup.split('|', QString::SkipEmptyParts); if (relatedGroups.size()>0) { m_relatedBugzillaProducts.append(relatedGroups); } } else { qWarning() << "Error while reading mapping entry. Entry exists but it is empty " "(or there was an error when reading)"; } } } }
int currentBuildDirIndex( KDevelop::IProject* project ) { KConfigGroup baseGrp = baseGroup(project); if ( baseGrp.hasKey( Config::buildDirOverrideIndexKey ) ) return baseGrp.readEntry<int>( Config::buildDirOverrideIndexKey, 0 ); else return baseGrp.readEntry<int>( Config::buildDirIndexKey, 0 ); // default is 0 because QString::number(0) apparently returns an empty string }
void Device::reloadPlugins() { QHash<QString, KdeConnectPlugin*> newPluginMap; QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface; QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface; if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices KConfigGroup pluginStates = KSharedConfig::openConfig(pluginsConfigFile())->group("Plugins"); PluginLoader* loader = PluginLoader::instance(); //Code borrowed from KWin foreach (const QString& pluginName, loader->getPluginList()) { QString enabledKey = pluginName + QString::fromLatin1("Enabled"); bool isPluginEnabled = (pluginStates.hasKey(enabledKey) ? pluginStates.readEntry(enabledKey, false) : loader->getPluginInfo(pluginName).isEnabledByDefault()); if (isPluginEnabled) { KdeConnectPlugin* plugin = m_plugins.take(pluginName); QStringList incomingInterfaces, outgoingInterfaces; if (plugin) { incomingInterfaces = m_pluginsByIncomingInterface.keys(plugin); outgoingInterfaces = m_pluginsByOutgoingInterface.keys(plugin); } else { const KPluginMetaData service = loader->getPluginInfo(pluginName); incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType"); outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType"); } //If we don't find intersection with the received on one end and the sent on the other, we don't //let the plugin stay //Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as //we assume that the other client doesn't know about capabilities. if (!m_incomingCapabilities.isEmpty() && !m_outgoingCapabilities.isEmpty() && (m_incomingCapabilities & outgoingInterfaces.toSet()).isEmpty() && (m_outgoingCapabilities & incomingInterfaces.toSet()).isEmpty() ) { delete plugin; continue; } if (!plugin) { plugin = loader->instantiatePluginForDevice(pluginName, this); } foreach(const QString& interface, incomingInterfaces) { newPluginsByIncomingInterface.insert(interface, plugin); } foreach(const QString& interface, outgoingInterfaces) { newPluginsByOutgoingInterface.insert(interface, plugin); } newPluginMap[pluginName] = plugin; }
QStringList KFileItem::overlays() const { QStringList names = d->m_entry.stringValue( KIO::UDSEntry::UDS_ICON_OVERLAY_NAMES ).split(','); if ( d->m_bLink ) { names.append("emblem-symbolic-link"); } if ( !S_ISDIR( d->m_fileMode ) // Locked dirs have a special icon, use the overlay for files only && !isReadable()) { names.append("object-locked"); } if ( checkDesktopFile(*this, false) ) { KDesktopFile cfg( localPath() ); const KConfigGroup group = cfg.desktopGroup(); // Add a warning emblem if this is an executable desktop file // which is untrusted. if ( group.hasKey( "Exec" ) && !KDesktopFile::isAuthorizedDesktopFile( localPath() ) ) { names.append( "emblem-important" ); } if (cfg.hasDeviceType()) { const QString dev = cfg.readDevice(); if (!dev.isEmpty()) { KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByDevice(dev); if (mountPoint) // mounted? names.append("emblem-mounted"); } } } if ( isHidden() ) { names.append("hidden"); } #ifndef Q_OS_WIN if( S_ISDIR( d->m_fileMode ) && d->m_bIsLocalUrl) { if (KSambaShare::instance()->isDirectoryShared( d->m_url.toLocalFile() ) || KNFSShare::instance()->isDirectoryShared( d->m_url.toLocalFile() )) { //kDebug() << d->m_url.path(); names.append("network-workgroup"); } } #endif // Q_OS_WIN if ( d->m_pMimeType && d->m_url.fileName().endsWith( QLatin1String( ".gz" ) ) && d->m_pMimeType->is("application/x-gzip") ) { names.append("application-zip"); } return names; }
void removeOverrideBuildDirIndex( KDevelop::IProject* project, bool writeToMainIndex ) { KConfigGroup baseGrp = baseGroup(project); if( !baseGrp.hasKey(Config::buildDirOverrideIndexKey) ) return; if( writeToMainIndex ) baseGrp.writeEntry( Config::buildDirIndexKey, baseGrp.readEntry(Config::buildDirOverrideIndexKey) ); baseGrp.deleteEntry(Config::buildDirOverrideIndexKey); }
bool SylpheedSettingsUtils::readConfig( const QString& key, const KConfigGroup& accountConfig, QString& value, bool remove_underscore ) { QString cleanedKey( key ); if ( remove_underscore ) cleanedKey.remove( QLatin1Char( '_' ) ); const QString useKey = QLatin1String( "set_" )+ cleanedKey; if ( accountConfig.hasKey( useKey ) && ( accountConfig.readEntry( useKey, 0 ) == 1 ) ) { value = accountConfig.readEntry( key ); return true; } return false; }
ServiceButton::ServiceButton( const KConfigGroup& config, QWidget* parent ) : PanelButton(parent, "ServiceButton"), _service(0) { QString id; if (config.hasKey("StorageId")) id = config.readPathEntry("StorageId"); else id = config.readPathEntry("DesktopFile"); loadServiceFromId(id); initialize(); }
bool KConfigConfig::read(const String& key, std::vector <String> *ret) const { if (!valid() || !ret || key.empty()) return false; KConfigGroup defaultGroup = m_config->group("SCIM"); QString qkey = QString::fromUtf8(key.c_str()); if (defaultGroup.hasKey(qkey)) { QStringList value = defaultGroup.readEntry(qkey, QStringList()); foreach(const QString& s, value) { ret->push_back(String(s.toUtf8())); }
void ClawsMailSettings::readTagColor(const KConfigGroup &group) { const QString customColorPattern(QLatin1String("custom_color%1")); const QString customColorLabelPattern(QLatin1String("custom_colorlabel%1")); QList<tagStruct> listTag; for(int i = 1; i<=15; ++i) { if(group.hasKey(customColorPattern.arg(i)) && group.hasKey(customColorLabelPattern.arg(i))) { tagStruct tag; const QString colorStr = group.readEntry(customColorPattern.arg(i)); const QString labelStr = group.readEntry(customColorLabelPattern.arg(i)); if(!colorStr.isEmpty()&& !labelStr.isEmpty()) { tag.color = QColor(colorStr).name(); tag.name = labelStr; listTag<<tag; } } } if(!listTag.isEmpty()) { ImportWizardUtil::addNepomukTag(listTag); } }
bool DimDisplay::loadAction(const KConfigGroup& config) { kDebug(); if (config.hasKey("idleTime")) { m_dimOnIdleTime = config.readEntry<int>("idleTime", 10000000); kDebug() << "Loading timeouts with " << m_dimOnIdleTime; registerIdleTimeout(m_dimOnIdleTime * 3 / 4); registerIdleTimeout(m_dimOnIdleTime / 2); registerIdleTimeout(m_dimOnIdleTime); } return true; }
//FIXME: the code for reading and writing these configuration entries should be regrouped // within a single class (currently, the code for writing the values can be found // in 'latexcommanddialog.cpp'). void LatexCommands::addUserCommands(const QString &name, QStringList &list) { KILE_DEBUG() << name; if(!m_config->hasGroup(name)) { KILE_DEBUG() << "\tGroup does not exist."; return; } KConfigGroup group = m_config->group(name); int nrOfDefinedCommands = group.readEntry("Number of Commands", 0); for(int i = 0; i < nrOfDefinedCommands; ++i) { const QString commandKey = "Command" + QString::number(i); const QString parametersKey = "Parameters" + QString::number(i); if(!group.hasKey(commandKey) || !group.hasKey(parametersKey)) { KILE_DEBUG() << "\tEntry" << i << "is invalid!"; } const QString command = group.readEntry(commandKey); const QString parameters = group.readEntry(parametersKey); list << command + ",-," + parameters; KILE_DEBUG() << "\tAdding: " << command + " --> " + parameters; } }
bool BrightnessControl::loadAction(const KConfigGroup& config) { // Handle profile changes m_lastProfile = m_currentProfile; m_currentProfile = config.parent().name(); kDebug() << "Profiles: " << m_currentProfile << m_lastProfile; if (config.hasKey("value")) { m_defaultValue = config.readEntry<int>("value", 50); } else { m_defaultValue = -1; } return true; }
void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2) { // Copy keys QMap<QString, QString> list = cg1.entryMap(); for (QMap<QString, QString>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { if (m_bOverwrite || !cg2.hasKey(it.key())) { cg2.writeEntry(it.key(), it.value()); } } // Copy subgroups Q_FOREACH(const QString &group, cg1.groupList()) { copyGroup(&cg1, group, &cg2, group); } }