Skip to content

Commit

Permalink
The metrics for radiobuttons and checkboxes should respect the zoom f…
Browse files Browse the repository at this point in the history
…actor.
  • Loading branch information
poizan42 committed Oct 31, 2018
1 parent 246098d commit 9ea1607
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/wkhtmltox/converter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ signals:
void checkboxCheckedSvgChanged(const QString & path);
void radiobuttonSvgChanged(const QString & path);
void radiobuttonCheckedSvgChanged(const QString & path);
void zoomFactorChanged(float zoomFactor);
public slots:
void beginConvertion();
bool convert();
Expand Down
4 changes: 4 additions & 0 deletions include/wkhtmltox/utilities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
*/
class DLL_PUBLIC MyLooksStyle: public QProxyStyle {
Q_OBJECT
private:
float zoomFactor;
public:
typedef QProxyStyle parent_t;
MyLooksStyle();
void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
bool weAreDrawingForms;

static QSvgRenderer * checkbox;
Expand All @@ -49,6 +52,7 @@ public slots:
void setCheckboxCheckedSvg(const QString & path);
void setRadioButtonSvg(const QString & path);
void setRadioButtonCheckedSvg(const QString & path);
void setZoomFactor(float zoomFactor);
};

DLL_PUBLIC int handleError(bool success, int errorCode);
Expand Down
1 change: 1 addition & 0 deletions src/lib/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void Converter::cancel() {
}

void Converter::emitCheckboxSvgs(const settings::LoadPage & ls) {
emit zoomFactorChanged(ls.zoomFactor);
emit checkboxSvgChanged(ls.checkboxSvg);
emit checkboxCheckedSvgChanged(ls.checkboxCheckedSvg);
emit radiobuttonSvgChanged(ls.radiobuttonSvg);
Expand Down
1 change: 1 addition & 0 deletions src/lib/pdf_c_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ MyPdfConverter::MyPdfConverter(settings::PdfGlobal * gs):
connect(&converter, SIGNAL(checkboxCheckedSvgChanged(const QString &)), a->style(), SLOT(setCheckboxCheckedSvg(const QString &)));
connect(&converter, SIGNAL(radiobuttonSvgChanged(const QString &)), a->style(), SLOT(setRadioButtonSvg(const QString &)));
connect(&converter, SIGNAL(radiobuttonCheckedSvgChanged(const QString &)), a->style(), SLOT(setRadioButtonCheckedSvg(const QString &)));
connect(&converter, SIGNAL(zoomFactorChanged(float)), a->style(), SLOT(setZoomFactor(float)));
}

MyPdfConverter::~MyPdfConverter() {
Expand Down
23 changes: 22 additions & 1 deletion src/lib/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ void MyLooksStyle::setRadioButtonCheckedSvg(const QString & path) {
"<circle id=\"c2\" cx=\"5.5\" cy=\"5.5\" r=\"1.5\" fill=\"black\" stroke=\"\" stroke-width=\"0\"/>\n", 11, 11);
}

MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false) {
void MyLooksStyle::setZoomFactor(float zoomFactor)
{
this->zoomFactor = zoomFactor;
}

MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false),
zoomFactor(1.0) {
}

void MyLooksStyle::producingForms(bool f) {weAreDrawingForms=f;}
Expand Down Expand Up @@ -137,6 +143,21 @@ void MyLooksStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *
}
}

int MyLooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const {
switch (metric)
{
case PM_ExclusiveIndicatorHeight:
case PM_ExclusiveIndicatorWidth:
case PM_IndicatorHeight:
case PM_IndicatorWidth:
case PM_CheckBoxLabelSpacing:
case PM_RadioButtonLabelSpacing:
return parent_t::pixelMetric(metric, option, widget)*zoomFactor;
default:
return parent_t::pixelMetric(metric, option, widget);
}
}

int handleError(bool success, int errorCode) {
QHash<int, const char *> cm;
cm[400] = "Bad Request";
Expand Down

0 comments on commit 9ea1607

Please sign in to comment.