From 9fe8687578e155f097abdeb4839f07255273fbe8 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Mon, 3 Aug 2015 14:27:58 +0200 Subject: [PATCH] More space for title text --- src/sidebarheader.cpp | 9 +++++---- src/sidebarheader.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sidebarheader.cpp b/src/sidebarheader.cpp index b4ab622..b6fb87a 100644 --- a/src/sidebarheader.cpp +++ b/src/sidebarheader.cpp @@ -22,7 +22,7 @@ $END_LICENSE */ #include "iconutils.h" #include "mediaview.h" #include "videosource.h" -#include "iconutils.h" +#include "fontutils.h" SidebarHeader::SidebarHeader(QWidget *parent) : QToolBar(parent) { } @@ -57,8 +57,8 @@ void SidebarHeader::setup() { addWidget(spacerWidget); } -QSize SidebarHeader::minimumSizeHint (void) const { - return(QSize(160, QFontMetrics(font()).height() * 1.9)); +QSize SidebarHeader::minimumSizeHint() const { + return QSize(160, QFontMetrics(font()).height() * 1.9); } void SidebarHeader::updateInfo() { @@ -121,13 +121,14 @@ void SidebarHeader::paintEvent(QPaintEvent *event) { if (title.isEmpty()) return; QPainter p(this); p.setPen(Qt::white); + p.setFont(FontUtils::small()); const QRect r = rect(); QString t = title; QRect textBox = p.boundingRect(r, Qt::AlignCenter, t); int i = 1; - static const int margin = 50; + const int margin = forwardAction->isVisible() ? 45 : 20; while (textBox.width() > r.width() - margin*2 && t.length() > 3) { t = t.left(t.length() - i).trimmed() + QLatin1String("..."); textBox = p.boundingRect(r, Qt::AlignCenter, t); diff --git a/src/sidebarheader.h b/src/sidebarheader.h index c0713f1..db16ace 100644 --- a/src/sidebarheader.h +++ b/src/sidebarheader.h @@ -46,7 +46,7 @@ private: void setTitle(const QString &title); QAction *backAction; - QAction * forwardAction; + QAction *forwardAction; QString title; QList videoSourceActions; }; -- 2.39.5