Commit Graph

265 Commits

Author SHA1 Message Date
bob sayshilol
0bc8c76c3c Fix strikethrough rendering in markdown converter
Previously the `<del>` tag that Discount emits would be removed by Qt
since it's not in the subset of HTML that it understands. It does know
about `<s>` though, so replace `<del>` with `<s>` to render strikethroughs
correctly.

Note that I couldn't get Okular to build locally (PEBCAK issue) so I split out this file to debug it. I've tested against http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip and ff866f73d4/tests/data and the only difference is that trailing whitespace is now trimmed from the end of a line:
```diff
8c8
< <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Dashes:</p>
---
> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Dashes: </p>
```
A quick search suggests this isn't a problem though https://stackoverflow.com/a/27026403:
> Within block tags (i.e. `<p>`, `<h1>`, `<div>`, ...) spaces as well as line breaks at the beginning or end of the tags should always be ignored (i.e. `<p>test</p>` should look the same as `<p> test </p>`).

I also tried https://doc.qt.io/qt-5/qtextdocument.html#setMarkdown which solves the strikethrough problem, though there are many visible differences with that approach. Most notably, everything is squashed together and code blocks lose their formatting.
2024-04-22 17:00:02 +00:00
Nicolas Fella
3a6988d9ee Add unit test for AFNumber_Format
Based on work from João Netto

Co-authored-by: João Netto <joaonetto901@gmail.com>
2024-04-17 06:54:22 +00:00
Sune Vuorela
717751a1f1 Fix multiline selection
In qt6, QRect::normalized changed it's meaning and it now has a 'span'
that preserves the old meaning.

Use the old span to get the old version of normalized so we can match on
the corners once again.

see https://codereview.qt-project.org/c/qt/qtbase/+/309932 for details.

BUG: 482249
2024-03-05 21:07:10 +00:00
Sune Vuorela
e7e889604f Newer clazy: More for loops 2024-03-04 16:54:09 +01:00
Sune Vuorela
2e008d437c Simplify textentity memory management
After trying to measure the effect of switching TinyTextEntity from a
custom SBO string type to just QString and getting a barely measurable
gain, TinyTextEntity kind of looked like TextEntity, so merge those two.

Also reduce the amount of new/deletes around TextEntities

Implement a string pool for some tiny strings, and various memory optimizations
2024-02-07 14:07:08 +00:00
Alexis Murzeau
2609f4001a Add support for app.popUpMenu and submenus in popUpMenuEx
These functions from `app` are JS functions that can be used by PDF
files.

Based on popUpMenuEx, the implementation of popUpMenu converts arguments
to app.popUpMenuEx format and then call it.

The popMenuEx function is improved to handle submenus as well using
`oSubMenu`.

app.popUpMenu is used in Altium Designer and EasyEDA exported PDFs.
See an example here:
https://www.st.com/en/evaluation-tools/32f723ediscovery.html#cad-resources
https://www.st.com/resource/en/schematic_pack/mb1260-f723e-d03_schematic.pdf

BUGS: 479777
2024-01-17 19:01:08 +00:00
Sune Vuorela
39fa288e3f Fix unit test warnings
The data keys are supposed to be unique, when adding data in a for loop,
use the function that can help with that.
2024-01-12 11:13:10 +01:00
Alexander Lohnau
0ad732f666 Remove unused includes and avoid Qt module include
This just causes compile time overhead
2023-12-28 14:14:15 +01:00
Albert Astals Cid
cfd2bcc240 tests: slotMouseNormalToggled was renamed 2023-12-21 13:55:05 +00:00
Sune Vuorela
70acf82817 Port from removed KConfigGroup keys api 2023-12-21 13:06:42 +01:00
Sune Vuorela
792425fc77 s/qAsConst/std::as_const/
We now definitely has std::as_const available and Qt has started nagging
about converting to std::as_const.

Implementation is the same for both functions, and qAsConst was a
stop-gap measure until std::as_const was sufficiently available.
2023-12-19 11:46:24 +00:00
Sune Vuorela
d03b9bd70d Try get DeferredDelete to happen a bit more 2023-12-18 22:56:22 +00:00
Sune Vuorela
19f44188be ALso fix showTabWarning 2023-12-18 22:56:22 +00:00
Sune Vuorela
05fb77b2bf Fix messagebox closing to use right config file 2023-12-18 22:56:22 +00:00
Sune Vuorela
6ab7e09e79 Move the mouse a bit in a unit test to hope we don't hit a link 2023-12-18 22:56:22 +00:00
Sune Vuorela
cd3a587e0c Fix jstest. In Qt6, AM times are now prefixed with specific unicode nonbreaking space instead of normal space 2023-12-18 22:56:22 +00:00
Carl Schwan
536bf0ec92 Make autotests compile with qt6 2023-12-18 22:56:22 +00:00
Carl Schwan
2f05100dc2 Adapt cmake for library name change for kexiv2 and plasma-activities 2023-12-18 22:56:22 +00:00
Nicolas Fella
c29f0fec54 Switch to kf6 2023-12-18 22:56:22 +00:00
Sune Vuorela
40cbc59bcf Adapt buildsystem to QtX11Extras change for Qt6 2023-12-18 22:56:22 +00:00
Sune Vuorela
f3be4f1cd3 Hardcode Qt6 2023-12-18 22:56:22 +00:00
Nicolas Fella
b1c904bda3 Don't hardcode Qt5
Prepares for using Qt6
2023-12-18 22:56:22 +00:00
Nicolas Fella
d4a344a189 Port away from deprecated KPluginLoader 2023-09-11 19:29:44 +00:00
Nicolas Fella
b5303248f0 Add missing includes 2023-09-11 16:47:17 +02:00
Sune Vuorela
f8a610b22c Fix distinguished name parser
Take the one improved for poppler and re-use it here.
2023-08-11 20:58:39 +00:00
Sune Vuorela
3eee43ffd8 Don't use private Qt api
Add some more unit testing to expose some bugs in previous implementation and fix those as well.
2023-08-10 23:06:18 +00:00
Sune Vuorela
c5909d0a6d Better suggested signed name
When signing a "filename versioned" pdf, e.g. foo-1.2.3.pdf, the
current suggestion for signed name is weird. the "_signed"
gets misplaced in the middle of the version.

Also, compressed pdf's (pdf.gz) gets up with weird suggestions.

Fix both of these cases and document (by tests) the current behavior.
2023-08-07 22:08:20 +00:00
Sune Vuorela
720e08220d Allow dbus to be disabled
In certain usecases, especially for non-linux desktop builds, the
advantage of of dbus is often limited. Provide a way to disable
building with dbus.

Note that this also disables the related functionalities of having a
second okular launch open the document in the first okular.

This also disables the unit tests that tests those features.
2023-07-18 07:53:42 +00:00
Oliver Sander
f694ab6343 Add test for field number formatting
This adds a test document with most formatting options directly accessible through acrobat.
Currently only the number format functions are tested as they are the only ones implemented.

Original patch is from Oliver Sander, rebased and fixed up by Nicolas Fella
2023-07-10 09:03:19 +00:00
Volker Krause
ec0e848c58 Rename the JS functions unit tests to no longer mention kjs 2023-06-22 17:44:49 +02:00
Friedrich W. H. Kossebau
725155b29d Include only needed headers instead of QtDBus module header
GIT_SILENT
2023-06-07 22:41:22 +00:00
Friedrich W. H. Kossebau
5e5ae0a7aa Include only needed headers instead of QtTest module header
GIT_SILENT
2023-06-07 23:11:21 +02:00
Sune Vuorela
b32ae775b4 Remove virtual methods from signature and certificate info
This is an abi break, but it menas we can extend signature and
certificate info in the future without breaking the abi again.

While we are at it, there is no need to hand around pointers to
certificate/signature info any longer, so clean up that. Fix memleaks as
side effect.
2023-05-03 09:15:42 +00:00
Nicolas Fella
0501c5d8c4 Fix raising window when attaching to an existing instance on Wayland
When the second instance is launched it receives an activation token per environment variable

We need to pass that token to the first instance so that it can use it to raise itself

Also properly use startup ids for this on X11 instead of relying on forceActiveWindow, which is a hack
2023-02-09 12:26:52 +00:00
Albert Astals Cid
d0beae60a9 Make signunsignedfieldtest pass again
the fake cert had expired ^_^
2022-11-20 01:25:46 +01:00
Albert Astals Cid
b935e24876 Make the CloseDialogHelper work better on my setup 2022-11-19 20:39:55 +01:00
Albert Astals Cid
366464c012 parttext: Don't require pdflatex to run test
We can just run commit the files needed for it, makes life a bit easier
2022-11-19 20:39:51 +01:00
Albert Astals Cid
91afa74342 Set minimum requirement to Ubuntu 22.04 2022-11-19 09:48:15 +00:00
Nicolas Fella
80afe26873 Implement event.change
This represents the newly entered data for each keystroke. This is often a single added character, but for cases like pasting text it can be more complex.

The PDF API reference doesn't specify any algorithm to use.

The algorithm used here works by iterating through both strings from the start until the first different character is encountered. Then the rest of the new text is considered the difference.

This doesn't produce the theoretically optimal/minimal diff, but seems to work well enough for practical application.

When text is removed the diff is empty
2022-09-13 21:51:15 +00:00
Albert Astals Cid
44304b32a5 Use the poppler version includes instead of check_cxx_source_compiles 2022-05-04 01:16:35 +02:00
Albert Astals Cid
d3dc35e159 Try to fix randomly failing jenkins 2022-04-08 10:46:46 +02:00
Albert Astals Cid
0d40301d50 Add a few definitions that will come with ECM 5.85
Better enforce them now, so that the work to port doesn't increase over
time

Not a super fan of this for regular applications, but oh well the ship
has sailed
2022-04-07 23:02:12 +00:00
M  B 
8aa96484da Markdown: Fix images with special chars in URLs not loaded
If an image URL contains a non-ASCII character (e.g. `kartöffelchen.jpg`), the html returned by the markdown parser contains the encoded path `kart%C3%B6ffelchen.jpg`. We must decode the path before checking if the image file exists.
2022-04-03 16:02:44 +00:00
Albert Astals Cid
252236d413 Port a few more QLinkedList to QList
We don't need the special properties of QLinkedList in any of those and
QLinkedList is deprecated, so move away from it
2022-03-31 17:08:01 +02:00
Albert Astals Cid
0741ef1838 Port away from more QLinkedLists
QLinkedList is gone from Qt6

The almost 1:1 port is std::list but we don't need iterator stability on
removal/insertion so just port to QList
2022-03-22 12:58:59 +01:00
Albert Astals Cid
04c21b9c70 Fix cmake warning 2022-03-19 18:44:26 +01:00
Albert Astals Cid
6767b8739e Port a few QLinkedList to QList
QLinkedList is deprecated in later Qt5 and gone in Qt6

The 1:1 port is std::list but in this cases all we ever do
is create the lists, push back to them, and pass then around
to be read, for that a QList is more than enough
2022-03-19 11:22:55 +00:00
Albert Astals Cid
2d007f27d3 foreach -> for
A future ECM update is going to force that on us, so do it now anyway
2022-03-19 10:58:47 +00:00
Albert Astals Cid
6747e7fe8b signals-> Q_SIGNALS
A future ECM update is going to force that on us, so do it now anyway
2022-03-19 10:58:47 +00:00
Albert Astals Cid
a2e1043149 slots -> Q_SLOTS
A future ECM update is going to force that on us, so do it now anyway
2022-03-19 10:58:47 +00:00