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.
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;

View File

@ -103,8 +103,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> 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.

View File

@ -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"));

View File

@ -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_);
}