Skip to content

Commit

Permalink
#5643: User will be asked if the merge should be cancelled before clo…
Browse files Browse the repository at this point in the history
…sing the control dialog.
  • Loading branch information
codereader committed Jun 24, 2021
1 parent c5c1d4d commit 19ab4ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/wxutil/window/TransientWindow.h
Expand Up @@ -48,7 +48,7 @@ class TransientWindow :
virtual ~TransientWindow() {}

// Override wxWindow::Show
virtual bool Show(bool show = true);
virtual bool Show(bool show = true) override;

virtual void ToggleVisibility();

Expand Down
21 changes: 21 additions & 0 deletions radiant/ui/merge/MergeControlDialog.cpp
Expand Up @@ -9,6 +9,7 @@
#include "imap.h"
#include "wxutil/PathEntry.h"
#include "wxutil/Bitmap.h"
#include "wxutil/dialog/MessageBox.h"
#include "scenelib.h"
#include "string/convert.h"
#include "os/path.h"
Expand Down Expand Up @@ -127,6 +128,26 @@ void MergeControlDialog::onMainFrameShuttingDown()
InstancePtr().reset();
}

bool MergeControlDialog::Show(bool show)
{
// Check if there's a merge operation in progress
// If yes, we ask the user before closing the window
if (!show && IsShown() && GlobalMapModule().getEditMode() == IMap::EditMode::Merge)
{
if (wxutil::Messagebox::Show(_("Abort the Merge Operation?"),
_("The current merge operation hasn't been finished yet.\nDo you want to abort the merge?"),
IDialog::MessageType::MESSAGE_ASK, this) == IDialog::RESULT_NO)
{
return false; // block this call
}

// User wants to cancel, abort the merge and continue calling base
GlobalMapModule().abortMergeOperation();
}

return TransientWindow::Show(show);
}

void MergeControlDialog::ShowDialog(const cmd::ArgumentList& args)
{
Instance().Show();
Expand Down
4 changes: 3 additions & 1 deletion radiant/ui/merge/MergeControlDialog.h
Expand Up @@ -11,7 +11,7 @@ namespace ui
{


class MergeControlDialog :
class MergeControlDialog final :
public wxutil::TransientWindow,
private wxutil::XmlResourceBasedWidget,
public SelectionSystem::Observer,
Expand All @@ -31,6 +31,8 @@ class MergeControlDialog :

static MergeControlDialog& Instance();

bool Show(bool show = true) override;

// The command target
static void ShowDialog(const cmd::ArgumentList& args);

Expand Down

0 comments on commit 19ab4ed

Please sign in to comment.