From 82399a242b6b215cd245bbce7c95923a4692280c Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Tue, 11 Mar 2014 18:44:58 -0400 Subject: Various fixes for skin styling. --- src/engine/enginebuffer.cpp | 6 +++--- src/skin/legacyskinparser.cpp | 2 +- src/widget/wlabel.cpp | 3 +++ src/widget/wpushbutton.cpp | 21 ++++++++++++++++++++- src/widget/wpushbutton.h | 2 ++ src/widget/wtrackproperty.cpp | 1 + 6 files changed, 30 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index ff207b4c00..7c90e3c11e 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -374,8 +374,8 @@ void EngineBuffer::setEngineMaster(EngineMaster* pEngineMaster) { void EngineBuffer::queueNewPlaypos(double newpos, enum SeekRequest seekType) { // All seeks need to be done in the Engine thread so queue it up. - // Write the position before the seek type, to reduce a possible race - // condition effect + // Write the position before the seek type, to reduce a possible race + // condition effect m_queuedPosition.setValue(newpos); m_iSeekQueued.fetchAndStoreRelease(seekType); } @@ -969,7 +969,7 @@ void EngineBuffer::processSlip(int iBufferSize) { void EngineBuffer::processSeek() { // We need to read position just after reading seekType, to ensure that we read // the matching poition to seek_typ or a position from a new seek just queued from an other thread - // the later case is ok, because we will pocess the new seek in the next call anyway. + // the later case is ok, because we will pocess the new seek in the next call anyway. SeekRequest seekType = static_cast(m_iSeekQueued.fetchAndStoreRelease(NO_SEEK)); double position = m_queuedPosition.getValue(); diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 305b4b9c48..3e8e2d9f00 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -610,7 +610,7 @@ QWidget* LegacySkinParser::parseWidgetStack(QDomElement node) { bool created; // TODO(rryan): Allow persist enabling. Not sure what the best // option is -- need to think about it. - pControl = controlFromConfigKey(configKey, false, &created); + pControl = controlFromConfigKey(configKey, true, &created); if (created) { // If we created the control, parent it to the child widget so // it doesn't leak. diff --git a/src/widget/wlabel.cpp b/src/widget/wlabel.cpp index 8e789afa54..f0faec9d68 100644 --- a/src/widget/wlabel.cpp +++ b/src/widget/wlabel.cpp @@ -55,11 +55,14 @@ void WLabel::setup(QDomNode node, const SkinContext& context) { } // Alignment + setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); if (context.hasNode(node, "Alignment")) { if (context.selectString(node, "Alignment") == "right") { setAlignment(Qt::AlignRight | Qt::AlignVCenter); } else if (context.selectString(node, "Alignment") == "center") { setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + } else if (context.selectString(node, "Alignment") == "left") { + setAlignment(Qt::AlignLeft | Qt::AlignVCenter); } } } 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(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); } } diff --git a/src/widget/wpushbutton.h b/src/widget/wpushbutton.h index f74a24a42b..001727a724 100644 --- a/src/widget/wpushbutton.h +++ b/src/widget/wpushbutton.h @@ -78,6 +78,7 @@ class WPushButton : public WWidget { // Array of associated pixmaps int m_iNoStates; QVector m_text; + QVector m_style; QVector m_pressedPixmaps; QVector m_unpressedPixmaps; @@ -88,6 +89,7 @@ class WPushButton : public WWidget { ControlPushButton::ButtonMode m_leftButtonMode; ControlPushButton::ButtonMode m_rightButtonMode; QTimer m_clickTimer; + QVector m_align; }; #endif diff --git a/src/widget/wtrackproperty.cpp b/src/widget/wtrackproperty.cpp index 533c080a09..775a341e01 100644 --- a/src/widget/wtrackproperty.cpp +++ b/src/widget/wtrackproperty.cpp @@ -22,6 +22,7 @@ void WTrackProperty::setup(QDomNode node, const SkinContext& context) { WLabel::setup(node, context); m_property = context.selectString(node, "Property"); + setAlignment(Qt::AlignLeft); } void WTrackProperty::slotTrackLoaded(TrackPointer track) { -- cgit v1.2.3