Commit graph

1756 commits

Author SHA1 Message Date
Yuri Chornoivan
5478b2ec92 Fix minor typos 2018-11-14 21:12:15 +02:00
Albert Astals Cid
16c25fbb33 Draw non-external text annotations with word wrap
Summary:
Instead of with wrap anywhere

BUGS: 398604

Reviewers: cfeck

Reviewed By: cfeck

Subscribers: sander, tobiasdeiminger, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D16147
2018-11-09 00:25:23 +01:00
Albert Astals Cid
ec692e459b Remove unused variables 2018-11-02 18:03:26 +01:00
Yuri Chornoivan
d3388cd6a1 Port away from deprecated setClearButtonShown 2018-10-28 12:49:50 +02:00
Nate Graham
33ca396def Create new "Zoom to 100%" action
Summary:
This patch implements a "Zoom to 100%" action and sticks it in the {nav View} menu. Since it's a `KStandardAction` with a `KStandardShortcut`, we automatically get the correct icon and keyboard shortcut, but we do override the name to be "Zoom to 100%" since that's clearer for Okular's use case.

FEATURE: 400048
FIXED-IN: 18.12.0

Test Plan:
- Action works to zoom the document to 100% scale when invoked
- Action is disabled when document is opened at 100% scale or is manually zoomed to 100% scale after being opened
- All other zoom modes and action still work

{F6341045}

Reviewers: #okular, #vdg, abetts

Reviewed By: #vdg, abetts

Subscribers: davidhurka, sander, tobiasdeiminger, veqz, abetts, aacid, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D16345
2018-10-27 08:49:50 -06:00
Yuri Chornoivan
2f014ccd20 Fix minor EBN issues 2018-10-18 22:04:49 +03:00
Dileep Sankhla
e44ff38706 Support setting text color for typewriter annotations
Summary:
Changing typewriter text color can be done in the typewriter properties dialog, or programmatically via new okular API methods TextAnnotation::textColor and TextAnnotation::setTextColor.

poppler >= 0.69 is required to store text color natively inside PDF documents. For other document types, text color is stored as metadata inside the document archive.

This work was done during GSoC 2018. See https://community.kde.org/GSoC/2018/StatusReports/DileepSankhla for details.

Test Plan:
- properties dialog of typewriter annotation has "Font Color" picker
- saving to PDF results in <r> <g> <b> rg operation in /DA
- saving to archive results in fontColor="rrggbb" attribute in metadata.xml

Reviewers: sander

Reviewed By: sander

Subscribers: kde-doc-english, sander, okular-devel

Tags: #okular, #documentation

Differential Revision: https://phabricator.kde.org/D15205
2018-10-04 20:02:55 +02:00
Dileep Sankhla
6dd7cf662d Add typewriter annotation tool
Summary:
Typewriter is originally specified by the PDF reference as special FreeText annotation, where Intent=FreeTextTypewriter. It features opaque letters on transparent background, so that users can fill non interactive forms. Herewith typewriter is implemented natively for PDF, and there's also an Okular specific implementation for other document types. The added tool reuses the inline note UI.

This work was done during GSoC 2018. See https://community.kde.org/GSoC/2018/StatusReports/DileepSankhla for details.

FEATURE: 353401

Test Plan:
- okularpartrc is generated (if not yet existing) with typewriter as 10th tool
- typewriter tool is also available in Annotation Tools -> Add, Typ "Typewriter"
- selecting the tool and left click into document opens inline note input dialog
- finishing creates an annotation similar to inline note, but with transparent background
- saving into PDF results in /Subtype FreeText /IT /FreeTextTypeWriter
- saving typewriter into archive stores color with alpha channel = 0x00
- opening annotated archive works, if archive was created with old Okular, and opened in patched Okular
- opening annotated archive works, if archive was created with patched Okular, and opened in old Okular

Reviewers: sander

Reviewed By: sander

Subscribers: ngraham, sander, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D15204
2018-09-25 22:47:01 +02:00
Tobias Deiminger
61e8b1d79d Merge remote-tracking branch 'origin/Applications/18.08' 2018-09-18 21:34:58 +02:00
Tobias Deiminger
fa7a1b3d06 Avoid undefined behavior due to dangling file descriptor
Summary:
We request a inhibit lock of DBus type UNIX_FD from systemd logind. It's wrapped into (and owned by) a QDBusUnixFileDescriptor object of automatic storage. The file descriptor will be closed in QDBusUnixFileDescriptor Dtor, and may be reused by some other facility (e.g. pulseaudio).

If we want to store the lock longer than QDBusUnixFileDescriptor lifetime, we have to dup the file descriptor. If we don't dup, and close the original fd later in PresentationWidget::allowPowerManagement, bad things may happen.

Besides that, what we get from systemd is really a file descriptor, not a "cookie". So I renamed the m_sleepInhibitCookie to m_sleepInhibitFd and changed initial state to -1 accordingly.

BUG 393478
BUG 398720

Test Plan:
- bugs don't occur any longer
- inhibiting sleep during presentation mode still works

Reviewers: aacid

Reviewed By: aacid

Subscribers: ngraham, anthonyfieroni, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D15574
2018-09-18 21:33:55 +02:00
Oliver Sander
b763bdba7a Simplify memory management of two private data members
- Use a QPixmap object instead of a QPixmap*
  Quote from the QPixmap documentation:
  "QPixmap objects can be passed around by value
   since the QPixmap class uses implicit data sharing."

- Replace another pointer by std::unique_ptr

Differential Revision: https://phabricator.kde.org/D15301
2018-09-12 14:17:30 +02:00
Dileep Sankhla
d61cef693d Store all annotation color attributes as ARGB string
Summary:
This is mainly preparation for D15204 (typewriter), where storing RGB won't be sufficient any longer.
Typewriter will need transparent background (alpha=0x00), which can only be expressed as ARGB string.

Current code handles name format identical for all annotations. It doesn't hurt to store all annotations in ARGB format, so instead of introducing special handling for typewriter, let's store all annotation color attributes as ARGB string.

Note: In case of previously existing okularpartrc, configuration will be reused without conversion. New color format will be written when new settings are saved. This has no bad effect.

Test Plan:
- when [Reviews] section in okularpartrc is initially generated, all annotation color attributes are in #AARRGGBB format
- saving into archive stores color with alpha channel (#AARRGGBB), for all kind of annotations

Reviewers: sander

Reviewed By: sander

Subscribers: dileepsankhla, sander, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D15279
2018-09-07 18:33:16 +02:00
Yuri Chornoivan
39b6e8147d Fix minor EBN issues 2018-09-01 11:25:57 +03:00
Yuri Chornoivan
c04ca1fa96 Fix minor EBN issues 2018-08-31 12:23:45 +03:00
Oliver Sander
81ac73fcf5 Show tooltips when hovering over links in mouse selection modes as well.
Previously, these tooltips were only shown in "Browse mode".
This patch adds them for "Selection", "Text selection", and
"Trim selection" as well.  These are the modes where the cursor
changes to a hand when hovering over a link.

BUG: 397783

Differential Revision: https://phabricator.kde.org/D15123
2018-08-29 13:32:05 +02:00
Peter Wu
61c2c2cedd TOC: Add collapse/expand options
Large specifications with many (nested) sections are painful to navigate
through when the TOC is expanded by default. Introduce four new options,
"Expand/Collapse whole section" is based on Kate's document view while
"Expand/Collapse all" was added to handle the top-level sections.

As for other viewers, PDF.js uses shift-click to handle the former while
using double-click on a the TOC icon to handle the latter. That is not
very obvious, so extending the context menu seems the next best option.

BUG: 216870

Differential Revision: https://phabricator.kde.org/D14904
2018-08-26 14:05:26 +02:00
Yuri Chornoivan
c7722c4078 Fix minor EBN issues 2018-08-17 21:05:01 +03:00
Ahmad Osama
5e622484c8 Fix problem of saving pdf switches from thumbnail view in sidebar to contents view
Summary:
When save/save as functions are called they internally call the openFile() function, in the open file function the side bar item is set to Table of Contents (ToC) item

```
if ( m_document->metaData( QStringLiteral("OpenTOC") ).toBool() && m_sidebar->isItemEnabled( m_toc ) && !m_sidebar->isCollapsed() && m_sidebar->currentItem() != m_toc )
{
     m_sidebar->setCurrentItem( m_toc, Sidebar::DoNotUncollapseIfCollapsed );
}
```
so I just store the sidebar's item before saving and then set this item back if changed.

BUG: 389668

Reviewers: #okular

Subscribers: aacid, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D14740
2018-08-13 11:13:00 +02:00
Albert Astals Cid
aed8e5ac28 Fix crash on shutdown when having edited text forms
This fixes the same crash as bug 393334 but in a better way
the old way was setting a variable on destruction and then trying
to use that variable in a slot, but that's obviously wrong since
we were already mid destructing the object.

BUG: 396807
2018-07-28 22:39:30 +02:00
Michael Eden
031b794ec8 Expose 'change colors' through dbus interface
Summary:
This exposes the Okular's functionality of changing the document's colors
through its d-bus interface. This is mainly useful for scripting Okular to
switch to a 'day mode' or 'night mode'.

[Example] Switching themes of two applications with one hotkey:

{F5905771}

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D13471
2018-06-26 13:05:45 +02:00
Andre Heinecke
18d404c3ee Support additional widget actions in PDF Forms
Summary:
This adds support for actions associated with form fields
through corresponding annotation widgets.

Test Plan:
Still needs a unit test, only tested manually with
the document attached in the task.

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: okular-devel, aacid

Tags: #okular

Maniphest Tasks: T8627

Differential Revision: https://phabricator.kde.org/D12665
2018-05-30 10:04:21 +02:00
Oliver Sander
004efa70e4 Draw a dark rectangle around highlighted search results
Summary:
BUG: 355043

Makes it easier to distinguish search results from text with a 'highlight' annotation.

Reviewers: #okular

Subscribers: okular-devel, simgunz, cfeck, aacid, ngraham

Tags: #okular

Differential Revision: https://phabricator.kde.org/D7662
2018-05-18 17:27:28 +02:00
Simone Gaiarin
48b9ca66a6 Raise annotation window when clicking on annotation
Summary:
Raise annotation window when clicking on the window title, window text edit, or the associated annotation.

BUG: 388532

Reviewers: #okular, aacid

Subscribers: okular-devel, ngraham, #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D10792
2018-05-18 15:17:58 +02:00
Albert Astals Cid
33a2eaf3c4 Merge remote-tracking branch 'origin/Applications/18.04' 2018-04-22 19:46:41 +02:00
Albert Astals Cid
3cea7c9927 Fix crash on exit when having edited a text area
For some reason Q/KTextEdit is sending textChanged inside the
destructor, so protect us from that.

BUG: 393334
2018-04-22 19:46:04 +02:00
Simone Gaiarin
cbc6f671e3 Change annotation type name when an annotation is associated to non-empty popup
Summary:
Mark the annotations that contain a non-empty popup. Especially useful to identify annotations that are not meant to contain an annotation as shapes or highlights.

BUG: 389836

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: rkflx, aacid, ngraham

Tags: #okular

Differential Revision: https://phabricator.kde.org/D10797
2018-04-20 19:43:14 +02:00
David Edmundson
804d0bd42a Fix rubber band selection drawing contents misaligned with scaling
Summary:
in drawPixmap(source, sourceRect) the source rect is in native pixels.

In this code the size was scaled by the DPR, but the location was not.
blendRect is the contents of a selection rectangle, offset from the
bounding darker blue rectangle. Hence we haven't really noticed.

This completely fixes the rectangle when the scale == 2.0/3.0

Some smaller artifacts remain on fractional scale factors, which is a
separate code bug with the same symptoms.

CCBUG: 386111

Reviewers: aacid, rkflx

Reviewed By: rkflx

Subscribers: sander, rkflx, anthonyfieroni, #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D8980
2018-04-09 22:58:37 +01:00
Fabian Kosmale
c70485cd74 use correct filepath
Summary:
Seems like someone forgot to consistently apply a change. Maybe the path
construction should be factored into a reusable lambda?

Test Plan:
Open Okular, open settings > configure Okular. Without the patch, you'll get a
"QFSFileEngine::open: No file name specified" warning, with the patch it
disappears. Note that there is also an unrelated "Illegal icon group:  7"
warning from KIconThemes, but I'm 99% certain that this is on KIconThemes doing
a bogus check in KIconEffect::apply, not on Okular

Reviewers: #okular, hetzenecker, aacid

Reviewed By: #okular, aacid

Subscribers: aacid, #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D12001
2018-04-07 01:14:50 +02:00
Albert Astals Cid
09109dd649 Fix Presentation Mode VideoWidget sizing
This fix smells a lot like a workaround for a bug in Qt but i could not
write down a sufficiently small testcase for it to report it to Qt, and
this is not wrong anyway since we eventually add playerPage to a
layout for this. What I tracked down was that since playerPage had no
parent, at some point a nativeId for it was being created and that
broke sizing back to the default 100x30 used in Qt instead of the
size we had given it.

For some reason i needed a PDF file with more than one video to
reproduce this problem, the first video was correctly sized but the
second one was 100x30.
2018-04-02 21:21:09 +02:00
Andre Heinecke
8ed1d14f8d Fix CheckBox script usage
Summary:
This implements setting / getting the value of buttons,
which is important for checkboxes in scripts. It also moves
the checkbox activate action after the value is set so that
the correct value is used when the activation script is
executed.

Reviewers: #okular

Tags: #okular

Maniphest Tasks: T8097

Differential Revision: https://phabricator.kde.org/D10868
2018-03-20 23:19:29 +01:00
Andre Heinecke
5c04f0834d Implement generic version of Form Widgets refresh
Summary:
The FormWidgetInterface now has a generic slotRefresh that
refreshes what all widgets have in common. This is the read-only state for now.

Reviewers: #okular

Tags: #okular

Maniphest Tasks: T8097

Differential Revision: https://phabricator.kde.org/D10866
2018-03-20 23:14:18 +01:00
Andre Heinecke
42717e1ae8 Access readOnly state of FormWidgets dynamically
Summary:
This is more of a cleanup patch that removes the obsolete m_canBeEnabled
member variable which was a leftover IMO from a time where readOnly fields were
shown as disabled. readOnly fields are invisible, not disabled, and the code no longer assumes that
readOnly does not change over time.

Test Plan: Tested manually and with a unittest which is part of the series.

Reviewers: #okular

Subscribers: aacid

Tags: #okular

Maniphest Tasks: T8097

Differential Revision: https://phabricator.kde.org/D10865
2018-03-20 23:14:12 +01:00
Albert Astals Cid
aecd77d4a9 Merge remote-tracking branch 'origin/Applications/17.12' 2018-02-25 19:17:56 +01:00
Tobias Deiminger
3c4f16ea4b Fix crash due to dangling pointer in MouseAnnotation
Summary:
BUG: 388228

Diff applies to Applications/17.12, and should be easy to merge to master. It's kept quite minimal as suggested by Albert.

Albert also suggested to add a dedicated unit test and I'd agree, but am not yet sure how to do it. The original bug involves several classes, including UI: Document, Page, AddAnnotationCommand, PageView, PageViewAnnotator, MouseAnnotation - to name a few. So a test for the exact bug scenario would become a bigger integration test rather than an isolated unit test. The other approach would be to do a real unit test on MouseAnnotation. But again, MouseAnnotation has nasty dependencies (e.g., needs a parent PageView) which I'd have to mock. Any ideas? I'd be interested in a discussion on this topic.

Test Plan:
 # Load a document (e.g. [[ http://www.philipebert.info/resources/WhatMathematicalKnowledgeCouldNotBe.pdf | linked PDF from bug report ]]) and enable highlight toolbar (F6).
 # Create highlight annotation.
 # Move the view port so that the annotation position is right beside the highlight tool icon.
 # Move the mouse over the annotation, and then horizontally left until you reach the tool icon; it's important to stay over the highlight annotation as long as in viewport.
 # Press ctrl-z for undo.
 # Click on highlight tool, move right into the document, create new highlight annotation.
 # Okular doesn't crash.

Reviewers: #okular

Subscribers: aacid, ngraham

Tags: #okular

Differential Revision: https://phabricator.kde.org/D9852
2018-02-25 19:11:17 +01:00
Andre Heinecke
d50c06df25 Add refresh widgets if underlying field changes
Summary:
If a field is updated because of a calculate form action /
a script execution, not only refresh the rendered pixmap but
also the corresponding formWidget.

Test Plan: Unittest in separate revision. Tested it manually, too.

Reviewers: #okular

Subscribers: aacid

Tags: #okular

Maniphest Tasks: T7805

Differential Revision: https://phabricator.kde.org/D10048
2018-02-22 00:12:34 +01:00
Dileep Sankhla
1e80804c1b Use correct arrow cursor for Annotations' close buttons
Summary:
When hovering the mouse over the X symbol to close a note the cursor remains the same of the current shape (hand, selection cursor) based on the tool selected.
This patch morphe the cursor to the standard arrow over the X symbol to close a note by adding setCursor() call in the CloseButton constructor

 BUG: 384381

Test Plan:
1.  Open okular and select Tools -> Review or press F6 to create a new pop-up note
2. Hover the mouse cursor over the close button (X) of the pop-up note window
3. You will see the standard arrow instead of the current tool based cursor.

Screenshot below (the tooltip saying "Close this note" was not captured by Spectacle application)
{F5685539}

Reviewers: #okular, ngraham

Reviewed By: ngraham

Subscribers: ngraham, #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D10209
2018-01-31 11:02:17 -07:00
Dileep Sankhla
de56b9c9c1 Use correct arrow cursor for Annotations' close buttons
Summary:
When hovering the mouse over the X symbol to close a note the cursor remains the same of the current shape (hand, selection cursor) based on the tool selected.
This patch morphe the cursor to the standard arrow over the X symbol to close a note by adding setCursor() call in the CloseButton constructor

 BUG: 384381

Test Plan:
1.  Open okular and select Tools -> Review or press F6 to create a new pop-up note
2. Hover the mouse cursor over the close button (X) of the pop-up note window
3. You will see the standard arrow instead of the current tool based cursor.

Screenshot below (the tooltip saying "Close this note" was not captured by Spectacle application)
{F5685539}

Reviewers: #okular, ngraham

Reviewed By: ngraham

Subscribers: ngraham, #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D10209
2018-01-31 10:58:07 -07:00
David Edmundson
ab433f701a Fix highlight/annotation clipping with Qt scaling
Summary:
pixelValue/pixelValue will give us a normalised value.

Normalised values shouldn't be modified by a device pixel ratio.
We want scaledRect not dScaledRect.

BUG: 386110

Test Plan:
Searched for text. Zoomed in, panned about
Created annotations, they still seemed to work

Subscribers: #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D8832
2017-11-23 23:29:47 +00:00
David Edmundson
1a3dc7d8e0 Fix highlight/annotation clipping with Qt scaling
Summary:
pixelValue/pixelValue will give us a normalised value.

Normalised values shouldn't be modified by a device pixel ratio.
We want scaledRect not dScaledRect.

BUG: 386110

Test Plan:
Searched for text. Zoomed in, panned about
Created annotations, they still seemed to work

Subscribers: #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D8832
2017-11-23 23:04:16 +00:00
Albert Astals Cid
19b7e3c112 The work in this branch was sponsored by LiMux
give them some credit in the headers
2017-11-16 09:58:31 +01:00
Albert Astals Cid
0da737a92b Merge remote-tracking branch 'origin/master' into dont-use-docdata-for-annots-and-forms 2017-11-03 10:03:00 +01:00
Alexey Demennikov
d679b3c9f2 Set the columns in "Overview" mode to match the amount of pages if document is small
Summary:
FEATURE: 355283

The principle is simple. This patch enables overriding the default columns for Overview mode, if the document is small. For example, if document has 1 or 2 pages and the default columns in Okular settings is 3, Overview mode will enable 1 or 2 columns for better UX

Reviewers: #okular, rkflx, ngraham

Reviewed By: rkflx, ngraham

Subscribers: ltoscano, aacid, rkflx, ngraham

Tags: #okular

Differential Revision: https://phabricator.kde.org/D8385
2017-10-28 21:20:10 +02:00
Albert Astals Cid
ca5422d0e9 Implement swapBackingFile for the PDF backend
How does it work:
 * What it does is really closing and opening the file again through poppler
 * This means that things that are generated in "open" time like Page, Rects, Annotations, Forms need to be updated
	* For Page what we do is swap the PagePrivate so that other classes that hold Page* don't break
		* Since some parts of the PagePrivate can be reused, we move them in PagePrivate::adoptGeneratedContents
	* For all the commands in the undo stack we need to update the annotations/forms it refers to, added a new function to do that
	* The annotationmodel needs updating it's pointers
	* The widgets for the forms are reused and their form* updated
	* the widgets for the videos are recreased since videos don't really hold much content (you lose the playing status on save but i think that's acceptable)

TODO: Make this work for .okular files
TODO: For files with password we will need to reload the file, asking for the password again and thus losing the undo stack, warn the user
TODO: autotests
2017-10-26 15:30:44 +02:00
Albert Astals Cid
423dd010e0 Remove m_formButtons
We don't need it, so it's one less thing to make sure we need to maintain in sync
2017-10-25 16:08:13 +02:00
Albert Astals Cid
5c9edea430 Don't store the form twice in the formwidget classes
Just use m_ff and cast it when needed.

This will make it easy in the future when the given form for a widget may change so we only need to update one value
2017-10-25 15:12:35 +02:00
Albert Astals Cid
ba02656646 Make m_annowindows a set instead of a hash
Will make it for easier maintainance when we need to reuse the windows and annotation pointers change
2017-10-25 14:59:17 +02:00
Albert Astals Cid
3435eb6df8 Convert m_formWidgets from hash to set
We don't use the key for anything
2017-10-25 14:51:58 +02:00
Albert Astals Cid
54bcb44559 Merge remote-tracking branch 'origin/master' into dont-use-docdata-for-annots-and-forms 2017-10-23 16:03:18 +02:00
Lukas Hetzenecker
ecc1141e02 HiDPI Support for Okular
Summary:
This patch enables HiDPI throughout the application

Every pixmap is multiplied by the devicePixelRatioF
QPainter code is ajusted to take the DPR value into account

All pixmaps get cached with the highest DPR of all screens. When moving the application to another screen, the cache doesn't have to be invalidated.

BUGS: 362856 383589
REVIEW: D6268
2017-10-14 14:47:20 +02:00
Renato Araujo Oliveira Filho
6d7403ff13 Interact with hyperlinks in TextSelect mode
Allow user to click on url while on any selection mode

Based on https://git.reviewboard.kde.org/r/124961/ by Jake Linder <JakeLinder@mail.com>

Includes several autotests to try to minimize possible regressions as much as possible

BUGS: 318078
REVIEW: 130246
2017-10-11 15:03:36 +02:00