void CustomBuildSystemConfigWidget::loadFrom( KConfig* cfg )
{
    ui->currentConfig->clear();
    QStringList groupNameList;
    KConfigGroup grp = cfg->group( ConfigConstants::customBuildSystemGroup );
    foreach( const QString& grpName, grp.groupList() ) {
        KConfigGroup subgrp = grp.group( grpName );
        CustomBuildSystemConfig config;

        config.title = subgrp.readEntry( ConfigConstants::configTitleKey, QString() );
        config.buildDir = subgrp.readEntry( ConfigConstants::buildDirKey, QUrl() );

        foreach( const QString& subgrpName, subgrp.groupList() ) {
            if( subgrpName.startsWith( ConfigConstants::toolGroupPrefix ) ) {
                KConfigGroup toolgrp = subgrp.group( subgrpName );
                CustomBuildSystemTool tool;
                tool.arguments = toolgrp.readEntry( ConfigConstants::toolArguments, "" );
                tool.executable = toolgrp.readEntry( ConfigConstants::toolExecutable, QUrl() );
                tool.envGrp = toolgrp.readEntry( ConfigConstants::toolEnvironment, QString() );
                tool.enabled = toolgrp.readEntry( ConfigConstants::toolEnabled, false );
                tool.type = CustomBuildSystemTool::ActionType( toolgrp.readEntry( ConfigConstants::toolType, 0 ) );
                config.tools[tool.type] = tool;
            }
        }
        configs << config;
        ui->currentConfig->addItem( config.title );
        groupNameList << grpName;
    }
    int idx = groupNameList.indexOf( grp.readEntry( ConfigConstants::currentConfigKey, "" ) );
    if( !groupNameList.isEmpty() && idx < 0 )
        idx = 0;

    ui->currentConfig->setCurrentIndex( idx );
    changeCurrentConfig( idx );
}
예제 #2
0
PlasmaApp::PlasmaApp()
    : KUniqueApplication(),
      m_corona(0),
      m_maxId(0)
{
    KGlobal::locale()->insertCatalog("plasma-standaloneplasmoids");
    KCrash::setFlags(KCrash::AutoRestart);

    KConfigGroup cg(KGlobal::config(), "General");
    Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", font()));

    corona();

    KConfigGroup applets = storedConfig(0);
    foreach (const QString &group, applets.groupList()) {
        KConfigGroup appletGroup(&applets, group);

        int id = appletGroup.name().toInt();
        QString pluginName = appletGroup.readEntry("plugin", QString());
        if (id != 0 && !pluginName.isEmpty()) {
            m_storedApplets.insert(pluginName, id);
            m_maxId = qMax(id, m_maxId);
        }
    }

    //newInstance();
    connect(this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
    setQuitOnLastWindowClosed(true);
}
bool TabletProfileConfigAdaptor::loadConfig (const KConfigGroup& config)
{
    Q_D( TabletProfileConfigAdaptor );
    assert(d->profile != NULL);

    d->profile->setName(config.name());
    d->profile->clearDevices();

    QStringList devices = config.groupList();

    foreach(const QString& dev, devices) {
        const DeviceType* deviceType = DeviceType::find(dev);

        if (deviceType == NULL) {
            kError() << QString::fromLatin1("Invalid device identifier '%1' found in configuration file!").arg(dev);
            continue;
        }

        KConfigGroup               devconfig(&config, dev);
        DeviceProfile              devprofile(*deviceType);
        DeviceProfileConfigAdaptor devadaptor(devprofile);

        devadaptor.loadConfig(devconfig);

        d->profile->setDevice(devprofile);
    }

    return true;
}
예제 #4
0
void CustomBuildSystemConfigWidget::loadFrom( KConfig* cfg )
{
    ui->currentConfig->clear();
    QStringList groupNameList;
    KConfigGroup grp = cfg->group( ConfigConstants::customBuildSystemGroup );
    foreach( const QString& grpName, grp.groupList() ) {
        KConfigGroup subgrp = grp.group( grpName );
        CustomBuildSystemConfig config;

        config.title = subgrp.readEntry( ConfigConstants::configTitleKey, "" );
        config.buildDir = subgrp.readEntry( ConfigConstants::buildDirKey, "" );

        foreach( const QString& subgrpName, subgrp.groupList() ) {
            if( subgrpName.startsWith( ConfigConstants::toolGroupPrefix ) ) {
                KConfigGroup toolgrp = subgrp.group( subgrpName );
                CustomBuildSystemTool tool;
                tool.arguments = toolgrp.readEntry( ConfigConstants::toolArguments, "" );
                tool.executable = toolgrp.readEntry( ConfigConstants::toolExecutable, KUrl() );
                tool.envGrp = toolgrp.readEntry( ConfigConstants::toolEnvironment, "default" );
                tool.enabled = toolgrp.readEntry( ConfigConstants::toolEnabled, false );
                tool.type = CustomBuildSystemTool::ActionType( toolgrp.readEntry( ConfigConstants::toolType, 0 ) );
                config.tools[tool.type] = tool;
            } else if( subgrpName.startsWith( ConfigConstants::projectPathPrefix ) ) {
                KConfigGroup pathgrp = subgrp.group( subgrpName );
                CustomBuildSystemProjectPathConfig path;
                path.path = pathgrp.readEntry( ConfigConstants::projectPathKey, "" );
                {
                    QByteArray tmp = pathgrp.readEntry( ConfigConstants::definesKey, QByteArray() );
                    QDataStream s(tmp);
                    s.setVersion( QDataStream::Qt_4_5 );
                    s >> path.defines;
                }

                {
                    QByteArray tmp = pathgrp.readEntry( ConfigConstants::includesKey, QByteArray() );
                    QDataStream s(tmp);
                    s.setVersion( QDataStream::Qt_4_5 );
                    s >> path.includes;
                }
                config.projectPaths << path;
            }
        }
        configs << config;
        ui->currentConfig->addItem( config.title );
        groupNameList << grpName;
    }
예제 #5
0
void PlasmoidProtocol::init()
{
    //this should never happen
    if (m_containment) {
        return;
    }

    Host* h = qobject_cast<Host*>(parent());
    QQuickItem* rootItem = h->rootItem();
    if (rootItem) {
        m_systrayApplet = rootItem->property("_plasma_applet").value<Plasma::Applet*>();
    }

    if (!m_systrayApplet) {
        qWarning() << "Don't have a parent applet, Can't initialize the Plasmoid protocol!!!";
        return;
    }

    int containmentId = 0;

    KConfigGroup cg = m_systrayApplet->config();
    cg = KConfigGroup(&cg, "Containments");
    if (cg.isValid() && cg.groupList().size()) {
        containmentId = cg.groupList().first().toInt();
    }

    m_containment = new Plasma::Containment(m_systrayApplet, QStringLiteral("null"), containmentId);
    m_containment->setImmutability(Plasma::Types::Mutable);
    m_containment->setFormFactor(Plasma::Types::Horizontal);
    m_containment->setLocation(m_systrayApplet->location());
    m_containment->setContainmentActions(QStringLiteral("RightButton;NoModifier"), QStringLiteral("org.kde.contextmenu"));
    m_containment->init();
    emit m_systrayApplet->containment()->corona()->containmentAdded(m_containment);

    connect(m_systrayApplet, &Plasma::Applet::locationChanged, this, [=]() {
        m_containment->setLocation(m_systrayApplet->location());
    });

    m_systrayApplet->setProperty("containment", QVariant::fromValue(m_containment));

    restorePlasmoids();
}
bool TabletProfileConfigAdaptor::saveConfig (KConfigGroup& config) const
{
    Q_D( const TabletProfileConfigAdaptor );
    assert(d->profile != NULL);

    // delete all groups before writing out the new device groups
    QStringList groups = config.groupList();

    foreach (const QString& group, groups) {
        KConfigGroup(&config, group).deleteGroup();
    }
예제 #7
0
void KonfUpdate::copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath)
{
    KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath);

    // Keys
    Q_FOREACH(const QString &key, cg.keyList()) {
        copyOrMoveKey(srcGroupPath, key, dstGroupPath, key);
    }

    // Subgroups
    Q_FOREACH(const QString &group, cg.groupList()) {
        QStringList groupPath = QStringList() << group;
        copyOrMoveGroup(srcGroupPath + groupPath, dstGroupPath + groupPath);
    }
}
예제 #8
0
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);
    }
}
예제 #9
0
void
TestImporterManager::creatingProviderShouldSaveGeneratedId()
{
    EXPECT_CALL( *m_mockManager, type() ).WillRepeatedly( Return( QString( "TestMockManager" ) ) );

    QVERIFY( !m_mockManager->managerConfig().exists() );

    m_mockManager->init();
    StatSyncing::ProviderPtr provider = m_mockManager->createProvider( QVariantMap() );

    KConfigGroup group = m_mockManager->managerConfig();
    QVERIFY( group.exists() );
    QVERIFY( !group.groupList().empty() );

    group = m_mockManager->providerConfig( provider );
    QVERIFY( group.exists() );
    QCOMPARE( group.readEntry( "uid", QString() ), provider->id() );
}
예제 #10
0
Settings SettingsIO::readSettings( KConfigGroup cg, KConfigGroup cgGlobal,
                                   Plasma::DataEngine *publictransportEngine )
{
    Settings settings;
    if ( !cg.hasKey("departureTimeFlags") && (cg.hasKey("showRemainingMinutes") ||
         cg.hasKey("showDepartureTime") || cg.hasKey("displayTimeBold")) )
    {
        // DEPRECATED This reads settings stored in old format (version < 0.11)
        kDebug() << "Reading settings in old format, will be converted to new format";
        settings.setShowRemainingTime( cg.readEntry("showRemainingMinutes", true) );
        cg.deleteEntry( "showRemainingMinutes" );


        settings.setDisplayDepartureTimeBold( cg.readEntry("displayTimeBold", true) );
        cg.deleteEntry( "displayTimeBold" );

        cg.writeEntry( "departureTimeFlags", static_cast<int>(settings.departureTimeFlags()) );
        cg.sync();
    } else {
        settings.setDepartureTimeFlags( static_cast< Settings::DepartureTimeFlags >(
                cg.readEntry("departureTimeFlags", static_cast<int>(Settings::DefaultDepartureTimeFlags))) );
    }

    const Settings::AdditionalDataRequestType requestType = static_cast< Settings::AdditionalDataRequestType >(
            cg.readEntry("additionalDataRequestType", static_cast<int>(Settings::DefaultAdditionalDataRequestType)));
    settings.setAdditionalDataRequestType( requestType );

    // Read stop settings TODO: Store in config groups like filters
    StopSettingsList stopSettingsList;
    int stopSettingCount = cgGlobal.readEntry( "stopSettings", 1 );
    QString test = "location";
    int i = 1;
    while ( cgGlobal.hasKey(test) ) {
        StopSettings stopSettings;
        QString suffix = i == 1 ? QString() : '_' + QString::number( i );
        stopSettings.set( LocationSetting, cgGlobal.readEntry("location" + suffix, "showAll") );
        stopSettings.set( ServiceProviderSetting,
                          cgGlobal.readEntry("serviceProvider" + suffix, "de_db") );
        stopSettings.set( CitySetting, cgGlobal.readEntry("city" + suffix, QString()) );
        stopSettings.setStops( cgGlobal.readEntry("stop" + suffix, QStringList()),
                               cgGlobal.readEntry("stopID" + suffix, QStringList()) );
        stopSettings.set( TimeOffsetOfFirstDepartureSetting,
                          cgGlobal.readEntry("timeOffsetOfFirstDeparture" + suffix, 0) );
        stopSettings.set( TimeOfFirstDepartureSetting,
                          QTime::fromString(cgGlobal.readEntry("timeOfFirstDepartureCustom" + suffix,
                                                               "12:00"), "hh:mm") );
        stopSettings.set( FirstDepartureConfigModeSetting,
                          cgGlobal.readEntry("firstDepartureConfigMode" + suffix,
                                             static_cast<int>(RelativeToCurrentTime)) );
        stopSettings.set( AlarmTimeSetting, cgGlobal.readEntry("alarmTime" + suffix, 5) );

        // Read favorite/recent journey search items for the current stop settings
        QByteArray journeySearchesData =
                cgGlobal.readEntry( "journeySearches" + suffix, QByteArray() );
        stopSettings.set( Settings::JourneySearchSetting, QVariant::fromValue(
                SettingsIO::decodeJourneySearchItems(&journeySearchesData)) );
        stopSettingsList << stopSettings;

        ++i;
        test = "location_" + QString::number( i );
        if ( i > stopSettingCount ) {
            break;
        }
    }

    settings.setCurrentStop( cg.readEntry("currentStopIndex", 0) );

    // Add initial stop settings when no settings are available
    if ( stopSettingsList.isEmpty() ) {
        kDebug() << "Stop settings list in settings is empty";
        if ( publictransportEngine ) {
            QString countryCode = KGlobal::locale()->country();
            Plasma::DataEngine::Data locationData = publictransportEngine->query( "Locations" );
            QString defaultServiceProviderId =
                    locationData[countryCode].toHash()["defaultProvider"].toString();

            StopSettings stopSettings;
            if ( defaultServiceProviderId.isEmpty() ) {
                stopSettings.set( LocationSetting, "showAll" );
            } else {
                stopSettings.set( LocationSetting, countryCode );
                stopSettings.set( ServiceProviderSetting, defaultServiceProviderId );
            }
            stopSettings.setStop( QString() );
            // TODO: Get initial stop names using StopFinder

            stopSettingsList << stopSettings;
        } else {
            stopSettingsList << StopSettings();
        }

    }
    settings.setStops( stopSettingsList );

    if ( settings.currentStopIndex() < 0 ) {
        settings.setCurrentStop( 0 ); // For compatibility with versions < 0.7
    } else if ( settings.currentStopIndex() >= settings.stops().count() ) {
        kDebug() << "Current stop index in settings invalid";
        settings.setCurrentStop( settings.stops().count() - 1 );
    }

    settings.setMaximalNumberOfDepartures( cg.readEntry("maximalNumberOfDepartures", 50) );
    settings.setLinesPerRow( cg.readEntry("linesPerRow", 2) );
    settings.setSizeFactor( Settings::sizeFactorFromSize(cg.readEntry("size", 2)) );
    settings.setDepartureArrivalListType( static_cast<DepartureArrivalListType>(
            cg.readEntry("departureArrivalListType", static_cast<int>(DepartureList))) );

    settings.setDrawShadows( cg.readEntry("drawShadows", true) );
    settings.setHideTargetColumn( cg.readEntry("hideColumnTarget", false) );
    settings.setColorize( cg.readEntry("colorize", true) );

    QString fontFamily = cg.readEntry( "fontFamily", QString() );
    settings.setUseThemeFont( fontFamily.isEmpty() );
    if ( !settings.useThemeFont() ) {
        settings.setFont( QFont(fontFamily) );
    } else {
        settings.setFont( Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont) );
    }

    // ***************** DEPRECATED BEGIN *****************************************************
    // *** Used for migration of filter settings from versions prior to version 0.10 RC1 ******
    FilterSettingsList filtersList;
    if ( cgGlobal.hasKey("filterConfigurationList") ) {
        kDebug() << "DEPRECATED Filter settings will be restructured for new version";
        QStringList filterConfigurationList =
                cgGlobal.readEntry( "filterConfigurationList", QStringList() );
        for ( int i = filterConfigurationList.count() - 1; i >= 0; --i ) {
            const QString &filterConfiguration = filterConfigurationList[ i ];
            if ( filterConfiguration.isEmpty() ) {
                filterConfigurationList.removeAt( i );
            }
        }

        kDebug() << "Config group list" << cgGlobal.groupList();
        kDebug() << "Filter config list:" << filterConfigurationList;

        // Read old filter settings
        foreach( const QString &filterConfiguration, filterConfigurationList ) {
            FilterSettings filters =
                    readFilterConfig( cgGlobal.group("filterConfig_" + filterConfiguration) );
            filters.name = filterConfiguration;
            filtersList << filters;
        }