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 <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef LAZYLOADEDIMAGE_H
|
#pragma once
|
||||||
#define LAZYLOADEDIMAGE_H
|
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -103,7 +102,6 @@ private:
|
||||||
|
|
||||||
void gifUpdateTimout();
|
void gifUpdateTimout();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
#endif // LAZYLOADEDIMAGE_H
|
|
||||||
|
|
|
@ -21,13 +21,15 @@ namespace messages {
|
||||||
|
|
||||||
Message::Message(const QString &text)
|
Message::Message(const QString &text)
|
||||||
: _words()
|
: _words()
|
||||||
|
, _text(text)
|
||||||
{
|
{
|
||||||
_words.push_back(
|
_words.push_back(
|
||||||
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
|
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)
|
: _words(words)
|
||||||
|
, _text(text)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Message(const QString &text);
|
Message(const QString &text);
|
||||||
Message(const std::vector<messages::Word> &words);
|
Message(const QString &text, const std::vector<messages::Word> &words);
|
||||||
|
|
||||||
bool getCanHighlightTab() const;
|
bool getCanHighlightTab() const;
|
||||||
const QString &getTimeoutUser() const;
|
const QString &getTimeoutUser() const;
|
||||||
|
@ -38,6 +38,8 @@ public:
|
||||||
bool isDisabled() const;
|
bool isDisabled() const;
|
||||||
const QString &getId() const;
|
const QString &getId() const;
|
||||||
|
|
||||||
|
const QString _text;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LazyLoadedImage *badgeStaff;
|
static LazyLoadedImage *badgeStaff;
|
||||||
static LazyLoadedImage *badgeAdmin;
|
static LazyLoadedImage *badgeAdmin;
|
||||||
|
|
|
@ -14,7 +14,7 @@ MessageBuilder::MessageBuilder()
|
||||||
|
|
||||||
SharedMessage MessageBuilder::build()
|
SharedMessage MessageBuilder::build()
|
||||||
{
|
{
|
||||||
return SharedMessage(new Message(_words));
|
return SharedMessage(new Message(this->originalMessage, _words));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBuilder::appendWord(const Word &word)
|
void MessageBuilder::appendWord(const Word &word)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef MESSAGEBUILDER_H
|
#pragma once
|
||||||
#define MESSAGEBUILDER_H
|
|
||||||
|
|
||||||
#include "messages/message.h"
|
#include "messages/message.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -20,11 +20,12 @@ public:
|
||||||
|
|
||||||
QString matchLink(const QString &string);
|
QString matchLink(const QString &string);
|
||||||
|
|
||||||
|
QString originalMessage;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Word> _words;
|
std::vector<Word> _words;
|
||||||
std::chrono::time_point<std::chrono::system_clock> _parseTime;
|
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
|
// words
|
||||||
QColor textColor = ircMessage->isAction() ? usernameColor : ColorScheme::getInstance().Text;
|
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;
|
long int i = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef URLFETCH_H
|
#pragma once
|
||||||
#define URLFETCH_H
|
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -25,6 +24,16 @@ static void urlFetch(const QString &url, std::function<void(QNetworkReply &)> su
|
||||||
QNetworkReply *reply = manager->get(request);
|
QNetworkReply *reply = manager->get(request);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
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) {
|
if (reply->error() == QNetworkReply::NetworkError::NoError) {
|
||||||
successCallback(*reply);
|
successCallback(*reply);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +58,6 @@ static void urlJsonFetch(const QString &url, std::function<void(QJsonObject &)>
|
||||||
successCallback(rootNode);
|
successCallback(rootNode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // URLFETCH_H
|
} // namespace util
|
||||||
|
} // namespace chatterino
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool ChatWidgetView::layoutMessages()
|
||||||
|
|
||||||
_scrollbar.setMaximum(messages.getSize());
|
_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
|
// If we were showing the latest messages and the scrollbar now wants to be rendered, scroll
|
||||||
// to bottom
|
// to bottom
|
||||||
// TODO: Do we want to check if the user is currently moving the scrollbar?
|
// 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
|
bool ScrollBar::isAtBottom() const
|
||||||
{
|
{
|
||||||
return this->getCurrentValue() == this->getMaximum() - this->getLargeChange();
|
return ((this->getMaximum() - this->getLargeChange()) - this->getCurrentValue()) <= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollBar::setMaximum(qreal value)
|
void ScrollBar::setMaximum(qreal value)
|
||||||
|
|
Loading…
Reference in a new issue