mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix scroll to bottom issue
This commit is contained in:
parent
768b3db27a
commit
b66dc479e6
10 changed files with 34 additions and 20 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QTimer>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace chatterino {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef LAZYLOADEDIMAGE_H
|
||||
#define LAZYLOADEDIMAGE_H
|
||||
#pragma once
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
@ -103,7 +102,6 @@ private:
|
|||
|
||||
void gifUpdateTimout();
|
||||
};
|
||||
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
||||
#endif // LAZYLOADEDIMAGE_H
|
||||
|
|
|
@ -21,13 +21,15 @@ namespace messages {
|
|||
|
||||
Message::Message(const QString &text)
|
||||
: _words()
|
||||
, _text(text)
|
||||
{
|
||||
_words.push_back(
|
||||
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
|
||||
}
|
||||
|
||||
Message::Message(const std::vector<Word> &words)
|
||||
Message::Message(const QString &text, const std::vector<Word> &words)
|
||||
: _words(words)
|
||||
, _text(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Message
|
|||
{
|
||||
public:
|
||||
Message(const QString &text);
|
||||
Message(const std::vector<messages::Word> &words);
|
||||
Message(const QString &text, const std::vector<messages::Word> &words);
|
||||
|
||||
bool getCanHighlightTab() const;
|
||||
const QString &getTimeoutUser() const;
|
||||
|
@ -38,6 +38,8 @@ public:
|
|||
bool isDisabled() const;
|
||||
const QString &getId() const;
|
||||
|
||||
const QString _text;
|
||||
|
||||
private:
|
||||
static LazyLoadedImage *badgeStaff;
|
||||
static LazyLoadedImage *badgeAdmin;
|
||||
|
|
|
@ -14,7 +14,7 @@ MessageBuilder::MessageBuilder()
|
|||
|
||||
SharedMessage MessageBuilder::build()
|
||||
{
|
||||
return SharedMessage(new Message(_words));
|
||||
return SharedMessage(new Message(this->originalMessage, _words));
|
||||
}
|
||||
|
||||
void MessageBuilder::appendWord(const Word &word)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MESSAGEBUILDER_H
|
||||
#define MESSAGEBUILDER_H
|
||||
#pragma once
|
||||
|
||||
#include "messages/message.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -20,11 +20,12 @@ public:
|
|||
|
||||
QString matchLink(const QString &string);
|
||||
|
||||
QString originalMessage;
|
||||
|
||||
private:
|
||||
std::vector<Word> _words;
|
||||
std::chrono::time_point<std::chrono::system_clock> _parseTime;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MESSAGEBUILDER_H
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -204,7 +204,9 @@ SharedMessage TwitchMessageBuilder::parse(const Communi::IrcPrivateMessage *ircM
|
|||
// words
|
||||
QColor textColor = ircMessage->isAction() ? usernameColor : ColorScheme::getInstance().Text;
|
||||
|
||||
QStringList splits = ircMessage->content().split(' ');
|
||||
const QString &originalMessage = ircMessage->content();
|
||||
b.originalMessage = originalMessage;
|
||||
QStringList splits = originalMessage.split(' ');
|
||||
|
||||
long int i = 0;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef URLFETCH_H
|
||||
#define URLFETCH_H
|
||||
#pragma once
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
@ -25,6 +24,16 @@ static void urlFetch(const QString &url, std::function<void(QNetworkReply &)> su
|
|||
QNetworkReply *reply = manager->get(request);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||
/* uncomment to follow redirects
|
||||
QVariant replyStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||
if (replyStatus >= 300 && replyStatus <= 304) {
|
||||
QString newUrl =
|
||||
reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString();
|
||||
urlFetch(newUrl, successCallback);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if (reply->error() == QNetworkReply::NetworkError::NoError) {
|
||||
successCallback(*reply);
|
||||
}
|
||||
|
@ -49,7 +58,6 @@ static void urlJsonFetch(const QString &url, std::function<void(QJsonObject &)>
|
|||
successCallback(rootNode);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // URLFETCH_H
|
||||
} // namespace util
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -112,7 +112,7 @@ bool ChatWidgetView::layoutMessages()
|
|||
|
||||
_scrollbar.setMaximum(messages.getSize());
|
||||
|
||||
if (showingLatestMessages && showScrollbar) {
|
||||
if (this->showingLatestMessages && showScrollbar) {
|
||||
// If we were showing the latest messages and the scrollbar now wants to be rendered, scroll
|
||||
// to bottom
|
||||
// TODO: Do we want to check if the user is currently moving the scrollbar?
|
||||
|
|
|
@ -96,7 +96,7 @@ void ScrollBar::scrollToBottom()
|
|||
|
||||
bool ScrollBar::isAtBottom() const
|
||||
{
|
||||
return this->getCurrentValue() == this->getMaximum() - this->getLargeChange();
|
||||
return ((this->getMaximum() - this->getLargeChange()) - this->getCurrentValue()) <= 1;
|
||||
}
|
||||
|
||||
void ScrollBar::setMaximum(qreal value)
|
||||
|
|
Loading…
Reference in a new issue