Пример #1
0
void KompareShell::readProperties(const KConfigGroup &config)
{
	// The 'config' object points to the session managed
	// config file. This function is automatically called whenever
	// the app is being restored. Read in here whatever you wrote
	// in 'saveProperties'

	QString mode = config.readEntry( "Mode", "ComparingFiles" );
	if ( mode == "ComparingFiles" )
	{
		m_mode  = Kompare::ComparingFiles;
		m_sourceURL  = config.readPathEntry( "SourceUrl", "" );
		m_destinationURL = config.readPathEntry( "DestinationFile", "" );

		viewPart()->readProperties( const_cast<KConfig *>(config.config()) );

		viewPart()->compareFiles( m_sourceURL, m_destinationURL );
	}
	else if ( mode == "ShowingDiff" )
	{
		m_mode = Kompare::ShowingDiff;
		m_diffURL = config.readPathEntry( "DiffUrl", "" );

		viewPart()->readProperties( const_cast<KConfig *>(config.config()) );

		m_viewPart->openUrl( m_diffURL );
	}
	else
	{ // just in case something weird has happened, don't restore the diff then
	  // Bruggie: or when some idiot like me changes the possible values for mode
	  // IOW, a nice candidate for a kconf_update thingy :)
		viewPart()->readProperties( const_cast<KConfig *>(config.config()) );
	}
}
Пример #2
0
void Koushin_TownEditor::Editor::fieldClicked(Koushin_TownEditor::EditorField* field)
{
  int x = field->boundingRect().topLeft().x() / m_fieldSize;
  int y = field->boundingRect().topLeft().y() / m_fieldSize;
  QString xString = QString("%1").arg(QString::number(x), 3, QLatin1Char('0'));
  QString yString = QString("%1").arg(QString::number(y), 3, QLatin1Char('0'));
  kDebug() << "Field clicked at " << xString << "," << yString;
  if(m_type == "plainField")
    field->setBrush(QBrush(Qt::white));
  if(m_type == "fieldWithForest")
    field->setBrush(QBrush(Qt::green));
  if(m_type == "fieldWithRocks")
    field->setBrush(QBrush(Qt::black));
  if(m_type == "fieldWithWater")
    field->setBrush(QBrush(Qt::blue));
  if(m_type == "fieldNotUsable")
    field->setBrush(QBrush(Qt::yellow));
  field->update(field->boundingRect());
  if(m_config) {
    foreach(QString groupName, m_fieldTypes) {
      if(groupName == m_type) {
	KConfigGroup group = m_config->group(groupName);
	group.writeEntry("field"+xString+yString, QString::number(x) + "," + QString::number(y));
	group.config()->sync();
      } else {
	KConfigGroup group = m_config->group(groupName);
	group.deleteEntry("field"+xString+yString);
	group.config()->sync();
      }
    }
  }
}
Пример #3
0
void Active_window_condition::cfg_write( KConfigGroup& cfg_P ) const
    {
    base::cfg_write( cfg_P );
    KConfigGroup windowConfig( cfg_P.config(), cfg_P.name() + "Window" );
    window()->cfg_write( windowConfig );
    cfg_P.writeEntry( "Type", "ACTIVE_WINDOW" ); // overwrites value set in base::cfg_write()
    }
Пример #4
0
Active_window_condition::Active_window_condition( KConfigGroup& cfg_P, Condition_list_base* parent_P )
    : Condition( cfg_P, parent_P )
    {
    KConfigGroup windowConfig( cfg_P.config(), cfg_P.name() + "Window" );
    _window = new Windowdef_list( windowConfig );
    init();
    set_match();
    }
Пример #5
0
void KateViewManager::saveViewConfiguration(KConfigGroup& config)
{
  // set Active ViewSpace to 0, just in case there is none active (would be
  // strange) and config somehow has previous value set
  config.writeEntry("Active ViewSpace", 0);

  m_splitterIndex = 0;
  saveSplitterConfig(this, config.config(), config.name());
}
Пример #6
0
QString path(KConfigGroup group)
{
    QString ret;
    while (group.exists()) {
        ret.prepend( "/" + group.name());
        group = group.parent();
    }
    ret.prepend(group.config()->name());
    return ret;
}
Пример #7
0
Condition_list_base::Condition_list_base( KConfigGroup& cfg_P, Condition_list_base* parent_P )
    : Condition( parent_P )
    {
    int cnt = cfg_P.readEntry( "ConditionsCount", 0 );
    for( int i = 0;
         i < cnt;
         ++i )
        {
        KConfigGroup conditionConfig( cfg_P.config(), cfg_P.name() + QString::number( i ) );
        (void) Condition::create_cfg_read( conditionConfig, this );
        }
    }
Пример #8
0
void Condition_list_base::cfg_write( KConfigGroup& cfg_P ) const
    {
    int i = 0;
    for( ConstIterator it(begin());
         it != end();
         ++it, ++i )
        {
        KConfigGroup conditionConfig( cfg_P.config(), cfg_P.name() + QString::number( i ) );
        (*it)->cfg_write( conditionConfig );
        }
    cfg_P.writeEntry( "ConditionsCount", i );
    }
void KeyboardInputAction::cfg_write( KConfigGroup& cfg_P ) const
    {
    base::cfg_write( cfg_P );
    cfg_P.writeEntry( "Type", "KEYBOARD_INPUT" ); // overwrites value set in base::cfg_write()
    cfg_P.writeEntry( "Input", input());

    cfg_P.writeEntry( "DestinationWindow", int(_destination) );

    if( _destination == SpecificWindow && dest_window() != NULL )
        {
        KConfigGroup windowGroup( cfg_P.config(), cfg_P.name() + "DestinationWindow" );
        dest_window()->cfg_write( windowGroup );
        }
    }
Пример #10
0
    void loadEntries(const KConfigGroup &grp)
    {
        recentFiles.clear();
        recentFilesIndex.clear();

        QString value;
        QString nameValue;
        QUrl url;

        KConfigGroup cg = grp;

        if ( cg.name().isEmpty()) {
            cg = KConfigGroup(cg.config(),"RecentFiles");
        }

        // read file list
        for (int i = 1; i <= maxItems; i++) {

            value = cg.readPathEntry(QString("File%1").arg(i), QString());
            if (value.isEmpty()) continue;
            url = QUrl(value);

            // gemini only handles local files
            // yes, i know the second half here isn't good on windows... but without it we fail on linux, and second part for windows
            if (!url.isLocalFile() && !value.startsWith('/') && value.midRef(2, 1) != QLatin1String(":")) {
                qDebug() << "Not a local file:" << url;
                continue;
            }

            // Don't restore if file doesn't exist anymore
            if (!QFile::exists(url.toLocalFile()) && !QFile::exists(value)) {
                qDebug() << "Recent file apparently no longer exists:" << url.toLocalFile();
                continue;
            }

            value = QDir::toNativeSeparators( value );

            // Don't restore where the url is already known (eg. broken config)
            if (recentFiles.contains(value))
                continue;

            nameValue = cg.readPathEntry(QString("Name%1").arg(i), url.fileName());

            if (!value.isNull())  {
                recentFilesIndex << nameValue;
                recentFiles << value;
           }
        }
    }
Пример #11
0
void SpriteDef::read(KConfigGroup &config)
{
    mDirX.set( config.readEntry( QStringLiteral("DirectionX"), QStringLiteral("0") ) );
    mDirY.set( config.readEntry( QStringLiteral("DirectionY"), QStringLiteral("0") ) );
    mStartX.set( config.readEntry( QStringLiteral("StartX"), QStringLiteral("0") ) );
    mStartY.set( config.readEntry( QStringLiteral("StartY"), QStringLiteral("0") ) );
    mEndX.set( config.readEntry( QStringLiteral("EndX"), QStringLiteral("10000") ) );
    mEndY.set( config.readEntry( QStringLiteral("EndY"), QStringLiteral("10000") ) );
    mLifeSpan = config.readEntry( QStringLiteral("LifeSpan"), -1 );
    mZ = config.readEntry( QStringLiteral("Z"), 1 );
    QString animation = config.readEntry( QStringLiteral("Animation"), QString() );
    KConfigBase *grp = config.config();
    mSeq = SpriteSequenceManager::manager()->load( *grp, animation );
    qDebug() << QStringLiteral("Set Z = ") << mZ;
}
Пример #12
0
    void saveEntries( const KConfigGroup &grp)
    {
        KConfigGroup cg = grp;

        if (cg.name().isEmpty()) {
            cg = KConfigGroup(cg.config(),"RecentFiles");
        }
        cg.deleteGroup();

        // write file list
        for (int i = 1; i <= recentFilesIndex.size(); ++i) {
            // i - 1 because we started from 1
            cg.writePathEntry(QString("File%1").arg(i), recentFiles[i - 1]);
            cg.writePathEntry(QString("Name%1").arg(i), recentFilesIndex[i - 1]);
        }
    }
Пример #13
0
void KompareShell::saveProperties(KConfigGroup &config)
{
	// The 'config' object points to the session managed
	// config file.  Anything you write here will be available
	// later when this app is restored
	if ( m_mode == Kompare::ComparingFiles )
	{
		config.writeEntry( "Mode", "ComparingFiles" );
		config.writePathEntry( "SourceUrl", m_sourceURL.url() );
		config.writePathEntry( "DestinationUrl", m_destinationURL.url() );
	}
	else if ( m_mode == Kompare::ShowingDiff )
	{
		config.writeEntry( "Mode", "ShowingDiff" );
		config.writePathEntry( "DiffUrl", m_diffURL.url() );
	}

	viewPart()->saveProperties( config.config() );
}
Пример #14
0
void SpriteGroup::read(KConfigGroup &config)
{
    qDebug() << QStringLiteral(" void SpriteGroup::read(KConfigBase &config) :") << config.name();

    SpriteRange countRange( config.readEntry( QStringLiteral("Count"), QStringLiteral("1") ) );
    mCount = countRange.random();

    mRefresh.set( config.readEntry( QStringLiteral("Refresh"), QStringLiteral("1000") ) );

    QStringList anims;
    anims = config.readEntry( QStringLiteral("Animations"), anims );
    QStringList::const_iterator lst;

    for( lst = anims.constBegin(); lst != anims.constEnd(); ++lst ) {
        KConfigGroup grp( config.config(), *lst );
        SpriteDef *obj = new SpriteDef( grp );
        mAvailable.append( obj );
    }
}
Пример #15
0
void KateViewManager::restoreViewConfiguration (const KConfigGroup& config)
{
  // remove all views and viewspaces + remove their xml gui clients
  for (int i = 0; i < m_viewList.count(); ++i)
    mainWindow()->guiFactory ()->removeClient (m_viewList.at(i));

  qDeleteAll( m_viewList );
  m_viewList.clear();
  qDeleteAll( m_viewSpaceList );
  m_viewSpaceList.clear();
  m_activeStates.clear();

  // start recursion for the root splitter (Splitter 0)
  restoreSplitter( config.config(), config.name() + "-Splitter 0", this, config.name() );

  // finally, make the correct view from the last session active
  int lastViewSpace = config.readEntry("Active ViewSpace", 0);
  if( lastViewSpace > m_viewSpaceList.size() ) lastViewSpace = 0;
  if( lastViewSpace >= 0 && lastViewSpace < m_viewSpaceList.size())
  {
    setActiveSpace( m_viewSpaceList.at( lastViewSpace ) );
    setActiveView( m_viewSpaceList.at( lastViewSpace )->currentView() );
    m_viewSpaceList.at( lastViewSpace )->currentView()->setFocus();
  }

  // emergency
  if (m_viewSpaceList.empty())
  {
    // kill bad children
    while (count())
      delete widget (0);

    KateViewSpace* vs = new KateViewSpace( this, 0 );
    addWidget (vs);
    vs->setActive( true );
    m_viewSpaceList.append(vs);
  }

  updateViewSpaceActions();
  // the view has (maybe) changed - promote it to the world
  emit viewChanged();
}
Пример #16
0
bool LldbDebugger::start(KConfigGroup& config, const QStringList& extraArguments)
{
    // Get path to executable
    QUrl lldbUrl = config.readEntry(Config::LldbExecutableEntry, QUrl());
    if (!lldbUrl.isValid() || !lldbUrl.isLocalFile()) {
        debuggerBinary_ = "lldb-mi";
    } else {
        debuggerBinary_ = lldbUrl.toLocalFile();
    }

    if (!checkVersion()) {
        return false;
    }

    // Get arguments
    QStringList arguments = extraArguments;
    //arguments << "-quiet";
    arguments.append(KShell::splitArgs(config.readEntry(Config::LldbArgumentsEntry, QString())));

    // Get environment
    const EnvironmentGroupList egl(config.config());
    const auto &envs = egl.variables(config.readEntry(Config::LldbEnvironmentEntry, egl.defaultGroup()));
    QProcessEnvironment processEnv;
    if (config.readEntry(Config::LldbInheritSystemEnvEntry, true)) {
        processEnv = QProcessEnvironment::systemEnvironment();
    }
    for (auto it = envs.begin(), ite = envs.end(); it != ite; ++it) {
        processEnv.insert(it.key(), it.value());
    }

    // Start!
    process_->setProcessEnvironment(processEnv);
    process_->setProgram(debuggerBinary_, arguments);
    process_->start();

    qCDebug(DEBUGGERLLDB) << "Starting LLDB with command" << debuggerBinary_ + ' ' + arguments.join(' ');
    qCDebug(DEBUGGERLLDB) << "LLDB process pid:" << process_->pid();
    emit userCommandOutput(debuggerBinary_ + ' ' + arguments.join(' ') + '\n');

    return true;
}
Пример #17
0
void process(Mode mode, KConfigGroup &grp, QString key, QString value)
{
    switch (mode) {
    case Read:
        if (IS_A_TTY(1))
            std::cout << CHAR(key) << ": " << CHAR(grp.readEntry(key, "does not exist")) << " (" << CHAR(path(grp)) << ")" << std::endl;
        else
            std::cout << CHAR(grp.readEntry(key, ""));
        break;
    case Write: {
        if (grp.isImmutable()) {
            std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
            exit(1);
        }
        bool added = !grp.hasKey(key);
        QString oldv;
        if (!added) oldv = grp.readEntry(key);
        grp.writeEntry(key, QString(value));
        grp.sync();
        if (added)
            std::cout << "New " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl;
        else
            std::cout << CHAR(key) << ": " << CHAR(oldv) << " -> " << CHAR(grp.readEntry(key)) << std::endl;
        break;
    }
    case Delete: {
        if (grp.isImmutable()) {
            std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
            exit(1);
        }
        if (grp.hasKey(key)) {
            std::cout << "Removed " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl;
            grp.deleteEntry(key);
            grp.sync();
        } else if (grp.hasGroup(key)) {
            std::cout << "There's a group, but no key: " << CHAR(key) << "\nPlease explicitly use deletegroup" << std::endl;
            exit(1);
        } else {
            std::cout << "There's no key " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl;
            exit(1);
        }
        break;
    }
    case DeleteGroup: {
        if (grp.hasGroup(key)) {
            grp = grp.group(key);
            if (grp.isImmutable()) {
                std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
                exit(1);
            }
            QMap<QString, QString> map = grp.entryMap();
            std::cout << "Removed " << CHAR(key) << gs_separator << std::endl;
            for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
                std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl;
            }
            grp.deleteGroup();
            grp.sync();
        } else {
            std::cout << "There's no group " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl;
            exit(1);
        }
        break;
    }
    case List:
    case ListKeys: {
        if (!grp.exists()) { // could be parent group
            if (mode == ListKeys)
                exit(1);
            QStringList groups = grp.parent().exists() ? grp.parent().groupList() : grp.config()->groupList();
            if (groups.isEmpty()) {
                std::cout << "The component/group " << CHAR(path(grp)) << " does not exist" << std::endl;
                exit(1);
            }
            std::cout << "Groups in " << CHAR(path(grp)) << gs_separator << std::endl;
            foreach (const QString &s, groups)
                if (key.isEmpty() || s.contains(key, Qt::CaseInsensitive))
                    std::cout << CHAR(s) << std::endl;
            exit(0);
        }

        QMap<QString, QString> map = grp.entryMap();
        if (map.isEmpty()) {
            std::cout << "The group " << CHAR(path(grp)) << " is empty" << std::endl;
            break;
        }

        if (mode == List) {
            bool matchFound = false;
            for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
                if (key.isEmpty() || it.key().contains(key, Qt::CaseInsensitive)) {
                    if (!matchFound)
                        std::cout << std::endl << CHAR(path(grp)) << gs_separator << std::endl;
                    matchFound = true;
                    std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl;
                }
            }

            if (!matchFound)
                std::cout << "No present key matches \"" << CHAR(key) << "\" in " << CHAR(path(grp));
            std::cout << std::endl;
        } else {
            for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
                if (key.isEmpty() || it.key().contains(key, Qt::CaseInsensitive)) {
                    std::cout << CHAR(it.key()) << std::endl;
                }
            }
        }
        break;
    }
    case ListGroups: {
        QStringList groups = grp.parent().exists() ? grp.parent().groupList() : grp.config()->groupList();
        foreach (const QString &s, groups)
            if (key.isEmpty() || s.contains(key, Qt::CaseInsensitive))
                std::cout << CHAR(s) << std::endl;
        exit(0);
    }
    case Replace: {
        if (grp.isImmutable()) {
            std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
            exit(1);
        }
        QStringList match = key.split("=");
        if (match.count() != 2) {
            std::cout << "The match sequence must be of the form <key regexp>=<value regexp>" << std::endl;
            exit(1);
        }
        QRegExp keyMatch(match.at(0), Qt::CaseInsensitive);
        QRegExp valueMatch(match.at(1), Qt::CaseInsensitive);
        QStringList replace = value.split("=");
        if (replace.count() != 2) {
            std::cout << "The replace sequence must be of the form <key string>=<value string>" << std::endl;
            exit(1);
        }
        QMap<QString, QString> map = grp.entryMap();
        QStringList keys;
        for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
            if (keyMatch.exactMatch(it.key()) && valueMatch.exactMatch(it.value())) {
                keys << it.key();
            }
        }
        foreach (const QString &key, keys) {
            QString newKey = key;
            newKey.replace(keyMatch, replace.at(0));
            QString newValue = grp.readEntry(key);
            const QString oldValue = newValue;
            newValue.replace(valueMatch, replace.at(1));
            if (key != newKey)
                grp.deleteEntry(key);
            grp.writeEntry(newKey, newValue);
            std::cout << CHAR(key) << ": " << CHAR(oldValue) << " -> " << CHAR(newKey) << ": " << CHAR(grp.readEntry(newKey)) << std::endl;
            grp.sync();
        }
        break;
    }
    Invalid:
    default:
        break;
    }