Ejemplo n.º 1
0
void ArtworkCalligraphyOptionWidget::loadCurrentProfile()
{
    KConfig config(KGlobal::mainComponent(), RCFILENAME);
    KConfigGroup generalGroup(&config, "General");
    QString currentProfile = generalGroup.readEntry("profile", QString());
    kDebug(38000) << currentProfile;
    // find the index needed by the comboBox
    int index = profilePosition(currentProfile);

    if (currentProfile.isEmpty() || index < 0) {
        kDebug(38000) << "invalid artworkcalligraphyrc!!" << currentProfile << index;
        return;
    }

    kDebug(38000) << m_comboBox->currentIndex() << index;
    m_comboBox->setCurrentIndex(index);

    Profile *profile = m_profiles[currentProfile];

    m_changingProfile = true;
    m_usePath->setChecked(profile->usePath);
    m_usePressure->setChecked(profile->usePressure);
    m_useAngle->setChecked(profile->useAngle);
    m_widthBox->setValue(profile->width);
    m_thinningBox->setValue(profile->thinning);
    m_angleBox->setValue(profile->angle);
    m_fixationBox->setValue(profile->fixation);
    m_capsBox->setValue(profile->caps);
    m_massBox->setValue(profile->mass);
    m_dragBox->setValue(profile->drag);
    m_changingProfile = false;
}
Ejemplo n.º 2
0
/*
#readEntry

    The second parameter is the default value.
*/
void MainWindow::viewConfig()
{
    KSharedConfigPtr config = KSharedConfig::openConfig();
    // Name of the ini header is `[general]`.
    KConfigGroup generalGroup(config, "general");
    KConfigGroup lessGeneralGroup(config, "int");
    textArea->setText(
        "[general] string = " + generalGroup.readEntry("string", "abc") + "\n" +
        "[general][lessGeneral] int = " + QString::number(lessGeneralGroup.readEntry("int", 1)) + "\n" +
        "[configxt] serverName = " + serverName + "\n" +
        "[configxt] serverName = " + QString::number(port)
    );
}
Ejemplo n.º 3
0
/*
#SharedConfig

    Shares multiple KConf instances nicely amongst concurrent access.

    Better than using KConf directly.

    New alternative to this method; KConfig XT

    Configuration files are ini files kept under `~/.kde/share/config` in Linux.

#ConfigGroup

    Inside a given config file or ini section, which ini section we are looking for.

#writeEntry

    Writting to config file is immediate.
*/
void MainWindow::saveConfig()
{
    // Name of the config file is determined from the application name if not given.
    // as APPNAMErc.
    KSharedConfigPtr config = KSharedConfig::openConfig();

    KConfigGroup generalGroup(config, "general");
    generalGroup.writeEntry("string", textArea->toPlainText());
    std::cout << textArea->toPlainText().toStdString() << std::endl;

    // lessGeneral is a subgroup of general and appears as `[general][lessGeneral]`
    // in the `ini` file.
    KConfigGroup lessGeneralGroup(&generalGroup, "lessGeneral");

    // Any data type is ok:
    lessGeneralGroup.writeEntry("int", 1);
}
Ejemplo n.º 4
0
void ArtworkCalligraphyOptionWidget::loadProfile(const QString &name)
{
    if (m_changingProfile)
        return;
    kDebug(38000) << "trying profile" << name;
    // write the new profile in the config file
    KConfig config(KGlobal::mainComponent(), RCFILENAME);
    KConfigGroup generalGroup(&config, "General");
    generalGroup.writeEntry("profile", name);
    config.sync();

    // and load it
    loadCurrentProfile();

    // don't show Current if it isn't selected
    if (name != i18nc("Current", "Profile selected now")) {
        removeProfile(i18nc("Current", "Profile selected now"));
    }
}
void KarbonCalligraphyOptionWidget::loadProfile(const QString &name)
{
    if (m_changingProfile)
        return;
    qDebug() << "trying profile" << name;
    // write the new profile in the config file
    KConfig config(RCFILENAME);
    KConfigGroup generalGroup(&config, "General");
    generalGroup.writeEntry("profile", name);
    config.sync();

    // and load it
    loadCurrentProfile();

    // don't show Current if it isn't selected
    if (name != i18n("Current")) {
        removeProfile(i18n("Current"));
    }
}
Ejemplo n.º 6
0
bool IconView::setWallpaper( const QString& wallpaper )
{
    if ( wallpaper.isEmpty() || !QImage().load( wallpaper ) )
        return false;

    m_wallpaper = wallpaper;
    delete m_pixmap;
    m_pixmap = new QPixmap( m_wallpaper );

    QPalette p;
    p.setBrush( QPalette::Base, QBrush( *m_pixmap ) );
    setPalette( p );

    KConfig config;
    KConfigGroup generalGroup( &config, "General" );
    generalGroup.writeEntry( "Wallpaper", m_wallpaper );
    generalGroup.config()->sync();

    return true;
}
Ejemplo n.º 7
0
void ArtworkCalligraphyOptionWidget::addDefaultProfiles()
{
    // check if the profiles where already added
    KConfig config(KGlobal::mainComponent(), RCFILENAME);
    KConfigGroup generalGroup(&config, "General");

    if (generalGroup.readEntry("defaultProfilesAdded", false))
        return;

    KConfigGroup profile0(&config, "Profile0");
    profile0.writeEntry("name", i18n("Mouse"));
    profile0.writeEntry("usePath", false);
    profile0.writeEntry("usePressure", false);
    profile0.writeEntry("useAngle", false);
    profile0.writeEntry("width", 30.0);
    profile0.writeEntry("thinning", 0.2);
    profile0.writeEntry("angle", 30);
    profile0.writeEntry("fixation", 1.0);
    profile0.writeEntry("caps", 0.0);
    profile0.writeEntry("mass", 3.0);
    profile0.writeEntry("drag", 0.7);

    KConfigGroup profile1(&config, "Profile1");
    profile1.writeEntry("name", i18n("Graphics Pen"));
    profile1.writeEntry("width", 50.0);
    profile1.writeEntry("usePath", false);
    profile1.writeEntry("usePressure", false);
    profile1.writeEntry("useAngle", false);
    profile1.writeEntry("thinning", 0.2);
    profile1.writeEntry("angle", 30);
    profile1.writeEntry("fixation", 1.0);
    profile1.writeEntry("caps", 0.0);
    profile1.writeEntry("mass", 1.0);
    profile1.writeEntry("drag", 0.9);

    generalGroup.writeEntry("profile", i18n("Mouse"));
    generalGroup.writeEntry("defaultProfilesAdded", true);

    config.sync();
}
Ejemplo n.º 8
0
//moved from KFormDesigner::FormManager
void KexiFormManager::createActions(KActionCollection* collection)
{
    d->collection = collection;
//    KXMLGUIClient* client = (KXMLGUIClient*)d->collection->parentGUIClient();

    d->lib->createWidgetActions(d->widgetActionGroup);
//! @todo insertWidget() slot?
//2.0    d->lib->createWidgetActions(client, d->collection,
//2.0                                this, SLOT(insertWidget(const QByteArray &)));

#ifdef KFD_SIGSLOTS
    if (d->features & KFormDesigner::Form::EnableConnections) {
        // nothing
    }
    else {
        d->dragConnectionAction = new KToggleAction(
            KIcon("signalslot"), i18n("Connect Signals/Slots"), d->collection);
        d->dragConnectionAction->setObjectName("drag_connection");
//        d->widgetActionGroup->addAction(d->dragConnectionAction);
        connect(d->dragConnectionAction, SIGNAL(triggered()),
                this, SLOT(startCreatingConnection()));
        d->dragConnectionAction->setChecked(false);
    }
#endif

    d->pointerAction = new KToggleAction(
        KIcon("mouse_pointer"), i18n("Pointer"), d->collection);
    d->pointerAction->setObjectName("edit_pointer");
    d->widgetActionGroup->addAction(d->pointerAction);
    connect(d->pointerAction, SIGNAL(triggered()),
            this, SLOT(slotPointerClicked()));
    d->pointerAction->setChecked(true);

    d->snapToGridAction = new KToggleAction(
        i18n("Snap to Grid"), d->collection);
    d->snapToGridAction->setObjectName("snap_to_grid");
//    d->widgetActionGroup->addAction(d->snapToGridAction);
//    d->snapToGridAction->setChecked(true);

#if 0 // 2.0: todo
    // Create the Style selection action (with a combo box in toolbar and submenu items)
    KSelectAction *styleAction = new KSelectAction(
        i18n("Style"), d->collection);
    styleAction->setObjectName("change_style");
    connect(styleAction, SIGNAL(triggered()),
            this, SLOT(slotStyle()));
    styleAction->setEditable(false);

//js: unused? KGlobalGroup cg = KGlobal::config()->group("General");
    QString currentStyle(kapp->style()->objectName().toLower());
    const QStringList styles = QStyleFactory::keys();
    styleAction->setItems(styles);
    styleAction->setCurrentItem(0);

    QStringList::ConstIterator endIt = styles.constEnd();
    int idx = 0;
    for (QStringList::ConstIterator it = styles.constBegin(); it != endIt; ++it, ++idx) {
        if ((*it).toLower() == currentStyle) {
            styleAction->setCurrentItem(idx);
            break;
        }
    }
    styleAction->setToolTip(i18n("Set the current view style."));
    styleAction->setMenuAccelsEnabled(true);
#endif

    d->lib->addCustomWidgetActions(d->collection);

#ifdef KEXI_DEBUG_GUI
    KConfigGroup generalGroup(KGlobal::config()->group("General"));
    if (generalGroup.readEntry("ShowInternalDebugger", false)) {
        KAction *a = new KAction(KIcon("run-build-file"), i18n("Show Form UI Code"), this);
        d->collection->addAction("show_form_ui", a);
        a->setShortcut(Qt::CTRL + Qt::Key_U);
        connect(a, SIGNAL(triggered()), this, SLOT(showFormUICode()));
    }
#endif

//! @todo move elsewhere
    {
        // (from obsolete kexiformpartinstui.rc)
        QStringList formActions;
        formActions
            << "edit_pointer"
            << QString() //sep
#ifndef KEXI_NO_AUTOFIELD_WIDGET
            << ":library_widget_KexiDBAutoField"
#endif
            << ":library_widget_KexiDBLabel"
            << ":library_widget_KexiDBImageBox"
            << ":library_widget_KexiDBLineEdit"
            << ":library_widget_KexiDBTextEdit"
            << ":library_widget_KPushButton"
            << ":library_widget_KexiDBComboBox"
            << ":library_widget_KexiDBCheckBox"
#ifndef KEXI_NO_FORM_LAYOUTS
            << ":library_widget_Spacer"
#endif
            << ":library_widget_Line"
            << ":library_widget_KexiFrame"
            << ":library_widget_QGroupBox"
            << ":library_widget_KFDTabWidget"
#ifndef KEXI_NO_FORM_SPRING_ELEMENT
            << ":library_widget_Spring"
#endif
            << QString() //sep
            ;
        KexiMainWindowIface *win = KexiMainWindowIface::global();
        foreach( const QString& actionName_, formActions ) {
            QAction *a;
            const QString actionName(actionName_.startsWith(':') ? actionName_.mid(1) : actionName_);
            if (actionName.isEmpty()) {
                a = new QAction(this);
                a->setSeparator(true);
            }
            else {
                a = d->widgetActionGroup->action(actionName);
            }
            if (actionName_.startsWith(':')) {  // icon only
                KexiSmallToolButton *btn = new KexiSmallToolButton(a, win->toolBar("form"));
                btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
                win->appendWidgetToToolbar("form", btn);
            }
            else {
                win->addToolBarAction("form", a);
            }
        }

        QSet<QString> iconOnlyActions;
        iconOnlyActions << "widget_assign_action" << "show_form_ui";
        const QList<QAction*> actions( d->collection->actions() );
        foreach( QAction *a, actions ) {
            if (iconOnlyActions.contains(a->objectName())) { // icon only
                KexiSmallToolButton *btn = new KexiSmallToolButton(a, win->toolBar("form"));
                btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
                win->appendWidgetToToolbar("form", btn);
            }
            else {
                win->addToolBarAction("form", a);
            }
        }
    }
Ejemplo n.º 9
0
void IconView::init()
{
    KConfig config;
    KConfigGroup generalGroup( &config, "General" );
    m_wallpaper = generalGroup.readEntry( "Wallpaper", DEFAULT_WALLPAPER );

    delete m_pixmap;
    m_pixmap = new QPixmap( m_wallpaper );
    QPalette p;
    p.setBrush( QPalette::Base, QBrush( *m_pixmap ) );
    setPalette( p );

    m_model = new KDirModel( this );
    KDirLister* lister = new KDirLister( this );
    lister->openUrl( KUrl( QDir::homePath() ) );
    m_model->setDirLister( lister );

    m_delegate = new KFileItemDelegate( this );
    m_delegate->setMaximumSize( QSize( 64, 64 ) );
    m_delegate->setShadowOffset( QPointF( 1, 1 ) );
    m_delegate->setShadowColor( QColor( 0xff, 0xff, 0xff ) );
    m_delegate->setShadowBlur( 1 );
    m_delegate->setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );

    m_proxyModel = new KDirSortFilterProxyModel( this );
    m_proxyModel->setSourceModel( m_model );

    setModel( m_proxyModel );
    setItemDelegate( m_delegate );

    m_selectionModel = new QItemSelectionModel( m_proxyModel );
    setSelectionModel( m_selectionModel );

    /// create actions
    KAction* cut = KStandardAction::cut( this, SLOT(cut()), this );
    KAction* copy = KStandardAction::copy( this, SLOT(copy()), this );

    KIO::FileUndoManager* manager = KIO::FileUndoManager::self();
    KAction* undo = KStandardAction::undo( manager, SLOT(undo()), this );
    connect( manager, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool)) );
    connect( manager, SIGNAL(undoTextChanged(const QString&)), SLOT(undoTextChanged(const QString&)) );
    undo->setEnabled( manager->undoAvailable() );

    KAction* paste = KStandardAction::paste( this, SLOT(paste()), this );
    KAction* pasteTo = KStandardAction::paste( this, SLOT(pasteTo()), this );
    pasteTo->setEnabled( false ); // Only enabled during popupMenu()

    QString actionText = KIO::pasteActionText();
    if ( !actionText.isEmpty() )
        paste->setText( actionText );
    else
        paste->setEnabled( false );

    KAction* refresh = new KAction(KIcon("user-desktop"), i18n("&Refresh Desktop"), this);
    connect( refresh, SIGNAL(triggered()), this, SLOT(refresh()) );

    KAction* wallpaper = new KAction(KIcon("tools-wizard"), i18n("&Change Wallpaper..."), this);
    connect( wallpaper, SIGNAL(triggered()), this, SLOT(changeWallpaper()) );

    KAction* rename = new KAction(KIcon("edit-rename"), i18n("&Rename"), this);
    rename->setShortcut( Qt::Key_F2 );
    connect( rename, SIGNAL(triggered()), SLOT(rename()) );

    KAction* trash = new KAction(KIcon("user-trash"), i18n("&Move to Trash"), this);
    trash->setShortcut( Qt::Key_Delete );
    connect( trash, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)),
             this, SLOT(moveToTrash(Qt::MouseButtons, Qt::KeyboardModifiers)) );

    KAction* del = new KAction(KIcon("edit-delete"), i18n("&Delete"), this);
    del->setShortcut( Qt::SHIFT + Qt::Key_Delete );
    connect( del, SIGNAL(triggered()), this, SLOT(deleteSelectedItems()) );

    KAction* emptyTrash = new KAction(KIcon("trash-empty"), i18n("&Empty Trash Bin"), this);
    KConfig trashConfig( "trashrc", KConfig::SimpleConfig );
    emptyTrash->setEnabled( !trashConfig.group( "Status" ).readEntry( "Empty", true ) );
    connect( emptyTrash, SIGNAL(triggered()), this, SLOT(emptyTrashBin()) );

    // Create the new menu
    m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", this);
    connect( m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew()) );

    m_actionCollection.addAction( "undo", undo );
    m_actionCollection.addAction( "cut", cut );
    m_actionCollection.addAction( "copy", copy );
    m_actionCollection.addAction( "paste", paste );
    m_actionCollection.addAction( "pasteto", pasteTo );
    m_actionCollection.addAction( "refresh", refresh );
    m_actionCollection.addAction( "wallpaper", wallpaper );
    m_actionCollection.addAction( "rename", rename );
    m_actionCollection.addAction( "trash", trash );
    m_actionCollection.addAction( "del", del );
    m_actionCollection.addAction( "empty_trash", emptyTrash );
}
Ejemplo n.º 10
0
void ArtworkCalligraphyOptionWidget::saveProfile(const QString &name)
{
    kDebug(38000) << name;
    Profile *profile = new Profile;
    profile->name = name;
    profile->usePath = m_usePath->isChecked();
    profile->usePressure = m_usePressure->isChecked();
    profile->useAngle = m_useAngle->isChecked();
    profile->width = m_widthBox->value();
    profile->thinning = m_thinningBox->value();
    profile->angle = m_angleBox->value();
    profile->fixation = m_fixationBox->value();
    profile->caps = m_capsBox->value();
    profile->mass = m_massBox->value();
    profile->drag = m_dragBox->value();

    if (m_profiles.contains(name)) {
        // there is already a profile with the same name, overwrite
        profile->index = m_profiles[name]->index;
        m_profiles.insert(name, profile);
    } else {
        // it is a new profile
        profile->index = m_profiles.count();
        m_profiles.insert(name, profile);
        // add the profile to the combobox
        kDebug(38000) << "BEFORE:";
        QString dbg;
        for (int i = 0; i < m_comboBox->count(); ++i)
            dbg += m_comboBox->itemText(i) + ' ';
        kDebug(38000) << dbg;
        int pos = profilePosition(name);
        m_changingProfile = true;
        m_comboBox->insertItem(pos, name);
        m_changingProfile = false;
        kDebug(38000) << "AFTER:";
        for (int i = 0; i < m_comboBox->count(); ++i)
            dbg += m_comboBox->itemText(i) + ' ';
        kDebug(38000) << dbg;
        kDebug(38000) << "new at" << pos << m_comboBox->itemText(pos) << name;
    }

    KConfig config(KGlobal::mainComponent(), RCFILENAME);
    QString str = "Profile" + QString::number(profile->index);
    KConfigGroup profileGroup(&config, str);

    profileGroup.writeEntry("name", name);
    profileGroup.writeEntry("usePath", profile->usePath);
    profileGroup.writeEntry("usePressure", profile->usePressure);
    profileGroup.writeEntry("useAngle", profile->useAngle);
    profileGroup.writeEntry("width", profile->width);
    profileGroup.writeEntry("thinning", profile->thinning);
    profileGroup.writeEntry("angle", profile->angle);
    profileGroup.writeEntry("fixation", profile->fixation);
    profileGroup.writeEntry("caps", profile->caps);
    profileGroup.writeEntry("mass", profile->mass);
    profileGroup.writeEntry("drag", profile->drag);

    KConfigGroup generalGroup(&config, "General");
    generalGroup.writeEntry("profile", name);

    config.sync();
    kDebug(38000) << name;

    int pos = profilePosition(name);
    kDebug(38000) << "adding in" << pos << m_comboBox->itemText(pos);
    m_comboBox->setCurrentIndex(profilePosition(name));
    kDebug(38000) << m_comboBox->currentText();
}
void MediaListSettings::writeConfigEntryForLRI(const QString &lri)
{
    QStringList configEntry = configEntryForLRI(lri);
    if (!configEntry.isEmpty() && configEntry.at(0).contains("Audio")) {
        KConfig config;
        KConfigGroup generalGroup( &config, "General" );
        int limit = m_parent->audioListsStack()->ui->semALimit->value();
        generalGroup.writeEntry(configEntry.at(0), limit);
        if (m_parent->audioListsStack()->ui->semASelectMore->isChecked() && configEntry.count() > 1) {
            if (configEntry.at(1) == "RecentAudioPlayed") {
                QStringList entry;
                if (m_parent->audioListsStack()->ui->semATimeComp->currentIndex() == 0) {
                    entry.append("<");
                } else {
                    entry.append(">");
                }
                entry.append(m_parent->audioListsStack()->ui->semATime->dateTime().toString("yyyyMMddHHmmss"));
                generalGroup.writeEntry(configEntry.at(1), entry);
            } else if (configEntry.at(1) == "HighestAudioRated") {
                QStringList entry;
                if (m_parent->audioListsStack()->ui->semARatingComp->currentIndex() == 0) {
                    entry.append(">=");
                } else if (m_parent->audioListsStack()->ui->semARatingComp->currentIndex() == 1) {
                    entry.append("=");
                } else {
                    entry.append("<=");
                }
                entry.append(QString("%1").arg(10 - m_parent->audioListsStack()->ui->semARating->currentIndex()));
                generalGroup.writeEntry(configEntry.at(1), entry);
            } else if (configEntry.at(1) == "FrequentAudioPlayed") {
                QStringList entry;
                if (m_parent->audioListsStack()->ui->semAFreqComp->currentIndex() == 0) {
                    entry.append(">=");
                } else if (m_parent->audioListsStack()->ui->semAFreqComp->currentIndex() == 1) {
                    entry.append("=");
                } else {
                    entry.append("<=");
                }
                entry.append(QString("%1").arg(m_parent->audioListsStack()->ui->semAFreq->value()));
                generalGroup.writeEntry(configEntry.at(1), entry);
            }
        } else if (configEntry.count() > 1) {
            generalGroup.deleteEntry(configEntry.at(1));
        }
        config.sync();
    } else if (!configEntry.isEmpty() && configEntry.at(0).contains("Video")) {
        KConfig config;
        KConfigGroup generalGroup( &config, "General" );
        int limit = m_parent->videoListsStack()->ui->semVLimit->value();
        generalGroup.writeEntry(configEntry.at(0), limit);
        if (m_parent->videoListsStack()->ui->semVSelectMore->isChecked() && configEntry.count() > 1) {
            if (configEntry.at(1) == "RecentVideoPlayed") {
                QStringList entry;
                if (m_parent->videoListsStack()->ui->semVTimeComp->currentIndex() == 0) {
                    entry.append("<");
                } else {
                    entry.append(">");
                }
                entry.append(m_parent->videoListsStack()->ui->semVTime->dateTime().toString("yyyyMMddHHmmss"));
                generalGroup.writeEntry(configEntry.at(1), entry);
            } else if (configEntry.at(1) == "HighestVideoRated") {
                QStringList entry;
                if (m_parent->videoListsStack()->ui->semVRatingComp->currentIndex() == 0) {
                    entry.append(">=");
                } else if (m_parent->videoListsStack()->ui->semVRatingComp->currentIndex() == 1) {
                    entry.append("=");
                } else {
                    entry.append("<=");
                }
                entry.append(QString("%1").arg(10 - m_parent->videoListsStack()->ui->semVRating->currentIndex()));
                generalGroup.writeEntry(configEntry.at(1), entry);
            } else if (configEntry.at(1) == "FrequentVideoPlayed") {
                QStringList entry;
                if (m_parent->videoListsStack()->ui->semVFreqComp->currentIndex() == 0) {
                    entry.append(">=");
                } else if (m_parent->videoListsStack()->ui->semVFreqComp->currentIndex() == 1) {
                    entry.append("=");
                } else {
                    entry.append("<=");
                }
                entry.append(QString("%1").arg(m_parent->videoListsStack()->ui->semVFreq->value()));
                generalGroup.writeEntry(configEntry.at(1), entry);
            }
        } else if (configEntry.count() > 1) {
            generalGroup.deleteEntry(configEntry.at(1));
        }
        config.sync();
    }
}
void MediaListSettings::readConfigEntryForLRI(const QString &lri)
{
    QStringList configEntry = configEntryForLRI(lri);
    if (!configEntry.isEmpty() && configEntry.at(0).contains("Audio")) {
        KConfig config;
        KConfigGroup generalGroup( &config, "General" );
        int limit = generalGroup.readEntry(configEntry.at(0), 20);
        m_parent->audioListsStack()->ui->semALimit->setValue(limit);
        m_parent->audioListsStack()->ui->semASelectMore->setChecked(false);
        if (configEntry.count() > 1) {
            if (generalGroup.hasKey(configEntry.at(1))) {
                QStringList entry = generalGroup.readEntry(configEntry.at(1), QStringList());
                if (!entry.isEmpty() && configEntry.at(1) == "RecentAudioPlayed") {
                    if (entry.at(0) == "<") {
                        m_parent->audioListsStack()->ui->semATimeComp->setCurrentIndex(0);
                    } else {
                        m_parent->audioListsStack()->ui->semATimeComp->setCurrentIndex(1);
                    }
                    QDateTime recentDateTime = QDateTime::fromString(entry.at(1), "yyyyMMddHHmmss");
                    m_parent->audioListsStack()->ui->semATime->setDateTime(recentDateTime);
                    m_parent->audioListsStack()->ui->semASelectMore->setChecked(true);
                } else if (!entry.isEmpty() && configEntry.at(1) == "HighestAudioRated") {
                    if (entry.at(0) == ">=") {
                        m_parent->audioListsStack()->ui->semARatingComp->setCurrentIndex(0);
                    } else if (entry.at(0) == "=") {
                        m_parent->audioListsStack()->ui->semARatingComp->setCurrentIndex(1);
                    } else {
                        m_parent->audioListsStack()->ui->semARatingComp->setCurrentIndex(2);
                    }
                    int ratingIndex = 10 - (entry.at(1).toInt());
                    if (ratingIndex < 0 || ratingIndex >= m_parent->audioListsStack()->ui->semARating->count()) {
                        ratingIndex = 0;
                    }
                    m_parent->audioListsStack()->ui->semARating->setCurrentIndex(ratingIndex);
                    m_parent->audioListsStack()->ui->semASelectMore->setChecked(true);
                } else if (!entry.isEmpty() && configEntry.at(1) == "FrequentAudioPlayed") {
                    if (entry.at(0) == ">=") {
                        m_parent->audioListsStack()->ui->semAFreqComp->setCurrentIndex(0);
                    } else if (entry.at(0) == "=") {
                        m_parent->audioListsStack()->ui->semAFreqComp->setCurrentIndex(1);
                    } else {
                        m_parent->audioListsStack()->ui->semAFreqComp->setCurrentIndex(2);
                    }
                    int frequentlyPlayedCount = qMax(0, entry.at(1).toInt());
                    m_parent->audioListsStack()->ui->semAFreq->setValue(frequentlyPlayedCount);
                    m_parent->audioListsStack()->ui->semASelectMore->setChecked(true);
                }
            }
        }
    } else if (!configEntry.isEmpty() && configEntry.at(0).contains("Video")) {
        KConfig config;
        KConfigGroup generalGroup( &config, "General" );
        int limit = generalGroup.readEntry(configEntry.at(0), 20);
        m_parent->videoListsStack()->ui->semVLimit->setValue(limit);
        m_parent->videoListsStack()->ui->semVSelectMore->setChecked(false);
        if (configEntry.count() > 1) {
            if (generalGroup.hasKey(configEntry.at(1))) {
                QStringList entry = generalGroup.readEntry(configEntry.at(1), QStringList());
                if (!entry.isEmpty() && configEntry.at(1) == "RecentVideoPlayed") {
                    if (entry.at(0) == "<") {
                        m_parent->videoListsStack()->ui->semVTimeComp->setCurrentIndex(0);
                    } else {
                        m_parent->videoListsStack()->ui->semVTimeComp->setCurrentIndex(1);
                    }
                    QDateTime recentDateTime = QDateTime::fromString(entry.at(1), "yyyyMMddHHmmss");
                    m_parent->videoListsStack()->ui->semVTime->setDateTime(recentDateTime);
                    m_parent->videoListsStack()->ui->semVSelectMore->setChecked(true);
                } else if (!entry.isEmpty() && configEntry.at(1) == "HighestVideoRated") {
                    if (entry.at(0) == ">=") {
                        m_parent->videoListsStack()->ui->semVRatingComp->setCurrentIndex(0);
                    } else if (entry.at(0) == "=") {
                        m_parent->videoListsStack()->ui->semVRatingComp->setCurrentIndex(1);
                    } else {
                        m_parent->videoListsStack()->ui->semVRatingComp->setCurrentIndex(2);
                    }
                    int ratingIndex = 10 - (entry.at(1).toInt());
                    if (ratingIndex < 0 || ratingIndex >= m_parent->videoListsStack()->ui->semVRating->count()) {
                        ratingIndex = 0;
                    }
                    m_parent->videoListsStack()->ui->semVRating->setCurrentIndex(ratingIndex);
                    m_parent->videoListsStack()->ui->semVSelectMore->setChecked(true);
                } else if (!entry.isEmpty() && configEntry.at(1) == "FrequentVideoPlayed") {
                    if (entry.at(0) == ">=") {
                        m_parent->videoListsStack()->ui->semVFreqComp->setCurrentIndex(0);
                    } else if (entry.at(0) == "=") {
                        m_parent->videoListsStack()->ui->semVFreqComp->setCurrentIndex(1);
                    } else {
                        m_parent->videoListsStack()->ui->semVFreqComp->setCurrentIndex(2);
                    }
                    int frequentlyPlayedCount = qMax(0, entry.at(1).toInt());
                    m_parent->videoListsStack()->ui->semVFreq->setValue(frequentlyPlayedCount);
                    m_parent->videoListsStack()->ui->semVSelectMore->setChecked(true);
                }
            }
        }
    }
}
void GlobalConfig::setHideAdvancedDevices(bool hide)
{
    K_D(GlobalConfig);
    QSettingsGroup generalGroup(&d->config, QLatin1String("General"));
    generalGroup.setValue(QLatin1String("HideAdvancedDevices"), hide);
}
void KonqSidebarTree::scanDir( KonqSidebarTreeItem *parent, const QString &path, bool isRoot )
{
    QDir dir( path );

    if ( !dir.isReadable() )
        return;

    kDebug(1201) << "scanDir" << path;

    QStringList entries = dir.entryList( QDir::Files );
    QStringList dirEntries = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);

    if ( isRoot )
    {
        bool copyConfig = (entries.isEmpty() && dirEntries.isEmpty());
        if (!copyConfig)
        {
            // Check version number
            // Version 1 was the dirtree of KDE 2.0.x (no versioning at that time, so default)
            // Version 2 includes the history
            // Version 3 includes the bookmarks
            // Version 4 includes lan.desktop and floppy.desktop, Alex
            // Version 5 includes the audiocd browser
            // Version 6 includes the printmanager and lan browser
            const int currentVersion = 6;
            QString key = QString::fromLatin1("X-KDE-DirTreeVersionNumber");
            KConfig versionCfg( path + "/.directory", KConfig::SimpleConfig);
            KConfigGroup generalGroup( &versionCfg, "General" );
            int versionNumber = generalGroup.readEntry( key, 1 );
            kDebug(1201) << "found version " << versionNumber;
            if ( versionNumber < currentVersion ) {
                generalGroup.writeEntry( key, currentVersion );
                versionCfg.sync();
                copyConfig = true;
            }
        }
        if (copyConfig) {
            // We will copy over the configuration for the dirtree, from the global directory
            const QStringList dirtree_dirs = KGlobal::dirs()->findDirs("data","konqsidebartng/virtual_folders/"+m_dirtreeDir.relDir+'/');


//            QString dirtree_dir = KGlobal::dirs()->findDirs("data","konqsidebartng/virtual_folders/"+m_dirtreeDir.relDir+"/").last();  // most global
//            kDebug(1201) << "dirtree_dir=" << dirtree_dir;

            /*
            // debug code

            const QStringList blah = m_sidebarModule->getInterfaces->componentData()->dirs()->dirs()->findDirs( "data", "konqueror/dirtree" );
            QStringList::ConstIterator eIt = blah.constBegin();
            QStringList::ConstIterator eEnd = blah.constEnd();
            for (; eIt != eEnd; ++eIt )
            kDebug(1201) << "findDirs got me " << *eIt;
            // end debug code
            */

            for (QStringList::const_iterator ddit=dirtree_dirs.constBegin(); ddit!=dirtree_dirs.constEnd(); ++ddit) {
                QString dirtree_dir=*ddit;
                if (dirtree_dir==path) continue;
                //    if ( !dirtree_dir.isEmpty() && dirtree_dir != path )
                {
                    QDir globalDir( dirtree_dir );
                    Q_ASSERT( globalDir.isReadable() );
                    // Only copy the entries that don't exist yet in the local dir
                    const QStringList globalDirEntries = globalDir.entryList();
                    QStringList::ConstIterator eIt = globalDirEntries.constBegin();
                    QStringList::ConstIterator eEnd = globalDirEntries.constEnd();
                    for (; eIt != eEnd; ++eIt )
                    {
                        //kDebug(1201) << "dirtree_dir contains " << *eIt;
                        if ( *eIt != "." && *eIt != ".."
                                && !entries.contains( *eIt ) && !dirEntries.contains( *eIt ) )
                        {   // we don't have that one yet -> copy it.
                            QString cp("cp -R -- ");
                            cp += KShell::quoteArg(dirtree_dir + *eIt);
                            cp += ' ';
                            cp += KShell::quoteArg(path);
                            kDebug(1201) << "executing " << cp;
                            ::system( QFile::encodeName(cp) );
                        }
                    }
                }
            }
            // hack to make QDir refresh the lists
            dir.setPath(path);
            entries = dir.entryList( QDir::Files );
            dirEntries = dir.entryList( QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot );
        }
    }


    // TODO: currently the filename order is used. Implement SortOrder? #69667

    QStringList::ConstIterator eIt = entries.constBegin();
    QStringList::ConstIterator eEnd = entries.constEnd();
    for (; eIt != eEnd; ++eIt ) {
        const QString filePath = path + *eIt;
        if (KDesktopFile::isDesktopFile(filePath)) {
            loadTopLevelItem(parent, filePath);
        }
    }

    eIt = dirEntries.constBegin();
    eEnd = dirEntries.constEnd();

    for (; eIt != eEnd; eIt++ )
    {
        const QString newPath = QString( path ).append( *eIt ).append( QLatin1Char( '/' ) );
        loadTopLevelGroup( parent, newPath );
    }
}
void runRdb( uint flags )
{
  // Obtain the application palette that is about to be set.
  bool exportColors      = flags & KRdbExportColors;
  bool exportQtColors    = flags & KRdbExportQtColors;
  bool exportQtSettings  = flags & KRdbExportQtSettings;
  bool exportXftSettings = flags & KRdbExportXftSettings;
  bool exportGtkTheme    = flags & KRdbExportGtkTheme;

  KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig( QStringLiteral("kdeglobals") );
  KConfigGroup kglobals(kglobalcfg, "KDE");
  QPalette newPal = KColorScheme::createApplicationPalette(kglobalcfg);

  QTemporaryFile tmpFile;
  if (!tmpFile.open())
  {
    qDebug() << "Couldn't open temp file";
    exit(0);
  }


  KConfigGroup generalCfgGroup(kglobalcfg, "General");

  QString gtkTheme;
  if (kglobals.hasKey("widgetStyle"))
    gtkTheme = kglobals.readEntry("widgetStyle");
  else
    gtkTheme = QStringLiteral("oxygen");

  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 );
  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 );

  // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps)
  if (exportColors)
  {
    KConfigGroup g(KSharedConfig::openConfig(), "WM");
    QString preproc;
    QColor backCol = newPal.color( QPalette::Active, QPalette::Background );
    addColorDef(preproc, "FOREGROUND"         , newPal.color( QPalette::Active, QPalette::Foreground ) );
    addColorDef(preproc, "BACKGROUND"         , backCol);
    addColorDef(preproc, "HIGHLIGHT"          , backCol.light(100+(2*KColorScheme::contrast()+4)*16/1));
    addColorDef(preproc, "LOWLIGHT"           , backCol.dark(100+(2*KColorScheme::contrast()+4)*10));
    addColorDef(preproc, "SELECT_BACKGROUND"  , newPal.color( QPalette::Active, QPalette::Highlight));
    addColorDef(preproc, "SELECT_FOREGROUND"  , newPal.color( QPalette::Active, QPalette::HighlightedText));
    addColorDef(preproc, "WINDOW_BACKGROUND"  , newPal.color( QPalette::Active, QPalette::Base ) );
    addColorDef(preproc, "WINDOW_FOREGROUND"  , newPal.color( QPalette::Active, QPalette::Text ) );
    addColorDef(preproc, "INACTIVE_BACKGROUND", g.readEntry("inactiveBackground", QColor(224, 223, 222)));
    addColorDef(preproc, "INACTIVE_FOREGROUND", g.readEntry("inactiveBackground", QColor(224, 223, 222)));
    addColorDef(preproc, "ACTIVE_BACKGROUND"  , g.readEntry("activeBackground", QColor(48, 174, 232)));
    addColorDef(preproc, "ACTIVE_FOREGROUND"  , g.readEntry("activeBackground", QColor(48, 174, 232)));
    //---------------------------------------------------------------

    tmpFile.write( preproc.toLatin1(), preproc.length() );

    QStringList list;

    const QStringList adPaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
        QStringLiteral("kdisplay/app-defaults/"), QStandardPaths::LocateDirectory);
    for (QStringList::ConstIterator it = adPaths.constBegin(); it != adPaths.constEnd(); ++it) {
      QDir dSys( *it );

      if ( dSys.exists() ) {
        dSys.setFilter( QDir::Files );
        dSys.setSorting( QDir::Name );
        dSys.setNameFilters(QStringList(QStringLiteral("*.ad")));
        list += dSys.entryList();
      }
    }

    for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
      copyFile(tmpFile, QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kdisplay/app-defaults/"+(*it)), true);
  }

  // Merge ~/.Xresources or fallback to ~/.Xdefaults
  QString homeDir = QDir::homePath();
  QString xResources = homeDir + "/.Xresources";

  // very primitive support for ~/.Xresources by appending it
  if ( QFile::exists( xResources ) )
    copyFile(tmpFile, xResources, true);
  else
    copyFile(tmpFile, homeDir + "/.Xdefaults", true);

  // Export the Xcursor theme & size settings
  KConfigGroup mousecfg(KSharedConfig::openConfig( QStringLiteral("kcminputrc") ), "Mouse" );
  QString theme = mousecfg.readEntry("cursorTheme", QString());
  QString size  = mousecfg.readEntry("cursorSize", QString());
  QString contents;

  if (!theme.isNull())
    contents = "Xcursor.theme: " + theme + '\n';

  if (!size.isNull())
    contents += "Xcursor.size: " + size + '\n';

  if (exportXftSettings)
  {
    if (generalCfgGroup.hasKey("XftAntialias"))
    {
      contents += QLatin1String("Xft.antialias: ");
      if(generalCfgGroup.readEntry("XftAntialias", true))
        contents += QLatin1String("1\n");
      else
        contents += QLatin1String("0\n");
    }

    if (generalCfgGroup.hasKey("XftHintStyle"))
    {
      QString hintStyle = generalCfgGroup.readEntry("XftHintStyle", "hintmedium");
      contents += QLatin1String("Xft.hinting: ");
      if(hintStyle.isEmpty())
        contents += QLatin1String("-1\n");
      else
      {
        if(hintStyle!=QLatin1String("hintnone"))
          contents += QLatin1String("1\n");
        else
          contents += QLatin1String("0\n");
        contents += "Xft.hintstyle: " + hintStyle + '\n';
      }
    }

    if (generalCfgGroup.hasKey("XftSubPixel"))
    {
      QString subPixel = generalCfgGroup.readEntry("XftSubPixel");
      if(!subPixel.isEmpty())
        contents += "Xft.rgba: " + subPixel + '\n';
    }

    KConfig _cfgfonts( QStringLiteral("kcmfonts") );
    KConfigGroup cfgfonts(&_cfgfonts, "General");

    if( cfgfonts.readEntry( "forceFontDPI", 0 ) != 0 )
      contents += "Xft.dpi: " + cfgfonts.readEntry( "forceFontDPI" ) + '\n';
    else
    {
      KProcess proc;
      proc << QStringLiteral("xrdb") << QStringLiteral("-quiet") << QStringLiteral("-remove") << QStringLiteral("-nocpp");
      proc.start();
      if (proc.waitForStarted())
      {
        proc.write( QByteArray( "Xft.dpi\n" ) );
        proc.closeWriteChannel();
        proc.waitForFinished();
      }
    }
  }

  if (contents.length() > 0)
    tmpFile.write( contents.toLatin1(), contents.length() );

  tmpFile.flush();

  KProcess proc;
#ifndef NDEBUG
  proc << QStringLiteral("xrdb") << QStringLiteral("-merge") << tmpFile.fileName();
#else
  proc << "xrdb" << "-quiet" << "-merge" << tmpFile.fileName();
#endif
  proc.execute();

  applyGtkStyles(exportColors, 1);
  applyGtkStyles(exportColors, 2);

  /* Qt exports */
  if ( exportQtColors || exportQtSettings )
  {
    QSettings* settings = new QSettings(QStringLiteral("Trolltech"));

    if ( exportQtColors )
      applyQtColors( kglobalcfg, *settings, newPal );    // For kcmcolors

    if ( exportQtSettings )
      applyQtSettings( kglobalcfg, *settings );          // For kcmstyle

    delete settings;
    QApplication::flush();
#if HAVE_X11
    if (qApp->platformName() == QStringLiteral("xcb")) {
        // We let KIPC take care of ourselves, as we are in a KDE app with
        // QApp::setDesktopSettingsAware(false);
        // Instead of calling QApp::x11_apply_settings() directly, we instead
        // modify the timestamp which propagates the settings changes onto
        // Qt-only apps without adversely affecting ourselves.

        // Cheat and use the current timestamp, since we just saved to qtrc.
        QDateTime settingsstamp = QDateTime::currentDateTime();

        static Atom qt_settings_timestamp = 0;
        if (!qt_settings_timestamp) {
            QString atomname(QStringLiteral("_QT_SETTINGS_TIMESTAMP_"));
            atomname += XDisplayName( 0 ); // Use the $DISPLAY envvar.
            qt_settings_timestamp = XInternAtom( QX11Info::display(), atomname.toLatin1(), False);
        }

        QBuffer stamp;
        QDataStream s(&stamp.buffer(), QIODevice::WriteOnly);
        s << settingsstamp;
        XChangeProperty( QX11Info::display(), QX11Info::appRootWindow(), qt_settings_timestamp,
                        qt_settings_timestamp, 8, PropModeReplace,
                        (unsigned char*) stamp.buffer().data(),
                        stamp.buffer().size() );
        QApplication::flush();
    }
#endif
  }

  //Legacy support:
  //Try to sync kde4 settings with ours

  Kdelibs4Migration migration;
  //kf5 congig groups for general and icons
  KConfigGroup generalGroup(kglobalcfg, "General");
  KConfigGroup iconsGroup(kglobalcfg, "Icons");

  const QString colorSchemeName = generalGroup.readEntry("ColorScheme", QString());
  //if no valid color scheme saved, something weird is going on, abort
  if (colorSchemeName.isEmpty()) {
      return;
  }
  //fix filename, copied from ColorsCM::saveScheme()
  QString colorSchemeFilename = colorSchemeName;
  colorSchemeFilename.remove('\''); // So Foo's does not become FooS
  QRegExp fixer(QStringLiteral("[\\W,.-]+(.?)"));
  int offset;
  while ((offset = fixer.indexIn(colorSchemeFilename)) >= 0)
      colorSchemeFilename.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper());
  colorSchemeFilename.replace(0, 1, colorSchemeFilename.at(0).toUpper());

  //clone the color scheme
  QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" +  colorSchemeFilename + ".colors");
  QString dest = migration.saveLocation("data", QStringLiteral("color-schemes")) + colorSchemeName + ".colors";

  QFile::remove(dest);
  QFile::copy(src, dest);

  //Apply the color scheme
  QString configFilePath = migration.saveLocation("config") + "kdeglobals";

  if (configFilePath.isEmpty()) {
      return;
  }

  KConfig kde4config(configFilePath, KConfig::SimpleConfig);

  KConfigGroup kde4generalGroup(&kde4config, "General");
  kde4generalGroup.writeEntry("ColorScheme", colorSchemeName);

  //fonts
  QString font = generalGroup.readEntry("font", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("font", font);
  }
  font = generalGroup.readEntry("desktopFont", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("desktopFont", font);
  }
  font = generalGroup.readEntry("menuFont", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("menuFont", font);
  }
  font = generalGroup.readEntry("smallestReadableFont", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("smallestReadableFont", font);
  }
  font = generalGroup.readEntry("taskbarFont", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("taskbarFont", font);
  }
  font = generalGroup.readEntry("toolBarFont", QString());
  if (!font.isEmpty()) {
      kde4generalGroup.writeEntry("toolBarFont", font);
  }

  //TODO: does exist any way to check if a qt4 widget style is present from a qt5 app?
  //kde4generalGroup.writeEntry("widgetStyle", "qtcurve");
  kde4generalGroup.sync();

  KConfigGroup kde4IconGroup(&kde4config, "Icons");
  QString iconTheme = iconsGroup.readEntry("Theme", QString());
  if (!iconTheme.isEmpty()) {
      kde4IconGroup.writeEntry("Theme", iconTheme);
  }
  kde4IconGroup.sync();

  //copy all the groups in the color scheme in kdeglobals
  KSharedConfigPtr kde4ColorConfig = KSharedConfig::openConfig(src, KConfig::SimpleConfig);

  foreach (const QString &grp, kde4ColorConfig->groupList()) {
      KConfigGroup cg(kde4ColorConfig, grp);
      KConfigGroup cg2(&kde4config, grp);
      cg.copyTo(&cg2);
  }

  //widgets settings
  KConfigGroup kglobals4(&kde4config, "KDE");
  kglobals4.writeEntry("ShowIconsInMenuItems", kglobals.readEntry("ShowIconsInMenuItems", true));
  kglobals4.writeEntry("ShowIconsOnPushButtons", kglobals.readEntry("ShowIconsOnPushButtons", true));
  kglobals4.writeEntry("contrast", kglobals.readEntry("contrast", 4));
  //FIXME: this should somehow check if the kde4 version of the style is installed
  kde4generalGroup.writeEntry("widgetStyle", kglobals.readEntry("widgetStyle", "breeze"));

  //toolbar style
  KConfigGroup toolbars4(&kde4config, "Toolbar style");
  KConfigGroup toolbars5(kglobalcfg, "Toolbar style");
  toolbars4.writeEntry("ToolButtonStyle", toolbars5.readEntry("ToolButtonStyle", "TextBesideIcon"));
  toolbars4.writeEntry("ToolButtonStyleOtherToolbars", toolbars5.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon"));
}