summaryrefslogtreecommitdiffstats
path: root/src/widget/wstatuslight.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget/wstatuslight.cpp')
-rw-r--r--src/widget/wstatuslight.cpp42
1 files changed, 36 insertions, 6 deletions
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();