Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatcher: allow sorting actions #9531

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

yparitcher
Copy link
Member

@yparitcher yparitcher commented Sep 19, 2022

mostly borrowed from @hius07 in #9526

Lightly tested.


This change is Reviewable

@Frenzie Frenzie added this to the 2022.09 milestone Sep 19, 2022
frontend/dispatcher.lua Outdated Show resolved Hide resolved
@hius07
Copy link
Member

hius07 commented Sep 19, 2022

Thank you. A couple of notes:
(1) After adding an action, Sort is immediately checked even I haven't sorted anything yet.
(2) In Gesture manager action menu now has 11 items (Pass through (default) and Pass through are above Sort) that causes two pages of the menu.

@hius07
Copy link
Member

hius07 commented Sep 19, 2022

More changes to the Profiles module are required. I may proceed with them after you finish the Dispatcher.

@yparitcher
Copy link
Member Author

(1) After adding an action, Sort is immediately checked even I haven't sorted anything yet.

Dispatcher now automatically sorts items by when they were added. (adding an item adds it to the sortlist, and removing an item deletes it). This allow not having to worry if the sort list is synced.
Items that were created before this PR are unsorted and will only be sorted if setting a sort order. (to get this behavior one can hold the sort item)

(2) In Gesture manager action menu now has 11 items (Pass through (default) and Pass through are above Sort) that causes two pages of the menu.

I know. :) This still needs to be dealt with.

More changes to the Profiles module are required. I may proceed with them after you finish the Dispatcher.

Please give me a few more days, as this is not finished yet (quickmenu etc)

@yparitcher yparitcher force-pushed the ordered_dispatch branch 2 times, most recently from 7fb0dc9 to ada81a7 Compare September 21, 2022 23:22
@yparitcher yparitcher marked this pull request as ready for review September 22, 2022 01:12
@yparitcher
Copy link
Member Author

(2) In Gesture manager action menu now has 11 items (Pass through (default) and Pass through are above Sort) that causes two pages of the menu.

Still looking for ways to arrange/fix this

local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
quickmenu = ButtonDialogTitle:new{
--name = name,
title = "Quick Menu",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For profiles we need to see the profile name here.

@poire-z
Copy link
Contributor

poire-z commented Sep 22, 2022

In Gesture manager action menu now has 11 items

Still looking for ways to arrange/fix this

Can we get a screenshot to know what you're talking about ? :)

@hius07
Copy link
Member

hius07 commented Sep 22, 2022

With the latest commits the conception has changed: the profile can be either executed or shown as QuickMenu, not both options. I'm fine with that.
@mergen3107, what is your experience? Are there profiles that sometimes you want to execute in full and sometimes to see as a QuickMenu to execute a single action only?

@mergen3107
Copy link
Contributor

So far I only used profiles in full, because my profiles are basically font face, font weight, font size and line spacing. So if I activated a profile and found out that, for example, line spacing doesn’t fit here, I’d just go to bottom menu to tweak it, not profile’s quick menu.

However, in a broader sense I’d imagine someone with a night mode + font + brightness changing profile wanting to activate only night mode with fonts, but not brightness.

@yparitcher
Copy link
Member Author

yparitcher commented Sep 23, 2022 via email

@hius07
Copy link
Member

hius07 commented Sep 26, 2022

Not directly oncerns this PR, but Dispatcher and creoptions and koptoptions. Are there any reasons to give the same names to actions in cre and pdf documents? Eg line_spacing and kopt_line_spacing, font_size and kopt_font_size.
This may cause a crash:
-assign the action "Reflowable : set font size to 22" to a gesture
-open pdf document, set reflow on
-apply the gesture

error: malloc of array (44546 x 62170 bytes) failed
./luajit: ./ffi/mupdf.lua:78: could not allocate pixmap: malloc of array (44546 x 62170 bytes) failed (1)
stack traceback:
	[C]: in function 'error'
	./ffi/mupdf.lua:78: in function 'merror'
	./ffi/mupdf.lua:1002: in function 'render_for_kopt'
	./ffi/mupdf.lua:1029: in function 'reflow'

The crash is caused by

local default_font_size = 22
-- the koptreader config goes from 0.1 to 3.0, but we want a regular font size
function PdfDocument:convertKoptToReflowableFontSize(font_size)
if font_size then
return font_size * default_font_size
end

We try to set font size to 22*22 and get OOM crash.

@hius07
Copy link
Member

hius07 commented Sep 29, 2022

Dunno is it worth to show action's value in QuickMenu. Some of the original values are not much informative and require getting text labels from creoptions/koptoptions.

01

@mergen3107
Copy link
Contributor

I think values are good! Makes more sense when you see what actually you are going to apply.

Also why the first two items different? Only these have verbs, others just say what the option is named and its value

@mergen3107
Copy link
Contributor

I mean, is this intentional and you plan to add verbs to all of them?

@hius07
Copy link
Member

hius07 commented Sep 29, 2022

Also why the first two items different? Only these have verbs, others just say what the option is named and its value

Current original strings from Dispatcher are displayed.

@hius07
Copy link
Member

hius07 commented Sep 29, 2022

@mergen3107, maybe it is of interest for you: #8590 (comment) and further

@yparitcher
Copy link
Member Author

In Gesture manager action menu now has 11 items

Still looking for ways to arrange/fix this

Can we get a screenshot to know what you're talking about ? :)

Gestures
FileManager_2022-10-02_205013
FileManager_2022-10-02_205018

Profiles
FileManager_2022-10-02_205039
FileManager_2022-10-02_205158

@poire-z
Copy link
Contributor

poire-z commented Oct 3, 2022

Can we get a screenshot to know what you're talking about ? :)

Gestures

Indeed :/ Moreover, they are 2 non-actions between a lot of actions (items or submenus).
May be move Show as QuickMenu and Sort at the end, so they are both displayed on the 2nd page and feel more independant ?
It would be nice to have a separator above these 2 on that 2nd page, to make it clear they don't really follow the actions submenus - so, may be add a 3rd item (before these 2) on the 2nd page, something like "About QuickMenu and sorting" explaining what/why/how.
(Anyway, add the separator, as when in Landscape mode, we don't get 10 items per page but less.)

@yparitcher yparitcher force-pushed the ordered_dispatch branch 2 times, most recently from 43f0126 to 4d9f7b4 Compare October 4, 2022 02:31
@yparitcher
Copy link
Member Author

Ready on my end.
Only lightly tested, as I have don't use profiles, and don't have a use for a QuickMenu

@yparitcher
Copy link
Member Author

Not directly oncerns this PR, but Dispatcher and creoptions and koptoptions. Are there any reasons to give the same names to actions in cre and pdf documents? Eg line_spacing and kopt_line_spacing, font_size and kopt_font_size. This may cause a crash: -assign the action "Reflowable : set font size to 22" to a gesture -open pdf document, set reflow on -apply the gesture

The reason dispatcher has different names is that the names are based on the names in creoptions and koptoptions which call different event base on which engine is being used.

Using Crengine settings in a MuPdf document is Undefined Behavior.

Reflowable : set font size is a crengine setting/event. calling it in a Mupdf document will not cause any event to fire (mupdf does not listen to that event), however any setting from creoptions and koptoptions will also update the configurable object (so as not to break the bottom menu). The configurable.font size is the same name for both cre and mupdf causing the config to think that the font size is 22 eventually leading to an OOM crash (It does not crash for me in the emulator, it just make the font size big.)

These interactions were discussed when dispatcher was first implemented, and the consensus was that if a user should be smart enough not to shoot himself in the foot, as technically the user can set many contradictory events.

@yparitcher yparitcher force-pushed the ordered_dispatch branch 2 times, most recently from cdbe342 to 6b78191 Compare October 4, 2022 02:52
@yparitcher
Copy link
Member Author

updated screenshots
Gestures
FileManager_2022-10-03_222537
FileManager_2022-10-03_222039
profiles
FileManager_2022-10-03_222102
FileManager_2022-10-03_222107

frontend/dispatcher.lua Outdated Show resolved Hide resolved
@hius07
Copy link
Member

hius07 commented Oct 4, 2022

Thanks, works good!

A couple of propositions:
-to see the profile name in the title of its QuickMenu
-since we always "execute" profile (even when showing its QM), no need of additional sign \u{F144} in the profile name in the Dispatcher

A fix required:
-after editing actions and going up to the profile properties, the label of the action near "Edit actions:" doesn't change.

@yparitcher
Copy link
Member Author

A fix required: -after editing actions and going up to the profile properties, the label of the action near "Edit actions:" doesn't change.

Fixed text -> text_func

@yparitcher
Copy link
Member Author

-since we always "execute" profile (even when showing its QM), no need of additional sign \u{F144} in the profile name in the Dispatcher

Done

@yparitcher
Copy link
Member Author

yparitcher commented Oct 4, 2022

A couple of propositions: -to see the profile name in the title of its QuickMenu

This one is hard, we don't know the name as we do not have context into what called Dispatcher allowing it to receive events from anywhere (and i would like to keep it that way)
also for example if a gesture opens a profile as a QuickMenu do we want the profile or the gesture?

@yparitcher
Copy link
Member Author

-to see the profile name in the title of its QuickMenu

Done

Fix condition check, simplify getNameFromItem

Allow sorting Dispatcher items and displaying them as a QuickMenu
@hius07
Copy link
Member

hius07 commented Oct 4, 2022

Great!

@yparitcher
Copy link
Member Author

@hius07
Enjoy polishing up profiles after this is merged, but please give me a chance to review any interactions with dispatcher :)
It might take me a few day as tonight/tomorrow is Yom Kippur and next week is Sukkot

@yparitcher yparitcher merged commit 8a754cd into koreader:master Oct 4, 2022
@yparitcher yparitcher deleted the ordered_dispatch branch October 4, 2022 15:47
@hius07
Copy link
Member

hius07 commented Oct 4, 2022

It is now very clear/ logical Profiles - Dispatcher interaction, I think it is worth to wait for users' response on using it, before any further development.

@yparitcher
Copy link
Member Author

It is now very clear/ logical Profiles - Dispatcher interaction, I think it is worth to wait for users' response on using it, before any further development.

Unless maybe make registering a profile to Dispatcher optional?

@poire-z
Copy link
Contributor

poire-z commented Oct 11, 2022

Not familiar with this PR code, so just mentionning this situation I got when playing with multiaction gesture.
I remember that at some point, I had added "Increase font size by # + 1", then later removed it.
It is still executed though:
image image

I guess because it's the "sort order" list that is used - and it may not be updated when we uncheked an action in the main menu. I have currently in my gestures.lua:

        ["multiswipe_southeast_northeast_northwest"] = {
            ["font_base_weight"] = 1,
            ["font_kerning"] = 0,
            ["font_size"] = 27,
            ["h_page_margins"] = {
                [1] = 30,
                [2] = 30,
            },
            ["settings"] = {
                ["order"] = {
                    [1] = "font_base_weight",
                    [2] = "font_kerning",
                    [3] = "increase_font",
                    [4] = "font_size",
                    [5] = "font_kerning",
                    [6] = "h_page_margins",
                },
            },
        },

(Also the duplicated font_kerning in settings.order.)

@yparitcher
Copy link
Member Author

@poire-z
If you added/ sorted between @hius07 original PR and this one there may be some funky interactions, See if you can reproduce 1. on a new gesture/profile 2. if you re-add and remove "Increase font size by # + 1".

@poire-z
Copy link
Contributor

poire-z commented Oct 12, 2022

Checked again with current master, same behaviour.
Moreover, I hadn't even used "Sort".
Added in that order: Increase font size +1, font weight, font kerning. When executed, font-size was first (in the notification list)
Removed Increase font size (first by setting default value 0 - which was not the way to do it, so then by long-press on the menu item). When executed, font-size is now last (in the notification list).
In my gestures.lua:

        ["multiswipe_northwest_southwest_northwest"] = {
            ["font_base_weight"] = 1,
            ["font_kerning"] = 1,
            ["settings"] = {
                ["order"] = {
                    [1] = "font_base_weight",
                    [2] = "font_kerning",
                    [3] = "increase_font",
                },
            },
        },

on a new gesture/profile

I only used Tap and gestures > multiswipe.

@yparitcher
Copy link
Member Author

(first by setting default value 0

The important part. :)
Fixed in #9628

@poire-z
Copy link
Contributor

poire-z commented Oct 12, 2022

I confirm that the issue did not happen when you don't do my "first by setting default value 0" :)
And I confirm your fix does fix this when I do that.

Minor and probably unrelated issue and probably not worth thinking about it (@hius07 ?):
you can't set "Increase font size" to 0 when using the +/- buttons. But you can when using the (new there?) Use default value: 0 button - and you can save it.
And although it's supposed to be 0 - and possibly have no effect, it does increase my font size by 5. It's possible 5 is some default increment when nothing/zero is given.

@hius07
Copy link
Member

hius07 commented Oct 12, 2022

It is unexpected for SpinWidget that the default value is less than min value.

increase_font = {category="incrementalnumber", event="IncreaseFontSize", min=0.5, max=255, step=0.5, title=_("Increase font size by %1"), rolling=true},

default_value = 0,

Anyways, I think there should not be any default value for this case.

Frenzie pushed a commit that referenced this pull request Oct 12, 2022
@hius07
Copy link
Member

hius07 commented Oct 12, 2022

I'd propose to change

value = location[settings] ~= nil and location[settings][k] or 0,

to value = location[settings] ~= nil and location[settings][k] or settingsList[k].min,

and remove line

default_value = 0,

Applicable for all incrementalnumber settings (increase/decrease font size, frontlight, warmth).

TranHHoang added a commit to TranHHoang/koreader that referenced this pull request Oct 23, 2022
KOReader 2022.10 "Muhara"

![koreader-2022-10](https://user-images.githubusercontent.com/202757/197379886-75c933df-8236-4be2-9287-304a88778b67.png)

We skipped last month's release because I was right in the middle of moving, which serendipitously coincided with fairly drastic changes that needed more time for testing, such as a big rewrite of gestures and multitouch (koreader#9463).

Users of the Dropbox plugin will now be able to use the new short-lived tokens (koreader#9496).

<img width="40%" alt="image" src="https://user-images.githubusercontent.com/59040746/193070490-a3d477db-bd82-431b-95fd-2c4765244378.png" align="right">One of the more visible additions is the new Chinese keyboard contributed by @weijiuqiao, based on the [stroke input method](https://en.wikipedia.org/wiki/Stroke_count_method) (koreader#9572). It's not smart and it requires knowledge of stroke order. A tutorial can be found [here](https://github.com/koreader/koreader/wiki/Chinese-keyboard), part of which I will reproduce below.

<hr>

The stroke input method groups character strokes into five categories. Then any character is typed by its stroke order.
| Key | Stroke type |
| ------ | ------ |
| `一` | Horizontal or rising stroke |
| `丨` | Vertical or vertical with hook |
| `丿` | Falling left |
| `丶` | Dot or falling right |
| `𠃋` | Turning |

For example, to input 大, keys `一丿丶` are used.

Note all turning strokes are input with a single `𠃋` key as long as they are written in one go. So 马 is input with `𠃋𠃋一`.

After getting the intended character, a `分隔`(Separate) or `空格`(Space) key should be used to finish the input. Otherwise, strokes of the next character will be appended to that of the current one thus changing the character.

Besides, the keyboard layout contains a wildcard key `*` to use in place of any uncertain stroke.

Swipe north on the `分隔`(Separate) key for quick deletion of unfinished strokes.

<hr>

Logo credit: @bubapet

We'd like to thank all contributors for their efforts. Some highlights since the previous release include:

* NewsDownloader: Strip byte order mark from xml string before parsing (koreader#9468) @ad1217
* GestureDetector: Full refactor for almost-sane(TM) MT gesture handling (koreader#9463) @NiLuJe
* Kobo: Unbreak touch input on fresh setups on Trilogy (koreader#9473) @NiLuJe
* Kobo: Fix input on Mk. 3 (i.e., Kobo Touch A/B). (koreader#9474, koreader#9481) @NiLuJe
* Kindle: Attempt to deal with sticky "waking up" hibernation banners (koreader#9491) @NiLuJe
* Add "Invert page turn buttons" to Dispatcher (koreader#9494) @NiLuJe
* [UIManager] Outsource device specific event handlers (koreader#9448) @zwim
* AutoWarmth: add a choice to control warmth and/or night mode (koreader#9504) @zwim
* Allow F5 key to reload document (koreader#9510) @poire-z
* bump crengine: better SVG support with extended LunaSVG (koreader#9510) @poire-z
* CRE/ImageViewer: get scaled blitbuffer when long-press on SVG (koreader#9510) @poire-z
* RenderImage: use crengine to render SVG image data (koreader#9510) @poire-z
* Wikipedia EPUBs: keep math SVG images (koreader#9510) @poire-z
* TextViewer: add Find (koreader#9507) @hius07
* A random assortment of fixes (koreader#9513) @NiLuJe
* Add Russian Wiktionary dictionary (koreader#9517) @Vuizur
* add custom mapping for tolino buttons (koreader#9509) @hasezoey
* Profiles: add QuickMenu (koreader#9526) @hius07
* ImageViewer: Clamp zoom factor to sane values (koreader#9529, koreader#9544) @NiLuJe
* ReaderDict: fix use of dicts with ifo with DOS line endings (koreader#9536) @poire-z
* Kobo: Initial Clara 2E support (koreader#9545) @NiLuJe
* TextViewer: add navigation buttons (koreader#9539) @hius07
* ConfigDialog: show button with default values in spinwidgets (koreader#9558) @hius07
* Misc: Get rid of the legacy defaults.lua globals (koreader#9546) @NiLuJe
* Misc: Use the ^ operator instead of math.pow (koreader#9550) @NiLuJe
* DocCache: Unbreak on !Linux platforms (koreader#9566) @NiLuJe
* Kobo: Clara 2E fixes (koreader#9559) @NiLuJe
* Keyboard: add Chinese stroke-based layout (koreader#9572, koreader#9582) @weijiuqiao
* Vocabulary builder: add Undo study status (koreader#9528, koreader#9582) @weijiuqiao
* Assorted bag'o tweaks & fixes (koreader#9569) @NiLuJe
* ReaderFont: add "Font-family fonts" submenu (koreader#9583) @poire-z
* FileManager: add Select button to the file long-press menu (koreader#9571) @hius07
* Dispatcher: Fixes, Sort & QuickMenu (koreader#9531) @yparitcher
* Cloud storage: add Dropbox short-lived tokens (koreader#9496) @hius07
* GH: Extend the issue template to request verbose debug logs for non-crash issues. (koreader#9585) @NiLuJe
* Logger: Use serpent instead of dump (koreader#9588) @NiLuJe
* LuaDefaults: Look for defaults.lua in $PWD first (koreader#9596) @NiLuJe
* UIManager: Don't lose track of the original rotation on reboot/poweroff (koreader#9606) @NiLuJe
* ReaderStatus: save status summary immediately on change (koreader#9619) @hius07
* [feat] Add Thai keyboard (koreader#9620) @weijiuqiao
* Dispatcher: Fix subtle bug with modified items being added twice to the sort index (koreader#9628) @yparitcher
* Vocabulary builder: supports review in reverse order (koreader#9605) @weijiuqiao
* Exporter plugin: allow adding book md5 checksum when exporting highlights (koreader#9610) @sp4ke
* buttondialogtitle: align upper borders (koreader#9631) @hius07
* Kobo: Always use open/write/close for sysfs writes (koreader#9635) @NiLuJe
* OPDS-PS: Fix hardcoded namespace in count (koreader#9650) @bigdale123

[Full changelog](koreader/koreader@v2022.08...v2022.10) — [closed milestone issues](https://github.com/koreader/koreader/milestone/59?closed=1)

---

Installation instructions: [Android](https://github.com/koreader/koreader/wiki/Installation-on-Android-devices) • [Cervantes](https://github.com/koreader/koreader/wiki/Installation-on-BQ-devices) • [ChromeOS](https://github.com/koreader/koreader/wiki/Installation-on-Chromebook-devices) • [Kindle](https://github.com/koreader/koreader/wiki/Installation-on-Kindle-devices) • [Kobo](https://github.com/koreader/koreader/wiki/Installation-on-Kobo-devices) • [PocketBook](https://github.com/koreader/koreader/wiki/Installation-on-PocketBook-devices) • [ReMarkable](https://github.com/koreader/koreader/wiki/Installation-on-ReMarkable) • [Desktop Linux](https://github.com/koreader/koreader/wiki/Installation-on-desktop-linux) • [MacOS](https://github.com/koreader/koreader/wiki/Installation-on-MacOS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants