summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemlinkhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-07 17:12:59 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-07 17:12:59 +0300
commit2538267ce30c5cfe3bbf23442e7c3a80e647f260 (patch)
tree5490d8aa2931645af09e35cee0e6b255592103a9 /src/gui/widgets/itemlinkhandler.cpp
parent7807ed17587b09c39dcd815a554f48e2f6ecb346 (diff)
downloadmv-2538267ce30c5cfe3bbf23442e7c3a80e647f260.tar.gz
mv-2538267ce30c5cfe3bbf23442e7c3a80e647f260.tar.bz2
mv-2538267ce30c5cfe3bbf23442e7c3a80e647f260.tar.xz
mv-2538267ce30c5cfe3bbf23442e7c3a80e647f260.zip
For commands in links in chat ask before executing command.
Diffstat (limited to 'src/gui/widgets/itemlinkhandler.cpp')
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index a8e90acd7..47314ca5c 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -42,6 +42,7 @@
#include "resources/db/itemdb.h"
+#include "listeners/inputactionremotelistener.h"
#include "listeners/openurllistener.h"
#include "debug.h"
@@ -52,7 +53,8 @@ namespace
} // namespace
ItemLinkHandler::ItemLinkHandler() :
- LinkHandler()
+ LinkHandler(),
+ mAllowCommands(true)
{
}
@@ -72,7 +74,22 @@ void ItemLinkHandler::handleCommandLink(const std::string &link,
cmd = cmdStr;
args.clear();
}
- inputManager.executeRemoteChatCommand(cmd, args, nullptr);
+ if (mAllowCommands)
+ {
+ inputManager.executeRemoteChatCommand(cmd, args, nullptr);
+ }
+ else
+ {
+ inputActionRemoteListener.setCommand(cmd, args);
+ ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
+ // TRANSLATORS: dialog message
+ _("Run command"),
+ strprintf("/%s %s", cmd.c_str(), args.c_str()),
+ SOUND_REQUEST,
+ false,
+ Modal_true);
+ confirmDlg->addActionListener(&inputActionRemoteListener);
+ }
}
void ItemLinkHandler::handleHelpLink(const std::string &link)