Skip to content

Conversation

@atdotde
Copy link
Collaborator

@atdotde atdotde commented Jan 11, 2026

These are the first steps using QLiteHtml for printing logbook pages in Qt6.

State of affairs: It prints logbook pages but all sizes are wrong. But I think it looks promising.
It does not try to really parse the html (which was a show stopper in the past) but simply uses a regex to do the
div class="diveProfile" to img replacement. This could also be done with xslt but not by me.

It requires the latest version of litehtml which contains a fix for a bug that would overlap tables. Maybe @dirkhh could update his QLiteHtml branch.

Describe the pull request:

  • Bug fix
  • Functional change
  • New feature
  • Code cleanup
  • Build system change
  • Documentation change
  • Language translation

Pull request long description:

Changes made:

Related issues:

Additional information:

Documentation change:

Mentions:

Signed-off-by: Robert C. Helling <[email protected]>
Signed-off-by: Robert C. Helling <[email protected]>
Signed-off-by: Robert C. Helling <[email protected]>
@atdotde atdotde requested a review from dirkhh January 11, 2026 16:00
@dirkhh
Copy link
Collaborator

dirkhh commented Jan 11, 2026

I'm traveling (actually diving, so not complaining), it may take be a couple of days before I get to this.

@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5514-patch.4.pull-request.liteprinter
WARNING: Use at your own risk.

@dirkhh
Copy link
Collaborator

dirkhh commented Jan 11, 2026

OK, I didn't review the code, and I didn't update your PR, but if you apply this:

diff --git a/scripts/get-dep-lib.sh b/scripts/get-dep-lib.sh
index 731a875ae..f5ed96326 100755
--- a/scripts/get-dep-lib.sh
+++ b/scripts/get-dep-lib.sh
@@ -19,7 +19,7 @@ CURRENT_MDBTOOLS="v1.0.0"
 CURRENT_QT_ANDROID_CMAKE="master"
 CURRENT_LIBMTP="v1.1.22"
 CURRENT_LIBRAW="0.21.4"
-CURRENT_QLITEHTML="b8f9096eae730ec9464b24874e4e6312144aa9ce"
+CURRENT_QLITEHTML="865c9bb2eb9dcef6a0fed5bc5c4a9ab4bd777f74"
 
 croak() {
        echo $@

you should get a qlitehtml library with the latest litehtml code.

Copy link
Collaborator

@dirkhh dirkhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, mostly pointless.
This looks like a really promising start, Robert.
Thanks for working on this!

#if defined(USE_WEBKIT)
webView(new QWebView),
printOptions(printOptions),
templateOptions(templateOptions),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just doing a quick read-through before heading to the harbor...
since you #ifdef that code, why are you removing those two lines? Or is that an unrelated change?

# include <qlitehtmlwidget.h>
#elif defined(USE_WEBKIT)
# include <QtWebKitWidgetst>
#include <QtWebKitWidgetst>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd whitespace change? either we do the space indent, or we don't?

templateOptions(templateOptions),
printMode(printMode),
singleDive(singleDive),
printOptions(printOptions),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I think this explains what my first comment was about... but then it should happen at the same time, in the same commit, no?

webView->setHtml(t.generateStatistics());
#else
;
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not my favorite way to express this -- why not just #ifdef the whole if/else-if?
What am I missing?

return QByteArray();
});
previewWidget.setGeometry(QRect(0,0,1600,1000));
previewWidget.setGeometry(QRect(0,0,1200,1000));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frankly, neither of these hard coded values is the right thing to do. Something-something based on the current window size? But that's me just being annoying, this is good for now

previewWidget.setHtml(content);
// QFile file("/Users/Helling_1/logbuch.html");
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
// return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😁
maybe not in the final version?

// previewWidget.setHtml(in.readAll());

QString repl = QString("<img height=\"30%\" width=\"30%\" src=\"file:///%1/dive_\\1.png\">").arg(printDir.path());
content.replace(QRegularExpression("<div\\s+class=\"diveProfile\"\\s+id=\"dive_([^\"]*)\"\\s*>\\s*</div>"), repl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brute force, but not wrong. And better than making it crazy complex and bringing in more dependencies, maybe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably provide some XSLT to do this in a more robust way, adding support for things like self-closing elements, or additional properties on the element itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See atdotde#5 for a way to do the html transformation with XSLT.

@dirkhh
Copy link
Collaborator

dirkhh commented Jan 11, 2026

clearly missing a widget in order to build...

Copy link
Member

@mikeller mikeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is pulling in some likely unwanted libdivecomputer changes - you probably need to make sure that libdivecomputer is on the latest version of Subsurface-DS9 in your branch.

Signed-off-by: Robert C. Helling <[email protected]>
@github-actions
Copy link

Artifacts:
Subsurface-Linux-AppImage-6.0.5514-patch.5.pull-request.liteprinter
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5514-patch.5.pull-request.liteprinter
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Windows-6.0.5514-patch.5.pull-request.liteprinter
WARNING: Use at your own risk.

@bstoeger
Copy link
Collaborator

If QLiteHtml is supported on all platforms, I would suggest replacing the old code instead of adding ifdef-ery complexity.

previewWidget.setStyleSheet(QString(
"QLiteHtmlWidget"
" { selection-background-color: %1; selection-color: %2; }")
.arg(colorBack).arg(colorText));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does .arg(colorBack, colorText) not work?

Yeah, this is not performance sensitive, but still...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants