[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: setting tooltip colors
From: Matthew Woehlke <mw_triad () users ! sourceforge ! net>
Date: 2007-10-12 21:33:37
Message-ID: feop7i$gbr$1 () sea ! gmane ! org
[Download RAW message or body]
Matthew Woehlke wrote:
> Matthew Woehlke wrote:
>> It came to my attention (1) that AFAIK (also tested by jpwhiting) KDE
>> doesn't actually /set/ tooltip colors yet. As I recall, setting them
>> means calling a Qt method, i.e. I am not sure if we can enforce KDE's
>> color preference for non-KDE applications. Anyway, this will require a
>> change in libs; unless someone has a better idea, I guess it will mean
>> setting the colors in KGlobalSettings::createApplicationPalette.
>>
>> I'll post the patch when it's ready, but this is a heads-up that a
>> change is needed (and a call for ideas if anyone has better knowledge
>> than me). I do not expect this to affect BC/SC in any way.
>>
>> 1: http://permalink.gmane.org/gmane.comp.kde.general/17490
>
> Here is the patch (attached; tested with kwrite). Can I please get an
> go/no-go to commit this?
Patch updated. I would really appreciate a go/no-go; currently, we have
broken functionality (a kcm that can set tooltip colors, but they are
not actually applied to QToolTip).
> I am still thinking about having KStyle (or at least oxygen for now) do
> this also, to catch at least Qt-only applications when using a KStyle,
> but to do it "nicely" (i.e. not duplicate this code) really needs the
> introduction of createTooltipPalette in KGlobalSettings. Thus, two
> obvious options:
>
> - add it, breaking the freeze for this small change
> - wait for 4.1, meanwhile duplicating this code
Not introducing side effects to createApplicationPalette basically
requires a new method. For now I added it to KGS::Private as it turns
out only KGS::Private needs to call it for KDE applications to work.
However this means that if KStyle also sets the tooltip palette (to make
Qt-only apps work), then the code must be duplicated. Also, it may be
that KDM needs to do something similar?
--
Matthew
Microsoft: driving people fscking insane...
["set-tooltip-colors.patch" (text/x-patch)]
Index: kernel/kglobalsettings.cpp
===================================================================
--- kernel/kglobalsettings.cpp (revision 724614)
+++ kernel/kglobalsettings.cpp (working copy)
@@ -44,6 +44,7 @@
#include <QApplication>
#include <QtDBus/QtDBus>
#include <QtGui/QStyleFactory>
+#include <QtGui/QToolTip>
#ifdef Q_WS_WIN
#include <windows.h>
@@ -100,6 +101,9 @@
void kdisplaySetFont();
void applyGUIStyle();
+ // TODO (4.1?) - make not-private, if used in KStyle
+ static QPalette createTooltipPalette(const KSharedConfigPtr &config = \
KSharedConfigPtr()); +
/**
* @internal
*
@@ -885,6 +889,47 @@
}
+QPalette KGlobalSettings::Private::createTooltipPalette(const KSharedConfigPtr \
&config) +{
+ QPalette palette = QToolTip::palette();
+
+ QPalette::ColorGroup setStates[3] = { QPalette::Active, QPalette::Inactive,
+ QPalette::Disabled };
+ QPalette::ColorGroup useStates[3] = { QPalette::Active, QPalette::Active,
+ QPalette::Disabled };
+
+ for ( int i = 0; i < 3 ; i++ ) {
+ // tooltips are never active (arguably a bug?), but should be drawn as if \
they were + QPalette::ColorGroup state = setStates[i];
+ QPalette::ColorGroup stateUsed = useStates[i];
+ KColorScheme schemeButton(stateUsed, KColorScheme::Button, config);
+ KColorScheme schemeSelection(stateUsed, KColorScheme::Selection, config);
+ KColorScheme schemeTooltip(stateUsed, KColorScheme::Tooltip, config);
+
+ palette.setBrush( state, QPalette::WindowText, schemeTooltip.foreground() );
+ palette.setBrush( state, QPalette::Window, schemeTooltip.background() );
+ palette.setBrush( state, QPalette::Base, schemeTooltip.background() );
+ palette.setBrush( state, QPalette::Text, schemeTooltip.foreground() );
+ palette.setBrush( state, QPalette::Button, schemeButton.background() );
+ palette.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
+ palette.setBrush( state, QPalette::Highlight, schemeSelection.background() \
); + palette.setBrush( state, QPalette::HighlightedText, \
schemeSelection.foreground() ); +
+ palette.setColor( state, QPalette::Light, schemeTooltip.shade( \
KColorScheme::LightShade ) ); + palette.setColor( state, QPalette::Midlight, \
schemeTooltip.shade( KColorScheme::MidlightShade ) ); + palette.setColor( \
state, QPalette::Mid, schemeTooltip.shade( KColorScheme::MidShade ) ); + \
palette.setColor( state, QPalette::Dark, schemeTooltip.shade( KColorScheme::DarkShade \
) ); + palette.setColor( state, QPalette::Shadow, schemeTooltip.shade( \
KColorScheme::ShadowShade ) ); +
+ palette.setBrush( state, QPalette::AlternateBase, schemeTooltip.background( \
KColorScheme::AlternateBackground) ); + palette.setBrush( state, \
QPalette::Link, schemeTooltip.foreground( KColorScheme::LinkText ) ); + \
palette.setBrush( state, QPalette::LinkVisited, schemeTooltip.foreground( \
KColorScheme::VisitedText ) ); + }
+
+ return palette;
+}
+
+
void KGlobalSettings::Private::kdisplaySetPalette()
{
// Added by Sam/Harald (TT) for Mac OS X initially, but why?
@@ -894,6 +939,7 @@
if (qApp && qApp->type() == QApplication::GuiClient) {
QApplication::setPalette( q->createApplicationPalette() );
+ QToolTip::setPalette( createTooltipPalette() );
emit q->kdisplayPaletteChanged();
emit q->appearanceChanged();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic