Put typing notifications above the text input

This commit is contained in:
Konstantinos Sideris 2017-10-04 22:00:26 +03:00
parent d60c2b76e3
commit 28b3a3fde0
4 changed files with 13 additions and 13 deletions

View file

@ -8,6 +8,7 @@ namespace conf
{ {
// Global settings. // Global settings.
static const int fontSize = 12; static const int fontSize = 12;
static const int textInputFontSize = 14;
static const int emojiSize = 14; static const int emojiSize = 14;
static const int headerFontSize = 21; static const int headerFontSize = 21;
static const int typingNotificationFontSize = 11; static const int typingNotificationFontSize = 11;

View file

@ -103,8 +103,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
text_input_ = new TextInputWidget(this); text_input_ = new TextInputWidget(this);
typingDisplay_ = new TypingDisplay(this); typingDisplay_ = new TypingDisplay(this);
contentLayout_->addWidget(text_input_);
contentLayout_->addWidget(typingDisplay_); contentLayout_->addWidget(typingDisplay_);
contentLayout_->addWidget(text_input_);
user_info_widget_ = new UserInfoWidget(sideBarTopWidget_); user_info_widget_ = new UserInfoWidget(sideBarTopWidget_);
sideBarTopWidgetLayout_->addWidget(user_info_widget_); sideBarTopWidgetLayout_->addWidget(user_info_widget_);
@ -298,7 +298,7 @@ ChatPage::syncFailed(const QString &msg)
return; return;
qWarning() << "Sync error:" << msg; qWarning() << "Sync error:" << msg;
sync_timer_->start(sync_interval_ * 5); sync_timer_->start(sync_interval_);
} }
// TODO: Should be moved in another class that manages this global list. // TODO: Should be moved in another class that manages this global list.

View file

@ -45,14 +45,14 @@ TextInputWidget::TextInputWidget(QWidget *parent)
{ {
setFont(QFont("Emoji One")); setFont(QFont("Emoji One"));
setFixedHeight(45); setFixedHeight(50);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
setStyleSheet("background-color: #fff;"); setStyleSheet("background-color: #fff;");
topLayout_ = new QHBoxLayout(); topLayout_ = new QHBoxLayout();
topLayout_->setSpacing(0); topLayout_->setSpacing(0);
topLayout_->setContentsMargins(5, 15, 0, 5); topLayout_->setContentsMargins(15, 0, 15, 5);
QIcon send_file_icon; QIcon send_file_icon;
send_file_icon.addFile(":/icons/icons/clip-dark.png", QSize(), QIcon::Normal, QIcon::Off); send_file_icon.addFile(":/icons/icons/clip-dark.png", QSize(), QIcon::Normal, QIcon::Off);
@ -69,14 +69,14 @@ TextInputWidget::TextInputWidget(QWidget *parent)
spinner_->hide(); spinner_->hide();
QFont font; QFont font;
font.setPixelSize(conf::fontSize); font.setPixelSize(conf::textInputFontSize);
input_ = new FilteredTextEdit(this); input_ = new FilteredTextEdit(this);
input_->setFixedHeight(32); input_->setFixedHeight(32);
input_->setFont(font); input_->setFont(font);
input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
input_->setPlaceholderText(tr("Write a message...")); input_->setPlaceholderText(tr("Write a message..."));
input_->setStyleSheet("color: #333333; border: none; margin: 0 5px"); input_->setStyleSheet("color: #333333; border: none; padding-top: 5px; margin: 0 5px");
sendMessageBtn_ = new FlatButton(this); sendMessageBtn_ = new FlatButton(this);
sendMessageBtn_->setForegroundColor(QColor("#acc7dc")); sendMessageBtn_->setForegroundColor(QColor("#acc7dc"));

View file

@ -7,7 +7,7 @@
TypingDisplay::TypingDisplay(QWidget *parent) TypingDisplay::TypingDisplay(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, leftPadding_{ 57 } , leftPadding_{ 24 }
{ {
QFont font; QFont font;
font.setPixelSize(conf::typingNotificationFontSize); font.setPixelSize(conf::typingNotificationFontSize);
@ -24,9 +24,9 @@ TypingDisplay::setUsers(const QStringList &uid)
text_ = uid.join(", "); text_ = uid.join(", ");
if (uid.size() == 1) if (uid.size() == 1)
text_ += tr(" is typing ..."); text_ += tr(" is typing");
else if (uid.size() > 1) else if (uid.size() > 1)
text_ += tr(" are typing ..."); text_ += tr(" are typing");
update(); update();
} }
@ -34,11 +34,10 @@ TypingDisplay::setUsers(const QStringList &uid)
void void
TypingDisplay::paintEvent(QPaintEvent *) TypingDisplay::paintEvent(QPaintEvent *)
{ {
QPen pen(QColor("#333")); QPen pen(QColor("#898989"));
QFont font; QFont font("Open Sans Bold");
font.setPixelSize(conf::typingNotificationFontSize); font.setPixelSize(conf::typingNotificationFontSize);
font.setWeight(40);
font.setItalic(true); font.setItalic(true);
QPainter p(this); QPainter p(this);
@ -52,5 +51,5 @@ TypingDisplay::paintEvent(QPaintEvent *)
QFontMetrics fm(font); QFontMetrics fm(font);
text_ = fm.elidedText(text_, Qt::ElideRight, width() - 3 * leftPadding_); text_ = fm.elidedText(text_, Qt::ElideRight, width() - 3 * leftPadding_);
p.drawText(region, Qt::AlignTop, text_); p.drawText(region, Qt::AlignVCenter, text_);
} }