-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #315237: Don't switch tab when opening a score when a modal is open
- Don't switch tab when opening a score when a modal is open - Make ScoreMigrationDialog QQuickWidget, so that it gets recognized by QApplication::activeModalWidget() - (This caused an issue that the QML content wasn't focussed when the dialog was opened, which I fixed too.) Result: - When you open one score, it is appended to the tab bar, and its tab is activated - The ScoreMigrationDialog for that score is shown - When you open a second score, it is appended to the tab bar, but its tab is not activated, because a modal dialog is open (namely the ScoreMigrationDialog for score 1) - When you close the dialog for score 1 and then switch to score 2 's tab, the ScoreMigrationDialog is shown for score 2.
- Loading branch information
1 parent
0ef97b5
commit afd77df
Showing
4 changed files
with
19 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
#include "scoremigrationdialog.h" | ||
|
||
#include <QQuickItem> | ||
|
||
ScoreMigrationDialog::ScoreMigrationDialog(QQmlEngine* engine, Ms::Score* score) | ||
: QQuickView(engine, nullptr), m_dialogModel(new ScoreMigrationDialogModel(score, this)) | ||
: QQuickWidget(engine, nullptr), m_dialogModel(new ScoreMigrationDialogModel(score, this)) | ||
{ | ||
setMinimumWidth(600); | ||
setMinimumHeight(m_dialogModel->isAutomaticPlacementAvailable() ? 570 : 548); | ||
|
||
setFlags(Qt::Dialog); | ||
setWindowFlags(Qt::Dialog); | ||
setWindowModality(Qt::ApplicationModal); | ||
|
||
setTitle(score->title()); | ||
setWindowTitle(score->title()); | ||
setSource(QUrl(QStringLiteral("qrc:/qml/migration/ScoreMigrationDialog.qml"))); | ||
|
||
setModality(Qt::ApplicationModal); | ||
setResizeMode(QQuickView::SizeRootObjectToView); | ||
setResizeMode(SizeRootObjectToView); | ||
|
||
connect(m_dialogModel, &ScoreMigrationDialogModel::closeRequested, this, &QQuickView::close); | ||
connect(m_dialogModel, &ScoreMigrationDialogModel::closeRequested, this, &QQuickWidget::close); | ||
|
||
if (rootObject()) | ||
rootObject()->setProperty("model", QVariant::fromValue(m_dialogModel)); | ||
} | ||
|
||
void ScoreMigrationDialog::focusInEvent(QFocusEvent* event) | ||
{ | ||
QQuickView::focusInEvent(event); | ||
QQuickWidget::focusInEvent(event); | ||
rootObject()->forceActiveFocus(); | ||
} | ||
|
||
void ScoreMigrationDialog::showEvent(QShowEvent* event) | ||
{ | ||
QQuickWidget::showEvent(event); | ||
setFocus(); | ||
rootObject()->forceActiveFocus(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters