From 19b526d4533841ca91209929f0d6aef6042a8eeb Mon Sep 17 00:00:00 2001 From: Max Sandholm Date: Thu, 16 Nov 2017 16:33:52 +0200 Subject: Use system color scheme (using a Qt stylesheet) #104 The color scheme of nheko obeys the default color theme of Qt (i.e. the system theme). It uses a Qt stylesheet to accomplish this, which means replacing the color theme with a custom theme would only be a matter of writing a new style sheet and loading it into the app. --- src/TextInputWidget.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/TextInputWidget.cc') diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index d71769f4..829784fd 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -133,8 +133,8 @@ FilteredTextEdit::minimumSizeHint() const void FilteredTextEdit::submit() { - if (toPlainText().trimmed().isEmpty()) - return; + if (toPlainText().trimmed().isEmpty()) + return; if (true_history_.size() == INPUT_HISTORY_SIZE) true_history_.pop_back(); @@ -176,7 +176,6 @@ TextInputWidget::TextInputWidget(QWidget *parent) setFixedHeight(conf::textInput::height); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setCursor(Qt::ArrowCursor); - setStyleSheet("background-color: #fff;"); topLayout_ = new QHBoxLayout(); topLayout_->setSpacing(0); @@ -192,6 +191,7 @@ TextInputWidget::TextInputWidget(QWidget *parent) spinner_ = new LoadingIndicator(this); spinner_->setFixedHeight(32); spinner_->setFixedWidth(32); + spinner_->setObjectName("FileUploadSpinner"); spinner_->hide(); QFont font; @@ -202,7 +202,7 @@ TextInputWidget::TextInputWidget(QWidget *parent) input_->setFont(font); input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); input_->setPlaceholderText(tr("Write a message...")); - input_->setStyleSheet("color: #333333; border: none; padding-top: 5px; margin: 0 5px"); + input_->setStyleSheet("border: none; padding-top: 5px;"); sendMessageBtn_ = new FlatButton(this); @@ -335,3 +335,12 @@ TextInputWidget::focusInEvent(QFocusEvent *event) { input_->setFocus(event->reason()); } + +void +TextInputWidget::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} -- cgit 1.5.1