mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Improve editing of hotkeys (#4628)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
fb02d59b48
commit
c7b22939d5
|
@ -4,6 +4,7 @@
|
|||
|
||||
- Minor: Add an icon showing when streamer mode is enabled (#4410)
|
||||
- Minor: Added `/shoutout <username>` commands to shoutout specified user. (#4638)
|
||||
- Minor: Improved editing hotkeys. (#4628)
|
||||
- Dev: Added command to set Qt's logging filter/rules at runtime (`/c2-set-logging-rules`). (#4637)
|
||||
- Dev: Added the ability to see & load custom themes from the Themes directory. No stable promises are made of this feature, changes might be made that breaks custom themes without notice. (#4570)
|
||||
- Dev: Added test cases for emote and tab completion. (#4644)
|
||||
|
|
|
@ -5,6 +5,20 @@
|
|||
#include <QString>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
inline const std::vector<std::pair<QString, std::vector<QString>>>
|
||||
HOTKEY_ARG_ON_OFF_TOGGLE = {
|
||||
{"Toggle", {}},
|
||||
{"Set to on", {"on"}},
|
||||
{"Set to off", {"off"}},
|
||||
};
|
||||
|
||||
inline const std::vector<std::pair<QString, std::vector<QString>>>
|
||||
HOTKEY_ARG_WITH_OR_WITHOUT_SELECTION = {
|
||||
{"No", {"withoutSelection"}},
|
||||
{"Yes", {"withSelection"}},
|
||||
};
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
@ -13,6 +27,9 @@ struct ActionDefinition {
|
|||
// displayName is the value that would be shown to a user when they edit or create a hotkey for an action
|
||||
QString displayName;
|
||||
|
||||
// argumentDescription is a description of the arguments in a format of
|
||||
// "<required arg: description of possible values> [optional arg: possible
|
||||
// values]"
|
||||
QString argumentDescription = "";
|
||||
|
||||
// minCountArguments is the minimum amount of arguments the action accepts
|
||||
|
@ -21,6 +38,20 @@ struct ActionDefinition {
|
|||
|
||||
// maxCountArguments is the maximum amount of arguments the action accepts
|
||||
uint8_t maxCountArguments = minCountArguments;
|
||||
|
||||
// possibleArguments is empty or contains all possible argument values,
|
||||
// it is an ordered mapping from option name (what the user sees) to
|
||||
// arguments (what the action code will see).
|
||||
// As std::map<K, V> does not guarantee order this is a std::vector<...>
|
||||
std::vector<std::pair<QString, std::vector<QString>>> possibleArguments =
|
||||
{};
|
||||
|
||||
// When possibleArguments are present this should be a string like
|
||||
// "Direction:" which will be shown before the values from
|
||||
// possibleArguments in the UI. Otherwise, it should be empty.
|
||||
QString argumentsPrompt = "";
|
||||
// A more detailed description of what argumentsPrompt means
|
||||
QString argumentsPromptHover = "";
|
||||
};
|
||||
|
||||
using ActionDefinitionMap = std::map<QString, ActionDefinition>;
|
||||
|
@ -39,9 +70,15 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
}},
|
||||
{"scrollPage",
|
||||
ActionDefinition{
|
||||
"Scroll",
|
||||
"<up or down>",
|
||||
1,
|
||||
.displayName = "Scroll",
|
||||
.argumentDescription = "<direction: up or down>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Up", {"up"}},
|
||||
{"Down", {"down"}},
|
||||
},
|
||||
.argumentsPrompt = "Direction:",
|
||||
}},
|
||||
{"search", ActionDefinition{"Focus search box"}},
|
||||
{"execModeratorAction",
|
||||
|
@ -57,9 +94,19 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"delete", ActionDefinition{"Close"}},
|
||||
{"focus",
|
||||
ActionDefinition{
|
||||
"Focus neighbouring split",
|
||||
"<up, down, left, or right>",
|
||||
1,
|
||||
.displayName = "Focus neighbouring split",
|
||||
.argumentDescription = "<direction: up, down, left or right>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Up", {"up"}},
|
||||
{"Down", {"down"}},
|
||||
{"Left", {"left"}},
|
||||
{"Right", {"right"}},
|
||||
},
|
||||
.argumentsPrompt = "Direction:",
|
||||
.argumentsPromptHover =
|
||||
"Which direction to look for a split to focus?",
|
||||
}},
|
||||
{"openInBrowser", ActionDefinition{"Open channel in browser"}},
|
||||
{"openInCustomPlayer",
|
||||
|
@ -71,10 +118,18 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"reconnect", ActionDefinition{"Reconnect to chat"}},
|
||||
{"reloadEmotes",
|
||||
ActionDefinition{
|
||||
"Reload emotes",
|
||||
"[channel or subscriber]",
|
||||
0,
|
||||
1,
|
||||
.displayName = "Reload emotes",
|
||||
.argumentDescription =
|
||||
"[type: channel or subscriber; default: all emotes]",
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"All emotes", {}},
|
||||
{"Channel emotes only", {"channel"}},
|
||||
{"Subscriber emotes only", {"subscriber"}},
|
||||
},
|
||||
.argumentsPrompt = "Emote type:",
|
||||
.argumentsPromptHover = "Which emotes should Chatterino reload",
|
||||
}},
|
||||
{"runCommand",
|
||||
ActionDefinition{
|
||||
|
@ -84,25 +139,41 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
}},
|
||||
{"scrollPage",
|
||||
ActionDefinition{
|
||||
"Scroll",
|
||||
"<up or down>",
|
||||
1,
|
||||
.displayName = "Scroll",
|
||||
.argumentDescription = "<up or down>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Up", {"up"}},
|
||||
{"Down", {"down"}},
|
||||
},
|
||||
.argumentsPrompt = "Direction:",
|
||||
.argumentsPromptHover =
|
||||
"Which direction do you want to see more messages",
|
||||
}},
|
||||
{"scrollToBottom", ActionDefinition{"Scroll to the bottom"}},
|
||||
{"scrollToTop", ActionDefinition{"Scroll to the top"}},
|
||||
{"setChannelNotification",
|
||||
ActionDefinition{
|
||||
"Set channel live notification",
|
||||
"[on or off. default: toggle]",
|
||||
0,
|
||||
1,
|
||||
.displayName = "Set channel live notification",
|
||||
.argumentDescription = "[on or off. default: toggle]",
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments = HOTKEY_ARG_ON_OFF_TOGGLE,
|
||||
.argumentsPrompt = "New value:",
|
||||
.argumentsPromptHover = "Should the channel live notification be "
|
||||
"enabled, disabled or toggled",
|
||||
}},
|
||||
{"setModerationMode",
|
||||
ActionDefinition{
|
||||
"Set moderation mode",
|
||||
"[on or off. default: toggle]",
|
||||
0,
|
||||
1,
|
||||
.displayName = "Set moderation mode",
|
||||
.argumentDescription = "[on or off. default: toggle]",
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments = HOTKEY_ARG_ON_OFF_TOGGLE,
|
||||
.argumentsPrompt = "New value:",
|
||||
.argumentsPromptHover =
|
||||
"Should the moderation mode be enabled, disabled or toggled",
|
||||
}},
|
||||
{"showSearch", ActionDefinition{"Search current channel"}},
|
||||
{"showGlobalSearch", ActionDefinition{"Search all channels"}},
|
||||
|
@ -114,21 +185,38 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"clear", ActionDefinition{"Clear message"}},
|
||||
{"copy",
|
||||
ActionDefinition{
|
||||
"Copy",
|
||||
"<source of text: split, splitInput or auto>",
|
||||
1,
|
||||
.displayName = "Copy",
|
||||
.argumentDescription =
|
||||
"<source of text: auto, split or splitInput>",
|
||||
.minCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Automatic", {"auto"}},
|
||||
{"Split", {"split"}},
|
||||
{"Split Input", {"splitInput"}},
|
||||
},
|
||||
.argumentsPrompt = "Source of text:",
|
||||
}},
|
||||
{"cursorToStart",
|
||||
ActionDefinition{
|
||||
"To start of message",
|
||||
"<withSelection or withoutSelection>",
|
||||
1,
|
||||
.displayName = "To start of message",
|
||||
.argumentDescription =
|
||||
"<selection mode: withSelection or withoutSelection>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments = HOTKEY_ARG_WITH_OR_WITHOUT_SELECTION,
|
||||
.argumentsPrompt = "Select text from cursor to start:",
|
||||
// XXX: write a hover for this that doesn't suck
|
||||
}},
|
||||
{"cursorToEnd",
|
||||
ActionDefinition{
|
||||
"To end of message",
|
||||
"<withSelection or withoutSelection>",
|
||||
1,
|
||||
.displayName = "To end of message",
|
||||
.argumentDescription =
|
||||
"<selection mode: withSelection or withoutSelection>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments = HOTKEY_ARG_WITH_OR_WITHOUT_SELECTION,
|
||||
.argumentsPrompt = "Select text from cursor to end:",
|
||||
// XXX: write a hover for this that doesn't suck
|
||||
}},
|
||||
{"nextMessage", ActionDefinition{"Choose next sent message"}},
|
||||
{"openEmotesPopup", ActionDefinition{"Open emotes list"}},
|
||||
|
@ -140,10 +228,16 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"selectWord", ActionDefinition{"Select word"}},
|
||||
{"sendMessage",
|
||||
ActionDefinition{
|
||||
"Send message",
|
||||
.displayName = "Send message",
|
||||
.argumentDescription =
|
||||
"[keepInput to not clear the text after sending]",
|
||||
0,
|
||||
1,
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Default behavior", {}},
|
||||
{"Keep message in input after sending it", {"keepInput"}},
|
||||
},
|
||||
.argumentsPrompt = "Behavior:",
|
||||
}},
|
||||
{"undo", ActionDefinition{"Undo"}},
|
||||
|
||||
|
@ -163,7 +257,7 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"moveTab",
|
||||
ActionDefinition{
|
||||
"Move tab",
|
||||
"<next, previous, or new index of tab>",
|
||||
"<where to move the tab: next, previous, or new index of tab>",
|
||||
1,
|
||||
}},
|
||||
{"newSplit", ActionDefinition{"Create a new split"}},
|
||||
|
@ -172,40 +266,73 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
|
|||
{"openTab",
|
||||
ActionDefinition{
|
||||
"Select tab",
|
||||
"<last, next, previous, or index of tab to select>",
|
||||
"<which tab to select: last, next, previous, or index>",
|
||||
1,
|
||||
}},
|
||||
{"openQuickSwitcher", ActionDefinition{"Open the quick switcher"}},
|
||||
{"popup",
|
||||
ActionDefinition{
|
||||
"New popup",
|
||||
"<split or window>",
|
||||
1,
|
||||
.displayName = "New popup",
|
||||
.argumentDescription = "<split or window>",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments{
|
||||
{"Focused Split", {"split"}},
|
||||
{"Entire Tab", {"window"}},
|
||||
},
|
||||
.argumentsPrompt = "Include:",
|
||||
.argumentsPromptHover =
|
||||
"What should be included in the new popup",
|
||||
}},
|
||||
{"quit", ActionDefinition{"Quit Chatterino"}},
|
||||
{"removeTab", ActionDefinition{"Remove current tab"}},
|
||||
{"reopenSplit", ActionDefinition{"Reopen closed split"}},
|
||||
{"setStreamerMode",
|
||||
ActionDefinition{
|
||||
"Set streamer mode",
|
||||
.displayName = "Set streamer mode",
|
||||
.argumentDescription =
|
||||
"[on, off, toggle, or auto. default: toggle]",
|
||||
0,
|
||||
1,
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments =
|
||||
{
|
||||
{"Toggle on/off", {}},
|
||||
{"Set to on", {"on"}},
|
||||
{"Set to off", {"off"}},
|
||||
{"Set to automatic", {"auto"}},
|
||||
},
|
||||
.argumentsPrompt = "New value:",
|
||||
.argumentsPromptHover =
|
||||
"Should streamer mode be enabled, disabled, toggled (on/off) "
|
||||
"or set to auto",
|
||||
}},
|
||||
{"toggleLocalR9K", ActionDefinition{"Toggle local R9K"}},
|
||||
{"zoom",
|
||||
ActionDefinition{
|
||||
"Zoom in/out",
|
||||
"<in, out, or reset>",
|
||||
1,
|
||||
.displayName = "Zoom in/out",
|
||||
.argumentDescription = "Argument:",
|
||||
.minCountArguments = 1,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments =
|
||||
{
|
||||
{"Zoom in", {"in"}},
|
||||
{"Zoom out", {"out"}},
|
||||
{"Reset zoom", {"reset"}},
|
||||
},
|
||||
.argumentsPrompt = "Option:",
|
||||
}},
|
||||
{"setTabVisibility",
|
||||
ActionDefinition{
|
||||
"Set tab visibility",
|
||||
"[on, off, or toggle. default: toggle]",
|
||||
0,
|
||||
1,
|
||||
}}}},
|
||||
.displayName = "Set tab visibility",
|
||||
.argumentDescription = "[on, off, or toggle. default: toggle]",
|
||||
.minCountArguments = 0,
|
||||
.maxCountArguments = 1,
|
||||
.possibleArguments = HOTKEY_ARG_ON_OFF_TOGGLE,
|
||||
.argumentsPrompt = "New value:",
|
||||
.argumentsPromptHover =
|
||||
"Should the tabs be enabled, disabled or toggled.",
|
||||
}},
|
||||
}},
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "controllers/hotkeys/HotkeyHelpers.hpp"
|
||||
|
||||
#include "controllers/hotkeys/ActionNames.hpp"
|
||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <QStringList>
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -27,4 +31,20 @@ std::vector<QString> parseHotkeyArguments(QString argumentString)
|
|||
return arguments;
|
||||
}
|
||||
|
||||
boost::optional<ActionDefinition> findHotkeyActionDefinition(
|
||||
HotkeyCategory category, const QString &action)
|
||||
{
|
||||
auto allActions = actionNames.find(category);
|
||||
if (allActions != actionNames.end())
|
||||
{
|
||||
const auto &actionsMap = allActions->second;
|
||||
auto definition = actionsMap.find(action);
|
||||
if (definition != actionsMap.end())
|
||||
{
|
||||
return {definition->second};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "controllers/hotkeys/ActionNames.hpp"
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <QString>
|
||||
|
||||
#include <vector>
|
||||
|
@ -7,5 +10,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
std::vector<QString> parseHotkeyArguments(QString argumentString);
|
||||
boost::optional<ActionDefinition> findHotkeyActionDefinition(
|
||||
HotkeyCategory category, const QString &action);
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -17,6 +17,14 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
|
|||
, data_(hotkey)
|
||||
{
|
||||
this->ui_->setupUi(this);
|
||||
this->setStyleSheet(R"(QToolTip {
|
||||
padding: 2px;
|
||||
background-color: #333333;
|
||||
border: 1px solid #545454;
|
||||
color: white;
|
||||
})");
|
||||
this->ui_->easyArgsPicker->setVisible(false);
|
||||
this->ui_->easyArgsLabel->setVisible(false);
|
||||
// dynamically add category names to the category picker
|
||||
for (const auto &[_, hotkeyCategory] : getApp()->hotkeys->categories())
|
||||
{
|
||||
|
@ -27,6 +35,19 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
|
|||
this->ui_->warningLabel->hide();
|
||||
|
||||
if (hotkey)
|
||||
{
|
||||
this->setFromHotkey(hotkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
// adding a new hotkey
|
||||
this->setWindowTitle("Add hotkey");
|
||||
this->ui_->categoryPicker->setCurrentIndex(
|
||||
size_t(HotkeyCategory::SplitInput));
|
||||
this->ui_->argumentsEdit->setPlainText("");
|
||||
}
|
||||
}
|
||||
void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||
{
|
||||
if (!hotkey->validAction())
|
||||
{
|
||||
|
@ -41,6 +62,65 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
|
|||
this->ui_->keyComboEdit->setKeySequence(
|
||||
QKeySequence::fromString(hotkey->keySequence().toString()));
|
||||
this->ui_->nameEdit->setText(hotkey->name());
|
||||
|
||||
auto def = findHotkeyActionDefinition(hotkey->category(), hotkey->action());
|
||||
if (def.has_value() && !def->possibleArguments.empty())
|
||||
{
|
||||
qCDebug(chatterinoHotkeys) << "Enabled easy picker and arg edit "
|
||||
"because we have arguments from hotkey";
|
||||
this->ui_->easyArgsLabel->setVisible(true);
|
||||
this->ui_->easyArgsPicker->setVisible(true);
|
||||
|
||||
this->ui_->argumentsEdit->setVisible(false);
|
||||
this->ui_->argumentsLabel->setVisible(false);
|
||||
this->ui_->argumentsDescription->setVisible(false);
|
||||
|
||||
this->ui_->easyArgsPicker->clear();
|
||||
this->ui_->easyArgsLabel->setText(def->argumentsPrompt);
|
||||
this->ui_->easyArgsLabel->setToolTip(def->argumentsPromptHover);
|
||||
int matchIdx = -1;
|
||||
for (int i = 0; i < def->possibleArguments.size(); i++)
|
||||
{
|
||||
const auto &[displayText, argData] = def->possibleArguments.at(i);
|
||||
this->ui_->easyArgsPicker->addItem(displayText);
|
||||
|
||||
// check if matches
|
||||
if (argData.size() != hotkey->arguments().size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool matches = true;
|
||||
for (int j = 0; j < argData.size(); j++)
|
||||
{
|
||||
if (argData.at(j) != hotkey->arguments().at(j))
|
||||
{
|
||||
matches = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matches)
|
||||
{
|
||||
matchIdx = i;
|
||||
}
|
||||
}
|
||||
if (matchIdx != -1)
|
||||
{
|
||||
this->ui_->easyArgsPicker->setCurrentIndex(matchIdx);
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(chatterinoHotkeys)
|
||||
<< "Did not match hotkey arguments for " << hotkey->toString()
|
||||
<< "using text edit instead of easy picker";
|
||||
this->showEditError("Arguments do not match what's expected. The "
|
||||
"argument picker is not available.");
|
||||
this->ui_->easyArgsLabel->setVisible(false);
|
||||
this->ui_->easyArgsPicker->setVisible(false);
|
||||
|
||||
this->ui_->argumentsEdit->setVisible(true);
|
||||
this->ui_->argumentsLabel->setVisible(true);
|
||||
this->ui_->argumentsDescription->setVisible(true);
|
||||
}
|
||||
// update arguments
|
||||
QString argsText;
|
||||
bool first = true;
|
||||
|
@ -57,15 +137,6 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
|
|||
}
|
||||
this->ui_->argumentsEdit->setPlainText(argsText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// adding a new hotkey
|
||||
this->setWindowTitle("Add hotkey");
|
||||
this->ui_->categoryPicker->setCurrentIndex(
|
||||
size_t(HotkeyCategory::SplitInput));
|
||||
this->ui_->argumentsEdit->setPlainText("");
|
||||
}
|
||||
}
|
||||
|
||||
EditHotkeyDialog::~EditHotkeyDialog()
|
||||
{
|
||||
|
@ -151,6 +222,14 @@ void EditHotkeyDialog::afterEdit()
|
|||
action = actionTemp.toString();
|
||||
}
|
||||
|
||||
auto def = findHotkeyActionDefinition(*category, action);
|
||||
if (def.has_value() && this->ui_->easyArgsPicker->isVisible())
|
||||
{
|
||||
arguments =
|
||||
def->possibleArguments.at(this->ui_->easyArgsPicker->currentIndex())
|
||||
.second;
|
||||
}
|
||||
|
||||
auto hotkey = std::make_shared<Hotkey>(
|
||||
*category, this->ui_->keyComboEdit->keySequence(), action, arguments,
|
||||
nameText);
|
||||
|
@ -263,24 +342,29 @@ void EditHotkeyDialog::updateArgumentsInput()
|
|||
}
|
||||
const ActionDefinition &def = definition->second;
|
||||
|
||||
if (def.maxCountArguments != 0)
|
||||
if (def.maxCountArguments == 0)
|
||||
{
|
||||
QString text =
|
||||
"Arguments wrapped in <> are required.\nArguments wrapped in "
|
||||
"[] "
|
||||
"are optional.\nArguments are separated by a newline.";
|
||||
qCDebug(chatterinoHotkeys) << "Disabled easy picker and arg edit "
|
||||
"because we don't have any arguments";
|
||||
this->ui_->argumentsLabel->setVisible(false);
|
||||
this->ui_->argumentsDescription->setVisible(false);
|
||||
this->ui_->argumentsEdit->setVisible(false);
|
||||
|
||||
this->ui_->easyArgsLabel->setVisible(false);
|
||||
this->ui_->easyArgsPicker->setVisible(false);
|
||||
return;
|
||||
}
|
||||
if (!def.argumentDescription.isEmpty())
|
||||
{
|
||||
this->ui_->argumentsDescription->setVisible(true);
|
||||
this->ui_->argumentsDescription->setText(
|
||||
def.argumentDescription);
|
||||
this->ui_->argumentsDescription->setText(def.argumentDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_->argumentsDescription->setVisible(false);
|
||||
}
|
||||
|
||||
text = QString("Arguments wrapped in <> are required.");
|
||||
QString text = "Arguments wrapped in <> are required.";
|
||||
if (def.maxCountArguments != def.minCountArguments)
|
||||
{
|
||||
text += QString("\nArguments wrapped in [] are optional.");
|
||||
|
@ -294,13 +378,33 @@ void EditHotkeyDialog::updateArgumentsInput()
|
|||
this->ui_->argumentsLabel->setVisible(true);
|
||||
this->ui_->argumentsDescription->setVisible(true);
|
||||
this->ui_->argumentsEdit->setVisible(true);
|
||||
}
|
||||
else
|
||||
|
||||
// update easy picker
|
||||
if (def.possibleArguments.empty())
|
||||
{
|
||||
this->ui_->argumentsLabel->setVisible(false);
|
||||
this->ui_->argumentsDescription->setVisible(false);
|
||||
this->ui_->argumentsEdit->setVisible(false);
|
||||
qCDebug(chatterinoHotkeys)
|
||||
<< "Disabled easy picker because we have possible arguments";
|
||||
this->ui_->easyArgsPicker->setVisible(false);
|
||||
this->ui_->easyArgsLabel->setVisible(false);
|
||||
return;
|
||||
}
|
||||
qCDebug(chatterinoHotkeys)
|
||||
<< "Enabled easy picker because we have possible arguments";
|
||||
this->ui_->easyArgsPicker->setVisible(true);
|
||||
this->ui_->easyArgsLabel->setVisible(true);
|
||||
|
||||
this->ui_->argumentsLabel->setVisible(false);
|
||||
this->ui_->argumentsEdit->setVisible(false);
|
||||
this->ui_->argumentsDescription->setVisible(false);
|
||||
|
||||
this->ui_->easyArgsPicker->clear();
|
||||
for (const auto &[displayText, _] : def.possibleArguments)
|
||||
{
|
||||
this->ui_->easyArgsPicker->addItem(displayText);
|
||||
}
|
||||
this->ui_->easyArgsPicker->setCurrentIndex(0);
|
||||
this->ui_->easyArgsLabel->setText(def.argumentsPrompt);
|
||||
this->ui_->easyArgsLabel->setToolTip(def.argumentsPromptHover);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ protected slots:
|
|||
|
||||
private:
|
||||
void showEditError(QString errorText);
|
||||
void setFromHotkey(std::shared_ptr<Hotkey> hotkey);
|
||||
|
||||
Ui::EditHotkeyDialog *ui_;
|
||||
std::shared_ptr<Hotkey> data_;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -42,6 +42,9 @@ see this message :)</string>
|
|||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="toolTip">
|
||||
<string>Set a name for the hotkey so you will be able to identify it later</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
|
@ -76,6 +79,9 @@ see this message :)</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="categoryPicker"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="actionLabel">
|
||||
<property name="text">
|
||||
|
@ -95,6 +101,9 @@ see this message :)</string>
|
|||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="keyComboLabel">
|
||||
<property name="toolTip">
|
||||
<string>Pressing this keybinding will invoke the hotkey</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keybinding:</string>
|
||||
</property>
|
||||
|
@ -107,6 +116,16 @@ see this message :)</string>
|
|||
<widget class="QKeySequenceEdit" name="keyComboEdit"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="easyArgsLabel">
|
||||
<property name="toolTip">
|
||||
<string>You are not supposed to see this, please report this!</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Argument:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="argumentsLabel">
|
||||
<property name="text">
|
||||
<string>Arguments:</string>
|
||||
|
@ -116,7 +135,7 @@ see this message :)</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="argumentsDescription">
|
||||
<property name="text">
|
||||
<string>You should never see this message :)</string>
|
||||
|
@ -126,7 +145,7 @@ see this message :)</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QPlainTextEdit" name="argumentsEdit">
|
||||
<property name="plainText">
|
||||
<string/>
|
||||
|
@ -136,8 +155,18 @@ see this message :)</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="categoryPicker"/>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="easyArgsPicker">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -169,8 +198,8 @@ see this message :)</string>
|
|||
<slot>afterEdit()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>257</x>
|
||||
<y>290</y>
|
||||
<x>263</x>
|
||||
<y>352</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
|
@ -185,8 +214,8 @@ see this message :)</string>
|
|||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>290</y>
|
||||
<x>331</x>
|
||||
<y>352</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
|
@ -201,8 +230,8 @@ see this message :)</string>
|
|||
<slot>updatePossibleActions()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>246</x>
|
||||
<y>85</y>
|
||||
<x>172</x>
|
||||
<y>118</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>75</x>
|
||||
|
@ -217,8 +246,8 @@ see this message :)</string>
|
|||
<slot>updateArgumentsInput()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>148</x>
|
||||
<y>119</y>
|
||||
<x>172</x>
|
||||
<y>156</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>74</x>
|
||||
|
|
Loading…
Reference in a new issue