Commit Graph

2723 Commits

Author SHA1 Message Date
Luis Ángel San Martín
26b4a85928 Rename id 2022-01-19 18:27:22 +01:00
Luis Ángel San Martín
6892a28d0a Check for undefined and null values in QML
Conditional chaining is not available in Qt5.15, so this is uglier than it should be.
2022-01-19 18:24:29 +01:00
Luis Ángel San Martín
68dbd90413 Update listeners definitions 2022-01-19 18:22:04 +01:00
Luis Ángel San Martín
1a25fd0740 Update listeners definitions 2022-01-19 18:20:05 +01:00
Luis Ángel San Martín
f3e08a04d7 Add some initial values for context variables 2022-01-19 18:17:53 +01:00
Luis Ángel San Martín
27383da945 Configure the initial size of the covers 2022-01-19 18:17:04 +01:00
Luis Ángel San Martín
59ae6c5e51 Extract method 2022-01-19 18:16:13 +01:00
Luis Ángel San Martín
2ae9b83bbf Make sure that opengl is used
QQuickWidget requires opengl.
2022-01-19 18:15:36 +01:00
Luis Ángel San Martín
b841aff4a3 Wrap booleans in QVariant when updating the qml context 2022-01-19 18:14:29 +01:00
Luis Ángel San Martín
768d7ee73c Set initial dummy values for some context references 2022-01-19 18:13:20 +01:00
Luis Ángel San Martín
e80f5a9f64 Move common initialization to the parent class 2022-01-19 18:12:40 +01:00
Luis Ángel San Martín
c948ee70cb Add some system info to the help/about dialog
I'll see what other info can be useful.
2022-01-16 11:19:19 +01:00
Luis Ángel San Martín
be684514e3
Merge pull request #189 from vedgy/enable-shortcuts-in-other-layouts
Fix keyboard shortcuts with alternative layouts; always limit Magnifying glass height; clean up related code
2022-01-16 11:18:24 +01:00
Igor Kushnir
662b5c99fd Don't leak "orphan" actions at exit
The original reason to orphan these actions is likely obsolete now.

Extract MainWindowViewer::addActionWithShortcut() to reduce code
duplication.
2022-01-15 18:02:31 +02:00
Igor Kushnir
482c19b358 Allow triggering Open latest comic action when the toolbar is hidden
This action is added to the toolbar but not to the viewer. Thus it
cannot be triggered when the toolbar is hidden. Adding it to
MainWindowViewer makes it available at all times.
2022-01-15 18:02:31 +02:00
Igor Kushnir
24e42f76d2 Make Magnifying glass shortcuts work with non-Latin layouts
Viewer::keyPressEvent()'s and MagnifyingGlass::keyPressEvent()'s custom
matching of these shortcuts is the same as
MainWindowViewer::keyPressEvent()'s before the recent commit
"Reader: make 3 keyboard shortcuts work with non-Latin layouts". That
commit's message details the issues with the custom code.

The Magnifying glass actions are now enabled/disabled when
loadedComicActions are enabled/disabled - for the same reason (see the
recent "Reader: make 12 keyboard shortcuts work with non-Latin layouts"
commit). In addition, Viewer::keyPressEvent() propagated the Magnifying
glass shortcuts to MagnifyingGlass only when it was visible. Therefore
showing/hiding Magnifying glass also enables/disables these actions.
Note that Viewer::showMagnifyingGlass() shows Magnifying glass only if
render->hasLoadedComic() returns true, so
MainWindowViewer::setMglassActionsEnabled slot can be connected directly
to Viewer::magnifyingGlassVisibilityChanged signal without checking this
condition again.
2022-01-15 18:02:31 +02:00
Igor Kushnir
5254e66da3 Fix a typo in Viewer::magnifyingGlassShowed name
Make Viewer::magnifyingGlassIsVisible() const.
2022-01-15 18:02:30 +02:00
Igor Kushnir
c8697ccd2d Always limit Magnifying glass's height
MagnifyingGlass::sizeUp() and MagnifyingGlass::sizeDown() grow/shrink
both width and height, but check only width's limits. Thus the user can
first increase Magnifying glass's height, then increase its size and
make the height greater than the main window's height. The user can also
first increase the width, then decrease the size until the height
shrinks to 0 and Magnifying glass disappears.

When Magnifying glass disappears, the only way to make it visible again
is to restore its default size by restarting YACReader, because the
invisible MagnifyingGlass widget does not receive wheel events and
Viewer::keyPressEvent() propagates shortcuts to mglass only if it is
visible. And even this workaround is possible only because YACReader
does not save/restore Magnifying glass's size (should it?).

Always checking both width and height limits fixes the bug. If one of
the dimensions reaches a limit, only the other dimension is modified. If
both dimensions reach their limits, neither is modified.
2022-01-15 18:02:30 +02:00
Igor Kushnir
efe9a1b995 MagnifyingGlass: get rid of C-style casts to Viewer*
qobject_cast<const Viewer *> improves const correctness.
QLabel::pixmap() is const-qualified => make Viewer::pixmap() const too.

Return non-const QPixmap from Viewer::pixmap() to let compiler move the
return value at the function's call sites.

Introduce a named constant maxRelativeDimension. Change its type from
float to double, which usually multiplies faster on x86-64.

Remove redundant parentheses to improve readability.
2022-01-15 18:02:30 +02:00
Igor Kushnir
fdba938fe8 MagnifyingGlass: don't updateImage() needlessly
Not all possible keyboard modifiers of a wheel event change
MagnifyingGlass's pixmap. So in case of e.g. MetaModifier or more than
one modifier, MagnifyingGlass::wheelEvent() calls updateImage() to no
avail.

Move the updateImage() call into the public slots to make them
self-sufficient. This also allows not to call updateImage() when the
pixmap is not changed in case the adjusted parameter has reached its
minimum or maximum value already.
2022-01-15 18:02:30 +02:00
Igor Kushnir
a1bb7735d2 Reader: make 12 keyboard shortcuts work with non-Latin layouts
Viewer::keyPressEvent()'s custom matching of these shortcuts is the same
as MainWindowViewer::keyPressEvent()'s before the recent commit
"Reader: make 3 keyboard shortcuts work with non-Latin layouts". That
commit's message details the issues with the custom code.

render->hasLoadedComic() condition in Viewer::keyPressEvent() becomes
true when Comic::_loaded is set to true. This always happens right after
Comic emits its numPages() signal. That is why the 12 fixed actions are
now enabled when Viewer emits its comicLoaded() signal, which is
connected to Render::numPages, which in turn is connected to
Comic::numPages signal.

The 12 fixed actions are now disabled when most other actions are
disabled: before a comic is opened and on comic opening error.
2022-01-15 18:02:30 +02:00
Igor Kushnir
0fad89dc03 Simplify code that disables previous/next comic actions 2022-01-15 18:02:30 +02:00
Igor Kushnir
f030a7fb0c Remove deprecated and always disabled alwaysOnTopAction 2022-01-15 18:02:30 +02:00
Igor Kushnir
b3c99823eb MainWindowViewer::createActions(): deduplicate setDisabled 2022-01-15 18:02:30 +02:00
Igor Kushnir
3bb475b47a MainWindowViewer: deduplicate enabling/disabling actions 2022-01-15 18:02:30 +02:00
Igor Kushnir
feaee915bc Extract Viewer::(vertical|horizontal)ScrollStep() 2022-01-15 18:02:30 +02:00
Igor Kushnir
133b547e7a Remove unused *Step* data members from Viewer 2022-01-15 18:02:30 +02:00
Igor Kushnir
88e0f5513a Reader: make 3 keyboard shortcuts work with non-Latin layouts
MainWindowViewer::keyPressEvent()'s custom matching of these shortcuts
does not leverage all the features of standard Qt shortcut matching. As
a result, the corresponding actions cannot be triggered when their
assigned shortcuts consist of a single Latin letter without modifiers
and e.g. Ukrainian keyboard layout is active.

Furthermore, some key presses (e.g. Scroll Lock in my customized
keyboard layout) set QKeyEvent::key() to 0, which the custom matching
considers equal to an unassigned shortcut. So an action without shortcut
is triggered by such a key press.

Adding these 3 actions to MainWindowViewer and connecting the
corresponding slots to their triggered() signals allows to remove the
custom matching code and thus eliminates both of its issues.
2022-01-15 18:02:30 +02:00
Luis Ángel San Martín
77c96de0ea Remove unused resources 2022-01-15 15:51:59 +01:00
Luis Ángel San Martín
e452178adb Log the device pixel ratio used while rendering 2022-01-15 11:54:40 +01:00
Luis Ángel San Martín
08021ba9a8 Take care of QToolButton not handling hdpi properly 2022-01-15 11:32:32 +01:00
Luis Ángel San Martín
565bc3a5d0 Replace all uses of devicePixelRatio with devicePixelRatioF 2022-01-14 19:22:50 +01:00
Luis Ángel San Martín
380aea2a66 Enable Qt::HighDpiScaleFactorRoundingPolicy::PassThrough 2022-01-14 19:21:43 +01:00
Luis Ángel San Martín
e532fa4439 Use devicePixelRatioF instead of devicePixelRatio when rendering pages 2022-01-13 23:12:05 +01:00
Luis Ángel San Martín
c414761be7 Update CHANGELOG 2022-01-13 23:06:39 +01:00
Luis Ángel San Martín
fce1f163aa Check that double click is done using the left button before toggling full-screen mode 2022-01-13 23:06:24 +01:00
Luis Ángel San Martín
d20958c14f Make forward and backward mouse buttons turn pages 2022-01-13 23:05:49 +01:00
Luis Ángel San Martín
dcb7e6e0c6 Add settings to control the page turn behavior on scroll 2022-01-13 23:04:22 +01:00
Luis Ángel San Martín
a1e0340b3d Fix some warnings 2021-12-29 17:58:40 +01:00
Luis Ángel San Martín
d8f224645d Remove YACReader::SearchModifiers
They are no longer used
2021-12-29 14:58:03 +01:00
Luis Ángel San Martín
1cf4ef97ea
Merge pull request #215 from vedgy/exit-search-mode-before-creating-folder
Library: exit search mode before creating a folder
2021-12-29 12:48:42 +01:00
Igor Kushnir
ea2c90011a Library: exit search mode before creating a folder
Creating a folder in search mode selects it and makes the UI look
half-way between Normal and Searching navigation statuses.

An alternative fix is to disable addFolderAction in search mode. But
this is more difficult to implement and inconsistent with the other
always-enabled folder and reading list actions.
2021-12-29 11:02:01 +01:00
Igor Kushnir
40ca07f8f8 Extract YACReaderNavigationController::exitSearchMode() 2021-12-29 11:01:35 +01:00
Luis Ángel San Martín
3a60d89f06
Merge pull request #239 from vedgy/concurrent-queue-fixes
Test, fix, improve, optimize ConcurrentQueue
2021-12-29 10:53:17 +01:00
Luis Ángel San Martín
e2cc1064fe Run tests in qt6 too 2021-12-29 09:36:44 +01:00
Igor Kushnir
d013abedc1 Azure: run tests as a step of each platform's job 2021-12-29 09:36:44 +01:00
Igor Kushnir
05b384ed6d Make ConcurrentQueue::waitAll() const
This member function does not affect the logical state of the class.
Making std::condition_variable and std::mutex data members mutable is
idiomatic as these classes are thread-safe synchronization primitives.
2021-12-29 09:36:44 +01:00
Igor Kushnir
72c78d0164 ConcurrentQueue: remove redundant checks
The C++ standard specifies `std::condition_variable::wait(lock, pred)`
as equivalent to `while (!pred()) wait(lock);`. It is implemented
exactly so in libstdc++, libc++ and MSVC.
2021-12-29 09:36:44 +01:00
Igor Kushnir
4cb542c8cc Remove ConcurrentQueue::joinAll()
This function is called only from ~ConcurrentQueue(). joinAll() is not
thread-safe and it cannot be called earlier without introducing a null
state. Moving the function's implementation into the definition of
~ConcurrentQueue() makes the code clearer. Removing joinAll() also
allows to establish and document invariants for two data members.

Assert consistency between jobsLeft and _queue in ~ConcurrentQueue().
2021-12-29 09:36:44 +01:00
Igor Kushnir
61cd245037 Document ConcurrentQueue and de-inline its implementation
ConcurrentQueue is currently used only by two classes and a test, but
modifying concurrent_queue.h requires recompiling 30 source files. None
of the member functions is so lightweight as to make it worth inlining.

An alternative to `@note ConcurrentQueue is unable to execute jobs if
@p threadCount == 0.` is `assert(threadCount != 0);`. But this would
force classes that contain a ConcurrentQueue data member to always start
a thread, even if they detect at runtime that they are never going to
enqueue a job.

Add Job type alias to avoid repeating the type.

Use default member initializers instead of the member initializer list
to make it clear [to the reader of the header] that no data member is
left uninitialized.
2021-12-29 09:36:44 +01:00