From 40ca5b04d13f4f585b48875a832dd9b739139d8e Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sun, 2 Dec 2007 11:01:33 +0000 Subject: [PATCH] blinken does not like the wordwrapping text so make it configurable with a flags parameter, this is bic but sc, besides we never guaranteed any kind of bc on libkdeeduui svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=743916 --- kdeeduui/kedufontutils.cpp | 6 ++++-- kdeeduui/kedufontutils.h | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kdeeduui/kedufontutils.cpp b/kdeeduui/kedufontutils.cpp index 9d0e9e9..b75be7d 100644 --- a/kdeeduui/kedufontutils.cpp +++ b/kdeeduui/kedufontutils.cpp @@ -11,7 +11,7 @@ #include -int fontUtils::fontSize(QPainter &p, const QString &s1, int w, int h) +int fontUtils::fontSize(QPainter &p, const QString &s1, int w, int h, Flags flags) { int size; QRect aux1; @@ -24,7 +24,9 @@ int fontUtils::fontSize(QPainter &p, const QString &s1, int w, int h) QFont f = p.font(); f.setPointSize(size); p.setFont(f); - aux1 = p.boundingRect(QRect(0, 0, w, h), Qt::TextWordWrap | Qt::AlignCenter, s1); + int qtFlags = Qt::AlignCenter | Qt::TextWordWrap; + if (flags & DoNotAllowWordWrap) qtFlags = qtFlags & ~Qt::TextWordWrap; + aux1 = p.boundingRect(QRect(0, 0, w, h), qtFlags, s1); if (aux1.width() == 0 || aux1.height() == 0) return -1; else if (aux1.width() > w || aux1.height() > h) size = qMin(w * size / aux1.width(), h * size / aux1.height()); else done = true; diff --git a/kdeeduui/kedufontutils.h b/kdeeduui/kedufontutils.h index a0f8bed..de8861f 100644 --- a/kdeeduui/kedufontutils.h +++ b/kdeeduui/kedufontutils.h @@ -17,7 +17,13 @@ class QString; namespace fontUtils { - int KDEEDUUI_EXPORT fontSize(QPainter &p, const QString &s1, int w, int h); + enum Flags + { + NoFlags = 1, + DoNotAllowWordWrap = 2 + }; + + int KDEEDUUI_EXPORT fontSize(QPainter &p, const QString &s1, int w, int h, Flags flags = NoFlags); } #endif -- 2.47.3