Commit 2c2b7d56 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Tooltip and link properties of the Color class are now writable. Fix 'Key.Backspace' property name.

[GB.GTK]
* NEW: Tooltip and link properties of the Color class are now writable. Override them if the default widget theme colors are unreadable.
* BUG: Fix 'Key.Backspace' property name.

[GB.GTK3]
* NEW: Tooltip and link properties of the Color class are now writable. Override them if the default widget theme colors are unreadable.
* BUG: Fix 'Key.Backspace' property name.

[GB.QT4]
* NEW: Tooltip and link properties of the Color class are now writable. Override them if the default widget theme colors are unreadable.
* BUG: Fix 'Key.Backspace' property name.

[GB.QT5]
* NEW: Tooltip and link properties of the Color class are now writable. Override them if the default widget theme colors are unreadable.
* BUG: Fix 'Key.Backspace' property name.
parent 6e5930ff
Pipeline #361942442 passed with stage
in 26 minutes and 25 seconds
......@@ -29,6 +29,20 @@
#include "gdesktop.h"
#include "gcolor.h"
GB_COLOR _link_foreground = COLOR_DEFAULT;
GB_COLOR _visited_foreground = COLOR_DEFAULT;
GB_COLOR _tooltip_foreground = COLOR_DEFAULT;
GB_COLOR _tooltip_background = COLOR_DEFAULT;
static void handle_color(void *_param, GB_COLOR color, GB_COLOR *var)
{
if (READ_PROPERTY)
GB.ReturnInteger(*var == COLOR_DEFAULT ? color : *var);
else
*var = VPROP(GB_INTEGER);
}
BEGIN_PROPERTY(Color_Background)
GB.ReturnInteger(gDesktop::getColor(gDesktop::BACKGROUND));
......@@ -91,25 +105,25 @@ END_PROPERTY
BEGIN_PROPERTY(Color_TooltipBackground)
GB.ReturnInteger(gDesktop::getColor(gDesktop::TOOLTIP_BACKGROUND));
handle_color(_param, gDesktop::getColor(gDesktop::TOOLTIP_BACKGROUND), &_tooltip_background);
END_PROPERTY
BEGIN_PROPERTY(Color_TooltipForeground)
GB.ReturnInteger(gDesktop::getColor(gDesktop::TOOLTIP_FOREGROUND));
handle_color(_param, gDesktop::getColor(gDesktop::TOOLTIP_FOREGROUND), &_tooltip_foreground);
END_PROPERTY
BEGIN_PROPERTY(Color_LinkForeground)
GB.ReturnInteger(gDesktop::getColor(gDesktop::LINK_FOREGROUND));
handle_color(_param, gDesktop::getColor(gDesktop::LINK_FOREGROUND), &_link_foreground);
END_PROPERTY
BEGIN_PROPERTY(Color_VisitedForeground)
GB.ReturnInteger(gDesktop::getColor(gDesktop::VISITED_FOREGROUND));
handle_color(_param, gDesktop::getColor(gDesktop::VISITED_FOREGROUND), &_visited_foreground);
END_PROPERTY
......@@ -122,16 +136,17 @@ GB_DESC CColorDesc[] =
GB_STATIC_PROPERTY_READ("LightBackground", "i", Color_LightBackground),
GB_STATIC_PROPERTY_READ("TextBackground", "i", Color_TextBackground),
GB_STATIC_PROPERTY_READ("ButtonBackground", "i", Color_ButtonBackground),
GB_STATIC_PROPERTY_READ("TooltipBackground", "i", Color_TooltipBackground),
GB_STATIC_PROPERTY_READ("Foreground", "i", Color_Foreground),
GB_STATIC_PROPERTY_READ("SelectedForeground", "i", Color_SelectedForeground),
GB_STATIC_PROPERTY_READ("LightForeground", "i", Color_LightForeground),
GB_STATIC_PROPERTY_READ("TextForeground", "i", Color_TextForeground),
GB_STATIC_PROPERTY_READ("ButtonForeground", "i", Color_ButtonForeground),
GB_STATIC_PROPERTY_READ("TooltipForeground", "i", Color_TooltipForeground),
GB_STATIC_PROPERTY_READ("LinkForeground", "i", Color_LinkForeground),
GB_STATIC_PROPERTY_READ("VisitedForeground", "i", Color_VisitedForeground),
GB_STATIC_PROPERTY("TooltipBackground", "i", Color_TooltipBackground),
GB_STATIC_PROPERTY("TooltipForeground", "i", Color_TooltipForeground),
GB_STATIC_PROPERTY("LinkForeground", "i", Color_LinkForeground),
GB_STATIC_PROPERTY("VisitedForeground", "i", Color_VisitedForeground),
GB_END_DECLARE
};
......
......@@ -132,7 +132,7 @@ GB_DESC CKeyDesc[] =
GB_CONSTANT("Escape", "i", GDK_Escape),
GB_CONSTANT("Tab", "i", GDK_Tab),
GB_CONSTANT("BackTab", "i", GDK_ISO_Left_Tab),
GB_CONSTANT("BackSpace", "i", GDK_BackSpace),
GB_CONSTANT("Backspace", "i", GDK_BackSpace),
GB_CONSTANT("Return", "i", GDK_Return),
GB_CONSTANT("Enter", "i", GDK_KP_Enter),
GB_CONSTANT("Ins", "i", GDK_Insert),
......
......@@ -32,6 +32,11 @@
#include "CWidget.h"
#include "CColor.h"
GB_COLOR _link_foreground = COLOR_DEFAULT;
GB_COLOR _visited_foreground = COLOR_DEFAULT;
GB_COLOR _tooltip_foreground = COLOR_DEFAULT;
GB_COLOR _tooltip_background = COLOR_DEFAULT;
static uint get_light_foreground()
{
return IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.3);
......@@ -52,9 +57,22 @@ QColor CCOLOR_make(GB_COLOR color)
return QColor(r, g, b, a);
}
static GB_COLOR get_color(QPalette::ColorRole role)
{
return QApplication::palette().color(role).rgb() & 0xFFFFFF;
}
static void return_color(QPalette::ColorRole role)
{
GB.ReturnInteger(QApplication::palette().color(role).rgb() & 0xFFFFFF);
GB.ReturnInteger(get_color(role));
}
static void handle_color(void *_param, GB_COLOR color, GB_COLOR *var)
{
if (READ_PROPERTY)
GB.ReturnInteger(*var == COLOR_DEFAULT ? color : *var);
else
*var = VPROP(GB_INTEGER);
}
BEGIN_PROPERTY(Color_Background)
......@@ -120,7 +138,7 @@ END_PROPERTY
BEGIN_PROPERTY(Color_TooltipBackground)
return_color(QPalette::ToolTipBase);
handle_color(_param, get_color(QPalette::ToolTipBase), &_tooltip_background);
END_PROPERTY
......@@ -135,23 +153,26 @@ BEGIN_PROPERTY(Color_TooltipForeground)
QColor fg = qApp->palette().color(QPalette::ToolTipText);
int lbg = get_luminance(bg);
int lfg = get_luminance(fg);
GB_COLOR col;
if (abs(lbg - lfg) <= 64)
fg.setHsv(fg.hue(), fg.saturation(), 255 - fg.value());
GB.ReturnInteger(fg.rgb() & 0xFFFFFF);
col = fg.rgb() & 0xFFFFFF;
handle_color(_param, col, &_tooltip_foreground);
END_PROPERTY
BEGIN_PROPERTY(Color_LinkForeground)
return_color(QPalette::Link);
handle_color(_param, get_color(QPalette::Link), &_link_foreground);
END_PROPERTY
BEGIN_PROPERTY(Color_VisitedForeground)
return_color(QPalette::LinkVisited);
handle_color(_param, get_color(QPalette::LinkVisited), &_visited_foreground);
END_PROPERTY
......@@ -164,16 +185,18 @@ GB_DESC CColorDesc[] =
GB_STATIC_PROPERTY_READ("LightBackground", "i", Color_LightBackground),
GB_STATIC_PROPERTY_READ("TextBackground", "i", Color_TextBackground),
GB_STATIC_PROPERTY_READ("ButtonBackground", "i", Color_ButtonBackground),
GB_STATIC_PROPERTY_READ("TooltipBackground", "i", Color_TooltipBackground),
GB_STATIC_PROPERTY_READ("Foreground", "i", Color_Foreground),
GB_STATIC_PROPERTY_READ("LightForeground", "i", Color_LightForeground),
GB_STATIC_PROPERTY_READ("SelectedForeground", "i", Color_SelectedForeground),
GB_STATIC_PROPERTY_READ("TextForeground", "i", Color_TextForeground),
GB_STATIC_PROPERTY_READ("ButtonForeground", "i", Color_ButtonForeground),
GB_STATIC_PROPERTY_READ("TooltipForeground", "i", Color_TooltipForeground),
GB_STATIC_PROPERTY_READ("LinkForeground", "i", Color_LinkForeground),
GB_STATIC_PROPERTY_READ("VisitedForeground", "i", Color_VisitedForeground),
GB_STATIC_PROPERTY("TooltipBackground", "i", Color_TooltipBackground),
GB_STATIC_PROPERTY("TooltipForeground", "i", Color_TooltipForeground),
GB_STATIC_PROPERTY("LinkForeground", "i", Color_LinkForeground),
GB_STATIC_PROPERTY("VisitedForeground", "i", Color_VisitedForeground),
GB_END_DECLARE
};
......
......@@ -169,7 +169,7 @@ GB_DESC CKeyDesc[] =
GB_CONSTANT("Escape", "i", Qt::Key_Escape),
GB_CONSTANT("Tab", "i", Qt::Key_Tab),
GB_CONSTANT("BackTab", "i", Qt::Key_Backtab),
GB_CONSTANT("BackSpace", "i", Qt::Key_Backspace),
GB_CONSTANT("Backspace", "i", Qt::Key_Backspace),
GB_CONSTANT("Return", "i", Qt::Key_Return),
GB_CONSTANT("Enter", "i", Qt::Key_Enter),
GB_CONSTANT("Ins", "i", Qt::Key_Insert),
......
  • You could sneak in a couple of extra properties Color.BallonBackground, Color.BalloonForeground

    The TooltipBackground change is great but has somewhat of an irony in that is does not actually effect Tooltips. (I tested on gtk and QT on gnome,cinnamon,mate,kde, Tooltip bg/fg did not change, even setting in _init() )

    It effects Balloons fine though, thank you :)

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment