OSDN Git Service

kcontrol: format and indent
authorIvailo Monev <xakepa10@gmail.com>
Mon, 26 Jun 2023 01:09:41 +0000 (04:09 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 26 Jun 2023 01:09:41 +0000 (04:09 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kcontrol/krdb/krdb.cpp
kcontrol/krdb/krdb.h

index b49db39..24b8cff 100644 (file)
 
 inline const char * gtkEnvVar(int version)
 {
-    return 2==version ? "GTK2_RC_FILES" : "GTK_RC_FILES";
+    return (2 == version ? "GTK2_RC_FILES" : "GTK_RC_FILES");
 }
 
 inline const char * sysGtkrc(int version)
 {
-    if(2==version)
-    {
-       if(access("/etc/opt/gnome/gtk-2.0", F_OK) == 0)
-           return "/etc/opt/gnome/gtk-2.0/gtkrc";
-       else
-           return "/etc/gtk-2.0/gtkrc";
+    if (version == 2) {
+        if (access("/etc/opt/gnome/gtk-2.0", F_OK) == 0) {
+            return "/etc/opt/gnome/gtk-2.0/gtkrc";
+        }
+        return "/etc/gtk-2.0/gtkrc";
     }
-    else
-    {
-       if(access("/etc/opt/gnome/gtk", F_OK) == 0)
-           return "/etc/opt/gnome/gtk/gtkrc";
-       else
-           return "/etc/gtk/gtkrc";
+    if (access("/etc/opt/gnome/gtk", F_OK) == 0) {
+        return "/etc/opt/gnome/gtk/gtkrc";
     }
+    return "/etc/gtk/gtkrc";
 }
 
 inline const char * userGtkrc(int version)
 {
-    return 2==version  ? "/.gtkrc-2.0" : "/.gtkrc";
+    if (version == 2) {
+        return "/.gtkrc-2.0";
+    }
+    return "/.gtkrc";
 }
 
 // -----------------------------------------------------------------------------
 static void applyGtkStyles(bool active, int version)
 {
-   QString gtkkde = KStandardDirs::locateLocal("config", 2==version?"gtkrc-2.0":"gtkrc");
-   QByteArray gtkrc = getenv(gtkEnvVar(version));
-   QStringList list = QFile::decodeName(gtkrc).split( ':');
-   QString userHomeGtkrc = QDir::homePath()+userGtkrc(version);
-   if (!list.contains(userHomeGtkrc))
-      list.prepend(userHomeGtkrc);
-   QLatin1String systemGtkrc = QLatin1String(sysGtkrc(version));
-   if (!list.contains(systemGtkrc))
-      list.prepend(systemGtkrc);
-   list.removeAll("");
-   list.removeAll(gtkkde);
-   list.append(gtkkde);
-
-   // Pass env. var to klauncher.
-   QString name = gtkEnvVar(version);
-   QString value = list.join(":");
-   KToolInvocation::setLaunchEnv(name, value);
+    QString gtkkde = KStandardDirs::locateLocal("config", version == 2 ? "gtkrc-2.0" : "gtkrc");
+    QByteArray gtkrc = qgetenv(gtkEnvVar(version));
+    QStringList list = QFile::decodeName(gtkrc).split(':');
+    QString userHomeGtkrc = QDir::homePath() + userGtkrc(version);
+    if (!list.contains(userHomeGtkrc)) {
+        list.prepend(userHomeGtkrc);
+    }
+    QLatin1String systemGtkrc = QLatin1String(sysGtkrc(version));
+    if (!list.contains(systemGtkrc)) {
+        list.prepend(systemGtkrc);
+    }
+    list.removeAll("");
+    list.removeAll(gtkkde);
+    list.append(gtkkde);
+
+    // Pass env. var to klauncher.
+    QString name = gtkEnvVar(version);
+    QString value = list.join(":");
+    KToolInvocation::setLaunchEnv(name, value);
 }
 
 // -----------------------------------------------------------------------------
 
-static void applyQtColors( QSettings& settings, QPalette& newPal )
+static void applyQtColors(QSettings &settings, QPalette&newPal)
 {
-  QStringList actcg, inactcg, discg;
-  /* export kde color settings */
-  int i;
-  for (i = 0; i < QPalette::NColorRoles; i++)
-     actcg   << newPal.color(QPalette::Active,
-                (QPalette::ColorRole) i).name();
-  for (i = 0; i < QPalette::NColorRoles; i++)
-     inactcg << newPal.color(QPalette::Inactive,
-                (QPalette::ColorRole) i).name();
-  for (i = 0; i < QPalette::NColorRoles; i++)
-     discg   << newPal.color(QPalette::Disabled,
-                (QPalette::ColorRole) i).name();
-
-  settings.setValue("Qt/Palette/active", actcg);
-  settings.setValue("Qt/Palette/inactive", inactcg);
-  settings.setValue("Qt/Palette/disabled", discg);
+    QStringList actcg, inactcg, discg;
+    /* export kde color settings */
+    int i;
+    for (i = 0; i < QPalette::NColorRoles; i++) {
+        actcg << newPal.color(QPalette::Active, (QPalette::ColorRole) i).name();
+    }
+    for (i = 0; i < QPalette::NColorRoles; i++) {
+        inactcg << newPal.color(QPalette::Inactive, (QPalette::ColorRole) i).name();
+    }
+    for (i = 0; i < QPalette::NColorRoles; i++) {
+        discg << newPal.color(QPalette::Disabled, (QPalette::ColorRole) i).name();
+    }
+
+    settings.setValue("Qt/Palette/active", actcg);
+    settings.setValue("Qt/Palette/inactive", inactcg);
+    settings.setValue("Qt/Palette/disabled", discg);
 }
 
 // -----------------------------------------------------------------------------
 
-static void applyQtSettings( KSharedConfigPtr kglobalcfg, QSettings& settings )
+static void applyQtSettings(KSharedConfigPtr kglobalcfg, QSettings &settings)
 {
-  /* export font settings */
-  KConfigGroup fontgrp( kglobalcfg, "General" );
-  QString font = fontgrp.readEntry("font", KGlobalSettings::generalFont().toString());
-  settings.setValue("Qt/font", font);
-
-  /* export effects settings */
-  KConfigGroup guigrp( kglobalcfg, "KDE-Global GUI Settings" );
-  int graphicEffects = guigrp.readEntry("GraphicEffectsLevel", int(KGlobalSettings::graphicEffectsLevelDefault()));
-  KGlobalSettings::GraphicEffects graphicEffectsFlags = KGlobalSettings::GraphicEffects(graphicEffects);
-  bool effectsEnabled = (graphicEffectsFlags != KGlobalSettings::NoEffects);
-  bool complexEffects = (graphicEffectsFlags & KGlobalSettings::ComplexAnimationEffects);
-
-  QStringList guieffects;
-  if (effectsEnabled) {
-    guieffects << QString("general");
-    // the fade effect requires compositor and as such is enabled only when complex animation is on
-    if (complexEffects) {
-      guieffects << QString("fademenu");
-      guieffects << QString("fadetooltip");
+    /* export font settings */
+    KConfigGroup fontgrp(kglobalcfg, "General");
+    QString font = fontgrp.readEntry("font", KGlobalSettings::generalFont().toString());
+    settings.setValue("Qt/font", font);
+
+    /* export effects settings */
+    KConfigGroup guigrp(kglobalcfg, "KDE-Global GUI Settings");
+    int graphicEffects = guigrp.readEntry("GraphicEffectsLevel", int(KGlobalSettings::graphicEffectsLevelDefault()));
+    KGlobalSettings::GraphicEffects graphicEffectsFlags = KGlobalSettings::GraphicEffects(graphicEffects);
+    bool effectsEnabled = (graphicEffectsFlags != KGlobalSettings::NoEffects);
+    bool complexEffects = (graphicEffectsFlags & KGlobalSettings::ComplexAnimationEffects);
+
+    QStringList guieffects;
+    if (effectsEnabled) {
+        guieffects << QString("general");
+        // the fade effect requires compositor and as such is enabled only when complex animation is on
+        if (complexEffects) {
+            guieffects << QString("fademenu");
+            guieffects << QString("fadetooltip");
+        }
+    } else {
+        guieffects << QString("none");
     }
-  } else {
-    guieffects << QString("none");
-  }
 
-  settings.setValue("Qt/GUIEffects", guieffects);
+    settings.setValue("Qt/GUIEffects", guieffects);
 }
 
 // -----------------------------------------------------------------------------
 
-static void addColorDef(QString& s, const char* n, const QColor& col)
+static void addColorDef(QString&s, const char *n, const QColor &col)
 {
-  QString tmp;
-
-  tmp.sprintf("#define %s #%02x%02x%02x\n",
-              n, col.red(), col.green(), col.blue());
-
-  s += tmp;
+    QString tmp;
+    tmp.sprintf("#define %s #%02x%02x%02x\n", n, col.red(), col.green(), col.blue());
+    s += tmp;
 }
 
 
 // -----------------------------------------------------------------------------
-
-static void copyFile(QFile& tmp, QString const& filename )
+static void copyFile(QFile &tmp, const QString &filename)
 {
-  QFile f( filename );
-  if ( f.open(QIODevice::ReadOnly) ) {
-      QByteArray buf( 8192, ' ' );
-      while ( !f.atEnd() ) {
-          int read = f.read( buf.data(), buf.size() );
-          if ( read > 0 )
-              tmp.write( buf.data(), read );
-      }
-  }
+    QFile f(filename);
+    if (f.open(QIODevice::ReadOnly)) {
+        QByteArray buf(8192, ' ');
+        while (!f.atEnd()) {
+            int read = f.read(buf.data(), buf.size());
+            if (read > 0) {
+                tmp.write(buf.data(), read);
+            }
+        }
+    }
 }
 
-
 // -----------------------------------------------------------------------------
-
-static QString item( int i ) {
-    return QString::number( i / 255.0, 'f', 3 );
+static QString item(int i)
+{
+    return QString::number(i / 255.0, 'f', 3);
 }
 
-static QString color( const QColor& col )
+static QString color(const QColor &col)
 {
-    return QString( "{ %1, %2, %3 }" ).arg( item( col.red() ) ).arg( item( col.green() ) ).arg( item( col.blue() ) );
+    return QString::fromLatin1("{ %1, %2, %3 }").arg(item(col.red())).arg(item(col.green())).arg(item(col.blue()));
 }
 
-static void createGtkrc( bool exportColors, const QPalette& cg, int version )
+static void createGtkrc(bool exportColors, const QPalette &cg, int version)
 {
     // lukas: why does it create in ~/.kde/share/config ???
     // pfeiffer: so that we don't overwrite the user's gtkrc.
     // it is found via the GTK_RC_FILES environment variable.
-    KSaveFile saveFile( KStandardDirs::locateLocal( "config", 2==version?"gtkrc-2.0":"gtkrc" ) );
-    if ( !saveFile.open() ) {
+    KSaveFile saveFile(KStandardDirs::locateLocal("config", version == 2 ? "gtkrc-2.0" : "gtkrc"));
+    if (!saveFile.open()) {
         return;
     }
 
-    QTextStream t ( &saveFile );
-    t.setCodec( QTextCodec::codecForLocale () );
+    QTextStream t(&saveFile);
+    t.setCodec(QTextCodec::codecForLocale());
 
     t << i18n(
             "# created by KDE, %1\n"
@@ -217,39 +214,38 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
             "#\n"
             "#\n", QDateTime::currentDateTime().toString());
 
-    if ( 2==version ) {  // we should maybe check for MacOS settings here
+    if (version == 2) {
         t << endl;
         t << "gtk-alternative-button-order = 1" << endl;
         t << endl;
     }
 
-    if (exportColors)
-    {
+    if (exportColors) {
         t << "style \"default\"" << endl;
         t << "{" << endl;
-        t << "  bg[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
-        t << "  bg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl;
-        t << "  bg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
-        t << "  bg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl;
-        t << "  bg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
+        t << "  bg[NORMAL] = " << color(cg.color(QPalette::Active, QPalette::Background)) << endl;
+        t << "  bg[SELECTED] = " << color(cg.color(QPalette::Active, QPalette::Highlight)) << endl;
+        t << "  bg[INSENSITIVE] = " << color(cg.color(QPalette::Active, QPalette::Background)) << endl;
+        t << "  bg[ACTIVE] = " << color(cg.color(QPalette::Active, QPalette::Mid)) << endl;
+        t << "  bg[PRELIGHT] = " << color(cg.color(QPalette::Active, QPalette::Background)) << endl;
         t << endl;
-        t << "  base[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Base ) ) << endl;
-        t << "  base[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl;
-        t << "  base[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
-        t << "  base[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl;
-        t << "  base[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl;
+        t << "  base[NORMAL] = " << color(cg.color(QPalette::Active, QPalette::Base)) << endl;
+        t << "  base[SELECTED] = " << color(cg.color(QPalette::Active, QPalette::Highlight)) << endl;
+        t << "  base[INSENSITIVE] = " << color(cg.color( QPalette::Active, QPalette::Background)) << endl;
+        t << "  base[ACTIVE] = " << color(cg.color(QPalette::Active, QPalette::Highlight)) << endl;
+        t << "  base[PRELIGHT] = " << color(cg.color(QPalette::Active, QPalette::Highlight)) << endl;
         t << endl;
-        t << "  text[NORMAL] = " << color( cg.color(QPalette::Active, QPalette::Text) ) << endl;
-        t << "  text[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl;
-        t << "  text[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl;
-        t << "  text[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl;
-        t << "  text[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl;
+        t << "  text[NORMAL] = " << color(cg.color(QPalette::Active, QPalette::Text) ) << endl;
+        t << "  text[SELECTED] = " << color(cg.color(QPalette::Active, QPalette::HighlightedText)) << endl;
+        t << "  text[INSENSITIVE] = " << color(cg.color(QPalette::Active, QPalette::Mid)) << endl;
+        t << "  text[ACTIVE] = " << color(cg.color(QPalette::Active, QPalette::HighlightedText)) << endl;
+        t << "  text[PRELIGHT] = " << color(cg.color(QPalette::Active, QPalette::HighlightedText)) << endl;
         t << endl;
-        t << "  fg[NORMAL] = " << color ( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl;
-        t << "  fg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl;
-        t << "  fg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl;
-        t << "  fg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl;
-        t << "  fg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl;
+        t << "  fg[NORMAL] = " << color (cg.color(QPalette::Active, QPalette::Foreground)) << endl;
+        t << "  fg[SELECTED] = " << color(cg.color(QPalette::Active, QPalette::HighlightedText)) << endl;
+        t << "  fg[INSENSITIVE] = " << color(cg.color(QPalette::Active, QPalette::Mid)) << endl;
+        t << "  fg[ACTIVE] = " << color(cg.color(QPalette::Active, QPalette::Foreground)) << endl;
+        t << "  fg[PRELIGHT] = " << color(cg.color(QPalette::Active, QPalette::Foreground)) << endl;
         t << "}" << endl;
         t << endl;
         t << "class \"*\" style \"default\"" << endl;
@@ -259,10 +255,10 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
         t << "style \"ToolTip\"" << endl;
         t << "{" << endl;
         QPalette group = QToolTip::palette();
-        t << "  bg[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Background ) ) << endl;
-        t << "  base[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Base ) ) << endl;
-        t << "  text[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Text ) ) << endl;
-        t << "  fg[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Foreground ) ) << endl;
+        t << "  bg[NORMAL] = " << color(group.color(QPalette::Active, QPalette::Background)) << endl;
+        t << "  base[NORMAL] = " << color(group.color(QPalette::Active, QPalette::Base)) << endl;
+        t << "  text[NORMAL] = " << color(group.color(QPalette::Active, QPalette::Text)) << endl;
+        t << "  fg[NORMAL] = " << color(group.color(QPalette::Active, QPalette::Foreground)) << endl;
         t << "}" << endl;
         t << endl;
         t << "widget \"gtk-tooltip\" style \"ToolTip\"" << endl;
@@ -274,8 +270,8 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
         // not every button, checkbox, etc.
         t << "style \"MenuItem\"" << endl;
         t << "{" << endl;
-        t << "  bg[PRELIGHT] = " << color( cg.color(QPalette::Highlight) ) << endl;
-        t << "  fg[PRELIGHT] = " << color( cg.color(QPalette::HighlightedText) ) << endl;
+        t << "  bg[PRELIGHT] = " << color(cg.color(QPalette::Highlight)) << endl;
+        t << "  fg[PRELIGHT] = " << color(cg.color(QPalette::HighlightedText)) << endl;
         t << "}" << endl;
         t << endl;
         t << "class \"*MenuItem\" style \"MenuItem\"" << endl;
@@ -286,199 +282,197 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
 
 // -----------------------------------------------------------------------------
 
-void runRdb( uint flags )
+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;
-
-  KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig( "kdeglobals" );
-  KConfigGroup kglobals(kglobalcfg, "KDE");
-  QPalette newPal = KGlobalSettings::createApplicationPalette(kglobalcfg);
-
-  KTemporaryFile tmpFile;
-  if (!tmpFile.open())
-  {
-    kDebug() << "Couldn't open temp file";
-    exit(0);
-  }
-
-  KConfigGroup generalCfgGroup(kglobalcfg, "General");
-
-  createGtkrc( exportColors, newPal, 1 );
-  createGtkrc( exportColors, newPal, 2 );
-
-  // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps)
-  if (exportColors)
-  {
-    KGlobal::dirs()->addResourceType("appdefaults", "data", "kdisplay/app-defaults/");
-    KGlobal::locale()->insertCatalog("krdb");
+    // 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;
+
+    KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig("kdeglobals");
+    KConfigGroup kglobals(kglobalcfg, "KDE");
+    QPalette newPal = KGlobalSettings::createApplicationPalette(kglobalcfg);
+
+    KTemporaryFile tmpFile;
+    if (!tmpFile.open()) {
+        kDebug() << "Couldn't open temp file";
+        ::exit(0);
+    }
+
+    KConfigGroup generalCfgGroup(kglobalcfg, "General");
+
+    createGtkrc(exportColors, newPal, 1);
+    createGtkrc(exportColors, newPal, 2);
+
+    // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps)
+    if (exportColors) {
+        KGlobal::dirs()->addResourceType("appdefaults", "data", "kdisplay/app-defaults/");
+        KGlobal::locale()->insertCatalog("krdb");
 
 #warning FIXME: KGlobalSettings race, palette settings may not be reloaded yet
-    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*KGlobalSettings::contrast()+4)*16/1));
-    addColorDef(preproc, "LOWLIGHT"           , backCol.dark(100+(2*KGlobalSettings::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", KGlobalSettings::inactiveTitleColor());
-    addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor());
-    addColorDef(preproc, "ACTIVE_BACKGROUND"  , KGlobalSettings::activeTitleColor());
-    addColorDef(preproc, "ACTIVE_FOREGROUND"  , KGlobalSettings::activeTitleColor());
-    //---------------------------------------------------------------
-
-    tmpFile.write( preproc.toLatin1(), preproc.length() );
-
-    QStringList list;
-
-    const QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", "");
-    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("*.ad"));
-        list += dSys.entryList();
-      }
+        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 * KGlobalSettings::contrast() + 4) * 16 / 1));
+        addColorDef(preproc, "LOWLIGHT"           , backCol.dark(100 + (2 * KGlobalSettings::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", KGlobalSettings::inactiveTitleColor());
+        addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor());
+        addColorDef(preproc, "ACTIVE_BACKGROUND"  , KGlobalSettings::activeTitleColor());
+        addColorDef(preproc, "ACTIVE_FOREGROUND"  , KGlobalSettings::activeTitleColor());
+        //---------------------------------------------------------------
+
+        tmpFile.write(preproc.toLatin1(), preproc.length());
+
+        QStringList list;
+        const QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", "");
+        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("*.ad"));
+                list += dSys.entryList();
+            }
+        }
+
+        for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) {
+            copyFile(tmpFile, KStandardDirs::locate("appdefaults", *it));
+        }
     }
 
-    for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
-      copyFile(tmpFile, KStandardDirs::locate("appdefaults", *it ));
-  }
-
-  // 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);
-  else
-    copyFile(tmpFile, homeDir + "/.Xdefaults");
-
-  // Export the Xcursor theme & size settings
-  KConfigGroup mousecfg(KSharedConfig::openConfig( "kcminputrc" ), "Mouse" );
-  QString theme = mousecfg.readEntry("cursorTheme", QString("Oxygen_White"));
-  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 += "Xft.antialias: ";
-      if(generalCfgGroup.readEntry("XftAntialias", true))
-        contents += "1\n";
-      else
-        contents += "0\n";
+    // 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);
+    } else {
+        copyFile(tmpFile, homeDir + "/.Xdefaults");
     }
 
-    if (generalCfgGroup.hasKey("XftHintStyle"))
-    {
-      QString hintStyle = generalCfgGroup.readEntry("XftHintStyle", "hintmedium");
-      contents += "Xft.hinting: ";
-      if(hintStyle.isEmpty())
-        contents += "-1\n";
-      else
-      {
-        if(hintStyle!="hintnone")
-          contents += "1\n";
-        else
-          contents += "0\n";
-        contents += "Xft.hintstyle: " + hintStyle + '\n';
-      }
+    // Export the Xcursor theme & size settings
+    KConfigGroup mousecfg(KSharedConfig::openConfig("kcminputrc"), "Mouse");
+    QString theme = mousecfg.readEntry("cursorTheme", QString("Oxygen_White"));
+    QString size  = mousecfg.readEntry("cursorSize", QString());
+    QString contents;
+
+    if (!theme.isNull()) {
+        contents = "Xcursor.theme: " + theme + '\n';
     }
 
-    if (generalCfgGroup.hasKey("XftSubPixel"))
-    {
-      QString subPixel = generalCfgGroup.readEntry("XftSubPixel");
-      if(!subPixel.isEmpty())
-        contents += "Xft.rgba: " + subPixel + '\n';
+    if (!size.isNull()) {
+        contents += "Xcursor.size: " + size + '\n';
     }
 
-    KConfig _cfgfonts( "kcmfonts" );
-    KConfigGroup cfgfonts(&_cfgfonts, "General");
-
-    if( cfgfonts.readEntry( "forceFontDPI", 0 ) != 0 )
-      contents += "Xft.dpi: " + cfgfonts.readEntry( "forceFontDPI" ) + '\n';
-    else
-    {
-      QProcess proc;
-      proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp");
-      if (proc.waitForStarted())
-      {
-        proc.write( QByteArray( "Xft.dpi\n" ) );
-        proc.closeWriteChannel();
-        proc.waitForFinished();
-      }
+    if (exportXftSettings) {
+        if (generalCfgGroup.hasKey("XftAntialias")) {
+            contents += "Xft.antialias: ";
+            if (generalCfgGroup.readEntry("XftAntialias", true)) {
+                contents += "1\n";
+            } else {
+                contents += "0\n";
+            }
+        }
+
+        if (generalCfgGroup.hasKey("XftHintStyle")) {
+            QString hintStyle = generalCfgGroup.readEntry("XftHintStyle", "hintmedium");
+            contents += "Xft.hinting: ";
+            if (hintStyle.isEmpty()) {
+                contents += "-1\n";
+            } else {
+                if (hintStyle != "hintnone") {
+                    contents += "1\n";
+                } else {
+                    contents += "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("kcmfonts");
+        KConfigGroup cfgfonts(&_cfgfonts, "General");
+
+        if (cfgfonts.readEntry("forceFontDPI", 0) != 0) {
+            contents += "Xft.dpi: " + cfgfonts.readEntry("forceFontDPI") + '\n';
+        } else {
+            QProcess proc;
+            proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp");
+            if (proc.waitForStarted()) {
+                proc.write(QByteArray("Xft.dpi\n"));
+                proc.closeWriteChannel();
+                proc.waitForFinished();
+            }
+        }
     }
-  }
 
-  if (contents.length() > 0)
-    tmpFile.write( contents.toLatin1(), contents.length() );
+    if (contents.length() > 0) {
+        tmpFile.write(contents.toLatin1(), contents.length());
+    }
 
-  tmpFile.flush();
+    tmpFile.flush();
 
-  QStringList procargs;
+    QStringList procargs;
 #ifndef NDEBUG
-  procargs << "-merge" << tmpFile.fileName();
+    procargs << "-merge" << tmpFile.fileName();
 #else
-  procargs << "-quiet" << "-merge" << tmpFile.fileName();
+    procargs << "-quiet" << "-merge" << tmpFile.fileName();
 #endif
-  QProcess::execute("xrdb", procargs);
-
-  applyGtkStyles(exportColors, 1);
-  applyGtkStyles(exportColors, 2);
-
-  /* Katie exports */
-  if ( exportQtColors || exportQtSettings )
-  {
-    {
-      QSettings settings(QLatin1String("Katie"), QSettings::NativeFormat);
-
-      if ( exportQtColors )
-        applyQtColors( settings, newPal );    // For kcmcolors
-
-      if ( exportQtSettings )
-        applyQtSettings( kglobalcfg, settings );          // For kcmstyle
+    QProcess::execute("xrdb", procargs);
+
+    applyGtkStyles(exportColors, 1);
+    applyGtkStyles(exportColors, 2);
+
+    /* Katie exports */
+    if (exportQtColors || exportQtSettings) {
+        {
+            QSettings settings(QLatin1String("Katie"), QSettings::NativeFormat);
+
+            if (exportQtColors) {
+                applyQtColors(settings, newPal); // For kcmcolors
+            }
+
+            if (exportQtSettings) {
+                applyQtSettings(kglobalcfg, settings); // For kcmstyle
+            }
+        }
+
+        QApplication::flush();
+        // 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
+        // Katie-only apps without adversely affecting ourselves.
+
+        // Cheat and use the current timestamp, since we just saved to qtrc.
+        QDateTime settingsstamp = QDateTime::currentDateTime();
+
+        static const QByteArray atomname("_QT_SETTINGS_TIMESTAMP");
+        static Atom qt_settings_timestamp = XInternAtom( QX11Info::display(), atomname.constData(), 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();
     }
-
-    QApplication::flush();
-#ifdef Q_WS_X11
-    // 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
-    // Katie-only apps without adversely affecting ourselves.
-
-    // Cheat and use the current timestamp, since we just saved to qtrc.
-    QDateTime settingsstamp = QDateTime::currentDateTime();
-
-    static const QByteArray atomname("_QT_SETTINGS_TIMESTAMP");
-    static Atom qt_settings_timestamp = XInternAtom( QX11Info::display(), atomname.constData(), 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
-  }
 }
 
index ac0daad..b53ebb6 100644 (file)
    Boston, MA 02110-1301, USA.
 */
 
-#ifndef _KRDB_H_
-#define _KRDB_H_
+#ifndef KRDB_H
+#define KRDB_H
 
 enum KRdbAction
 {
-   KRdbExportColors      = 0x0001,   // Export colors to non-(KDE/Qt) apps
-   KRdbExportQtColors    = 0x0002,   // Export KDE's colors to qtrc
-   KRdbExportQtSettings  = 0x0004,   // Export all possible qtrc settings, excluding colors
-   KRdbExportXftSettings = 0x0008,   // Export KDE's Xft (anti-alias) settings
+    KRdbExportColors      = 0x0001,   // Export colors to non-(KDE/Qt) apps
+    KRdbExportQtColors    = 0x0002,   // Export KDE's colors to qtrc
+    KRdbExportQtSettings  = 0x0004,   // Export all possible qtrc settings, excluding colors
+    KRdbExportXftSettings = 0x0008,   // Export KDE's Xft (anti-alias) settings
 };
 
-void runRdb( uint flags );
+void runRdb(uint flags);
 
-#endif
+#endif // KRDB_H