diff options
Diffstat (limited to 'src/widget')
-rw-r--r-- | src/widget/wdisplay.cpp | 2 | ||||
-rw-r--r-- | src/widget/wknobcomposed.cpp | 2 | ||||
-rw-r--r-- | src/widget/wpixmapstore.cpp | 2 | ||||
-rw-r--r-- | src/widget/wpushbutton.cpp | 2 | ||||
-rw-r--r-- | src/widget/wstatuslight.cpp | 42 | ||||
-rw-r--r-- | src/widget/wstatuslight.h | 8 | ||||
-rw-r--r-- | src/widget/wwidgetgroup.cpp | 2 |
7 files changed, 48 insertions, 12 deletions
diff --git a/src/widget/wdisplay.cpp b/src/widget/wdisplay.cpp index 05d416d12d..81177b3d62 100644 --- a/src/widget/wdisplay.cpp +++ b/src/widget/wdisplay.cpp @@ -40,7 +40,7 @@ void WDisplay::setup(QDomNode node, const SkinContext& context) { // Set background pixmap if available if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( - context.selectElement(node, "BackPath"), "mode", "TILE"); + context.selectElement(node, "BackPath"), "scalemode", "TILE"); setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")), Paintable::DrawModeFromString(mode_str)); } diff --git a/src/widget/wknobcomposed.cpp b/src/widget/wknobcomposed.cpp index 611e6d8a75..6a449dd46b 100644 --- a/src/widget/wknobcomposed.cpp +++ b/src/widget/wknobcomposed.cpp @@ -18,7 +18,7 @@ void WKnobComposed::setup(QDomNode node, const SkinContext& context) { // Set background pixmap if available if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( - context.selectElement(node, "BackPath"), "mode", "TILE"); + context.selectElement(node, "BackPath"), "scalemode", "TILE"); setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")), Paintable::DrawModeFromString(mode_str)); } diff --git a/src/widget/wpixmapstore.cpp b/src/widget/wpixmapstore.cpp index ecaf076110..63b1839833 100644 --- a/src/widget/wpixmapstore.cpp +++ b/src/widget/wpixmapstore.cpp @@ -30,7 +30,7 @@ Paintable::DrawMode Paintable::DrawModeFromString(QString str) { } else if (str.toUpper() == "STRETCH") { return STRETCH; } - qWarning() << "Unknown string for drawing mode " << str << ", using TILE"; + qWarning() << "Unknown string for Paintable drawing mode " << str << ", using TILE"; return TILE; } diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp index fe558c419f..e82e50c934 100644 --- a/src/widget/wpushbutton.cpp +++ b/src/widget/wpushbutton.cpp @@ -62,7 +62,7 @@ void WPushButton::setup(QDomNode node, const SkinContext& context) { // Set background pixmap if available if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( - context.selectElement(node, "BackPath"), "mode", "TILE"); + context.selectElement(node, "BackPath"), "scalemode", "TILE"); setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")), Paintable::DrawModeFromString(mode_str)); } diff --git a/src/widget/wstatuslight.cpp b/src/widget/wstatuslight.cpp index df07d7fc64..0585826685 100644 --- a/src/widget/wstatuslight.cpp +++ b/src/widget/wstatuslight.cpp @@ -47,6 +47,16 @@ void WStatusLight::setNoPos(int iNoPos) { m_pixmaps.resize(iNoPos); } +WStatusLight::SizeMode WStatusLight::SizeModeFromString(QString str) { + if (str.toUpper() == "FIXED" ) { + return FIXED; + } else if (str.toUpper() == "RESIZE") { + return RESIZE; + } + qWarning() << "Unknown status light size mode " << str << ", using FIXED"; + return FIXED; +} + void WStatusLight::setup(QDomNode node, const SkinContext& context) { // Number of states. Add one to account for the background. setNoPos(context.selectInt(node, "NumberPos") + 1); @@ -56,18 +66,27 @@ void WStatusLight::setup(QDomNode node, const SkinContext& context) { // Accept either PathStatusLight or PathStatusLight1 for value 1, QString nodeName = QString("PathStatusLight%1").arg(i); if (context.hasNode(node, nodeName)) { - setPixmap(i, context.getSkinPath(context.selectString(node, nodeName))); + QString mode = context.selectAttributeString( + context.selectElement(node, nodeName), "sizemode", "FIXED"); + setPixmap(i, context.getSkinPath(context.selectString(node, nodeName)), + SizeModeFromString(mode)); } else if (i == 0 && context.hasNode(node, "PathBack")) { - setPixmap(i, context.getSkinPath(context.selectString(node, "PathBack"))); + QString mode = context.selectAttributeString( + context.selectElement(node, "PathBack"), "sizemode", "FIXED"); + setPixmap(i, context.getSkinPath(context.selectString(node, "PathBack")), + SizeModeFromString(mode)); } else if (i == 1 && context.hasNode(node, "PathStatusLight")) { - setPixmap(i, context.getSkinPath(context.selectString(node, "PathStatusLight"))); + QString mode = context.selectAttributeString( + context.selectElement(node, "PathStatusLight"), "sizemode", "FIXED"); + setPixmap(i, context.getSkinPath(context.selectString(node, "PathStatusLight")), + SizeModeFromString(mode)); } else { m_pixmaps[i].clear(); } } } -void WStatusLight::setPixmap(int iState, const QString& filename) { +void WStatusLight::setPixmap(int iState, const QString& filename, SizeMode mode) { if (iState < 0 || iState >= m_pixmaps.size()) { return; } @@ -78,8 +97,19 @@ void WStatusLight::setPixmap(int iState, const QString& filename) { if (!pPixmap.isNull() && !pPixmap->isNull()) { m_pixmaps[iState] = pPixmap; - // Set size of widget equal to pixmap size - setFixedSize(pPixmap->size()); + switch (mode) { + case RESIZE: + // Allow the pixmap to stretch or tile. + setBaseSize(pPixmap->size()); + break; + case FIXED: + // Set size of widget equal to pixmap size + setFixedSize(pPixmap->size()); + break; + default: + setFixedSize(pPixmap->size()); + break; + } } else { qDebug() << "WStatusLight: Error loading pixmap:" << filename << iState; m_pixmaps[iState].clear(); diff --git a/src/widget/wstatuslight.h b/src/widget/wstatuslight.h index 721dd1a520..6f860b59eb 100644 --- a/src/widget/wstatuslight.h +++ b/src/widget/wstatuslight.h @@ -34,10 +34,16 @@ class WStatusLight : public WWidget { Q_OBJECT public: + enum SizeMode { + FIXED, + RESIZE, + }; + WStatusLight(QWidget *parent=0); virtual ~WStatusLight(); void setup(QDomNode node, const SkinContext& context); + static SizeMode SizeModeFromString(QString str); public slots: void onConnectedControlValueChanged(double v); @@ -46,7 +52,7 @@ class WStatusLight : public WWidget { void paintEvent(QPaintEvent *); private: - void setPixmap(int iState, const QString &filename); + void setPixmap(int iState, const QString &filename, SizeMode mode); void setNoPos(int iNoPos); // Current position diff --git a/src/widget/wwidgetgroup.cpp b/src/widget/wwidgetgroup.cpp index 28dddad32d..5bc3bc66bd 100644 --- a/src/widget/wwidgetgroup.cpp +++ b/src/widget/wwidgetgroup.cpp @@ -83,7 +83,7 @@ void WWidgetGroup::setup(QDomNode node, const SkinContext& context) { // Set background pixmap if available if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( - context.selectElement(node, "BackPath"), "mode", "TILE"); + context.selectElement(node, "BackPath"), "scalemode", "TILE"); setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")), Paintable::DrawModeFromString(mode_str)); } |