Skip to content

Commit

Permalink
Merge pull request #963 from GamingasCZ/quitting
Browse files Browse the repository at this point in the history
Better warning popup when quitting with unsaved recording
  • Loading branch information
MaartenBaert authored Jun 13, 2022
2 parents 93a8810 + 77e3259 commit c092f3e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/GUI/PageRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,17 @@ PageRecord::~PageRecord() {

bool PageRecord::ShouldBlockClose() {
if(m_output_manager != NULL) {
if(MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION,
enum_button answer = MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION,
tr("You have not saved the current recording yet, if you quit now it will be lost.\n"
"Are you sure that you want to quit?"), BUTTON_YES | BUTTON_NO, BUTTON_YES) != BUTTON_YES) {
"What would you like to do with it?"), BUTTON_SAVE | BUTTON_DISCARD | BUTTON_CANCEL);
if(answer == BUTTON_DISCARD) {
return false;
}
if(answer == BUTTON_CANCEL) {
return true;
}
if(answer == BUTTON_SAVE) {
OnRecordSave();
return true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ enum_button MessageBox(QMessageBox::Icon icon, QWidget* parent, const QString& t
{BUTTON_YES_ALWAYS, QDialogButtonBox::tr("Yes, always"), QMessageBox::YesRole , NULL},
{BUTTON_NO , QDialogButtonBox::tr("&No") , QMessageBox::NoRole , NULL},
{BUTTON_NO_NEVER , QDialogButtonBox::tr("No, never") , QMessageBox::NoRole , NULL},
{BUTTON_DISCARD , QDialogButtonBox::tr("Discard") , QMessageBox::AcceptRole, NULL},
{BUTTON_SAVE , QDialogButtonBox::tr("Save") , QMessageBox::YesRole , NULL}
};

// add buttons
Expand Down
2 changes: 2 additions & 0 deletions src/common/Dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ enum enum_button : int {
BUTTON_YES_ALWAYS = 0x0008,
BUTTON_NO = 0x0010,
BUTTON_NO_NEVER = 0x0020,
BUTTON_DISCARD = 0x0040,
BUTTON_SAVE = 0x0080,
};

// Shows a standard Qt dialog with translated buttons.
Expand Down
9 changes: 7 additions & 2 deletions src/translations/simplescreenrecorder_cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2207,9 +2207,9 @@ Tyto klávesy budou odchyceny a nebudou předány nahrávané aplikaci.</transla
<message>
<location filename="../GUI/PageRecord.cpp" line="435"/>
<source>You have not saved the current recording yet, if you quit now it will be lost.
Are you sure that you want to quit?</source>
What would you like to do with it?</source>
<translation>Aktuální nahrávka dosud nebyla uložena a pokud program ukončíte nyní, bude ztracena.
Opravdu chcete program ukončit? </translation>
Co s ní chcete dělat?</translation>
</message>
<message>
<location filename="../GUI/PageRecord.cpp" line="447"/>
Expand Down Expand Up @@ -2551,6 +2551,11 @@ Tlačítko Spustit nahrávání je nahoře ;).</translation>
<source>No, never</source>
<translation type="unfinished">Ne, nikdy</translation>
</message>
<message>
<location filename="../common/Dialogs.cpp" line="41"/>
<source>Discard</source>
<translation type="unfinished">Zahodit</translation>
</message>
</context>
<context>
<name>QMessageBox</name>
Expand Down

0 comments on commit c092f3e

Please sign in to comment.