Skip to content

launch read timer with gesture#14061

Merged
Frenzie merged 7 commits into
koreader:masterfrom
Volterxien:gesture_timer
Jul 18, 2025
Merged

launch read timer with gesture#14061
Frenzie merged 7 commits into
koreader:masterfrom
Volterxien:gesture_timer

Conversation

@Volterxien

@Volterxien Volterxien commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Closes #14014.
I plan to move the gesture menu options. Just wanted to get this out here first and we can discuss best place to put this. I would suspect a submenu somewhere.


This change is Reviewable

@Volterxien

Copy link
Copy Markdown
Contributor Author

Commenting to add that the bug in the original patch @Frenzie provided was that the alarm_time var was never used if then_t was provided by the callback

Comment thread plugins/readtimer.koplugin/main.lua Outdated
Comment thread plugins/readtimer.koplugin/main.lua Outdated
Comment thread plugins/readtimer.koplugin/main.lua Outdated
end
end

function ReadTimer:onShowAlarmMenu(touchmenu_instance)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess you intended this as "called from menu" or something but that's a bit confusing. ;-)

Just onShowAlarm or onShowAlarmDialog/Widget or something should be clearer.

Comment thread plugins/readtimer.koplugin/main.lua Outdated
return seconds
end

function ReadTimer:onShowTimerMenu(touchmenu_instance)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same of course.

Comment thread plugins/readtimer.koplugin/main.lua Outdated

end

function ReadTimer:onSetAlarm(alarm_time, callback, then_t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh right, I just remembered that my patch was actually a quick abandoned sketch to enable something like "set alarm for 10 minutes from now," which is a bit different than what I responded to. If we're just opening a dialog this doesn't need to be an event.

Which is to say, setAlarm should do the trick.

Comment thread plugins/readtimer.koplugin/main.lua Outdated
UIManager:show(time_widget)
end

function ReadTimer:onSetInterval(timer_time, callback)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And here.

Comment thread plugins/readtimer.koplugin/main.lua Outdated
self:unschedule()
self:rescheduleIn(seconds)

if callback then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I cannot find the call of this method without callback, can you point me to?

Comment thread frontend/dispatcher.lua Outdated
-- Reader
show_alarm_menu = {category="none", event="ShowAlarmMenu", title=_("Set reader alarm"), reader=true},
show_timer_menu = {category="none", event="ShowTimerMenu", title=_("Set reader timer"), reader=true},
stop_timer = {category="none", event="StopTimer", title=_("Stop reader timer"), reader=true},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Plugins do this in the following way, for example:

Dispatcher:registerAction("book_statistics",
{category="none", event="ShowBookStats", title=_("Reading statistics: current book"), reader=true})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we want to put them under reader? Or elsewhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

General like dictionary.

Comment thread plugins/readtimer.koplugin/main.lua Outdated
end
end

function ReadTimer:onStopTimer(is_event, touchmenu_instance)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

touchmenu_instance is a flag, no need for additional is_event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was struggling with this. Thanks for pointing this out

Comment thread plugins/readtimer.koplugin/main.lua Outdated
end

function ReadTimer:SetAlarm(alarm_time, then_t, touchmenu_instance)
if not then_t then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How can this happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point lol

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above, the concept behind these functions in my quick concept patch was to call onSetAlarm and onSetInterval without displaying a dialog.[1] The way this has been rewritten of course it doesn't make sense anymore, and it can be readded if someone decides to implement that after all.

[1] Concretely, you'd set up an action to set the alarm at 23:30 for example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I was thinking you had originally planned. I guess it could be implemented like that in addition to how it's currently implemented, if that's wanted, since I'm already working on this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I forget who asked or where.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tagged issue at the top

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pardon, I was a bit unclear but that's not why I quickly wrote that patch a few months ago and forgot about it until I saw that issue. ;-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh you meant for the original patch lol my bad. Yeah I getcha. I Appreciate the jump start regardless

@hius07

hius07 commented Jul 17, 2025

Copy link
Copy Markdown
Member

All these new event handlers are unique, so please return true from all of them to stop event propagation.

Comment thread plugins/readtimer.koplugin/main.lua Outdated
@Frenzie Frenzie added this to the 2025.06 milestone Jul 18, 2025
@Frenzie Frenzie merged commit de78961 into koreader:master Jul 18, 2025
4 checks passed
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
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.

FR: ability to launch read timer with a gesture

3 participants