Changeset View
Changeset View
Standalone View
Standalone View
kcms/krdb/krdb.cpp
| Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Line(s) | 252 | static QString item( int i ) { | |||
|---|---|---|---|---|---|
| 253 | return QString::number( i / 255.0, 'f', 3 ); | 253 | return QString::number( i / 255.0, 'f', 3 ); | ||
| 254 | } | 254 | } | ||
| 255 | 255 | | |||
| 256 | static QString color( const QColor& col ) | 256 | static QString color( const QColor& col ) | ||
| 257 | { | 257 | { | ||
| 258 | return QStringLiteral( "{ %1, %2, %3 }" ).arg( item( col.red() ) ).arg( item( col.green() ) ).arg( item( col.blue() ) ); | 258 | return QStringLiteral( "{ %1, %2, %3 }" ).arg( item( col.red() ) ).arg( item( col.green() ) ).arg( item( col.blue() ) ); | ||
| 259 | } | 259 | } | ||
| 260 | 260 | | |||
| 261 | static void createGtkrc( bool exportColors, const QPalette& cg, bool exportGtkTheme, const QString& gtkTheme, int version ) | 261 | static void createGtkrc( const QPalette& cg, bool exportGtkTheme, const QString& gtkTheme, int version ) | ||
| 262 | { | 262 | { | ||
| 263 | // lukas: why does it create in ~/.kde/share/config ??? | 263 | // lukas: why does it create in ~/.kde/share/config ??? | ||
| 264 | // pfeiffer: so that we don't overwrite the user's gtkrc. | 264 | // pfeiffer: so that we don't overwrite the user's gtkrc. | ||
| 265 | // it is found via the GTK_RC_FILES environment variable. | 265 | // it is found via the GTK_RC_FILES environment variable. | ||
| 266 | QSaveFile saveFile( writableGtkrc(version) ); | 266 | QSaveFile saveFile( writableGtkrc(version) ); | ||
| 267 | if ( !saveFile.open(QIODevice::WriteOnly) ) | 267 | if ( !saveFile.open(QIODevice::WriteOnly) ) | ||
| 268 | return; | 268 | return; | ||
| 269 | 269 | | |||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 308 | { | |||
| 326 | } | 326 | } | ||
| 327 | 327 | | |||
| 328 | if (!gtk2ThemeFilename.isEmpty()) | 328 | if (!gtk2ThemeFilename.isEmpty()) | ||
| 329 | { | 329 | { | ||
| 330 | t << "include \"" << gtk2ThemeFilename << "\"" << endl; | 330 | t << "include \"" << gtk2ThemeFilename << "\"" << endl; | ||
| 331 | t << endl; | 331 | t << endl; | ||
| 332 | t << "gtk-theme-name=\"" << gtkStyle << "\"" << endl; | 332 | t << "gtk-theme-name=\"" << gtkStyle << "\"" << endl; | ||
| 333 | t << endl; | 333 | t << endl; | ||
| 334 | if (gtkStyle == QLatin1String("oxygen-gtk")) | | |||
| 335 | exportColors = false; | | |||
| 336 | } | 334 | } | ||
| 337 | } | 335 | } | ||
| 338 | 336 | | |||
| 339 | } | 337 | } | ||
| 340 | 338 | | |||
| 341 | if (exportColors) | | |||
| 342 | { | | |||
| 343 | t << "style \"default\"" << endl; | | |||
| 344 | t << "{" << endl; | | |||
| 345 | t << " bg[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Window ) ) << endl; | | |||
| 346 | t << " bg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; | | |||
| 347 | t << " bg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Window ) ) << endl; | | |||
| 348 | t << " bg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; | | |||
| 349 | t << " bg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Window ) ) << endl; | | |||
| 350 | t << endl; | | |||
| 351 | t << " base[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Base ) ) << endl; | | |||
| 352 | t << " base[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; | | |||
| 353 | t << " base[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Window ) ) << endl; | | |||
| 354 | t << " base[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; | | |||
| 355 | t << " base[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; | | |||
| 356 | t << endl; | | |||
| 357 | t << " text[NORMAL] = " << color( cg.color(QPalette::Active, QPalette::Text) ) << endl; | | |||
| 358 | t << " text[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; | | |||
| 359 | t << " text[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; | | |||
| 360 | t << " text[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; | | |||
| 361 | t << " text[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; | | |||
| 362 | t << endl; | | |||
| 363 | t << " fg[NORMAL] = " << color ( cg.color( QPalette::Active, QPalette::WindowText ) ) << endl; | | |||
| 364 | t << " fg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; | | |||
| 365 | t << " fg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; | | |||
| 366 | t << " fg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::WindowText ) ) << endl; | | |||
| 367 | t << " fg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::WindowText ) ) << endl; | | |||
| 368 | t << "}" << endl; | | |||
| 369 | t << endl; | | |||
| 370 | t << "class \"*\" style \"default\"" << endl; | | |||
| 371 | t << endl; | | |||
| 372 | | ||||
| 373 | // tooltips don't have the standard background color | | |||
| 374 | t << "style \"ToolTip\"" << endl; | | |||
| 375 | t << "{" << endl; | | |||
| 376 | t << " bg[NORMAL] = " << color( cg.color( QPalette::ToolTipBase ) ) << endl; | | |||
| 377 | t << " base[NORMAL] = " << color( cg.color( QPalette::ToolTipBase ) ) << endl; | | |||
| 378 | t << " text[NORMAL] = " << color( cg.color( QPalette::ToolTipText ) ) << endl; | | |||
| 379 | t << " fg[NORMAL] = " << color( cg.color( QPalette::ToolTipText ) ) << endl; | | |||
| 380 | t << "}" << endl; | | |||
| 381 | t << endl; | | |||
| 382 | t << "widget \"gtk-tooltip\" style \"ToolTip\"" << endl; | | |||
| 383 | t << "widget \"gtk-tooltips\" style \"ToolTip\"" << endl; | | |||
| 384 | t << "widget \"gtk-tooltip*\" style \"ToolTip\"" << endl; | | |||
| 385 | t << endl; | | |||
| 386 | | ||||
| 387 | | ||||
| 388 | // highlight the current (mouse-hovered) menu-item | | |||
| 389 | // not every button, checkbox, etc. | | |||
| 390 | t << "style \"MenuItem\"" << endl; | | |||
| 391 | t << "{" << endl; | | |||
| 392 | t << " bg[PRELIGHT] = " << color( cg.color(QPalette::Highlight) ) << endl; | | |||
| 393 | t << " fg[PRELIGHT] = " << color( cg.color(QPalette::HighlightedText) ) << endl; | | |||
| 394 | t << "}" << endl; | | |||
| 395 | t << endl; | | |||
| 396 | t << "class \"*MenuItem\" style \"MenuItem\"" << endl; | | |||
| 397 | t << endl; | | |||
| 398 | } | | |||
| 399 | saveFile.commit(); | 339 | saveFile.commit(); | ||
| 400 | } | 340 | } | ||
| 401 | 341 | | |||
| 402 | // --------------------------------------------------------------------- | 342 | // --------------------------------------------------------------------- | ||
| 403 | 343 | | |||
| 404 | QString gtkColorsHelper(const QString &name, const QString &color) | 344 | QString gtkColorsHelper(const QString &name, const QString &color) | ||
| 405 | { | 345 | { | ||
| 406 | return QStringLiteral("@define-color %1 %2;\n").arg(name, color); | 346 | return QStringLiteral("@define-color %1 %2;\n").arg(name, color); | ||
| ▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Line(s) | 609 | { | |||
| 690 | KConfigGroup generalCfgGroup(kglobalcfg, "General"); | 630 | KConfigGroup generalCfgGroup(kglobalcfg, "General"); | ||
| 691 | 631 | | |||
| 692 | QString gtkTheme; | 632 | QString gtkTheme; | ||
| 693 | if (kglobals.hasKey("widgetStyle")) | 633 | if (kglobals.hasKey("widgetStyle")) | ||
| 694 | gtkTheme = kglobals.readEntry("widgetStyle"); | 634 | gtkTheme = kglobals.readEntry("widgetStyle"); | ||
| 695 | else | 635 | else | ||
| 696 | gtkTheme = QStringLiteral("oxygen"); | 636 | gtkTheme = QStringLiteral("oxygen"); | ||
| 697 | 637 | | |||
| 698 | createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 ); | 638 | createGtkrc( newPal, exportGtkTheme, gtkTheme, 1 ); | ||
| 699 | createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 ); | 639 | createGtkrc( newPal, exportGtkTheme, gtkTheme, 2 ); | ||
| 700 | 640 | | |||
| 701 | // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) | 641 | // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) | ||
| 702 | if (exportColors) | 642 | if (exportColors) | ||
gikari: Is this somewhat relevant to GTK? | |||||
cblack: Pretty sure it's writing the xrdb there. | |||||
| 703 | { | 643 | { | ||
| 704 | KConfigGroup g(KSharedConfig::openConfig(), "WM"); | 644 | KConfigGroup g(KSharedConfig::openConfig(), "WM"); | ||
| 705 | QString preproc; | 645 | QString preproc; | ||
| 706 | QColor backCol = newPal.color( QPalette::Active, QPalette::Window ); | 646 | QColor backCol = newPal.color( QPalette::Active, QPalette::Window ); | ||
| 707 | addColorDef(preproc, "FOREGROUND" , newPal.color( QPalette::Active, QPalette::WindowText ) ); | 647 | addColorDef(preproc, "FOREGROUND" , newPal.color( QPalette::Active, QPalette::WindowText ) ); | ||
| 708 | addColorDef(preproc, "BACKGROUND" , backCol); | 648 | addColorDef(preproc, "BACKGROUND" , backCol); | ||
| 709 | addColorDef(preproc, "HIGHLIGHT" , backCol.lighter(100+(2*KColorScheme::contrast()+4)*16/1)); | 649 | addColorDef(preproc, "HIGHLIGHT" , backCol.lighter(100+(2*KColorScheme::contrast()+4)*16/1)); | ||
| 710 | addColorDef(preproc, "LOWLIGHT" , backCol.darker(100+(2*KColorScheme::contrast()+4)*10)); | 650 | addColorDef(preproc, "LOWLIGHT" , backCol.darker(100+(2*KColorScheme::contrast()+4)*10)); | ||
| ▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines | |||||
Is this somewhat relevant to GTK?