[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:
wandererfan
2022-12-17 07:41:37 -05:00
committed by WandererFan
parent ed8e45ac9b
commit d63ac0f7f6
34 changed files with 3257 additions and 2160 deletions

View File

@@ -23,11 +23,12 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cmath>
# include <sstream>
# include <QGraphicsItem>
# include <QRectF>
#include <QGraphicsColorizeEffect>
#include <QGraphicsEffect>
#include <QGraphicsItem>
#include <QRectF>
#include <cmath>
#include <sstream>
#endif
#include <Base/Console.h>
@@ -36,13 +37,14 @@
#include <Mod/TechDraw/App/DrawViewDraft.h>
#include <Mod/TechDraw/App/DrawViewSymbol.h>
#include "QGIViewSymbol.h"
#include "PreferencesGui.h"
#include "QGCustomSvg.h"
#include "QGDisplayArea.h"
#include "QGIViewSymbol.h"
#include "Rez.h"
using namespace TechDrawGui;
using namespace TechDraw;
QGIViewSymbol::QGIViewSymbol()
{
@@ -67,21 +69,19 @@ QGIViewSymbol::~QGIViewSymbol()
// m_svgItem belongs to this group and will be deleted by Qt
}
void QGIViewSymbol::setViewSymbolFeature(TechDraw::DrawViewSymbol *obj)
void QGIViewSymbol::setViewSymbolFeature(TechDraw::DrawViewSymbol* obj)
{
// called from QGVPage. (once)
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
setViewFeature(static_cast<TechDraw::DrawView*>(obj));
}
void QGIViewSymbol::updateView(bool update)
{
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
auto viewSymbol(dynamic_cast<TechDraw::DrawViewSymbol*>(getViewObject()));
if (!viewSymbol)
return;
if (update ||
viewSymbol->isTouched() ||
viewSymbol->Symbol.isTouched()) {
if (update || viewSymbol->isTouched() || viewSymbol->Symbol.isTouched()) {
draw();
}
@@ -104,20 +104,21 @@ void QGIViewSymbol::draw()
void QGIViewSymbol::drawSvg()
{
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
auto viewSymbol(dynamic_cast<TechDraw::DrawViewSymbol*>(getViewObject()));
if (!viewSymbol)
return;
double rezfactor = Rez::getRezFactor();
double scaling = viewSymbol->getScale();
double pxMm = 3.78; //96px/25.4mm ( CSS/SVG defined value of 96 pixels per inch)
// double pxMm = 3.54; //90px/25.4mm ( inkscape value version <= 0.91)
//some software uses different px/in, so symbol will need Scale adjusted.
double pxMm = 3.78;//96px/25.4mm ( CSS/SVG defined value of 96 pixels per inch)
// double pxMm = 3.54; //90px/25.4mm ( inkscape value version <= 0.91)
//some software uses different px/in, so symbol will need Scale adjusted.
//Arch/Draft views are in px and need to be scaled @ rezfactor px/mm to ensure proper representation
if (viewSymbol->isDerivedFrom(TechDraw::DrawViewArch::getClassTypeId()) ||
viewSymbol->isDerivedFrom(TechDraw::DrawViewDraft::getClassTypeId()) ) {
if (viewSymbol->isDerivedFrom(TechDraw::DrawViewArch::getClassTypeId())
|| viewSymbol->isDerivedFrom(TechDraw::DrawViewDraft::getClassTypeId())) {
scaling = scaling * rezfactor;
} else {
}
else {
scaling = scaling * rezfactor / pxMm;
}
m_svgItem->setScale(scaling);
@@ -135,9 +136,23 @@ void QGIViewSymbol::symbolToSvg(QByteArray qba)
prepareGeometryChange();
if (!m_svgItem->load(&qba)) {
Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n", getViewName());
Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n",
getViewName());
}
m_svgItem->centerAt(0., 0.);
if (Preferences::lightOnDark()) {
QColor color = PreferencesGui::getAccessibleQColor(QColor(Qt::black));
QGraphicsColorizeEffect* colorizeEffect = new QGraphicsColorizeEffect();
colorizeEffect->setColor(color);
m_svgItem->setGraphicsEffect(colorizeEffect);
}
else {
//remove and delete any existing graphics effect
if (m_svgItem->graphicsEffect()) {
m_svgItem->setGraphicsEffect(nullptr);
}
}
}
void QGIViewSymbol::rotateView()
@@ -147,4 +162,3 @@ void QGIViewSymbol::rotateView()
double rot = getViewObject()->Rotation.getValue();
m_displayArea->setRotation(-rot);
}