Fix crash caused by shortcuts when no project is loaded
This commit is contained in:
parent
b371860eb1
commit
174f66c35b
1 changed files with 12 additions and 22 deletions
|
@ -70,28 +70,18 @@ MainWindow::~MainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setWindowDisabled(bool disabled) {
|
void MainWindow::setWindowDisabled(bool disabled) {
|
||||||
for (auto *child : findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
|
for (auto action : findChildren<QAction *>())
|
||||||
bool disableThis = disabled;
|
action->setDisabled(disabled);
|
||||||
if (child->objectName() == "menuBar") {
|
for (auto child : findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly))
|
||||||
// disable all but the menuFile and menuHelp
|
child->setDisabled(disabled);
|
||||||
for (auto *menu : child->findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
|
for (auto menu : ui->menuBar->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly))
|
||||||
disableThis = disabled;
|
menu->setDisabled(disabled);
|
||||||
if (menu->objectName() == "menuFile") {
|
ui->menuBar->setDisabled(false);
|
||||||
// disable all but the action_Open_Project and action_Exit
|
ui->menuFile->setDisabled(false);
|
||||||
for (auto *action : menu->actions()) {
|
ui->action_Open_Project->setDisabled(false);
|
||||||
action->setDisabled(disabled);
|
ui->action_Exit->setDisabled(false);
|
||||||
}
|
ui->menuHelp->setDisabled(false);
|
||||||
ui->action_Open_Project->setDisabled(false);
|
ui->actionAbout_Porymap->setDisabled(false);
|
||||||
ui->action_Exit->setDisabled(false);
|
|
||||||
disableThis = false;
|
|
||||||
}
|
|
||||||
menu->setDisabled(disableThis);
|
|
||||||
}
|
|
||||||
child->findChild<QWidget *>("menuHelp")->setDisabled(false);
|
|
||||||
disableThis = false;
|
|
||||||
}
|
|
||||||
child->setDisabled(disableThis);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initWindow() {
|
void MainWindow::initWindow() {
|
||||||
|
|
Loading…
Reference in a new issue