[TD]add light text on dark page mode
- some visually impaired users need white graphics on dark page. - revise Annotation dialog to respect dark style
This commit is contained in:
@@ -91,7 +91,12 @@ App::Color PreferencesGui::sectionLineColor()
|
||||
|
||||
QColor PreferencesGui::sectionLineQColor()
|
||||
{
|
||||
return sectionLineColor().asValue<QColor>();
|
||||
//if the App::Color version has already lightened the color, we don't want to do it agin
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("SectionColor", 0x000000FF));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
App::Color PreferencesGui::centerColor()
|
||||
@@ -105,7 +110,11 @@ App::Color PreferencesGui::centerColor()
|
||||
|
||||
QColor PreferencesGui::centerQColor()
|
||||
{
|
||||
return centerColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x000000FF));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::vertexQColor()
|
||||
@@ -118,30 +127,39 @@ App::Color PreferencesGui::dimColor()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::dimQColor()
|
||||
{
|
||||
return PreferencesGui::dimColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
|
||||
App::Color PreferencesGui::leaderColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/LeaderLine");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::leaderQColor()
|
||||
{
|
||||
return PreferencesGui::leaderColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/LeaderLine");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
int PreferencesGui::dimArrowStyle()
|
||||
@@ -208,20 +226,24 @@ QString PreferencesGui::weldingDirectory()
|
||||
return qSymbolDir;
|
||||
}
|
||||
|
||||
|
||||
App::Color PreferencesGui::gridColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::gridQColor()
|
||||
{
|
||||
return PreferencesGui::gridColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
double PreferencesGui::gridSpacing()
|
||||
@@ -241,3 +263,70 @@ bool PreferencesGui::showGrid()
|
||||
bool show = hGrp->GetBool("showGrid", false);
|
||||
return show;
|
||||
}
|
||||
|
||||
App::Color PreferencesGui::pageColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("PageColor", 0xFFFFFFFF)); //#FFFFFFFF white
|
||||
return result;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::pageQColor()
|
||||
{
|
||||
return PreferencesGui::pageColor().asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::getAccessibleQColor(QColor orig)
|
||||
{
|
||||
if (Preferences::lightOnDark() && Preferences::monochrome()) {
|
||||
return lightTextQColor();
|
||||
}
|
||||
if (Preferences::lightOnDark()) {
|
||||
return lightenColor(orig);
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::lightTextQColor()
|
||||
{
|
||||
return Preferences::lightTextColor().asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::reverseColor(QColor orig)
|
||||
{
|
||||
int revRed = 255 - orig.red();
|
||||
int revBlue = 255 - orig.blue();
|
||||
int revGreen = 255 - orig.green();
|
||||
return QColor(revRed, revGreen, revBlue);
|
||||
}
|
||||
|
||||
// largely based on code from https://invent.kde.org/graphics/okular and
|
||||
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
|
||||
QColor PreferencesGui::lightenColor(QColor orig)
|
||||
{
|
||||
// get component colours on [0, 255]
|
||||
uchar red = orig.red();
|
||||
uchar blue = orig.blue();
|
||||
uchar green = orig.green();
|
||||
uchar alpha = orig.alpha();
|
||||
|
||||
// shift color values
|
||||
uchar m = std::min( {red, blue, green} );
|
||||
red -= m;
|
||||
blue -= m;
|
||||
green -= m;
|
||||
|
||||
// calculate chroma (colour range)
|
||||
uchar chroma = std::max( {red, blue, green} );
|
||||
|
||||
// calculate lightened colour value
|
||||
uchar newm = 255 - chroma - m;
|
||||
red += newm;
|
||||
green += newm;
|
||||
blue += newm;
|
||||
|
||||
return QColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user