mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: pass printFontScale on creation of the profile
Not having to readjust the scale on-demand will make the code distinctly simpler. Let's just pass it once. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5df0efbc7f
commit
a14f740df0
7 changed files with 15 additions and 23 deletions
|
@ -609,7 +609,7 @@ void PlannerWidgets::printDecoPlan()
|
|||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
|
||||
auto profile = std::make_unique<ProfileWidget2>(DivePlannerPointsModel::instance(), nullptr);
|
||||
auto profile = std::make_unique<ProfileWidget2>(DivePlannerPointsModel::instance(), 1.0, nullptr);
|
||||
profile->setPlanState(&displayed_dive, 0);
|
||||
profile->plotDive(&displayed_dive, 0, true, true);
|
||||
profile->setPrintMode(true);
|
||||
|
|
|
@ -102,8 +102,14 @@ void Printer::flowRender()
|
|||
|
||||
void Printer::render(int pages)
|
||||
{
|
||||
auto profile = std::make_unique<ProfileWidget2>(nullptr, nullptr);
|
||||
double printFontScale = 1.0;
|
||||
// get all refereces to diveprofile class in the Html template
|
||||
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
||||
|
||||
// A "standard" profile has about 600 pixels in height.
|
||||
// Scale the fonts in the printed profile accordingly.
|
||||
// This is arbitrary, but it seems to work reasonably well.
|
||||
double printFontScale = collection.count() > 0 ? collection[0].geometry().size().height() / 600.0 : 1.0;
|
||||
auto profile = std::make_unique<ProfileWidget2>(nullptr, printFontScale, nullptr);
|
||||
|
||||
// apply printing settings to profile
|
||||
profile->setFrameStyle(QFrame::NoFrame);
|
||||
|
@ -116,18 +122,6 @@ void Printer::render(int pages)
|
|||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
|
||||
// get all refereces to diveprofile class in the Html template
|
||||
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
||||
|
||||
if (collection.count() > 0) {
|
||||
// A "standard" profile has about 600 pixels in height.
|
||||
// Scale the fonts in the printed profile accordingly.
|
||||
// This is arbitrary, but it seems to work reasonably.
|
||||
QSize size = collection[0].geometry().size();
|
||||
printFontScale = size.height() / 600.0;
|
||||
}
|
||||
profile->setFontPrintScale(printFontScale);
|
||||
|
||||
int elemNo = 0;
|
||||
for (int i = 0; i < pages; i++) {
|
||||
// render the base Html template
|
||||
|
|
|
@ -26,7 +26,7 @@ ProfileWidget::ProfileWidget()
|
|||
ui.profHR, // very few dive computers support this
|
||||
ui.profTissues }; // maybe less frequently used
|
||||
|
||||
view.reset(new ProfileWidget2(DivePlannerPointsModel::instance(), this));
|
||||
view.reset(new ProfileWidget2(DivePlannerPointsModel::instance(), 1.0, this));
|
||||
QToolBar *toolBar = new QToolBar(this);
|
||||
for (QAction *a: toolbarActions)
|
||||
toolBar->addAction(a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue