Skip to content

Commit

Permalink
Added modal parent to Save/Discard prompts via pull request #1484 fro…
Browse files Browse the repository at this point in the history
…m omgtehlion/dialog-fix
  • Loading branch information
dvorka authored Feb 3, 2024
2 parents c42a07e + 8a900ce commit 9298f39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/src/qt/note_editor_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ void NoteEditorView::keyPressEvent(QKeyEvent* event)
QMessageBox msgBox{
QMessageBox::Question,
tr("Exit Editor"),
tr("Do you really want to exit editor without saving?")
tr("Do you really want to exit editor without saving?"),
{},
parent
};
QPushButton* yes = msgBox.addButton("&Yes", QMessageBox::YesRole);
#ifdef __APPLE__
Expand Down
10 changes: 6 additions & 4 deletions app/src/qt/orloj_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ OrlojPresenter::OrlojPresenter(
SLOT(slotShowOutlineHeader()));
}

int dialogSaveOrCancel()
int dialogSaveOrCancel(QWidget* view)
{
// l10n by moving this dialog either to Qt class OR view class
QMessageBox msgBox{
QMessageBox::Question,
QObject::tr("Save Note"),
QObject::tr("Do you want to save changes?")
QObject::tr("Do you want to save changes?"),
{},
view
};

QPushButton* discard = msgBox.addButton(
Expand Down Expand Up @@ -791,7 +793,7 @@ bool OrlojPresenter::avoidDataLossOnNoteEdit()
if(Configuration::getInstance().isUiEditorAutosave()) {
decision = OrlojButtonRoles::SAVE_ROLE;
} else {
decision = dialogSaveOrCancel();
decision = dialogSaveOrCancel(view);
}

switch(decision) {
Expand All @@ -815,7 +817,7 @@ bool OrlojPresenter::avoidDataLossOnNoteEdit()
return true;
}
} else if(activeFacet == OrlojPresenterFacets::FACET_EDIT_OUTLINE_HEADER) {
int decision = dialogSaveOrCancel();
int decision = dialogSaveOrCancel(view);
switch(decision) {
case OrlojButtonRoles::DISCARD_ROLE:
// do nothing
Expand Down

0 comments on commit 9298f39

Please sign in to comment.