-
Notifications
You must be signed in to change notification settings - Fork 15
Add Script Panel Shortcuts #253
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
base: main
Are you sure you want to change the base?
Conversation
Cuperino
commented
Mar 29, 2025
- feat: Add New, Open, and Save shortcuts to Script Panel
- fix: Check whether script needs to be saved before opening a new one
narnaud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to add shrtucts to the ScriptPanel::ScriptPanel.
This way the shortcuts will be visible on hover (better for discoverability).
The only problem will be to handle the same shortcuts multiple time, I can't remmeber if Qt do that nicely by derfault. Another option will be to use Ctrl+Alt+Foo for example.
|
I like the idea of handling them from ScriptPanel::ScriptPanel. Need to look how that would be done without creating conflicting bindings. In QML one can have one event handling function call another, effectively forwarding events conditionally. I wouldn't go for Ctrl+Alt+Foo because that would go against muscle memory. Standard binding outcomes should adapt according on the context. |
b67c689 to
7c2bd13
Compare
| auto document = Core::Project::instance()->currentDocument(); | ||
| if (document) | ||
| document->save(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to not change the mainwindow.cpp - after all, those actions are specific to the script panel.
We could do that with a QShortcut in ScriptPanel:
auto shortcut = new QShortcut(QKeySequence::Open, this);
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
connect(shortcut, &QShortcut::activatedAmbiguously, this, &ScriptPanel::openScript);
Or, maybe better, create actions on the tool buttons and assign non-ambiguous shortcuts (Shift+Ctrl+...).
| } | ||
| return; | ||
| } | ||
| case Qt::Key_N: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done in one line in the constrtuctor with:
newScriptAction->setShortcut(QKeySequence::New);
If you are afraid of ambiguous shortcuts, see for the others