Qt Stylesheet, etc

Asked by Oli Gilo on 2017-12-07

I converted from Zathura to qpdfview yesterday but I am having trouble adjusting a number of the features in order to settle.

That^ line was, of course, meant to follow my expression of gratitude for developing/maintaining this application.

So here are the items that I am trying to achieve:

1- declare Semicolon as a keyboard shortcut in order to shift the Vim-style navigation keys to the right by two (Emacs reasons);
2- hide both vertical and horizonal scroll bars (I tried a few Qt stylesheet formats/expressions but none worked --I'm new to Qt);
3- enable smooth scrolling;
4- set the foreground/dark (text and maybe images too) and background/ligh colors to specific color codes as in Okular and Zathura (I suppose this entails performance degradation but it makes for closer-to-seamless transition from terminal to pdfs, especially in tiling window managers).

That last (two) item(s) probably need adjustments/additions to the source code, but I was hoping you could at least point me in the right direction to make it so.

Thank you,

Question information

English Edit question
qpdfview Edit question
No assignee Edit question
Solved by:
Adam Reichold
Last query:
Last reply:
Best Adam Reichold (adamreichold) said : #1

Hello Oli,

I am glad if you find the application useful. Concerning you questions:

ad 1: This seems to be a limitation in parsing strings using QKeySequence, but you should be able to accomplish this by manually editing ~/.config/qpdfview/shortcuts.conf and setting the desired key to ";", meaning e.g. moveUp=";" including the quotes.

ad 2: Everything that is possible should be described at [1], but I think scroll bar visibility which is governed by a dynamic policy can only be controlled via C++ code.

ad 3: I am not sure this is currently possible with plain Qt Widgets, i.e. it would need to be implemented in qpdfview itself or using a third-party library.

ad 4: Have a look at the RenderFlags type and the implementation of the method RenderTask::run where the currently supported effects like trimming margins or blending the paper color are implemented. It should be reasonable simple to extend these but if you have any questions, feel free to ask here or on the mailing list.

Best regards, Adam.

[1] https://doc.qt.io/qt-5/stylesheet-reference.html

Oli Gilo (oligilo) said : #2


Thank you for your response. As per your suggestions:

1. I was able to modify the shortcuts following your method.

2. I was able to bind hiding the scroll bars to a shortcut but only after changing the way horizontal scrolling is handled in the code.

3. It is allegedly possible to implement the so-called 'kinetic scrolling' in Qt5 using the QScroller class but I'm new to Qt so.. :)

4. I was able to fashion a preliminary version of this by rewriting the 'convertToGrayscale' function; it is reasonably performant but I'm not quite satisfied with the way it handles color/shade gradients (I'm using a threshold) as well as the way it follows/interacts with antialiasing (for text on gray (as opposed to white) backgrounds).

I'll update you when I have a better handle on #4.

Best regards,

Oli Gilo (oligilo) said : #3

Thanks Adam Reichold, that solved my question.

Adam Reichold (adamreichold) said : #4

Hello again,

I am glad you where able to resolve your issues at least partially. I would be very glad if/when you submit your changes for upstream inclusion. If would be even more glad if you could try to use Launchpad's merge request functionality and open several merge requests for the distinct changes, e.g. scrollbar hiding, kinetic scrolling and color modifications. (Also if you want, I can look into using QScroller: I was just not aware of it until now and I could try preparing that particular merge request.)

Best regards, Adam.

Oli Gilo (oligilo) said : #5

I sure will. I'm not familiar with the Bazaar system but that's a matter of time. I'll submit a merge for hiding scrollbars and give kinetic scrolling another try before admitting defeat. As for color modifications, I was thinking of incorporating it into a separate per-document settings dialog along with other such options/features.

Louis (louisgag) said : #6

Dear Adam,
I don't know if the smooth scrolling has been implemented (did Oli commit the changes?), because I'm only using the packaged version of qpdfview, but I would nonetheless add my vote for it as a feature as it is quite useful to me.
Thanks for making this great pdf viewer.
Kind regards,

Adam Reichold (adamreichold) said : #7

Hello Louis,

no changes for kinetic scrolling have been proposed for merging so far. So sorry, but there does not seem to be anything in the works at the moment. I created a separate wish list bug to track this.

Best regards,