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 | void runRdb( uint flags ) | 344 | void runRdb( uint flags ) | ||
405 | { | 345 | { | ||
406 | // Obtain the application palette that is about to be set. | 346 | // Obtain the application palette that is about to be set. | ||
Show All 18 Lines | |||||
425 | KConfigGroup generalCfgGroup(kglobalcfg, "General"); | 365 | KConfigGroup generalCfgGroup(kglobalcfg, "General"); | ||
426 | 366 | | |||
427 | QString gtkTheme; | 367 | QString gtkTheme; | ||
428 | if (kglobals.hasKey("widgetStyle")) | 368 | if (kglobals.hasKey("widgetStyle")) | ||
429 | gtkTheme = kglobals.readEntry("widgetStyle"); | 369 | gtkTheme = kglobals.readEntry("widgetStyle"); | ||
430 | else | 370 | else | ||
431 | gtkTheme = QStringLiteral("oxygen"); | 371 | gtkTheme = QStringLiteral("oxygen"); | ||
432 | 372 | | |||
433 | createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 ); | 373 | createGtkrc( newPal, exportGtkTheme, gtkTheme, 1 ); | ||
434 | createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 ); | 374 | createGtkrc( newPal, exportGtkTheme, gtkTheme, 2 ); | ||
435 | 375 | | |||
436 | // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) | 376 | // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) | ||
437 | if (exportColors) | 377 | if (exportColors) | ||
gikari: Is this somewhat relevant to GTK? | |||||
cblack: Pretty sure it's writing the xrdb there. | |||||
438 | { | 378 | { | ||
439 | KConfigGroup g(KSharedConfig::openConfig(), "WM"); | 379 | KConfigGroup g(KSharedConfig::openConfig(), "WM"); | ||
440 | QString preproc; | 380 | QString preproc; | ||
441 | QColor backCol = newPal.color( QPalette::Active, QPalette::Window ); | 381 | QColor backCol = newPal.color( QPalette::Active, QPalette::Window ); | ||
442 | addColorDef(preproc, "FOREGROUND" , newPal.color( QPalette::Active, QPalette::WindowText ) ); | 382 | addColorDef(preproc, "FOREGROUND" , newPal.color( QPalette::Active, QPalette::WindowText ) ); | ||
443 | addColorDef(preproc, "BACKGROUND" , backCol); | 383 | addColorDef(preproc, "BACKGROUND" , backCol); | ||
444 | addColorDef(preproc, "HIGHLIGHT" , backCol.lighter(100+(2*KColorScheme::contrast()+4)*16/1)); | 384 | addColorDef(preproc, "HIGHLIGHT" , backCol.lighter(100+(2*KColorScheme::contrast()+4)*16/1)); | ||
445 | addColorDef(preproc, "LOWLIGHT" , backCol.darker(100+(2*KColorScheme::contrast()+4)*10)); | 385 | addColorDef(preproc, "LOWLIGHT" , backCol.darker(100+(2*KColorScheme::contrast()+4)*10)); | ||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |
Is this somewhat relevant to GTK?