summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp21
-rw-r--r--src/gui/widgets/itemlinkhandler.h9
-rw-r--r--src/gui/windows/chatwindow.cpp2
-rw-r--r--src/gui/windows/confirmdialog.cpp11
4 files changed, 35 insertions, 8 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)
diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h
index 6350b9fc3..6a0f87cb7 100644
--- a/src/gui/widgets/itemlinkhandler.h
+++ b/src/gui/widgets/itemlinkhandler.h
@@ -39,9 +39,12 @@ class ItemLinkHandler final : public LinkHandler
void handleLink(const std::string &link,
MouseEvent *event) override final;
+ void setAllowCommands(const bool b)
+ { mAllowCommands = b; }
+
private:
- static void handleCommandLink(const std::string &link,
- const std::string &prefix);
+ void handleCommandLink(const std::string &link,
+ const std::string &prefix);
static void handleHelpLink(const std::string &link);
@@ -51,6 +54,8 @@ class ItemLinkHandler final : public LinkHandler
static void handleItemLink(const std::string &link);
static void handleSearchLink(const std::string &link);
+
+ bool mAllowCommands;
};
#endif // GUI_WIDGETS_ITEMLINKHANDLER_H
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index b3a0ced78..5bed12f72 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -169,6 +169,8 @@ ChatWindow::ChatWindow() :
mColorPicker->addActionListener(this);
mColorPicker->setSelected(mChatColor);
+ mItemLinkHandler->setAllowCommands(false);
+
loadWindowState();
mColorPicker->setPosition(this->getWidth() - mColorPicker->getWidth()
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
index 62636fc16..e08177ef4 100644
--- a/src/gui/windows/confirmdialog.cpp
+++ b/src/gui/windows/confirmdialog.cpp
@@ -77,12 +77,15 @@ void ConfirmDialog::postInit()
if (width < inWidth)
width = inWidth;
- setContentSize(mTextBox->getMinWidth() + fontHeight, height + fontHeight +
- noButton->getHeight());
+ int windowWidth = width;
+ if (windowWidth < mTextBox->getMinWidth() + fontHeight)
+ {
+ windowWidth = mTextBox->getMinWidth() + fontHeight;
+ }
+ setContentSize(windowWidth,
+ height + fontHeight + noButton->getHeight());
mTextBox->setPosition(mPadding, mPadding);
- // 8 is the padding that GUIChan adds to button widgets
- // (top and bottom combined)
const int buttonPadding = getOption("buttonPadding", 8);
yesButton->setPosition((width - inWidth) / 2, height + buttonPadding);
noButton->setPosition(yesButton->getX() + yesButton->getWidth()