zealdocs / zeal

Offline documentation browser inspired by Dash
https://zealdocs.org
GNU General Public License v3.0
11.37k stars 778 forks source link

Esc as keyboard shortcut to dismiss #153

Open captn3m0 opened 10 years ago

captn3m0 commented 10 years ago

I just started using Zeal, and while I'm loving it, I don't like that I have to either Alt-Tab or Alt+F4 it to go back to my code. It would be awesome if Zeal could be dismissed with just an Esc.

I'm also using the sublime-text plugin, which makes zeal appear by F1, thus making Esc ideal for dismissal due to its closeness.

zoli commented 10 years ago

This is available by Alt+Space and you can modify it from Edit menu to.

captn3m0 commented 10 years ago

Currently, there is a single keyboard shortcut for both showing and dismissing zeal. What I'm asking for is a special key to just dismiss Zeal, preferably Esc. Currently, Esc just clears the search field, and does nothing much useful. I feel it can be put to much better use as a shortcut for dismissal.

dufferzafar commented 10 years ago

@captn3m0 Are you on Windows? because if you are, that can easily be done via an Autohotkey script, but yes the feature makes sense and should be added.

captn3m0 commented 10 years ago

Nah, I'm on Linux.

dufferzafar commented 10 years ago

Haven't found a nice AHK replacement on Linux sadly...

zoli commented 10 years ago

I changed default Esc behavior from clearing the query to hiding the window, Clearing the query is done by Ctrl+R now.

captn3m0 commented 10 years ago

Thanks a lot!

Now on to compile zeal (was using the ppa)

trollixx commented 9 years ago

I like the idea of using Esc for hiding Zeal. I am just not sure what the best work flow would be. Should there be two different hot keys, one global to show Zeal, and then another (Esc) to hide active window?

ssokolow commented 8 years ago

Haven't found a nice AHK replacement on Linux sadly...

I've been meaning to write something along those lines for several years but can never seem to make time.

My advice is to look into LDTP if you want to quickly hack together a one-off solution. It's a Python-based testing library that puppets windows using the accessibility system. (ie. AppleScript-like "Click button Foo" instructions rather than "Move to these coordinates and simulate a click")

dufferzafar commented 8 years ago

@ssokolow Thanks, LDTP looks useful. My main need actuall isn't window automation (& clicking) but simple Hotkey/Hotstring based actions. So, I want something like when I press Ctrl+Shift+K some arbitrary Python code can be executed. Do you know of a way I can currently achieve that?

P.S. I've been thinking of writing something AHK-like in Python too. Maybe we could discuss some ideas?

ssokolow commented 8 years ago

@dufferzafar

There are multiple ways I could suggest to bind hotkeys to Python code, depending on what characteristics you value.

As for an AHK-like solution, I'd love to discuss it but, as I'm currently under a time crunch with my degree project, I'm not sure how much discussion I'll be able to make room for before May 1st.

Perhaps we could continue this conversation via e-mail to avoid cluttering up this issue? (Rather than sharing my e-mail publicly, I'd prefer you use my contact form at http://blog.ssokolow.com/contact/ to start the conversation, then I can start a normal e-mail exchange by replying.)

lzap commented 8 years ago

Quickly evaluated this feature and it looks like one would need to override QLineEdit (key press event) and modify the main window event handling method as well (to dismiss when line edit component is not focused). The problem is QT Designer is used, therefore the component needs to be made compatible. Also preferences window would need a change. Bunch of work. I started this as a few-lines patch and I gave up - QT Designer blocks this for me. Anyway, dropping the comment for future reference.

lzap commented 8 years ago

I like the idea of using Esc for hiding Zeal. I am just not sure what the best work flow would be. Should there be two different hot keys, one global to show Zeal, and then another (Esc) to hide active window?

Yes, I kinda like this "inconsistent" approach, because you don't always bring the window via global hotkey. E.g. it's logical when you open it up from an editor to try to close it via Esc. Now, Esc brings focus to the line edit, if you hit it for the second time, then it does nothing. My idea was to call toggleWindow when line edit was focused, but I realized whats described above and gave up.

One question raises tho - if this should be implemented only from line edit (so sometimes two Esc key pressess are needed) or only one (additional mapping in MainWindow::keyPressEvent). I lean towards the latter.

I just discovered Zeal, fantastic job! Thanks.