Skip to content

Conversation

@Cuperino
Copy link
Member

  • feat: Add New, Open, and Save shortcuts to Script Panel
  • fix: Check whether script needs to be saved before opening a new one

@Cuperino Cuperino added 🪲 bug Something isn't working ⬆️ feature New feature or request labels Mar 29, 2025
@Cuperino Cuperino requested a review from narnaud March 29, 2025 21:43
@Cuperino Cuperino self-assigned this Mar 29, 2025
Copy link
Member

@narnaud narnaud left a 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.

@Cuperino
Copy link
Member Author

Cuperino commented Apr 6, 2025

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.

@Cuperino Cuperino force-pushed the scriptpanel/shortcuts branch from b67c689 to 7c2bd13 Compare April 12, 2025 17:17
auto document = Core::Project::instance()->currentDocument();
if (document)
document->save();
}
Copy link
Member

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:
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪲 bug Something isn't working ⬆️ feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants