Commit graph

310 commits

Author SHA1 Message Date
Simone Gaiarin 0fb2058e2a Make quick annotation tools checkable
CCBUG: 425438
2021-05-10 05:36:29 +00:00
Simone Gaiarin 6b61909ac5 Select quick tool directly without proxying a builtin annotation 2021-05-10 05:36:29 +00:00
Simone Gaiarin 3f18367efd Refactor code for selecting annotation tool 2021-05-10 05:36:29 +00:00
Simone Gaiarin e000489268 Refactor selection of last used annotation tool 2021-05-10 05:36:29 +00:00
Nicolas Fella e73bf99e58 Remove GuiUtils::iconLoader
It's unused
2021-05-05 21:36:34 +00:00
Nicolas Fella b0542ca0b2 Use QIcon::fromTheme instead of GuiUtils::iconLoader
The only relevant behavior of the custom icon loader is the automatic
fallback to <share>/okular/pics, which we can do ourselves with QIcon
API.
2021-05-05 21:36:34 +00:00
Nicolas Fella 1e9711ba37 Add <share>/okular/pics to icon search path
This is automatically done when using KIconLoader, but not when using another QIcon implementation.
2021-05-05 21:36:34 +00:00
Gerd Wachsmuth 6a6b6ca345 Fix bug: select browse tool after trim select 2021-04-25 13:43:18 -06:00
Nicolas Fella ef5254b020 Remove some unused includes 2021-04-25 14:27:46 +02:00
shenleban tongying 1855f9e4b1 Patch: Let form and sign interface to respect the OSD setting 2021-04-23 03:44:44 +00:00
David Hurka 5a58d3bb8e Simplify ToggleActionMenu
* Remove the ImplicitDefaultAction intelligence, so ToggleActionMenu is
  not more than a KActionMenu with setDefaultAction().
* Instead, reset the default action when it gets removed from the menu().
  This is done by filtering QActionEvent from menu().
* Add an autotest for ToggleActionMenu.

This replaces prior efforts to fix problems in ToggleActionMenu
in !245 and !254, following the discussion on the virtual meeting
at 2021-02-26.

6b26a2b4b and 1786e6c99 have already ported PageView and
AnnotationActionHandler to the simplified interface.
2021-04-23 01:54:42 +00:00
Albert Astals Cid 394001017e Merge remote-tracking branch 'origin/release/21.04' 2021-04-22 22:01:23 +02:00
Gerd Wachsmuth f6b58ed804 Fix bug: select browse tool after trim select 2021-04-21 08:01:10 +02:00
Gerd Wachsmuth 61551d2356 Fix: Viewport coords normalized w.r.t. full page
The coordinates in Viewport.rePos are normalized on the full page. In
two functions within pageview.cpp, these were treated as coordinates on
the cropped page.

CCBUG: 198427

This partially fixes the bug 198427 in the case that the cropping of the
target pages (and the pages around the target) is known at the time the
link is clicked. That is, it works if

- One uses 'Trim To Selection'
- One uses 'Trim To Margin' and has already viewed at the target
page(s).

In the case that the cropping of the page at the target is unknown, we
still end up at the wrong position.
2021-04-20 07:48:51 +02:00
Albert Astals Cid 89a90cf0b5 Merge remote-tracking branch 'origin/release/21.04' 2021-04-15 16:44:45 +02:00
Nate Graham dea517bb69 Use icons-only "Show Sidebar" Button with new icon, if available
This commit makes the "Show Sidebar" button that's on the toolbar by
default use the new `sidebar-expand` icon, if present. If not, it falls
back to the old `view-sidetree` icon for compatibility's sake.

We also make thie button icons-only by default, as the new icon is
clearer than the old one. This saves some horizontal space in the
defualt toolbar, which is now quite wide.
2021-04-14 16:31:52 -06:00
Albert Astals Cid e3f5df3154 Signature: Don't show "Reason: Not Available" if there's no signing reason
Reason in this context is
    (Optional) The reason for the signing, such as ( I agree ... ).

But since it's not really obvious what it means, showing
  Reason: Not Available
is probably more weird to users than simply not showing it at all
2021-04-14 22:05:38 +02:00
Albert Astals Cid ff5f4cbc45 Open the signed document on the page with the new signature
It's still not perfect because it probably won't show the signature
since signatures "usually" go to the bottom of the page and we're only
focusing on that page, which means the beginning which depending on zoom
settings may very well not include the signature, but at least it's
closer
2021-04-14 22:05:38 +02:00
David Hurka 6b26a2b4bd Port PageView to simplified ToggleActionMenu 2021-04-11 17:55:51 +00:00
David Hurka 2e1ddaa109 Enable horizontal mouse wrap for Browse tool drag scrolling
Also fixes calculation of wrap edges, where top and bottom edge were swapped.

BUG: 371904
2021-04-11 09:56:41 +00:00
Albert Astals Cid 8a39d598af Merge remote-tracking branch 'origin/release/21.04' 2021-04-10 11:30:02 +02:00
Albert Astals Cid f7ea32c129 Don't call i18n before constructing QApplication
It doesn't work
2021-04-09 21:41:23 +00:00
David Faure 6b3da83f69 Merge remote-tracking branch 'origin/release/21.04' 2021-04-09 23:15:32 +02:00
David Faure c118ab9482 Fix valgrind warning about uninit variables 2021-04-09 12:39:12 +02:00
Nate Graham 0906d5ea0a Merge branch 'release/21.04' 2021-04-08 19:22:15 -06:00
Gerd Wachsmuth 0a23d4a001 Fix a bug with zoom levels on cropped pages
BUG: 342003

Uses ideas of https://bugs.kde.org/show_bug.cgi?id=342003#c5
2021-04-08 22:27:20 +02:00
Mahmoud Khalil aa0d1b459b Fixes changing continuous mode while on tabs issue
Toggling the Continuous mode while opening multiple tabs caused an issue
in Okular, in which it considered it a global setting. So, toggling it
for one document, then toggling it again for the other documents may not
take effect. This should fix it by considering this setting a per
document setting, and therefore toggling the mode for one document
shouldn't have any effect for other documents.

BUGS: 422080
2021-04-07 23:39:55 +02:00
Nicolas Fella 00b60aec24 [print preview] Load okular part directly
The current code goes through KMimeTypeTrader to find a ps or PDF part.
In both cases it's highly likely that it will be okularpart so we can use that directly.
2021-04-06 22:20:01 +00:00
Albert Astals Cid 77269a8025 Merge remote-tracking branch 'origin/release/21.04' 2021-04-05 21:01:05 +02:00
Albert Astals Cid d3b2317ab7 conf: Fix layout warnings
QLayout: Attempting to add QLayout "" to DlgGeneral "", which already has a layout
QLayout: Attempting to add QLayout "" to DlgPresentation "", which already has a layout
2021-04-05 10:35:21 +00:00
Albert Astals Cid 997e1d9137 Fix playing RichMedia annotations
BUGS: 434962
2021-04-05 11:41:02 +02:00
David Hurka 01c240c06d Fix white background flashing up when using Invert Lightness/Luma
These color modes make white background black,
but PagePainter wasn’t updated to draw black background
when pixmaps are not yet available.

BUG: 431372
2021-04-04 14:46:00 +02:00
David Hurka 1786e6c99a Port AnnotationActionHandler’s shape and stamp menus to simplified ToggleActionMenu 2021-03-30 17:04:13 +00:00
David Hurka 67325270ec Fix viewport jumps when drag-scrolling beyond screen edges
This creates CursorWrapHelper, which wraps the cursor
from e. g. top screen edge to bottom screen edge,
and calculates the drag offset from the actual cursor movement.
2021-03-25 12:22:19 +00:00
David Hurka d71929ffda Config dialog: Make screen combo box update in realtime
Makes PreferredScreenSelector repopulate itself when screens are added or removed;
using QApplication::screenAdded/Removed() signals.
2021-03-20 18:34:12 +00:00
Oliver Sander 7ffd08aafb Use device pixel ratio for the correct screen
The method qApp->devicePixelRatio() should only be used under
special circumstances.  The documentation of QGuiApplication says:

  "Returns the highest screen device pixel ratio found on the system.
   [...] Use this function only when you don't know which window
   you are targeting. If you do know the target window,
   use QWindow::devicePixelRatio() instead."

The Okular code used qApp->devicePixelRatio() a few times without
reason.  Few people noticed this, because apparently only Windows
and Wayland can set per-screen dprs.  This patch replaces those
calls with the correct QWindow call.
2021-03-19 07:27:22 +00:00
Oliver Sander ccda6d2a65 Remove device pixel ratio scaling from PixmapRequest
The PixmapRequest constructor expected width and height in logical
pixels, and scaled them to device pixels.  However, not knowing what
screen the request is for, it had to use qApp->devicePixelRatio()
for the scaling.  That value may not be correct if not all screens
use the same scaling.

Fix this by introducing a new constructor that takes the device
pixel ratio as an additional argument, and deprecating the old
constructor.
2021-03-08 00:23:11 +01:00
Albert Astals Cid e3d090e9ab Merge remote-tracking branch 'origin/release/20.12' 2021-03-01 00:37:10 +01:00
Albert Astals Cid 6f5b23290f presentation: Show better the status of the "playing" button
This fixes the issue that it's not obvious how to stop the next page
timer if a pdf has defined a given duration.

BUGS: 432416
2021-02-28 23:05:57 +00:00
Michael Augaitis 9f5c05028d Make ESC key leave fullscreen
BUG: 366276, 417337, 269677
2021-02-09 23:57:47 +00:00
David Hurka 53a9f56668 Presentation config: Replace transitions checkbox by “Instant” item in combobox 2021-02-04 10:24:57 +00:00
David Hurka f69026dd7f Disable KXMLGUI workaround for adding toolbars at ≥ KF 5.78 2021-02-03 13:58:25 +00:00
David Hurka ed87909807 Move “Advance automatically” checkbox to its spin box 2021-01-10 14:52:40 +00:00
David Hurka 7e9b0b09f2 Move “Use custom background color” checkbox to its color button. 2021-01-04 15:46:22 +01:00
Yuri Chornoivan 09075395d7 Fix minor typos 2021-01-02 09:32:40 +02:00
David Hurka 134cbc30d5 Port config dialogs from .ui to QFormLayout
* C++ instead of .ui files.
* Put every control in a QFormLayout row.
* Where possible, use only a single layout, i. e. no nesting.
* Use rows with an empty QLabel as horizontal spacer.
  Content grouping by whitespace instead of group boxes.
* Where group boxes were used for labeling tool managers,
  use a <h3> QLabel instead.
* Where group boxes were used for labeling control groups,
  drop the label or label only the first control (like in Dolphin).
* Use combo boxes instead of radio button groups.
  (I don’t know how to connect radio buttons to KConfigWidgets...)
* Don’t use checkboxes as label, that doesn’t lay out correctly.
  Instead, put the checkbox in an own row, although it controls the same feature.

Some of the changes are not perfect yet, so I opened
https://invent.kde.org/graphics/okular/-/issues/45 to outline further improvements.
2021-01-01 01:09:10 +00:00
Albert Astals Cid 9d0800a57a Merge remote-tracking branch 'origin/release/20.12' 2020-12-27 12:10:55 +01:00
Albert Astals Cid 9e23338b00 Fix opening markdown files
In d2ae2c283d we introduced a tweak that
broke opening markdown files.

what we really want is this:
 * If the mimetype from the filename is text (or children) but looking
   at the data says it's not text, then try opening first opening with
   the data suggeted mimetype
 * But if the data suggested mimetype says it's text, use the filename
   suggested mimetype since for example, the only way to really
   differentiate markdown from text is the filename, so trust that

BUGS: 430538
2020-12-27 00:16:58 +00:00
David Hurka 4c7a2ac60e Connect presentation screen selection to KConfigWidgets
This adds a class PreferredScreenSelector, which is a QComboBox that
holds items for each connected screen, and provides a preferredScreen
property which is accessed by KConfigDialogManager.
This class also allows to remember a disconnected screen by adding
a temporary item “Screen xy (disconnected)”.
2020-12-26 16:50:52 +00:00
Steven Chua 2917e73953 Fix Table Selection polluting clipboard history
The Table Select tool no longer automatically copies its
contents to the clipboard, but only to the selection clipboard.
(Middle-click paste clipboard.) Instead, after creating
the table, the user can right-click to bring up a popup
menu with the action "Copy Table Contents to the Clipboard".
Clicking on this will copy the table contents to the clipboard.
Ctrl+C also works.

BUG: 402110
2020-12-25 13:04:44 +00:00
Albert Astals Cid 110ccd619c Sign: Make 'start over' be actually start over and not cancel 2020-12-15 08:08:06 +00:00
Albert Astals Cid bb97810957 Only show certificates that are still valid when signing
No point in letting people sign a file with a certificate that's no
longer valid
2020-12-14 21:23:41 +00:00
Albert Astals Cid d89b1dfb81 signining: Reference to the manual when there's no certificates available 2020-12-13 21:31:14 +00:00
Albert Astals Cid b642ba5863 Add KUIT marker for "Start Over" 2020-12-13 21:31:14 +00:00
Albert Astals Cid f0aac79ad3 Reword for the "signature too small" text 2020-12-13 21:31:14 +00:00
Albert Astals Cid 0f4be27338 Use the action icon instead of the mimetype icon 2020-12-13 21:31:14 +00:00
Albert Astals Cid 7bbdf9e20a Don't include the moc, makes clang-tidy happier 2020-12-13 21:31:14 +00:00
Albert Astals Cid 33ccbc0449 Signing: Don't say that there are no certificates if the user cancels...
...entering the pwd for the certificate store

Also Move CertificateStoreImpl to PopplerCertificateStore, since
PopplerCertificateStore was declared but never defined and use it
in CertificateTools to get the certificate list instead of calling
the poppler classes directly
2020-12-13 21:31:14 +00:00
Albert Astals Cid 242718a9a2 Only ask for certificate password if really needed 2020-12-13 21:31:14 +00:00
Albert Astals Cid 49f784ecf9 When signing save to a new file, not over the current one 2020-12-13 21:31:14 +00:00
Albert Astals Cid 5d15203682 Signature: We don't need to pass the page number anymore 2020-12-13 21:31:14 +00:00
Albert Astals Cid be50f03acf Pass the pageview to the signature annotator
This way we don't use nullptr as part for the dialogs, it's always a bit
ugly to do so
2020-12-13 21:31:14 +00:00
Albert Astals Cid bd00acb5c4 Warn if the signature we're trying to create is too small 2020-12-13 21:31:14 +00:00
Albert Astals Cid 9728d8b426 We don't do getFoo in Okular API 2020-12-13 21:31:14 +00:00
Albert Astals Cid a4030a20f5 Properly cancel the signature mode if we don't add one 2020-12-13 21:31:14 +00:00
Albert Astals Cid 6325a4fe0b Make sure you have no unsaved changes before saving 2020-12-13 21:31:14 +00:00
Albert Astals Cid a5df71a79a Sign -> Digitally Sign
And remove from toolbar, it's not that important it should be there

Also increase version
2020-12-13 21:31:14 +00:00
Albert Astals Cid 18ef1349f1 Improvements to adding digital signatures
* Don't make WidgetAnnotation know about signatures stuff, widget
   annotations are for multiple things
 * Don't create an "empty" widget annotation and then call sign on it
   (which is wrong because widget annotations can be multiple things),
   just say sign the document with this data (cert, l&f, etc)
 * Remove the "management" functionality from CertificateTools it was
   only visual, i.e. it didn't really add/remove certificates
 * Ask for the NSS password (if needed)
2020-12-13 21:31:14 +00:00
Albert Astals Cid 43900fe56e Warn the user if there's no availabe signing certificates 2020-12-13 21:31:14 +00:00
Albert Astals Cid b09e23f6ab Run clang-format
Attempting to fix the whole chain of commits is not worth it
2020-12-13 21:31:14 +00:00
Thorsten Behrens b52adfeaee Fix more clang-tidy unhappines 2020-12-13 21:31:14 +00:00
Katarina Behrens 20b34d00c9 Make clang-tidy happier 2020-12-13 21:31:14 +00:00
Thorsten Behrens e9577f5f7d Properly set signature annotation bounds after insertion 2020-12-13 21:31:14 +00:00
Thorsten Behrens 9bca008f9d Init m_signatureMode in ctor 2020-12-13 21:31:14 +00:00
Thorsten Behrens 3eedb21a83 Consistenly use CERT nick to refer to signing key 2020-12-13 21:31:14 +00:00
Thorsten Behrens f7d6045b92 Add poppler NSS support
Move certificate config down into generator code
Read available signing certificates from poppler NSS
2020-12-13 21:31:14 +00:00
Thorsten Behrens ae2c6a55c2 Fix crash on invalid engine 2020-12-13 21:31:14 +00:00
Thorsten Behrens b96dac6df3 Add certificate store for access to NSS keys
WIP - add interfaces and methods to get access to NSS-via-poppler
sign certificates, and provide them for signing documents.
2020-12-13 21:31:14 +00:00
Thorsten Behrens 847b423e2a Add better diagnostics 2020-12-13 21:31:14 +00:00
Thorsten Behrens e3e582ee5c Add feature flag for poppler signing API
Test and conditionally-compile pdf signing feature, depending
on poppler new-ness.
2020-12-13 21:31:14 +00:00
Katarina Behrens b33a12d786 Prompt for password and stick it to widget annotation 2020-12-13 21:31:14 +00:00
Katarina Behrens 45fc7cd805 Read the certificates from configuration 2020-12-13 21:31:14 +00:00
Katarina Behrens 38c5b614b4 Simplify adding certificates to config and implement edit slot 2020-12-13 21:31:14 +00:00
Katarina Behrens cc908b9f92 Pass pointer to widget annotation just added down the chain 2020-12-13 21:31:14 +00:00
Katarina Behrens 66f2bff5ca Pass bounding rectangle down the chain 2020-12-13 21:31:14 +00:00
Katarina Behrens d320fa17ad Stub some iface for signing the document 2020-12-13 21:31:14 +00:00
Katarina Behrens c560a4a20e Eventually hide the message window 2020-12-13 21:31:14 +00:00
Katarina Behrens 48dc3779f7 Add empty widget annotation 2020-12-13 21:31:14 +00:00
Katarina Behrens b2c5aa61d7 Read/write certificate settings 2020-12-13 21:31:14 +00:00
Katarina Behrens dd0c06a82b Signature mode must eventually end 2020-12-13 21:31:14 +00:00
Katarina Behrens 6cff306bab Making 'Sign' button a toggle was a bad idea 2020-12-13 21:31:14 +00:00
Katarina Behrens 3330f8407a Open filepicker to select p12, pfx file to add to user identity 2020-12-13 21:31:14 +00:00
Katarina Behrens 242710cae7 Recycle WidgetConfigurationToolsBase for certificate management dlg 2020-12-13 21:31:14 +00:00
Katarina Behrens 060175735f Open certificate selection dialog on mouse release 2020-12-13 21:31:14 +00:00
Katarina Behrens 339ce239f5 Draw an initial rectangle where to place the signature 2020-12-13 21:31:14 +00:00
Katarina Behrens b5117aff6c Add slot for 'Sign' button, shows info overlay so far 2020-12-13 21:31:14 +00:00
Katarina Behrens 888d287f1f Add 'Sign' button to toolbar 2020-12-13 21:31:14 +00:00
Katarina Behrens 69ddb957f1 Add config page to configure signing identities/certificates 2020-12-13 21:31:14 +00:00
Katarina Behrens 2845db76fb Add 'Sign' menu entry 2020-12-13 21:31:14 +00:00
Laurent Montel 3f58639e06 operator+/- is disabled for QFlags in qt6 2020-12-09 08:34:49 +01:00
Friedrich W. H. Kossebau 48891b7203 ui.rc files: consistently use <gui> instead of deprecated <kpartgui> 2020-11-28 17:29:11 +01:00
Albert Astals Cid 6f761b9e3a Merge remote-tracking branch 'origin/release/20.12' 2020-11-27 00:29:36 +01:00
Albert Astals Cid 239827baad Rework how we open urls that have a #
Previously if it was a remote url that had # and a . after the # we
assumed the url had no fragment and everything was filename.

We don't do that anymore, what we do now is try to open the url as
parsed, i.e. before the # is the filename after is the fragment, and if
that fails we try to open everything as filename and nothing as
fragment.

Unfortunately given how kpart internals handle opening local vs remote
urls we need to do this in two places.

Also we have to remove the test that checked that the url was mangled at
the shell level because we don't do that anymore. Unfortunately can't
add a test for the new codepage since it would involve starting an http
server ^_^

Filenames:
  source2e.pdf
  foo#bar.pdf

What works:
 * okular http://localhost/source2e.pdf#subsection.68.3
 * okular file:///srv/http/source2e.pdf#subsection.68.3
 * okular source2e.pdf#subsection.68.3 (in the /srv/http folder)
 * okular source2e.pdf#2
 * okular http://localhost/foo#bar.pdf
 * okular file:///srv/http/foo#bar.pdf
 * okular foo#bar.pdf (in the /srv/http folder)

What doesn't work:
 * okular http://localhost/foo#bar.pdf#2

I think it's a fair limitation that if you want to open a file that contains # in the name and also use a # page marker you need to use the encoded url like okular http://localhost/foo%23bar.pdf#2
after all things like firefox will totally fail opening http://localhost/foo#bar.pdf and will just work if you give the encoded url

BUGS: 426976
2020-11-26 10:07:58 +00:00
Albert Astals Cid 023976ccfd Show annotation tip when selecting the tool in continuous mode
BUGS: 426782
2020-11-26 09:12:21 +00:00
Albert Astals Cid d2ae2c283d More fine tuning of the mime of the opened file
In fba90677fc we introduced a "if we're
told this is a text file let's check the mime of the content only since
text files never fail to open".

This extends it to anything that inherits from text now, so if you
rename a PDF file to bla.php it still tries to open as a pdf first and
if that files as a php file
2020-11-25 22:41:34 +00:00
Nate Graham 49a7caf64c Merge branch 'release/20.12' 2020-11-20 12:01:00 -07:00
David Hurka c6a3275151 Fix QScroller crash on Qt < 5.14 and certain screen arrangements
QScrollerPrivate::setDpiFromWidget() before Qt 5.14 crashes
when the target widget does not intersect a physical screen,
because QDesktopWidget returns screen index `-1` in this case,
which leads to an out-of-range read from QApplication::screens(),
which leads to a segfault when reading from an invalid QScreen* pointer.

This adds a workaround that checks for the `-1` situation,
and then tries to resize PageView temporarily to intersect at least some screen.

BUG: 425188
FIXED-IN: 20.12
2020-11-20 18:01:20 +00:00
Alex Rosca 8ae95b29c8 Avoid unintentional accelerating flicks by reducing maximum flick time
When making a flick using the mouse or the touchscreen and then slowly
dragging the pages in the same direction with the flick, it unintentionally
reenters the flicking state after a mouse button release and it's quite
annoying. The commit reduces the maximum time before the next flick.

Steps to reproduce:
1) Flick in direction A.
2) While the view is coasting, decide that you want to stop close to the current position.
3) Grab the view (still coasting), and drag it slowly in direction A.
4) When you reached the desired point, stop your movement, and release the view.
5) QScroller interprets this release as “accelerating flick”,
   and makes the view coast faster in direction A.

Upstream bug is QTBUG-88249; QScroller ignores MinimumVelocity for accelerating flicks.
2020-11-20 17:54:07 +00:00
David Hurka a83261db92 Merge branch 'release/20.12' into master 2020-11-18 20:35:53 +01:00
David Hurka 19d5dd8ec7 New part/ directory for okularpart sources from /, ui/, conf/
Source files are no longer separated by UI and non-UI and similar,
but only by their build target.

* ui/ -> part/
* Move all source files from conf/ to part/
* Keep config skeleton definitions in conf/, needed for the mobile target too
* Move editdrawingtooldialogtest.h from conf/autotests/ to autotests/
* ui/data/icons/ -> icons/
* Move /part.cpp, /part.rc and similar files to part/
* Adapt include paths in source files
* Adapt CMakeLists.txt files (in / and in subdirectories)
* Adapt /Messages.sh
2020-11-18 19:32:56 +00:00