aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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)
{