Remove the reserved space gap for the typing notifications
This commit is contained in:
parent
aec5587947
commit
d4c3dac28f
@ -122,11 +122,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||
splitter->addWidget(content_);
|
||||
splitter->restoreSizes(parent->width());
|
||||
|
||||
text_input_ = new TextInputWidget(this);
|
||||
typingDisplay_ = new TypingDisplay(this);
|
||||
contentLayout_->addWidget(typingDisplay_);
|
||||
text_input_ = new TextInputWidget(this);
|
||||
contentLayout_->addWidget(text_input_);
|
||||
|
||||
typingDisplay_ = new TypingDisplay(content_);
|
||||
typingDisplay_->hide();
|
||||
connect(
|
||||
text_input_, &TextInputWidget::heightChanged, typingDisplay_, &TypingDisplay::setOffset);
|
||||
|
||||
typingRefresher_ = new QTimer(this);
|
||||
typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT);
|
||||
|
||||
@ -592,8 +595,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||
// Callbacks to update the user info (top left corner of the page).
|
||||
connect(this, &ChatPage::setUserAvatar, user_info_widget_, &UserInfoWidget::setAvatar);
|
||||
connect(this, &ChatPage::setUserDisplayName, this, [this](const QString &name) {
|
||||
QSettings settings;
|
||||
auto userid = settings.value("auth/user_id").toString();
|
||||
auto userid = utils::localUser();
|
||||
user_info_widget_->setUserId(userid);
|
||||
user_info_widget_->setDisplayName(name);
|
||||
});
|
||||
@ -890,9 +892,7 @@ QStringList
|
||||
ChatPage::generateTypingUsers(const QString &room_id, const std::vector<std::string> &typing_users)
|
||||
{
|
||||
QStringList users;
|
||||
|
||||
QSettings settings;
|
||||
QString local_user = settings.value("auth/user_id").toString();
|
||||
auto local_user = utils::localUser();
|
||||
|
||||
for (const auto &uid : typing_users) {
|
||||
const auto remote_user = QString::fromStdString(uid);
|
||||
@ -1262,8 +1262,7 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
|
||||
void
|
||||
ChatPage::getProfileInfo()
|
||||
{
|
||||
QSettings settings;
|
||||
const auto userid = settings.value("auth/user_id").toString().toStdString();
|
||||
const auto userid = utils::localUser().toStdString();
|
||||
|
||||
http::client()->get_profile(
|
||||
userid, [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
|
||||
|
@ -477,6 +477,8 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
||||
|
||||
setFixedHeight(widgetHeight);
|
||||
input_->setFixedHeight(textInputHeight);
|
||||
|
||||
emit heightChanged(widgetHeight);
|
||||
});
|
||||
connect(input_, &FilteredTextEdit::showSuggestions, this, [this](const QString &q) {
|
||||
if (q.isEmpty() || !cache::client())
|
||||
|
@ -166,6 +166,7 @@ private slots:
|
||||
signals:
|
||||
void sendTextMessage(QString msg);
|
||||
void sendEmoteMessage(QString msg);
|
||||
void heightChanged(int height);
|
||||
|
||||
void uploadImage(const QSharedPointer<QIODevice> data, const QString &filename);
|
||||
void uploadFile(const QSharedPointer<QIODevice> data, const QString &filename);
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QPoint>
|
||||
#include <QShowEvent>
|
||||
|
||||
#include "Config.h"
|
||||
#include "TypingDisplay.h"
|
||||
@ -8,21 +10,33 @@
|
||||
constexpr int LEFT_PADDING = 24;
|
||||
|
||||
TypingDisplay::TypingDisplay(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: OverlayWidget(parent)
|
||||
, offset_{conf::textInput::height}
|
||||
{
|
||||
QFont f;
|
||||
f.setPixelSize(conf::typingNotificationFontSize);
|
||||
|
||||
setFont(f);
|
||||
|
||||
setFixedHeight(QFontMetrics(font()).height() + 2);
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
void
|
||||
TypingDisplay::setOffset(int margin)
|
||||
{
|
||||
offset_ = margin;
|
||||
move(0, parentWidget()->height() - offset_ - height());
|
||||
}
|
||||
|
||||
void
|
||||
TypingDisplay::setUsers(const QStringList &uid)
|
||||
{
|
||||
move(0, parentWidget()->height() - offset_ - height());
|
||||
|
||||
text_.clear();
|
||||
|
||||
if (uid.isEmpty()) {
|
||||
text_.clear();
|
||||
hide();
|
||||
update();
|
||||
|
||||
return;
|
||||
@ -35,6 +49,7 @@ TypingDisplay::setUsers(const QStringList &uid)
|
||||
else if (uid.size() > 1)
|
||||
text_ += tr(" are typing");
|
||||
|
||||
show();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QWidget>
|
||||
#include "ui/OverlayWidget.h"
|
||||
|
||||
class TypingDisplay : public QWidget
|
||||
class QPaintEvent;
|
||||
|
||||
class TypingDisplay : public OverlayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -17,10 +18,14 @@ public:
|
||||
void setTextColor(const QColor &color) { textColor_ = color; };
|
||||
QColor textColor() const { return textColor_; };
|
||||
|
||||
public slots:
|
||||
void setOffset(int margin);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
int offset_;
|
||||
QColor textColor_;
|
||||
QString text_;
|
||||
};
|
||||
|
@ -490,8 +490,6 @@ TimelineView::init()
|
||||
QIcon icon;
|
||||
icon.addFile(":/icons/icons/ui/angle-arrow-down.png");
|
||||
scrollDownBtn_ = new FloatingButton(icon, this);
|
||||
scrollDownBtn_->setBackgroundColor(QColor("#F5F5F5"));
|
||||
scrollDownBtn_->setForegroundColor(QColor("black"));
|
||||
scrollDownBtn_->hide();
|
||||
|
||||
connect(scrollDownBtn_, &QPushButton::clicked, this, [this]() {
|
||||
@ -509,8 +507,13 @@ TimelineView::init()
|
||||
scroll_widget_ = new QWidget(this);
|
||||
scroll_widget_->setObjectName("scroll_widget");
|
||||
|
||||
// Height of the typing display.
|
||||
QFont f;
|
||||
f.setPixelSize(conf::typingNotificationFontSize);
|
||||
const int bottomMargin = QFontMetrics(f).height() + 6;
|
||||
|
||||
scroll_layout_ = new QVBoxLayout(scroll_widget_);
|
||||
scroll_layout_->setContentsMargins(4, 0, 15, 15);
|
||||
scroll_layout_->setContentsMargins(4, 0, 15, bottomMargin);
|
||||
scroll_layout_->setSpacing(0);
|
||||
scroll_layout_->setObjectName("timelinescrollarea");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user