forked from mia/Aegisub
Add a better error message when a hotkey is set for an invalid command
This commit is contained in:
parent
40ddfa8e59
commit
46315d872f
4 changed files with 17 additions and 11 deletions
|
@ -28,11 +28,6 @@
|
||||||
|
|
||||||
namespace agi { struct Context; }
|
namespace agi { struct Context; }
|
||||||
|
|
||||||
DEFINE_BASE_EXCEPTION_NOINNER(CommandError, agi::Exception)
|
|
||||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandNotFound, CommandError, "command/notfound")
|
|
||||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandIconNone, CommandError, "command/icon")
|
|
||||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandIconInvalid, CommandError, "command/icon/invalid")
|
|
||||||
|
|
||||||
#define CMD_NAME(a) const char* name() const { return a; }
|
#define CMD_NAME(a) const char* name() const { return a; }
|
||||||
#define STR_MENU(a) wxString StrMenu(const agi::Context *) const { return _(a); }
|
#define STR_MENU(a) wxString StrMenu(const agi::Context *) const { return _(a); }
|
||||||
#define STR_DISP(a) wxString StrDisplay(const agi::Context *) const { return _(a); }
|
#define STR_DISP(a) wxString StrDisplay(const agi::Context *) const { return _(a); }
|
||||||
|
@ -72,6 +67,9 @@ struct cname : public Command { \
|
||||||
|
|
||||||
/// Commands
|
/// Commands
|
||||||
namespace cmd {
|
namespace cmd {
|
||||||
|
DEFINE_BASE_EXCEPTION_NOINNER(CommandError, agi::Exception)
|
||||||
|
DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandNotFound, CommandError, "command/notfound")
|
||||||
|
|
||||||
enum CommandFlags {
|
enum CommandFlags {
|
||||||
/// Default command type
|
/// Default command type
|
||||||
COMMAND_NORMAL = 0,
|
COMMAND_NORMAL = 0,
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
|
#include "compat.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
|
@ -163,12 +164,19 @@ bool check(std::string const& context, agi::Context *c, int key_code, int modifi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check(std::string const& context, agi::Context *c, wxKeyEvent &evt) {
|
bool check(std::string const& context, agi::Context *c, wxKeyEvent &evt) {
|
||||||
|
try {
|
||||||
if (!hotkey::check(context, c, evt.GetKeyCode(), evt.GetModifiers())) {
|
if (!hotkey::check(context, c, evt.GetKeyCode(), evt.GetModifiers())) {
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (cmd::CommandNotFound const& e) {
|
||||||
|
wxMessageBox(to_wx(e.GetChainedMessage()), _("Invalid command name for hotkey"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTER | wxSTAY_ON_TOP);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> get_hotkey_strs(std::string const& context, std::string const& command) {
|
std::vector<std::string> get_hotkey_strs(std::string const& context, std::string const& command) {
|
||||||
return inst->GetHotkeys(context, command);
|
return inst->GetHotkeys(context, command);
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
if (icon_bmp.IsOk())
|
if (icon_bmp.IsOk())
|
||||||
icon.CopyFromBitmap(icon_bmp);
|
icon.CopyFromBitmap(icon_bmp);
|
||||||
}
|
}
|
||||||
catch (agi::Exception const& e) {
|
catch (agi::Exception const&) {
|
||||||
// Just use no icon; error is reported in the description column
|
// Just use no icon; error is reported in the description column
|
||||||
}
|
}
|
||||||
variant << wxDataViewIconText(to_wx(combo.CmdName()), icon);
|
variant << wxDataViewIconText(to_wx(combo.CmdName()), icon);
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace {
|
||||||
try {
|
try {
|
||||||
command = cmd::get(command_name);
|
command = cmd::get(command_name);
|
||||||
}
|
}
|
||||||
catch (CommandNotFound const&) {
|
catch (cmd::CommandNotFound const&) {
|
||||||
LOG_W("toolbar/command/not_found") << "Command '" << command_name << "' not found; skipping";
|
LOG_W("toolbar/command/not_found") << "Command '" << command_name << "' not found; skipping";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue