- fix: mainwindow action's short cut doesn't work, if the action is not in menu or toolbar

This commit is contained in:
Roy Qu 2022-01-27 23:48:46 +08:00
parent 0c2d569cb9
commit f298cc7b47
4 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Red Panda C++ Version 0.14.0
- enhancement: greatly speed up code completion - enhancement: greatly speed up code completion
- fix: code folding calcuation not correct when some codes are folded and editing after them - fix: code folding calcuation not correct when some codes are folded and editing after them
- enhancement: code completion ui redesigned - enhancement: code completion ui redesigned
- fix: mainwindow action's short cut doesn't work, if the action is not in menu or toolbar
Red Panda C++ Version 0.13.4 Red Panda C++ Version 0.13.4
- fix: when copy comments, don't auto indent - fix: when copy comments, don't auto indent

View File

@ -97,6 +97,7 @@ MainWindow::MainWindow(QWidget *parent)
mSystemTurnedOff(false) mSystemTurnedOff(false)
{ {
ui->setupUi(this); ui->setupUi(this);
addActions( this->findChildren<QAction *>(QString(), Qt::FindChildrenRecursively));
// status bar // status bar
mFileInfoStatus=new QLabel(); mFileInfoStatus=new QLabel();
mFileEncodingStatus = new LabelWithMenu(); mFileEncodingStatus = new LabelWithMenu();
@ -167,6 +168,7 @@ MainWindow::MainWindow(QWidget *parent)
mMenuNew->addAction(ui->actionNew_Project); mMenuNew->addAction(ui->actionNew_Project);
ui->menuFile->insertMenu(ui->actionOpen,mMenuNew); ui->menuFile->insertMenu(ui->actionOpen,mMenuNew);
mMenuExport = new QMenu(tr("Export")); mMenuExport = new QMenu(tr("Export"));
mMenuExport->addAction(ui->actionExport_As_RTF); mMenuExport->addAction(ui->actionExport_As_RTF);
mMenuExport->addAction(ui->actionExport_As_HTML); mMenuExport->addAction(ui->actionExport_As_HTML);
@ -5664,6 +5666,7 @@ void MainWindow::on_actionExport_As_HTML_triggered()
void MainWindow::on_actionMove_To_Other_View_triggered() void MainWindow::on_actionMove_To_Other_View_triggered()
{ {
qDebug()<<"test";
Editor * editor = mEditorList->getEditor(); Editor * editor = mEditorList->getEditor();
if (editor) { if (editor) {
mEditorList->swapEditor(editor); mEditorList->swapEditor(editor);

View File

@ -2297,6 +2297,9 @@
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+B</string> <string>Ctrl+B</string>
</property> </property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action> </action>
<action name="actionOpen_Terminal"> <action name="actionOpen_Terminal">
<property name="icon"> <property name="icon">
@ -2448,6 +2451,9 @@
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+M</string> <string>Ctrl+M</string>
</property> </property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action> </action>
<action name="actionC_C_Reference"> <action name="actionC_C_Reference">
<property name="text"> <property name="text">

View File

@ -57,13 +57,23 @@ void EnvironmentShortcutModel::reload()
{ {
beginResetModel(); beginResetModel();
mShortcuts.clear(); mShortcuts.clear();
QList<QAction*> actions = pMainWindow->findChildren<QAction*>(QString(),Qt::FindDirectChildrenOnly); QList<QAction*> actions = pMainWindow->findChildren<QAction*>(QString(), Qt::FindDirectChildrenOnly);
QList<QMenu*> menus = pMainWindow->menuBar()->findChildren<QMenu*>(); QList<QMenu*> menus = pMainWindow->menuBar()->findChildren<QMenu*>();
foreach( const QMenu* menu, menus) { foreach( const QMenu* menu, menus) {
if (menu->title().isEmpty()) if (menu->title().isEmpty())
continue; continue;
loadShortCutsOfMenu(menu, actions); loadShortCutsOfMenu(menu, actions);
} }
foreach (QAction* action,actions) {
if (!action->text().isEmpty()) {
PEnvironmentShortcut item = std::make_shared<EnvironmentShortcut>();
item->name = action->objectName();
item->fullPath = QString("%1 : %2").arg(tr("action"),action->text());
item->action = action;
item->shortcut = action->shortcut().toString().trimmed();
mShortcuts.append(item);
}
}
endResetModel(); endResetModel();
} }