Improve reply popup after thread update (#4923)
Co-authored-by: nerix <nero.9@hotmail.de> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1542,7 +1542,7 @@ void Split::drag()
|
||||
stopDraggingSplit();
|
||||
}
|
||||
|
||||
void Split::setInputReply(const std::shared_ptr<MessageThread> &reply)
|
||||
void Split::setInputReply(const MessagePtr &reply)
|
||||
{
|
||||
this->input_->setReply(reply);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelView;
|
||||
class MessageThread;
|
||||
class SplitHeader;
|
||||
class SplitInput;
|
||||
class SplitContainer;
|
||||
@@ -75,7 +74,7 @@ public:
|
||||
|
||||
void setContainer(SplitContainer *container);
|
||||
|
||||
void setInputReply(const std::shared_ptr<MessageThread> &reply);
|
||||
void setInputReply(const MessagePtr &reply);
|
||||
|
||||
static pajlada::Signals::Signal<Qt::KeyboardModifiers>
|
||||
modifierStatusChanged;
|
||||
|
||||
@@ -359,7 +359,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
|
||||
if (this->enableInlineReplying_)
|
||||
{
|
||||
// Remove @username prefix that is inserted when doing inline replies
|
||||
message.remove(0, this->replyThread_->root()->displayName.length() +
|
||||
message.remove(0, this->replyThread_->displayName.length() +
|
||||
1); // remove "@username"
|
||||
|
||||
if (!message.isEmpty() && message.at(0) == ' ')
|
||||
@@ -373,7 +373,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
|
||||
getApp()->commands->execCommand(message, c, false);
|
||||
|
||||
// Reply within TwitchChannel
|
||||
tc->sendReply(sendMessage, this->replyThread_->rootId());
|
||||
tc->sendReply(sendMessage, this->replyThread_->id);
|
||||
|
||||
this->postMessageSend(message, arguments);
|
||||
return "";
|
||||
@@ -992,7 +992,7 @@ void SplitInput::editTextChanged()
|
||||
// We need to verify that
|
||||
// 1. the @username prefix exists and
|
||||
// 2. if a character exists after the @username, it is a space
|
||||
QString replyPrefix = "@" + this->replyThread_->root()->displayName;
|
||||
QString replyPrefix = "@" + this->replyThread_->displayName;
|
||||
if (!text.startsWith(replyPrefix) ||
|
||||
(text.length() > replyPrefix.length() &&
|
||||
text.at(replyPrefix.length()) != ' '))
|
||||
@@ -1065,15 +1065,29 @@ void SplitInput::giveFocus(Qt::FocusReason reason)
|
||||
this->ui_.textEdit->setFocus(reason);
|
||||
}
|
||||
|
||||
void SplitInput::setReply(std::shared_ptr<MessageThread> reply,
|
||||
bool showReplyingLabel)
|
||||
void SplitInput::setReply(MessagePtr reply, bool showReplyingLabel)
|
||||
{
|
||||
auto oldParent = this->replyThread_;
|
||||
if (this->enableInlineReplying_ && oldParent)
|
||||
{
|
||||
// Remove old reply prefix
|
||||
auto replyPrefix = "@" + oldParent->displayName;
|
||||
auto plainText = this->ui_.textEdit->toPlainText().trimmed();
|
||||
if (plainText.startsWith(replyPrefix))
|
||||
{
|
||||
plainText.remove(0, replyPrefix.length());
|
||||
}
|
||||
this->ui_.textEdit->setPlainText(plainText.trimmed());
|
||||
this->ui_.textEdit->moveCursor(QTextCursor::EndOfBlock);
|
||||
this->ui_.textEdit->resetCompletion();
|
||||
}
|
||||
|
||||
this->replyThread_ = std::move(reply);
|
||||
|
||||
if (this->enableInlineReplying_)
|
||||
{
|
||||
// Only enable reply label if inline replying
|
||||
auto replyPrefix = "@" + this->replyThread_->root()->displayName;
|
||||
auto replyPrefix = "@" + this->replyThread_->displayName;
|
||||
auto plainText = this->ui_.textEdit->toPlainText().trimmed();
|
||||
if (!plainText.startsWith(replyPrefix))
|
||||
{
|
||||
@@ -1086,7 +1100,7 @@ void SplitInput::setReply(std::shared_ptr<MessageThread> reply,
|
||||
this->ui_.textEdit->resetCompletion();
|
||||
}
|
||||
this->ui_.replyLabel->setText("Replying to @" +
|
||||
this->replyThread_->root()->displayName);
|
||||
this->replyThread_->displayName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
@@ -19,7 +20,6 @@ class Split;
|
||||
class EmotePopup;
|
||||
class InputCompletionPopup;
|
||||
class EffectLabel;
|
||||
class MessageThread;
|
||||
class ResizingTextEdit;
|
||||
class ChannelView;
|
||||
enum class CompletionKind;
|
||||
@@ -40,8 +40,7 @@ public:
|
||||
QString getInputText() const;
|
||||
void insertText(const QString &text);
|
||||
|
||||
void setReply(std::shared_ptr<MessageThread> reply,
|
||||
bool showInlineReplying = true);
|
||||
void setReply(MessagePtr reply, bool showInlineReplying = true);
|
||||
void setPlaceholderText(const QString &text);
|
||||
|
||||
/**
|
||||
@@ -135,7 +134,7 @@ protected:
|
||||
EffectLabel *cancelReplyButton;
|
||||
} ui_{};
|
||||
|
||||
std::shared_ptr<MessageThread> replyThread_ = nullptr;
|
||||
MessagePtr replyThread_ = nullptr;
|
||||
bool enableInlineReplying_;
|
||||
|
||||
pajlada::Signals::SignalHolder managedConnections_;
|
||||
|
||||
Reference in New Issue
Block a user