Skip to content

Instantly share code, notes, and snippets.

@vvasabi
Last active February 24, 2016 11:28
Show Gist options
  • Save vvasabi/8046477 to your computer and use it in GitHub Desktop.
Save vvasabi/8046477 to your computer and use it in GitHub Desktop.
Make it possible to make CutyCapt output pngs with transparent background. Just add --no-background=on in parameter.
Index: CutyCapt.cpp
===================================================================
--- CutyCapt.cpp (revision 10)
+++ CutyCapt.cpp (working copy)
@@ -363,6 +363,7 @@
" --js-can-access-clipboard=<on|off> Script clipboard privs (default: unknown)\n"
#if QT_VERSION >= 0x040500
" --print-backgrounds=<on|off> Backgrounds in PDF/PS output (default: off) \n"
+ " --no-background=<on|off> Transparent background (as opposed to white background) (default: off) \n"
" --zoom-factor=<float> Page zoom factor (default: no zooming) \n"
" --zoom-text-only=<on|off> Whether to zoom only the text (default: off) \n"
" --http-proxy=<url> Address for HTTP proxy server (default: none)\n"
@@ -543,6 +544,13 @@
} else if (strncmp("--links-included-in-focus-chain", s, nlen) == 0) {
page.setAttribute(QWebSettings::LinksIncludedInFocusChain, value);
+ } else if (strncmp("--no-background", s, nlen) == 0) {
+ if (strcmp("on", value) == 0) {
+ QPalette palette = page.palette();
+ palette.setBrush(QPalette::Base, Qt::transparent);
+ page.setPalette(palette);
+ }
+
#if QT_VERSION >= 0x040500
} else if (strncmp("--print-backgrounds", s, nlen) == 0) {
page.setAttribute(QWebSettings::PrintElementBackgrounds, value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment