summary refs log tree commit diff
path: root/src/TextInputWidget.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-10-06 18:07:02 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-10-06 18:07:02 +0300
commit675f1be777a7ba61b6e7082ea5d4240e078d8b22 (patch)
treea157c7119bf054ad1aec11886e092e822905b769 /src/TextInputWidget.cpp
parentRemove debug logs from Windows builds (diff)
downloadnheko-675f1be777a7ba61b6e7082ea5d4240e078d8b22.tar.xz
Adjust the height of the bottom widgets
Diffstat (limited to '')
-rw-r--r--src/TextInputWidget.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp
index 7ec65dc9..5fcba7a9 100644
--- a/src/TextInputWidget.cpp
+++ b/src/TextInputWidget.cpp
@@ -43,7 +43,6 @@
 
 static constexpr size_t INPUT_HISTORY_SIZE = 127;
 static constexpr int MAX_TEXTINPUT_HEIGHT  = 120;
-static constexpr int InputHeight           = 24;
 static constexpr int ButtonHeight          = 22;
 
 FilteredTextEdit::FilteredTextEdit(QWidget *parent)
@@ -446,7 +445,13 @@ FilteredTextEdit::showPreview(const QMimeData *source, const QStringList &format
 TextInputWidget::TextInputWidget(QWidget *parent)
   : QWidget(parent)
 {
-        setFixedHeight(conf::textInput::height);
+        QFont f;
+        f.setPointSizeF(f.pointSizeF());
+        const int fontHeight    = QFontMetrics(f).height();
+        const int contentHeight = fontHeight * 2.5;
+        const int InputHeight   = fontHeight * 1.5;
+
+        setFixedHeight(contentHeight);
         setCursor(Qt::ArrowCursor);
 
         topLayout_ = new QHBoxLayout();
@@ -472,16 +477,20 @@ TextInputWidget::TextInputWidget(QWidget *parent)
         input_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
         input_->setPlaceholderText(tr("Write a message..."));
 
-        connect(input_, &FilteredTextEdit::heightChanged, this, [this](int height) {
-                int textInputHeight = std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, InputHeight));
-                int widgetHeight =
-                  std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, conf::textInput::height));
+        connect(input_,
+                &FilteredTextEdit::heightChanged,
+                this,
+                [this, InputHeight, contentHeight](int height) {
+                        int textInputHeight =
+                          std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, InputHeight));
+                        int widgetHeight =
+                          std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, contentHeight));
 
-                setFixedHeight(widgetHeight);
-                input_->setFixedHeight(textInputHeight);
+                        setFixedHeight(widgetHeight);
+                        input_->setFixedHeight(textInputHeight);
 
-                emit heightChanged(widgetHeight);
-        });
+                        emit heightChanged(widgetHeight);
+                });
         connect(input_, &FilteredTextEdit::showSuggestions, this, [this](const QString &q) {
                 if (q.isEmpty() || !cache::client())
                         return;