Beispiel #1
0
void
dvbcut_settings::save_settings() {
  setValue("/version", 2);	// latest config version
  beginGroup("/wheel");
    setValue("/incr_normal", wheel_increments[WHEEL_INCR_NORMAL]);
    setValue("/incr_shift", wheel_increments[WHEEL_INCR_SHIFT]);
    setValue("/incr_ctrl", wheel_increments[WHEEL_INCR_CTRL]);
    setValue("/incr_alt", wheel_increments[WHEEL_INCR_ALT]);
    setValue("/threshold", wheel_threshold);
    setValue("/delta", wheel_delta);
  endGroup();	// wheel
  beginGroup("/slider");
    setValue("/jog_maximum", jog_maximum);
    setValue("/jog_threshold", jog_threshold);
    setValue("/jog_offset", jog_offset);
    setValue("/jog_interval", jog_interval);
    setValue("/lin_interval", lin_interval);
  endGroup();	// slider
  beginGroup("/lastdir");
    setValue("/name", lastdir);
    setValue("/update", lastdir_update);
  endGroup();	// lastdir
  beginGroup("/viewscalefactor");
    setValue("/current", viewscalefactor);
    setValue("/custom", viewscalefactor_custom);
  endGroup();	// viewscalefactor
  setValue("/export_format", export_format);
  beginGroup("/recentfiles");
    // first remove any OLD recentfiles entries to clean the settings file (<revision 108)!!!
    QStringList keys = childKeys();
    for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) 
      remove("/" + *it);
    // then remove ALL new recentfiles entries!!!
    // (otherwise it would be a mess with erased&inserted muliple file entries of different size)
    QStringList subkeys = childGroups();
    for ( QStringList::Iterator its = subkeys.begin(); its != subkeys.end(); ++its ) {
      beginGroup("/" + *its);
      QStringList keys = childKeys();
      endGroup();
      for ( QStringList::Iterator itk = keys.begin(); itk != keys.end(); ++itk ) 
        remove("/"  + *its + "/" + *itk);
    }    
    setValue("/max", int(recentfiles_max));
    // and NOW write the updated list from scratch!!!
    for (unsigned int i = 0; i < recentfiles.size(); ++i) {
      QString key = "/" + QString::number(i);
      beginGroup(key);
        int j=0;
        for(std::list<std::string>::iterator it=settings().recentfiles[i].first.begin();
                                             it!=settings().recentfiles[i].first.end(); it++, j++) 
          setValue("/" + QString::number(j), it->c_str());
        setValue("/idx", recentfiles[i].second.c_str());
      endGroup();	// key
    }
  endGroup();	// recentfiles
  setValue("/start_bof", start_bof);
  setValue("/stop_eof", stop_eof);
  beginGroup("/snapshots");
    setValue("/type", snapshot_type);
    setValue("/quality", snapshot_quality);
    setValue("/prefix", snapshot_prefix);
    setValue("/delimiter", snapshot_delimiter);
    setValue("/first", snapshot_first);
    setValue("/width", snapshot_width);
    setValue("/extension", snapshot_extension);
    setValue("/range", snapshot_range);
    setValue("/samples", snapshot_samples);
  endGroup();	// snapshots
  beginGroup("/pipe");
    for (unsigned int i = 0; i < pipe_command.size(); ++i) {
      QString key = "/" + QString::number(i);
      beginGroup(key);
	setValue("/command", pipe_command[i]);
	setValue("/post", pipe_post[i]);
	setValue("/label", pipe_label[i]);
	setValue("/format", pipe_format[i]);
      endGroup();	// key
    }
  endGroup();	// pipe
  beginGroup("/chapters");
    setValue("/interval", chapter_interval);
    setValue("/tolerance", chapter_tolerance);
    setValue("/threshold", chapter_threshold);
    setValue("/minimum", chapter_minimum);
  endGroup();	// auto chapters
}
Beispiel #2
0
dvbcut_settings::dvbcut_settings() : QSettings(DVBCUT_QSETTINGS_DOMAIN, DVBCUT_QSETTINGS_PRODUCT) {
  beginGroup(DVBCUT_QSETTINGS_PRODUCT);
  loaded = false;
}
Beispiel #3
0
void Manager::initDefaults()
{
    QPalette appPlt( QApplication::palette() );

    beginGroup("IDE");

    setDefault("startWithSession", "last");

    beginGroup("interpreter");
    setDefault("autoStart", true);
    endGroup();

    setDefault("postWindow/scrollback", 1000);

    beginGroup("editor");

    setDefault("spaceIndent", false);
    setDefault("indentWidth", 4);
    setDefault("stepForwardEvaluation", false);
    setDefault("lineWrap", true);
    setDefault("disableBlinkingCursor", false);
    setDefault("highlightBracketContents", true);
    setDefault("inactiveEditorFadeAlpha", 64);
    setDefault("insertMatchingTokens", false);

    setDefault("blinkDuration", 600);

    setDefault("font/family", "monospace");
    setDefault("font/antialias", true);

    beginGroup("colors");

    QTextCharFormat matchingBracketsFormat;
    matchingBracketsFormat.setForeground(Qt::red);
    matchingBracketsFormat.setBackground(QColor("#ffff7f"));
    matchingBracketsFormat.setFontWeight(QFont::Bold);
    setDefault("matchingBrackets", QVariant::fromValue(matchingBracketsFormat));

    QTextCharFormat bracketMismatchFormat;
    bracketMismatchFormat.setBackground(QColor(150,0,0));
    bracketMismatchFormat.setForeground(Qt::white);
    setDefault("mismatchedBrackets", QVariant::fromValue(bracketMismatchFormat));

    QTextCharFormat evaluatedCodeFormat;
    evaluatedCodeFormat.setBackground(QColor("#F8A200"));
    evaluatedCodeFormat.setForeground(Qt::black);
    setDefault("evaluatedCode", QVariant::fromValue(evaluatedCodeFormat));

    QTextCharFormat currentLineFormat;
    {
        QColor bkg = appPlt.color(QPalette::Base);
        int value = bkg.value();
        if (value > 40)
            bkg.setHsv( bkg.hue(), bkg.saturation(), value - 11);
        else
            bkg.setHsv( bkg.hue(), bkg.saturation(), value + 20 );
        currentLineFormat.setBackground(bkg.toRgb());
    }
    setDefault("currentLine", QVariant::fromValue(currentLineFormat));

    QTextCharFormat searchResultFormat;
    searchResultFormat.setBackground(appPlt.color(QPalette::Highlight).darker(200));
    searchResultFormat.setForeground(appPlt.color(QPalette::HighlightedText).darker(200));
    setDefault("searchResult", QVariant::fromValue(searchResultFormat));

    endGroup(); // colors

    beginGroup("highlighting");
    initHighlightingDefaults();
    endGroup(); // highlighting

    endGroup(); // editor

    endGroup(); // IDE
}
Beispiel #4
0
RazorSettings::RazorSettings(const QSettings& parentSettings, const QString& subGroup, QObject* parent):
    QSettings(parentSettings.organizationName(), parentSettings.applicationName(), parent),
    d_ptr(new RazorSettingsPrivate(this))
{
    beginGroup(subGroup);
}
void TTCutSettings::writeSettings()
{
  beginGroup( "/Settings" );

  // Navigation settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Navigation" );
  setValue( "FastSlider/",      TTCut::fastSlider );
  setValue( "StepSliderClick/", TTCut::stepSliderClick );
  setValue( "StepPgUpDown/",    TTCut::stepPgUpDown );
  setValue( "StepArrowKeys/",   TTCut::stepArrowKeys );
  setValue( "StepPlusAlt/",     TTCut::stepPlusAlt );
  setValue( "StepPlusCtrl/",    TTCut::stepPlusCtrl );
  setValue( "StepQuickJump/",   TTCut::stepQuickJump );
  setValue( "StepMouseWheel/",  TTCut::stepMouseWheel );
  endGroup();

  // Common options
  // ---------------------------------------------------------------------------
  beginGroup( "/Common" );
  setValue( "TempDirPath/" , TTCut::tempDirPath );
  setValue( "LastDirPath/" , TTCut::lastDirPath );
  endGroup();

  // Preview
  // ---------------------------------------------------------------------------
  beginGroup( "/Preview" );
  setValue( "PreviewSeconds/",  TTCut::cutPreviewSeconds );
  setValue( "SkipFrames/",      TTCut::playSkipFrames );
  endGroup();

  // Search
  // ---------------------------------------------------------------------------
  beginGroup( "/Search" );
  setValue( "Length/",          TTCut::searchLength );
  setValue( "Accuracy/",        TTCut::searchAccuracy );
  endGroup();

  // Index files
  // ---------------------------------------------------------------------------
  beginGroup( "/IndexFiles" );
  setValue( "CreateVideoIDD/",  TTCut::createVideoIDD );
  setValue( "CreateAudioIDD/",  TTCut::createAudioIDD );
  setValue( "CreatePrevIDD/",   TTCut::createPrevIDD );
  setValue( "CreateD2V/",       TTCut::createD2V );
  setValue( "ReadVideoIDD/",    TTCut::readVideoIDD );
  setValue( "ReadAudioIDD",     TTCut::readAudioIDD );
  setValue( "ReadPrevIDD/",     TTCut::readPrevIDD );
  endGroup();

  // Log file
  // --------------------------------------------------------------------------
  beginGroup( "/LogFile" );
  setValue( "CreateLogFile/",     TTCut::createLogFile );
  setValue( "LogModeConsole/",    TTCut::logModeConsole );
  setValue( "LogModeExtended/",   TTCut::logModeExtended );
  setValue( "LogVideoIndexInfo/", TTCut::logVideoIndexInfo );
  setValue( "LogAudioIndexInfo/", TTCut::logAudioIndexInfo );
  endGroup();
  
  // Encoder settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Encoder" );
  setValue( "EncoderMode/",     TTCut::encoderMode );
  endGroup();

  // Muxer settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Muxer" );
  setValue( "MuxMode/",         TTCut::muxMode );
  setValue( "Mpeg2Target/",     TTCut::mpeg2Target );
  setValue( "MuxProg/",         TTCut::muxProg );
  setValue( "MuxProgPath/",     TTCut::muxProgPath );
  setValue( "MuxProgCmd/",      TTCut::muxProgCmd );
  setValue( "MuxOutputDir/",    TTCut::muxOutputPath );
  setValue( "MuxDeleteES/",     TTCut::muxDeleteES );
  setValue( "MuxPause/",        TTCut::muxPause );
  endGroup();

  // Chapter settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Chapter" );
  setValue( "SpumuxChapter/",   TTCut::spumuxChapter );
  endGroup();

  // Cut option
  // ---------------------------------------------------------------------------
  beginGroup( "/CutOptions" );
  setValue( "DirPath/",         TTCut::cutDirPath );
  setValue( "VideoName/",       TTCut::cutVideoName );
  setValue( "WriteMaxBitrate/", TTCut::cutWriteMaxBitrate );
  setValue( "WriteSeqEnd/",     TTCut::cutWriteSeqEnd );
  setValue( "CorrectTimeCode/", TTCut::correctCutTimeCode );
  setValue( "CorrectBitrate/",  TTCut::correctCutBitRate );
  setValue( "CreateIDD/",       TTCut::createCutIDD );
  setValue( "ReadIDD/",         TTCut::readCutIDD );
  endGroup();

  // Recent files
  // --------------------------------------------------------------------------
  beginGroup( "/RecentFiles" );
  setValue( "RecentFiles/", TTCut::recentFileList );
  endGroup();
 
  endGroup(); // settings
}
void TTCutSettings::readSettings()
{
  // read application settings
  // ---------------------------------------------------------------------------
  // Navigation settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Settings" );

  beginGroup( "/Navigation" );
  TTCut::fastSlider      = value( "FastSlider/", TTCut::fastSlider ).toBool();
  TTCut::stepSliderClick = value( "StepSliderClick/", TTCut::stepSliderClick ).toInt();
  TTCut::stepPgUpDown    = value( "StepPgUpDown/",TTCut::stepPgUpDown ).toInt();
  TTCut::stepArrowKeys   = value( "StepArrowKeys/",TTCut::stepArrowKeys ).toInt();
  TTCut::stepPlusAlt     = value( "StepPlusAlt/", TTCut::stepPlusAlt ).toInt();
  TTCut::stepPlusCtrl    = value( "StepPlusCtrl/", TTCut::stepPlusCtrl ).toInt();
  TTCut::stepQuickJump   = value( "StepQuickJump/", TTCut::stepQuickJump ).toInt();
  TTCut::stepMouseWheel  = value( "StepMouseWheel/", TTCut::stepMouseWheel ).toInt();
  endGroup();

  // Common options
  // ---------------------------------------------------------------------------
  beginGroup( "/Common" );
  TTCut::tempDirPath = value( "TempDirPath/", TTCut::tempDirPath ).toString();
  TTCut::lastDirPath = value( "LastDirPath/", TTCut::lastDirPath ).toString();
  endGroup();

  // Preview
  // ---------------------------------------------------------------------------
  beginGroup( "/Preview" );
  TTCut::cutPreviewSeconds = value( "PreviewSeconds/", TTCut::cutPreviewSeconds ).toInt();
  TTCut::playSkipFrames    = value( "SkipFrames/", TTCut::playSkipFrames ).toInt();
  endGroup();

  // Search
  // ---------------------------------------------------------------------------
  beginGroup( "/Search" );
  TTCut::searchLength   = value( "Length/", TTCut::searchLength ).toInt();
  TTCut::searchAccuracy = value( "Accuracy/", TTCut::searchAccuracy ).toInt();
  endGroup();

  // Index files
  // ---------------------------------------------------------------------------
  beginGroup( "/IndexFiles" );
  TTCut::createVideoIDD = value( "CreateVideoIDD/", TTCut::createVideoIDD ).toBool();
  TTCut::createAudioIDD = value( "CreateAudioIDD/", TTCut::createAudioIDD ).toBool();
  TTCut::createPrevIDD  = value( "CreatePrevIDD/", TTCut::createPrevIDD ).toBool();
  TTCut::createD2V      = value( "CreateD2V/", TTCut::createD2V ).toBool();
  TTCut::readVideoIDD   = value( "ReadVideoIDD/", TTCut::readVideoIDD ).toBool();
  TTCut::readAudioIDD   = value( "ReadAudioIDD", TTCut::readAudioIDD ).toBool();
  TTCut::readPrevIDD    = value( "ReadPrevIDD/", TTCut::readPrevIDD ).toBool();
  endGroup();

  // Log file
  // --------------------------------------------------------------------------
  beginGroup( "/LogFile" );
  TTCut::createLogFile     = value( "CreateLogFile/",     TTCut::createLogFile ).toBool();
  TTCut::logModeConsole    = value( "LogModeConsole/",    TTCut::logModeConsole ).toBool();
  TTCut::logModeExtended   = value( "LogModeExtended/",   TTCut::logModeExtended ).toBool();
  TTCut::logVideoIndexInfo = value( "LogVideoIndexInfo/", TTCut::logVideoIndexInfo ).toBool();
  TTCut::logAudioIndexInfo = value( "LogAudioIndexInfo/", TTCut::logAudioIndexInfo ).toBool();
  endGroup();
  
  // Encoder settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Encoder" );
  TTCut::encoderMode = value( "EncoderMode/", TTCut::encoderMode ).toBool();
  endGroup();

  // Muxer settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Muxer" );
  TTCut::muxMode       = value( "MuxMode/",      TTCut::muxMode ).toInt();
  TTCut::mpeg2Target   = value( "Mpeg2Target/",  TTCut::mpeg2Target ).toInt();
  TTCut::muxProg       = value( "MuxProg/",      TTCut::muxProg ).toString();
  TTCut::muxProgPath   = value( "MuxProgPath/",  TTCut::muxProgPath ).toString();
  TTCut::muxProgCmd    = value( "MuxProgCmd/",   TTCut::muxProgCmd ).toString();
  TTCut::muxOutputPath = value( "MuxOutputDir/", TTCut::muxOutputPath ).toString();
  TTCut::muxDeleteES   = value( "MuxDeleteES/",  TTCut::muxDeleteES ).toBool();
  TTCut::muxPause      = value( "MuxPause/",     TTCut::muxPause ).toBool();
  endGroup();

  // Chapter settings
  // ---------------------------------------------------------------------------
  beginGroup( "/Chapter" );
  TTCut::spumuxChapter = value( "SpumuxChapter/", TTCut::spumuxChapter ).toBool();
  endGroup();

  // Cut option
  // ---------------------------------------------------------------------------
  beginGroup( "/CutOptions" );
  TTCut::cutDirPath         = value( "DirPath/", TTCut::cutDirPath ).toString();
  TTCut::cutVideoName       = value( "VideoName/", TTCut::cutVideoName ).toString();
  TTCut::cutWriteMaxBitrate = value( "WriteMaxBitrate/", TTCut::cutWriteMaxBitrate ).toBool();
  TTCut::cutWriteSeqEnd     = value( "WriteSeqEnd/", TTCut::cutWriteSeqEnd ).toBool();
  TTCut::correctCutTimeCode = value( "CorrectTimeCode/", TTCut::correctCutTimeCode ).toBool();
  TTCut::correctCutBitRate  = value( "CorrectBitrate/", TTCut::correctCutBitRate ).toBool();
  TTCut::createCutIDD       = value( "CreateIDD/", TTCut::createCutIDD ).toBool();
  TTCut::readCutIDD         = value( "ReadIDD/", TTCut::readCutIDD ).toBool();
  endGroup();

  // Recent files
  // --------------------------------------------------------------------------
  beginGroup( "/RecentFiles" );
  TTCut::recentFileList    = value( "RecentFiles/", TTCut::recentFileList ).toStringList();
  endGroup();
  
  endGroup(); // settings

  // check temporary path; we must ensure taht we have a temporary directory
  // the temporary directory is used for the preview clips and for
  // the temporary avi-clips
  if ( !QDir( TTCut::tempDirPath ).exists() )
    TTCut::tempDirPath = QDir::tempPath();

  // check the cut directory path
  if ( !QDir( TTCut::cutDirPath ).exists() )
    TTCut::cutDirPath = QDir::currentPath();
}
Beispiel #7
0
void Settings::Save(const QString& prefix, const QString& key, const QVariant& value)
{
	beginGroup(prefix);
	setValue(key, value);
	endGroup();
}
Beispiel #8
0
QStringList ConfigHandler::getDatabaseList() {
    beginGroup("Database");
    QStringList children = childGroups();
    endGroup();
    return children;
}
unicorn::UserSettings::UserSettings( QString username )
{
    beginGroup( "Users" );
    beginGroup( username );
}
Beispiel #10
0
void TConfig::endGroup()
{
    if (!k->lastGroup.isEmpty())
        beginGroup(k->lastGroup);
}
Beispiel #11
0
Config::Config(QObject* parent)
    : QSettings(ORGNAME, PROGNAME, parent)
{
    keywordsSorted = keywords.keywords.values();
    keywordsSorted.sort();

    languages.insert("English", "en_EN");
    languages.insert("Russian", "ru_RU");

    maxRecentFiles = 9;
    maxHistory 	   = 10;

    beginGroup("General");
    language    	   = value("language", "English").toString();
    recentFiles 	   = value("recentFiles").toStringList();
    openFiles   	   = value("openFiles").toStringList();
    lastFile  		   = value("lastFile").toString();
    mainWindowGeometry = value("mainWindowGeometry").toByteArray();
    mainWindowState    = value("mainWindowState").toByteArray();
    helpWindowGeometry = value("helpWindowGeometry").toByteArray();
    endGroup();

    beginGroup("Editor");
    fontFamily   = value("fontFamily", "Courier New").toString();
    fontSize     = value("fontSize", 12).toInt();
    tabIndents   = value("tabIndents").toBool();
    autoIndent   = value("autoIndent").toBool();
    backUnindent = value("backUnindent").toBool();
    spaceTabs    = value("spaceTabs", true).toBool();
    indentSize   = value("indentSize", 4).toInt();
    tabSize      = value("tabSize", 4).toInt();
    whitespaces  = value("whitespaces").toBool();

    QTextCharFormat fmt; // формат по умолчанию, не изменяется
    fmt.setBackground(QColor(255, 255, 255, 0)) ; // прозрачный белый

    int size = beginReadArray("ColorScheme");

    for (int i = 0; i < size; i++) {
        setArrayIndex(i);

        QString type = value("type").toString();

        colorScheme.insert(type, fmt);
        colorScheme[type].setFontItalic(value("italic").toBool());
        colorScheme[type].setFontWeight(value("weihgt").toInt());
        colorScheme[type].setForeground(value("foreground").value<QColor>());
        colorScheme[type].setBackground(value("background").value<QColor>());
    }

    endArray();

    QHashIterator<QString, QString> it(keywords.keywords);

    while (it.hasNext()) {
        it.next();

        QString keyword = it.value();

        keyword.replace("*", "\\*").replace("$", "\\$");
        patterns.insert(it.key(), QRegExp(tr("\\b%1\\b").arg(keyword)));

        if (!colorScheme.contains(it.key())) // для всех слов пустая схема при size == 0
            colorScheme.insert(it.key(), fmt);
    }

    // 1. для неключевых слов добавить шаблон
    patterns.insert("Parentheses", 	    QRegExp("[\\(\\)\\[\\]]"));
    patterns.insert("Numbers", 			QRegExp("(^|\\s)[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"));
    patterns.insert("Local Variables",  QRegExp("\\$?\\?[\\w-]+"));
    patterns.insert("Global Variables", QRegExp("\\?\\*[\\w-]+\\*"));

    // 2. настроить схему по умолчанию
    if (!size) {
        colorScheme.insert("Constructs", fmt);
        colorScheme["Constructs"].setFontWeight(QFont::Bold);
        colorScheme["Constructs"].setForeground(Qt::darkBlue);

        colorScheme.insert("Strings", fmt);
        colorScheme["Strings"].setForeground(Qt::darkRed);

        colorScheme.insert("Comments", fmt);
        colorScheme["Comments"].setFontItalic(true);
        colorScheme["Comments"].setForeground(Qt::darkGreen);

        colorScheme.insert("Parentheses", fmt);
        colorScheme["Parentheses"].setFontWeight(QFont::Bold);

        colorScheme.insert("Numbers", fmt);
        colorScheme["Numbers"].setForeground(Qt::darkYellow);

        colorScheme.insert("Local Variables", fmt);
        colorScheme["Local Variables"].setForeground(Qt::darkYellow);

        colorScheme.insert("Global Variables", fmt);
        colorScheme["Global Variables"].setForeground(Qt::darkYellow);

        colorScheme.insert("Text", fmt);
        colorScheme["Text"].setForeground(Qt::black);
        colorScheme["Text"].setBackground(Qt::white);

        colorScheme.insert("Line Numbers", fmt);
        colorScheme["Line Numbers"].setForeground(Qt::gray);
        colorScheme["Line Numbers"].setBackground(QColor(30, 60, 90));
    }

    endGroup(); // Editor

    beginGroup("Sessions");
    leaveOpen       = value("leaveOpen").toBool();
    sessions 	    = value("sessions").toMap();
    sessionSplitter	= value("sessionSplitter").toByteArray();
    endGroup();

    beginGroup("Snippets");
    snippetPath		= value("snippetPath").toString();
    snippetSplitter = value("snippetSplitter").toByteArray();
    endGroup();

    beginGroup("SearchReplace");
    findHistory     = value("findHistory").toStringList();
    replaceHistory  = value("replaceHistory").toStringList();
    matchCase       = value("matchCase").toBool();
    regExp          = value("regExp").toBool();
    allFiles        = value("allFiles").toBool();
    endGroup();
}
Beispiel #12
0
Config::~Config()
{
    beginGroup("General");
    setValue("language",           language);
    setValue("recentFiles",        recentFiles);
    setValue("openFiles",          openFiles);
    setValue("lastFile",           lastFile);
    setValue("mainWindowGeometry", mainWindowGeometry);
    setValue("mainWindowState",    mainWindowState);
    setValue("helpWindowGeometry", helpWindowGeometry);
    endGroup();

    beginGroup("Editor");
    setValue("fontFamily",   fontFamily);
    setValue("fontSize",     fontSize);
    setValue("tabIndents",   tabIndents);
    setValue("autoIndent",   autoIndent);
    setValue("backUnindent", backUnindent);
    setValue("spaceTabs",    spaceTabs);
    setValue("indentSize",   indentSize);
    setValue("tabSize",      tabSize);
    setValue("whitespaces",  whitespaces);

    QMapIterator<QString, QTextCharFormat> it(colorScheme);

    beginWriteArray("ColorScheme");

    int i = 0;

    while (it.hasNext()) {
        it.next();

        setArrayIndex(i++);
        setValue("type",       it.key());
        setValue("italic",     it.value().font().italic());
        setValue("weihgt",     it.value().font().weight());
        setValue("foreground", it.value().foreground());
        setValue("background", it.value().background());
    }

    endArray();

    endGroup(); // Editor

    beginGroup("Sessions");
    setValue("leaveOpen", 	    leaveOpen);
    setValue("sessions", 		sessions);
    setValue("sessionSplitter", sessionSplitter);
    endGroup();

    beginGroup("Snippets");
    setValue("snippetPath",     snippetPath);
    setValue("snippetSplitter", snippetSplitter);
    endGroup();

    beginGroup("SearchReplace");
    findHistory.sort();
    replaceHistory.sort();
    setValue("findHistory",     findHistory);
    setValue("replaceHistory",  replaceHistory);
    setValue("matchCase", 	    matchCase);
    setValue("regExp",    	    regExp);
    setValue("allFiles",  	    allFiles);
    endGroup();
}
bool Preferences::_loadOk()
{
    TestMode::Mode testMode;
    quint8 pingsPerHost;
    quint8 pingThreads;
    quint8 pingTimeoutSecs;
    quint8 downloadTestSecs;
    QString hostlistUrl;

    sync();

    if(!childGroups().contains("Preferences"))
    {
        return false;
    }

    beginGroup("Preferences");
    testMode = (TestMode::Mode) value("TestMode", 0).toUInt();

    if(!(testMode == TestMode::Info || testMode == TestMode::Ping || testMode == TestMode::Download || testMode == TestMode::All))
    {
        return false;
    }

    pingsPerHost = value("PingsPerHost", 0).toUInt();

    if(pingsPerHost < 1 || pingsPerHost > 10)
    {
        return false;
    }

    pingThreads = value("PingThreads", 0).toUInt();

    if(pingThreads < 1 || pingThreads > 8)
    {
        return false;
    }

    pingTimeoutSecs = value("PingTimeoutSecs", 0).toUInt();

    if(pingTimeoutSecs < 1 || pingTimeoutSecs > 4)
    {
        return false;
    }

    downloadTestSecs = value("DownloadTestSecs", 0).toUInt();

    if(downloadTestSecs < 5 || downloadTestSecs > 30)
    {
        return false;
    }

    hostlistUrl = value("HostlistUrl", QString("")).toString();

    if(hostlistUrl.isEmpty() || !QUrl(hostlistUrl).isValid())
    {
        return false;
    }

    // At this point, preferences INI file was valid. Load its preferences
    TESTMODE = testMode;
    PINGSPERHOST = pingsPerHost;
    PINGTHREADS = pingThreads;
    PINGTIMEOUTSECS = pingTimeoutSecs;
    DOWNLOADTESTSECS = downloadTestSecs;
    HOSTLISTURL = hostlistUrl;
    emit message(trUtf8("Loaded preferences from") + ' ' + QDir::toNativeSeparators(fileName()));

    return true;
}