示例#1
0
/** 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;
}
// 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 ();
    }
}
// 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 ();
}
// 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 ();
}
示例#5
0
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 ) );
}
示例#6
0
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 );
}
// private slot
void kpMainWindow::slotShowGridToggled ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotActionShowGridToggled()" << endl;
#endif

    updateMainViewGrid ();


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

    cfg->writeEntry (kpSettingShowGrid, m_configShowGrid = m_actionShowGrid->isChecked ());
    cfg->sync ();
}
示例#8
0
void HostConfig::writeIfNotEmpty( KConfigBase &config, const QString &name, const QString &value )
{
    if ( value.isEmpty() )
        return;

    config.writeEntry( name, value );
}
// private slot
void kpMainWindow::slotResizeScale ()
{
    if (toolHasBegunShape ())
        tool ()->endShapeInternal ();

    kpToolResizeScaleDialog dialog (this);
    dialog.setKeepAspectRatio (d->m_resizeScaleDialogLastKeepAspect);

    if (dialog.exec () && !dialog.isNoOp ())
    {
        kpToolResizeScaleCommand *cmd = new kpToolResizeScaleCommand (
            dialog.actOnSelection (),
            dialog.imageWidth (), dialog.imageHeight (),
            dialog.type (),
            this);

        bool addSelCreateCommand = (dialog.actOnSelection () ||
                                    cmd->scaleSelectionWithImage ());
        bool addSelPullCommand = dialog.actOnSelection ();

        addImageOrSelectionCommand (
            cmd,
            addSelCreateCommand,
            addSelPullCommand);

        // Resized document?
        if (!dialog.actOnSelection () &&
            dialog.type () == kpToolResizeScaleCommand::Resize)
        {
            // TODO: this should be the responsibility of kpDocument
            saveDefaultDocSize (QSize (dialog.imageWidth (), dialog.imageHeight ()));
        }
    }


    if (d->m_resizeScaleDialogLastKeepAspect != dialog.keepAspectRatio ())
    {
        d->m_resizeScaleDialogLastKeepAspect = dialog.keepAspectRatio ();

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

        cfg->writeEntry (kpSettingResizeScaleLastKeepAspect,
                         d->m_resizeScaleDialogLastKeepAspect);
        cfg->sync ();
    }
}
示例#10
0
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;
}
// 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 ();
}
// private slot
void kpMainWindow::slotZoomedThumbnailToggled ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotZoomedThumbnailToggled()" << endl;
#endif

    m_configZoomedThumbnail = m_actionZoomedThumbnail->isChecked ();

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

    cfg->writeEntry (kpSettingThumbnailZoomed, m_configZoomedThumbnail);
    cfg->sync ();


    updateThumbnailZoomed ();
}
示例#13
0
QString KOrnPassword::readKOrnPassword( int box, int account, const KConfigBase &fallbackConfig )
{
	QString result;

	if( readKOrnPassword( box, account, result ) )
		return result;
	else
		return fallbackConfig.readEntry( "password" );
}
// private slot
void kpMainWindow::slotShowThumbnailToggled ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotShowThumbnailToggled()" << endl;
#endif

    m_configThumbnailShown = m_actionShowThumbnail->isChecked ();

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

    cfg->writeEntry (kpSettingThumbnailShown, m_configThumbnailShown);
    cfg->sync ();


    enableThumbnailOptionActions (m_actionShowThumbnail->isChecked ());
    updateThumbnail ();
}
示例#15
0
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;
}
// private slot
void kpMainWindow::slotTextStrikeThruChanged ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotTextStrikeThruChanged() alive="
               << m_isFullyConstructed
               << " strikeThru="
               << m_actionTextStrikeThru->isChecked ()
               << endl;
#endif

    if (!m_isFullyConstructed)
        return;

    if (m_toolText && m_toolText->hasBegun ())
        m_toolText->slotStrikeThruChanged (m_actionTextStrikeThru->isChecked ());

    KConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupText);
    KConfigBase *cfg = cfgGroupSaver.config ();
    cfg->writeEntry (kpSettingStrikeThru, m_actionTextStrikeThru->isChecked ());
    cfg->sync ();
}
// private slot
void kpMainWindow::slotThumbnailShowRectangleToggled ()
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow::slotThumbnailShowRectangleToggled()" << endl;
#endif

    d->m_configThumbnailShowRectangle = d->m_actionShowThumbnailRectangle->isChecked ();

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

    cfg->writeEntry (kpSettingThumbnailShowRectangle, d->m_configThumbnailShowRectangle);
    cfg->sync ();


    if (m_thumbnailView)
    {
        m_thumbnailView->showBuddyViewScrollableContainerRectangle (
            d->m_actionShowThumbnailRectangle->isChecked ());
    }
}
示例#18
0
void HostConfigMap::load( KConfigBase &config, const QStringList &hosts )
{
    clear();

    for ( QStringList::ConstIterator it = hosts.begin(); it != hosts.end(); ++it ) {
        config.setGroup( "Host " + *it );

        HostConfig src;
        if ( !src.load( config ) )
            continue;

        insert( *it, src );
    }
}
示例#19
0
QStringList HostConfigMap::save( KConfigBase &config ) const
{
    QStringList hostList;

    for ( ConstIterator it = begin(); it != end(); ++it ) {
        QString host = it.key();

        hostList << host;

        config.setGroup( "Host " + host );
        ( *it ).save( config );
    }

    return hostList;
}
// 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 ();
}
示例#21
0
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;
}
示例#22
0
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())
                    pEnv = getenv(aVarName.ascii());
                if(pEnv)
                {
                    // !!! Sergey A. Sukiyazov <*****@*****.**> !!!
                    // A environment variables may contain values in 8bit
                    // locale cpecified encoding or in UTF8 encoding.
                    aValue.replace(nDollarPos, nEndPos - nDollarPos, KStringHandler::from8Bit(pEnv));
                }
                else
                    aValue.remove(nDollarPos, nEndPos - nDollarPos);
            }
            else
            {
                // remove one of the dollar signs
                aValue.remove(nDollarPos, 1);
                nDollarPos++;
            }
            nDollarPos = aValue.find('$', nDollarPos);
        }
    }

    return aValue;
}
示例#23
0
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;
        }
    }
}
示例#24
0
void KOrnPassword::deleteKOrnPassword( int box, int account, KConfigBase& fallbackConfig )
{
	deleteKOrnPassword( box, account );
	if( fallbackConfig.hasKey( "password" ) )
		fallbackConfig.deleteEntry( "password" );
}