mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added settings to mention users with ,
This commit is contained in:
parent
b84c3ac3be
commit
b513caf572
|
@ -77,7 +77,7 @@ int CompletionModel::rowCount(const QModelIndex &) const
|
|||
return this->items_.size();
|
||||
}
|
||||
|
||||
void CompletionModel::refresh(const QString &prefix)
|
||||
void CompletionModel::refresh(const QString &prefix, bool isFirstWord)
|
||||
{
|
||||
std::function<void(const QString &, TaggedString::Type)> addString;
|
||||
if (getSettings()->prefixOnlyEmoteCompletion)
|
||||
|
@ -120,6 +120,9 @@ void CompletionModel::refresh(const QString &prefix)
|
|||
auto usernames = channel->accessChatters();
|
||||
|
||||
QString usernamePrefix = prefix;
|
||||
QString usernamePostfix =
|
||||
isFirstWord && getSettings()->mentionUsersWithComma ? ","
|
||||
: QString();
|
||||
|
||||
if (usernamePrefix.startsWith("@"))
|
||||
{
|
||||
|
@ -127,7 +130,8 @@ void CompletionModel::refresh(const QString &prefix)
|
|||
for (const auto &name :
|
||||
usernames->subrange(Prefix(usernamePrefix)))
|
||||
{
|
||||
addString("@" + name, TaggedString::Type::Username);
|
||||
addString("@" + name + usernamePostfix,
|
||||
TaggedString::Type::Username);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -135,7 +139,8 @@ void CompletionModel::refresh(const QString &prefix)
|
|||
for (const auto &name :
|
||||
usernames->subrange(Prefix(usernamePrefix)))
|
||||
{
|
||||
addString(name, TaggedString::Type::Username);
|
||||
addString(name + usernamePostfix,
|
||||
TaggedString::Type::Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
virtual QVariant data(const QModelIndex &index, int) const override;
|
||||
virtual int rowCount(const QModelIndex &) const override;
|
||||
|
||||
void refresh(const QString &prefix);
|
||||
void refresh(const QString &prefix, bool isFirstWord = false);
|
||||
|
||||
private:
|
||||
TaggedString createUser(const QString &str);
|
||||
|
|
|
@ -104,6 +104,8 @@ public:
|
|||
|
||||
BoolSetting pauseChatOnHover = {"/behaviour/pauseChatHover", false};
|
||||
BoolSetting autorun = {"/behaviour/autorun", false};
|
||||
BoolSetting mentionUsersWithComma = {"/behaviour/mentionUsersWithComma",
|
||||
true};
|
||||
|
||||
/// Commands
|
||||
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};
|
||||
|
|
|
@ -102,6 +102,17 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
|||
}
|
||||
|
||||
QString currentCompletionPrefix = this->textUnderCursor();
|
||||
bool isFirstWord = [&] {
|
||||
QString plainText = this->toPlainText();
|
||||
for (int i = this->textCursor().position(); i >= 0; i--)
|
||||
{
|
||||
if (plainText[i] == ' ')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
|
||||
// check if there is something to complete
|
||||
if (currentCompletionPrefix.size() <= 1)
|
||||
|
@ -117,7 +128,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
|||
// First type pressing tab after modifying a message, we refresh our
|
||||
// completion model
|
||||
this->completer_->setModel(completionModel);
|
||||
completionModel->refresh(currentCompletionPrefix);
|
||||
completionModel->refresh(currentCompletionPrefix, isFirstWord);
|
||||
this->completionInProgress_ = true;
|
||||
this->completer_->setCompletionPrefix(currentCompletionPrefix);
|
||||
this->completer_->complete();
|
||||
|
|
|
@ -262,6 +262,8 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
|||
layout.addCheckbox("Show stream title", s.headerStreamTitle);
|
||||
|
||||
layout.addTitle("Miscellaneous");
|
||||
layout.addCheckbox("Mention users with a comma (User,)",
|
||||
s.mentionUsersWithComma);
|
||||
layout.addCheckbox("Show joined users (< 1000 chatters)", s.showJoins);
|
||||
layout.addCheckbox("Show parted users (< 1000 chatters)", s.showParts);
|
||||
layout.addCheckbox("Lowercase domains", s.lowercaseDomains);
|
||||
|
|
Loading…
Reference in a new issue