diff options
Diffstat (limited to 'src/widget/wpushbutton.cpp')
-rw-r--r-- | src/widget/wpushbutton.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp index c7785ccb0a..f530c1ddd2 100644 --- a/src/widget/wpushbutton.cpp +++ b/src/widget/wpushbutton.cpp @@ -80,6 +80,16 @@ void WPushButton::setup(QDomNode node, const SkinContext& context) { context.getSkinPath(context.selectString(state, "Unpressed"))); } m_text.replace(iState, context.selectString(state, "Text")); + QString alignment = context.selectString(state, "Alignment"); + if (alignment == "left") { + m_align.replace(iState, Qt::AlignLeft); + } else if (alignment == "right") { + m_align.replace(iState, Qt::AlignRight); + } else { + // Default is center. + m_align.replace(iState, Qt::AlignCenter); + } + m_style.replace(iState, context.selectString(state, "Style")); } } state = state.nextSibling(); @@ -182,6 +192,8 @@ void WPushButton::setStates(int iStates) { m_pressedPixmaps.resize(iStates); m_unpressedPixmaps.resize(iStates); m_text.resize(iStates); + m_style.resize(iStates); + m_align.resize(iStates); } void WPushButton::setPixmap(int iState, bool bPressed, const QString &filename) { @@ -218,6 +230,13 @@ void WPushButton::onConnectedControlValueChanged(double v) { if (m_iNoStates == 1) { m_bPressed = (v == 1.0); } + int idx = static_cast<int>(v) % m_iNoStates; + if (idx < m_style.size()) { + QString style = m_style.at(idx); + if (!style.isEmpty()) { + setStyleSheet(style); + } + } update(); } @@ -255,7 +274,7 @@ void WPushButton::paintEvent(QPaintEvent* e) { QString text = m_text.at(idx); if (!text.isEmpty()) { - p.drawText(rect(), Qt::AlignCenter, text); + p.drawText(rect(), m_align.at(idx), text); } } |