summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-30 13:24:36 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-30 13:24:36 +0300
commit9038c950aef4a59cc9f928541cb20b010be9a8df (patch)
tree504b717640347d041253a3067248e5311da96da6 /src/ui
parentRemove obsolete font/size setting (diff)
downloadnheko-9038c950aef4a59cc9f928541cb20b010be9a8df.tar.xz
Remove pixel value from fonts
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/FlatButton.cpp2
-rw-r--r--src/ui/InfoMessage.cpp24
-rw-r--r--src/ui/InfoMessage.h7
-rw-r--r--src/ui/TextField.cpp2
4 files changed, 16 insertions, 19 deletions
diff --git a/src/ui/FlatButton.cpp b/src/ui/FlatButton.cpp
index 45a7683e..a828f582 100644
--- a/src/ui/FlatButton.cpp
+++ b/src/ui/FlatButton.cpp
@@ -218,7 +218,7 @@ FlatButton::setFontSize(qreal size)
         font_size_ = size;
 
         QFont f(font());
-        f.setPixelSize(size);
+        f.setPointSizeF(size);
         setFont(f);
 
         update();
diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp
index 3151bedf..e107b18f 100644
--- a/src/ui/InfoMessage.cpp
+++ b/src/ui/InfoMessage.cpp
@@ -1,5 +1,5 @@
-#include "InfoMessage.h"
 #include "Config.h"
+#include "InfoMessage.h"
 
 #include <QDateTime>
 #include <QPainter>
@@ -12,18 +12,16 @@ constexpr int HMargin  = 20;
 InfoMessage::InfoMessage(QWidget *parent)
   : QWidget{parent}
 {
-        font_.setWeight(60);
-        font_.setPixelSize(conf::timeline::fonts::dateSeparator);
+        initFont();
 }
 
 InfoMessage::InfoMessage(QString msg, QWidget *parent)
   : QWidget{parent}
   , msg_{msg}
 {
-        font_.setWeight(60);
-        font_.setPixelSize(conf::timeline::fonts::dateSeparator);
+        initFont();
 
-        QFontMetrics fm{font_};
+        QFontMetrics fm{font()};
         width_  = fm.width(msg_) + HPadding * 2;
         height_ = fm.ascent() + 2 * VPadding;
 
@@ -35,7 +33,7 @@ InfoMessage::paintEvent(QPaintEvent *)
 {
         QPainter p(this);
         p.setRenderHint(QPainter::Antialiasing);
-        p.setFont(font_);
+        p.setFont(font());
 
         // Center the box horizontally & vertically.
         auto textRegion = QRectF(width() / 2 - width_ / 2, HMargin, width_, height_);
@@ -54,8 +52,7 @@ InfoMessage::paintEvent(QPaintEvent *)
 DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
   : InfoMessage{parent}
 {
-        auto now  = QDateTime::currentDateTime();
-        auto days = now.daysTo(datetime);
+        auto now = QDateTime::currentDateTime();
 
         QString fmt;
 
@@ -64,14 +61,9 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
         else
                 fmt = QString("ddd d MMMM");
 
-        if (days == 0)
-                msg_ = tr("Today");
-        else if (std::abs(days) == 1)
-                msg_ = tr("Yesterday");
-        else
-                msg_ = datetime.toString(fmt);
+        msg_ = datetime.toString(fmt);
 
-        QFontMetrics fm{font_};
+        QFontMetrics fm{font()};
         width_  = fm.width(msg_) + HPadding * 2;
         height_ = fm.ascent() + 2 * VPadding;
 
diff --git a/src/ui/InfoMessage.h b/src/ui/InfoMessage.h
index 58f98b0c..f8f457e3 100644
--- a/src/ui/InfoMessage.h
+++ b/src/ui/InfoMessage.h
@@ -25,12 +25,17 @@ public:
 
 protected:
         void paintEvent(QPaintEvent *event) override;
+        void initFont()
+        {
+                QFont f;
+                f.setWeight(QFont::Medium);
+                setFont(f);
+        }
 
         int width_;
         int height_;
 
         QString msg_;
-        QFont font_;
 
         QDateTime datetime_;
 
diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp
index 7e2f359a..c4582085 100644
--- a/src/ui/TextField.cpp
+++ b/src/ui/TextField.cpp
@@ -76,7 +76,7 @@ TextField::setLabelFontSize(qreal size)
 
         if (label_) {
                 QFont font(label_->font());
-                font.setPixelSize(size);
+                font.setPointSizeF(size);
                 label_->setFont(font);
                 label_->update();
         }