From 28b3a3fde02e5fc422bfc44cfbedb940815b823b Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Wed, 4 Oct 2017 22:00:26 +0300 Subject: [PATCH] Put typing notifications above the text input --- include/Config.h | 1 + src/ChatPage.cc | 4 ++-- src/TextInputWidget.cc | 8 ++++---- src/TypingDisplay.cc | 13 ++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/Config.h b/include/Config.h index 50f9eb85..2412a4d0 100644 --- a/include/Config.h +++ b/include/Config.h @@ -8,6 +8,7 @@ namespace conf { // Global settings. static const int fontSize = 12; +static const int textInputFontSize = 14; static const int emojiSize = 14; static const int headerFontSize = 21; static const int typingNotificationFontSize = 11; diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 52468f64..0800fe32 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -103,8 +103,8 @@ ChatPage::ChatPage(QSharedPointer client, QWidget *parent) text_input_ = new TextInputWidget(this); typingDisplay_ = new TypingDisplay(this); - contentLayout_->addWidget(text_input_); contentLayout_->addWidget(typingDisplay_); + contentLayout_->addWidget(text_input_); user_info_widget_ = new UserInfoWidget(sideBarTopWidget_); sideBarTopWidgetLayout_->addWidget(user_info_widget_); @@ -298,7 +298,7 @@ ChatPage::syncFailed(const QString &msg) return; 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. diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index 4d5f4d5f..f894a247 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -45,14 +45,14 @@ TextInputWidget::TextInputWidget(QWidget *parent) { setFont(QFont("Emoji One")); - setFixedHeight(45); + setFixedHeight(50); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setCursor(Qt::ArrowCursor); setStyleSheet("background-color: #fff;"); topLayout_ = new QHBoxLayout(); topLayout_->setSpacing(0); - topLayout_->setContentsMargins(5, 15, 0, 5); + topLayout_->setContentsMargins(15, 0, 15, 5); QIcon send_file_icon; send_file_icon.addFile(":/icons/icons/clip-dark.png", QSize(), QIcon::Normal, QIcon::Off); @@ -69,14 +69,14 @@ TextInputWidget::TextInputWidget(QWidget *parent) spinner_->hide(); QFont font; - font.setPixelSize(conf::fontSize); + font.setPixelSize(conf::textInputFontSize); input_ = new FilteredTextEdit(this); input_->setFixedHeight(32); input_->setFont(font); input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 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_->setForegroundColor(QColor("#acc7dc")); diff --git a/src/TypingDisplay.cc b/src/TypingDisplay.cc index 619b70cb..7792d3e4 100644 --- a/src/TypingDisplay.cc +++ b/src/TypingDisplay.cc @@ -7,7 +7,7 @@ TypingDisplay::TypingDisplay(QWidget *parent) : QWidget(parent) - , leftPadding_{ 57 } + , leftPadding_{ 24 } { QFont font; font.setPixelSize(conf::typingNotificationFontSize); @@ -24,9 +24,9 @@ TypingDisplay::setUsers(const QStringList &uid) text_ = uid.join(", "); if (uid.size() == 1) - text_ += tr(" is typing ..."); + text_ += tr(" is typing"); else if (uid.size() > 1) - text_ += tr(" are typing ..."); + text_ += tr(" are typing"); update(); } @@ -34,11 +34,10 @@ TypingDisplay::setUsers(const QStringList &uid) void TypingDisplay::paintEvent(QPaintEvent *) { - QPen pen(QColor("#333")); + QPen pen(QColor("#898989")); - QFont font; + QFont font("Open Sans Bold"); font.setPixelSize(conf::typingNotificationFontSize); - font.setWeight(40); font.setItalic(true); QPainter p(this); @@ -52,5 +51,5 @@ TypingDisplay::paintEvent(QPaintEvent *) QFontMetrics fm(font); text_ = fm.elidedText(text_, Qt::ElideRight, width() - 3 * leftPadding_); - p.drawText(region, Qt::AlignTop, text_); + p.drawText(region, Qt::AlignVCenter, text_); }