aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-10-17 16:03:25 +0200
committerDavid Robillard <d@drobilla.net>2019-10-17 16:03:25 +0200
commit87416aca2e6bedc8745a613a8bd09bf8c1cc9ee1 (patch)
tree4b7900f3e457fe44a21930b2e92648ed3285382e /src
parent953d26ec7cff335614d347109aabb2fe72c9147e (diff)
downloadjalv-87416aca2e6bedc8745a613a8bd09bf8c1cc9ee1.tar.gz
jalv-87416aca2e6bedc8745a613a8bd09bf8c1cc9ee1.tar.bz2
jalv-87416aca2e6bedc8745a613a8bd09bf8c1cc9ee1.zip
Avoid deprecated QFontMetrics::width
Diffstat (limited to 'src')
-rw-r--r--src/jalv_qt.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/jalv_qt.cpp b/src/jalv_qt.cpp
index 2afb3ea..80141f2 100644
--- a/src/jalv_qt.cpp
+++ b/src/jalv_qt.cpp
@@ -299,6 +299,7 @@ private:
void setRange(float min, float max);
QString getValueLabel(float value);
float getValue();
+ int stringWidth(const QString& str);
const LilvPlugin* plugin;
struct Port* port;
@@ -464,7 +465,7 @@ Control::Control(PortContainer portContainer, QWidget* parent)
name = QString("%1").arg(lilv_node_as_string(nname));
// Handle long names
- if (fontMetrics().width(name) > CONTROL_WIDTH) {
+ if (stringWidth(name) > CONTROL_WIDTH) {
setTitle(fontMetrics().elidedText(name, Qt::ElideRight, CONTROL_WIDTH));
} else {
setTitle(name);
@@ -513,7 +514,7 @@ QString
Control::getValueLabel(float value)
{
if (scaleMap[value]) {
- if (fontMetrics().width(scaleMap[value]) > CONTROL_WIDTH) {
+ if (stringWidth(scaleMap[value]) > CONTROL_WIDTH) {
label->setToolTip(scaleMap[value]);
return fontMetrics().elidedText(QString(scaleMap[value]),
Qt::ElideRight,
@@ -559,6 +560,16 @@ Control::getValue()
}
}
+int
+Control::stringWidth(const QString& str)
+{
+#if QT_VERSION >= 0x050B00
+ return fontMetrics().horizontalAdvance(str);
+#else
+ return fontMetrics().width(str);
+#endif
+}
+
void
Control::dialChanged(int dialValue)
{