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


C++ KConfigBase类代码示例

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


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

示例1: kdDebug

/** No descriptions */
bool KCountryPage::save(KLanguageButton *comboCountry, KLanguageButton *comboLang) {
	kdDebug() << "KCountryPage::save()" << endl;
	KConfigBase *config = KGlobal::config();

	config->setGroup(QString::fromLatin1("Locale"));
	config->writeEntry(QString::fromLatin1("Country"), comboCountry->current(), true, true);
	config->writeEntry(QString::fromLatin1("Language"), comboLang->current(), true, true);
	config->sync();

	// only make the system reload the language, if the selected one deferes from the old saved one.
	if (b_savedLanguageChanged) {
		// Tell kdesktop about the new language
		QCString replyType; QByteArray replyData;
		QByteArray data, da;
		QDataStream stream( data, IO_WriteOnly );
		stream << comboLang->current();
		if ( !kapp->dcopClient()->isAttached() )
			kapp->dcopClient()->attach();
		// ksycoca needs to be rebuilt
		KProcess proc;
		proc << QString::fromLatin1("kbuildsycoca");
		proc.start(KProcess::DontCare);
		kdDebug() << "KLocaleConfig::save : sending signal to kdesktop" << endl;
		// inform kicker and kdeskop about the new language
		kapp->dcopClient()->send( "kicker", "Panel", "restart()", QString::null);
		// call, not send, so that we know it's done before coming back
		// (we both access kdeglobals...)
		kapp->dcopClient()->call( "kdesktop", "KDesktopIface", "languageChanged(QString)", data, replyType, replyData );
	}
	// KPersonalizer::next() probably waits for a return-value
	return true;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: tool

// private slot
void kpMainWindow::slotMoreEffects ()
{
    if (toolHasBegunShape ())
        tool ()->endShapeInternal ();

    kpEffectsDialog dialog ((bool) m_document->selection (), this);
    dialog.selectEffect (d->m_moreEffectsDialogLastEffect);

    if (dialog.exec () && !dialog.isNoOp ())
    {
        addImageOrSelectionCommand (dialog.createCommand ());
    }


    if (d->m_moreEffectsDialogLastEffect != dialog.selectedEffect ())
    {
        d->m_moreEffectsDialogLastEffect = dialog.selectedEffect ();

        KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupGeneral);
        KConfigBase *cfg = cfgGroupSaver.config ();

        cfg->writeEntry (kpSettingMoreEffectsLastEffect,
                         d->m_moreEffectsDialogLastEffect);
        cfg->sync ();
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:27,代码来源:kpmainwindow_image.cpp

示例3: kdDebug

// private slot
void kpMainWindow::slotTextFontSizeChanged ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotTextFontSizeChanged() alive="
               << m_isFullyConstructed
               << " fontSize="
               << m_actionTextFontSize->fontSize ()
               << endl;
#endif

    if (!m_isFullyConstructed)
        return;

    if (m_toolText && m_toolText->hasBegun ())
    {
        m_toolText->slotFontSizeChanged (m_actionTextFontSize->fontSize (),
                                         m_textOldFontSize);
    }

    // Since editable KSelectAction's steal focus from view, switch back to mainView
    // TODO: back to the last view
    if (m_mainView)
        m_mainView->setFocus ();

    KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupText);
    KConfigBase *cfg = cfgGroupSaver.config ();
    cfg->writeEntry (kpSettingFontSize, m_actionTextFontSize->fontSize ());
    cfg->sync ();

    m_textOldFontSize = m_actionTextFontSize->fontSize ();
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:32,代码来源:kpmainwindow_text.cpp

示例4: kdDebug

// private slot
void kpMainWindow::slotSaveThumbnailGeometry ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::saveThumbnailGeometry()" << endl;
#endif

    if (!m_thumbnail)
        return;

    QRect rect (m_thumbnail->x (), m_thumbnail->y (),
                m_thumbnail->width (), m_thumbnail->height ());
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "\tthumbnail relative geometry=" << rect << endl;
#endif

    m_configThumbnailGeometry = mapFromGlobal (rect);

#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "\tCONFIG: saving thumbnail geometry "
                << m_configThumbnailGeometry
                << endl;
#endif

    KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupThumbnail);
    KConfigBase *cfg = cfgGroupSaver.config ();

    cfg->writeEntry (kpSettingThumbnailGeometry, m_configThumbnailGeometry);
    cfg->sync ();
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:30,代码来源:kpmainwindow_view.cpp

示例5: save

void HostConfig::save( KConfigBase &config ) const
{
    if ( isNull() )
        return;

    config.writeEntry( "Host", name );
    if ( port != 0 )
        config.writeEntry( "Port", port );

    config.writeEntry( "Version", snmpVersionToString( version ) );

    if ( version != SnmpVersion3 ) {
        writeIfNotEmpty( config, "Community", community );
        return;
    }

    writeIfNotEmpty( config, "SecurityName", securityName );

    config.writeEntry( "SecurityLevel", securityLevelToString( securityLevel ) );

    if ( securityLevel == NoAuthPriv )
        return;

    writeIfNotEmpty( config, "AuthType", authenticationProtocolToString( authentication.protocol ) );
    writeIfNotEmpty( config, "AuthPassphrase", KStringHandler::obscure( authentication.key ) );

    if ( securityLevel == AuthNoPriv )
        return;

    writeIfNotEmpty( config, "PrivType", privacyProtocolToString( privacy.protocol ) );
    writeIfNotEmpty( config, "PrivPassphrase", KStringHandler::obscure( privacy.key ) );
}
开发者ID:serghei,项目名称:kde3-kdeutils,代码行数:32,代码来源:hostconfig.cpp

示例6: writeKOrnPassword

void KOrnPassword::writeKOrnPassword( int box, int account, KConfigBase& fallbackConfig, const QString& password )
{
	if( writeKOrnPassword( box, account, password ) )
	{
		if( fallbackConfig.hasKey( "password" ) )
			fallbackConfig.deleteEntry( "password" );
	}
	else
		fallbackConfig.writeEntry( "password", password );
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例7: writeIfNotEmpty

void HostConfig::writeIfNotEmpty( KConfigBase &config, const QString &name, const QString &value )
{
    if ( value.isEmpty() )
        return;

    config.writeEntry( name, value );
}
开发者ID:serghei,项目名称:kde3-kdeutils,代码行数:7,代码来源:hostconfig.cpp

示例8: readKMailPassword

QString KOrnPassword::readKMailPassword( int accountnr, const KConfigBase& fallbackConfig )
{
	QString password;
	open();

	if( !m_wallet || !m_wallet->isOpen() || m_openFailed )
		return KMailDecrypt( fallbackConfig.readEntry( "pass" ) );

	if( !m_wallet->hasFolder( "kmail" ) )
		return KMailDecrypt( fallbackConfig.readEntry( "pass" ));
	m_wallet->setFolder( "kmail" );

	if( m_wallet->readPassword( QString( "account-%1" ).arg( accountnr ), password ) != 0 )
		return fallbackConfig.readEntry( "password" );

	return password;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: kdDebug

// private slot
void kpMainWindow::slotShowPathToggled ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotShowPathToggled()" << endl;
#endif

    m_configShowPath = m_actionShowPath->isChecked ();

    slotUpdateCaption ();


    KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupGeneral);
    KConfigBase *cfg = cfgGroupSaver.config ();

    cfg->writeEntry (kpSettingShowPath, m_configShowPath);
    cfg->sync ();
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:18,代码来源:kpmainwindow_settings.cpp

示例10: readKOrnPassword

QString KOrnPassword::readKOrnPassword( int box, int account, const KConfigBase &fallbackConfig )
{
	QString result;

	if( readKOrnPassword( box, account, result ) )
		return result;
	else
		return fallbackConfig.readEntry( "password" );
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例11: load

bool HostConfig::load( KConfigBase &config )
{
    name = config.readEntry( "Host" );
    if ( name.isEmpty() )
        return false;

    port = config.readNumEntry( "Port", defaultSnmpPort() );

    bool ok = false;
    version = stringToSnmpVersion( config.readEntry( "Version" ), &ok );
    if ( !ok )
        return false;

    if ( version != SnmpVersion3 ) {
        community = config.readEntry( "Community" );
        return true;
    }

    securityName = config.readEntry( "SecurityName" );

    securityLevel = stringToSecurityLevel( config.readEntry( "SecurityLevel" ), &ok );
    if ( !ok )
        return false;

    if ( securityLevel == NoAuthPriv )
        return true;

    authentication.protocol = stringToAuthenticationProtocol( config.readEntry( "AuthType" ), &ok );
    if ( !ok )
        return false;
    authentication.key = KStringHandler::obscure( config.readEntry( "AuthPassphrase" ) );

    if ( securityLevel == AuthNoPriv )
        return true;

    privacy.protocol = stringToPrivacyProtocol( config.readEntry( "PrivType" ), &ok );
    if ( !ok )
        return false;
    privacy.key = KStringHandler::obscure( config.readEntry( "PrivPassphrase" ) );

    return true;
}
开发者ID:serghei,项目名称:kde3-kdeutils,代码行数:42,代码来源:hostconfig.cpp

示例12: cfgGroupSaver

// private
void kpMainWindow::readAndApplyTextSettings ()
{
    KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupText);
    KConfigBase *cfg = cfgGroupSaver.config ();

    m_actionTextFontFamily->setFont (cfg->readEntry (kpSettingFontFamily, QString::fromLatin1 ("Times")));
    m_actionTextFontSize->setFontSize (cfg->readNumEntry (kpSettingFontSize, 14));
    m_actionTextBold->setChecked (cfg->readBoolEntry (kpSettingBold, false));
    m_actionTextItalic->setChecked (cfg->readBoolEntry (kpSettingItalic, false));
    m_actionTextUnderline->setChecked (cfg->readBoolEntry (kpSettingUnderline, false));
    m_actionTextStrikeThru->setChecked (cfg->readBoolEntry (kpSettingStrikeThru, false));

    m_textOldFontFamily = m_actionTextFontFamily->font ();
    m_textOldFontSize = m_actionTextFontSize->fontSize ();
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:16,代码来源:kpmainwindow_text.cpp

示例13: init

bool KAccelActions::init( KConfigBase& config, const QString& sGroup )
{
	kdDebug(125) << "KAccelActions::init( " << sGroup << " )" << endl;
	QMap<QString, QString> mapEntry = config.entryMap( sGroup );
	resize( mapEntry.count() );

	QMap<QString, QString>::Iterator it( mapEntry.begin() );
	for( uint i = 0; it != mapEntry.end(); ++it, i++ ) {
		QString sShortcuts = *it;
		KShortcut cuts;

		kdDebug(125) << it.key() << " = " << sShortcuts << endl;
		if( !sShortcuts.isEmpty() && sShortcuts != "none" )
			cuts.init( sShortcuts );

		m_prgActions[i] = new KAccelAction( it.key(), it.key(), it.key(),
			cuts, cuts,
			0, 0,          // pObjSlot, psMethodSlot,
			true, false ); // bConfigurable, bEnabled
	}

	return true;
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例14: readEntry

QString KConfigBase::readEntry(const char *pKey, const QString &aDefault) const
{
    // we need to access _locale instead of the method locale()
    // because calling locale() will create a locale object if it
    // doesn't exist, which requires KConfig, which will create a infinite
    // loop, and nobody likes those.
    if(!bLocaleInitialized && KGlobal::_locale)
    {
        // get around const'ness.
        KConfigBase *that = const_cast< KConfigBase * >(this);
        that->setLocale();
    }

    QString aValue;

    bool expand = false;
    // construct a localized version of the key
    // try the localized key first
    KEntry aEntryData;
    KEntryKey entryKey(mGroup, 0);
    entryKey.c_key = pKey;
    entryKey.bDefault = readDefaults();
    entryKey.bLocal = true;
    aEntryData = lookupData(entryKey);
    if(!aEntryData.mValue.isNull())
    {
        // for GNOME .desktop
        aValue = KStringHandler::from8Bit(aEntryData.mValue.data());
        expand = aEntryData.bExpand;
    }
    else
    {
        entryKey.bLocal = false;
        aEntryData = lookupData(entryKey);
        if(!aEntryData.mValue.isNull())
        {
            aValue = QString::fromUtf8(aEntryData.mValue.data());
            if(aValue.isNull())
            {
                static const QString &emptyString = KGlobal::staticQString("");
                aValue = emptyString;
            }
            expand = aEntryData.bExpand;
        }
        else
        {
            aValue = aDefault;
        }
    }

    // only do dollar expansion if so desired
    if(expand || bExpand)
    {
        // check for environment variables and make necessary translations
        int nDollarPos = aValue.find('$');

        while(nDollarPos != -1 && nDollarPos + 1 < static_cast< int >(aValue.length()))
        {
            // there is at least one $
            if((aValue)[nDollarPos + 1] == '(')
            {
                uint nEndPos = nDollarPos + 1;
                // the next character is no $
                while((nEndPos <= aValue.length()) && (aValue[nEndPos] != ')'))
                    nEndPos++;
                nEndPos++;
                QString cmd = aValue.mid(nDollarPos + 2, nEndPos - nDollarPos - 3);

                QString result;
                FILE *fs = popen(QFile::encodeName(cmd).data(), "r");
                if(fs)
                {
                    {
                        QTextStream ts(fs, IO_ReadOnly);
                        result = ts.read().stripWhiteSpace();
                    }
                    pclose(fs);
                }
                aValue.replace(nDollarPos, nEndPos - nDollarPos, result);
            }
            else if((aValue)[nDollarPos + 1] != '$')
            {
                uint nEndPos = nDollarPos + 1;
                // the next character is no $
                QString aVarName;
                if(aValue[nEndPos] == '{')
                {
                    while((nEndPos <= aValue.length()) && (aValue[nEndPos] != '}'))
                        nEndPos++;
                    nEndPos++;
                    aVarName = aValue.mid(nDollarPos + 2, nEndPos - nDollarPos - 3);
                }
                else
                {
                    while(nEndPos <= aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == '_'))
                        nEndPos++;
                    aVarName = aValue.mid(nDollarPos + 1, nEndPos - nDollarPos - 1);
                }
                const char *pEnv = 0;
                if(!aVarName.isEmpty())
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:101,代码来源:kconfigbase.cpp

示例15: KeyFilter

Kleo::KConfigBasedKeyFilter::KConfigBasedKeyFilter( const KConfigBase & config )
    : KeyFilter(),
      mSpecificity( 0 ),
      mItalic( false ),
      mBold( false ),
      mStrikeOut( false ),
      mUseFullFont( false ),
      mRevoked( DoesNotMatter ),
      mExpired( DoesNotMatter ),
      mDisabled( DoesNotMatter ),
      mRoot( DoesNotMatter ),
      mCanEncrypt( DoesNotMatter ),
      mCanSign( DoesNotMatter ),
      mCanCertify( DoesNotMatter ),
      mCanAuthenticate( DoesNotMatter ),
      mHasSecret( DoesNotMatter ),
      mIsOpenPGP( DoesNotMatter ),
      mWasValidated( DoesNotMatter ),
      mOwnerTrust( LevelDoesNotMatter ),
      mOwnerTrustReferenceLevel( GpgME::Key::Unknown ),
      mValidity( LevelDoesNotMatter ),
      mValidityReferenceLevel( GpgME::UserID::Unknown )
{
    mFgColor = config.readColorEntry( "foreground-color" );
    mBgColor = config.readColorEntry( "background-color" );
    mName = config.readEntry( "name", i18n("<unnamed>") );
    mIcon = config.readEntry( "icon" );
    if ( config.hasKey( "font" ) ) {
        mUseFullFont = true;
        mFont = config.readFontEntry( "font" );
    } else {
        mItalic = config.readBoolEntry( "font-italic", false );
        mBold = config.readBoolEntry( "font-bold", false );
    }
    mStrikeOut = config.readBoolEntry( "font-strikeout", false );
#ifdef SET
#undef SET
#endif
#define SET(member,key) \
  if ( config.hasKey( key ) ) { \
    member = config.readBoolEntry( key ) ? Set : NotSet ; \
    ++mSpecificity; \
  }
    SET( mRevoked, "is-revoked" );
    SET( mExpired, "is-expired" );
    SET( mDisabled, "is-disabled" );
    SET( mRoot, "is-root-certificate" );
    SET( mCanEncrypt, "can-encrypt" );
    SET( mCanSign, "can-sign" );
    SET( mCanCertify, "can-certify" );
    SET( mCanAuthenticate, "can-authenticate" );
    SET( mHasSecret, "has-secret-key" );
    SET( mIsOpenPGP, "is-openpgp-key" );
    SET( mWasValidated, "was-validated" );
#undef SET
    static const struct {
        const char * prefix;
        LevelState state;
    } prefixMap[] = {
        { "is-", Is },
        { "is-not-", IsNot },
        { "is-at-least-", IsAtLeast },
        { "is-at-most-", IsAtMost },
    };
    for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) {
        const QString key = QString( prefixMap[i].prefix ) + "ownertrust";
        if ( config.hasKey( key ) ) {
            mOwnerTrust = prefixMap[i].state;
            mOwnerTrustReferenceLevel = map2OwnerTrust( config.readEntry( key ) );
            ++mSpecificity;
            break;
        }
    }
    for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) {
        const QString key = QString( prefixMap[i].prefix ) + "validity";
        if ( config.hasKey( key ) ) {
            mValidity = prefixMap[i].state;
            mValidityReferenceLevel = map2Validity( config.readEntry( key ) );
            ++mSpecificity;
            break;
        }
    }
}
开发者ID:,项目名称:,代码行数:83,代码来源:


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