当前位置: 首页>>代码示例>>C++>>正文


C++ KConfigGroup::hasKey方法代码示例

本文整理汇总了C++中KConfigGroup::hasKey方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfigGroup::hasKey方法的具体用法?C++ KConfigGroup::hasKey怎么用?C++ KConfigGroup::hasKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KConfigGroup的用法示例。


在下文中一共展示了KConfigGroup::hasKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadConfig

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);
    }
}
开发者ID:ZaWertun,项目名称:kio_recentfolders,代码行数:11,代码来源:kio_recentfolders.cpp

示例2: writeColorEntry

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));
    }
}
开发者ID:adaptee,项目名称:konsole,代码行数:27,代码来源:ColorScheme.cpp

示例3: config

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"));
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:31,代码来源:test_update_kwin_49.cpp

示例4: clockConfigChanged

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();
    }
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:56,代码来源:clock.cpp

示例5: loadAction

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;
}
开发者ID:KDE,项目名称:powerdevil,代码行数:14,代码来源:suspendsession.cpp

示例6: entryKey

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
}
开发者ID:cancamilo,项目名称:amarok,代码行数:28,代码来源:MountPointManager.cpp

示例7: currentSize

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;
}
开发者ID:fluxer,项目名称:kde-workspace,代码行数:28,代码来源:trashsizecache.cpp

示例8: copyOrMoveKey

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;
}
开发者ID:vasi,项目名称:kdelibs,代码行数:27,代码来源:kconf_update.cpp

示例9: readColorEntry

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);
}
开发者ID:adaptee,项目名称:konsole,代码行数:26,代码来源:ColorScheme.cpp

示例10: testActionGroup

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"));
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:25,代码来源:kdesktopfiletest.cpp

示例11: doLoadState

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();
}
开发者ID:Match-Yang,项目名称:digikam,代码行数:26,代码来源:gpssearchview.cpp

示例12: loadFromFile

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
}
开发者ID:isdamir,项目名称:kdbg,代码行数:59,代码来源:typetable.cpp

示例13: getRelatedProductsUsingInternalFile

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)";
            }
        }
    }
}
开发者ID:KDE,项目名称:plasma-workspace,代码行数:43,代码来源:productmapping.cpp

示例14: currentBuildDirIndex

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
}
开发者ID:salamanderrake,项目名称:KDevelop,代码行数:10,代码来源:cmakeutils.cpp

示例15: reloadPlugins

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;
            }
开发者ID:zhangtianye,项目名称:kdeconnect-kde,代码行数:55,代码来源:device.cpp


注:本文中的KConfigGroup::hasKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。