mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fix red text color persisting from message overflow highlight (#4204)
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
188782ddca
commit
db12693a27
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
|
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
|
||||||
- Bugfix: Fixed unnecessary saving of windows layout. (#4201)
|
- Bugfix: Fixed unnecessary saving of windows layout. (#4201)
|
||||||
- Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198)
|
- Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace chatterino {
|
||||||
|
|
||||||
static const char *ANONYMOUS_USERNAME ATTR_UNUSED = "justinfan64537";
|
static const char *ANONYMOUS_USERNAME ATTR_UNUSED = "justinfan64537";
|
||||||
|
|
||||||
|
static constexpr int TWITCH_MESSAGE_LIMIT = 500;
|
||||||
|
|
||||||
inline QByteArray getDefaultClientID()
|
inline QByteArray getDefaultClientID()
|
||||||
{
|
{
|
||||||
return QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal");
|
return QByteArray("7ue61iz46fz11y3cugd0l3tawb4taal");
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||||
#include "messages/Link.hpp"
|
#include "messages/Link.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
|
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QSignalBlocker>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
@ -885,25 +887,29 @@ void SplitInput::editTextChanged()
|
||||||
app->commands->execCommand(text, this->split_->getChannel(), true);
|
app->commands->execCommand(text, this->split_->getChannel(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSettings()->messageOverflow.getValue() == MessageOverflow::Highlight)
|
if (text.length() > 0 &&
|
||||||
|
getSettings()->messageOverflow.getValue() == MessageOverflow::Highlight)
|
||||||
{
|
{
|
||||||
if (text.length() > TWITCH_MESSAGE_LIMIT &&
|
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
||||||
text.length() > this->lastOverflowLength)
|
QTextCharFormat format;
|
||||||
{
|
QList<QTextEdit::ExtraSelection> selections;
|
||||||
QTextCharFormat format;
|
|
||||||
format.setForeground(Qt::red);
|
|
||||||
|
|
||||||
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
cursor.setPosition(qMin(text.length(), TWITCH_MESSAGE_LIMIT),
|
||||||
cursor.setPosition(lastOverflowLength, QTextCursor::MoveAnchor);
|
QTextCursor::MoveAnchor);
|
||||||
|
cursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
|
||||||
|
selections.append({cursor, format});
|
||||||
|
|
||||||
|
if (text.length() > TWITCH_MESSAGE_LIMIT)
|
||||||
|
{
|
||||||
|
cursor.setPosition(TWITCH_MESSAGE_LIMIT, QTextCursor::MoveAnchor);
|
||||||
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||||
|
format.setForeground(Qt::red);
|
||||||
this->lastOverflowLength = text.length();
|
selections.append({cursor, format});
|
||||||
|
|
||||||
cursor.setCharFormat(format);
|
|
||||||
}
|
}
|
||||||
else if (this->lastOverflowLength != TWITCH_MESSAGE_LIMIT)
|
// block reemit of QTextEdit::textChanged()
|
||||||
{
|
{
|
||||||
this->lastOverflowLength = TWITCH_MESSAGE_LIMIT;
|
const QSignalBlocker b(this->ui_.textEdit);
|
||||||
|
this->ui_.textEdit->setExtraSelections(selections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,6 @@ public:
|
||||||
QString getInputText() const;
|
QString getInputText() const;
|
||||||
void insertText(const QString &text);
|
void insertText(const QString &text);
|
||||||
|
|
||||||
static const int TWITCH_MESSAGE_LIMIT = 500;
|
|
||||||
|
|
||||||
void setReply(std::shared_ptr<MessageThread> reply,
|
void setReply(std::shared_ptr<MessageThread> reply,
|
||||||
bool showInlineReplying = true);
|
bool showInlineReplying = true);
|
||||||
void setPlaceholderText(const QString &text);
|
void setPlaceholderText(const QString &text);
|
||||||
|
@ -151,8 +149,6 @@ protected:
|
||||||
QString currMsg_;
|
QString currMsg_;
|
||||||
int prevIndex_ = 0;
|
int prevIndex_ = 0;
|
||||||
|
|
||||||
int lastOverflowLength = TWITCH_MESSAGE_LIMIT;
|
|
||||||
|
|
||||||
// Hidden denotes whether this split input should be hidden or not
|
// Hidden denotes whether this split input should be hidden or not
|
||||||
// This is used instead of the regular QWidget::hide/show because
|
// This is used instead of the regular QWidget::hide/show because
|
||||||
// focus events don't work as expected, so instead we use this bool and
|
// focus events don't work as expected, so instead we use this bool and
|
||||||
|
|
Loading…
Reference in a new issue