Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5440: Add FileOverwriteConfirmationHandler to UI module
- Loading branch information
1 parent
e836a29
commit 35364ec
Showing
6 changed files
with
60 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "idialogmanager.h" | ||
#include "iradiant.h" | ||
#include "messages/FileOverwriteConfirmation.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
class FileOverwriteConfirmationHandler | ||
{ | ||
private: | ||
std::size_t _msgSubscription; | ||
|
||
public: | ||
FileOverwriteConfirmationHandler() | ||
{ | ||
_msgSubscription = GlobalRadiantCore().getMessageBus().addListener( | ||
radiant::IMessage::Type::FileOverwriteConfirmation, | ||
radiant::TypeListener<radiant::FileOverwriteConfirmation>( | ||
sigc::mem_fun(this, &FileOverwriteConfirmationHandler::handleRequest))); | ||
} | ||
|
||
~FileOverwriteConfirmationHandler() | ||
{ | ||
GlobalRadiantCore().getMessageBus().removeListener(_msgSubscription); | ||
} | ||
|
||
private: | ||
void handleRequest(radiant::FileOverwriteConfirmation& msg) | ||
{ | ||
// Ask the user | ||
auto msgBox = GlobalDialogManager().createMessageBox( | ||
msg.hasTitle() ? msg.getTitle() : _("Confirm overwrite"), | ||
msg.getMessage(), | ||
ui::IDialog::MESSAGE_ASK | ||
); | ||
|
||
auto result = msgBox->run(); | ||
|
||
if (result == ui::IDialog::RESULT_YES) | ||
{ | ||
msg.confirmOverwrite(); | ||
} | ||
|
||
msg.setHandled(true); | ||
} | ||
}; | ||
|
||
} |
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
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