From a108ebc846282126337a65c651928b1fa8566d26 Mon Sep 17 00:00:00 2001 From: Jean Claveau Date: Tue, 30 Sep 2014 22:42:55 +0200 Subject: PixmapSource passed by value --- src/widget/wdisplay.cpp | 6 +++--- src/widget/wdisplay.h | 2 +- src/widget/wknobcomposed.cpp | 12 ++++++------ src/widget/wknobcomposed.h | 4 ++-- src/widget/wpixmapstore.cpp | 32 +++++++++++++++----------------- src/widget/wpixmapstore.h | 4 ++-- src/widget/wpushbutton.cpp | 22 +++++++++++----------- src/widget/wpushbutton.h | 4 ++-- src/widget/wslidercomposed.cpp | 20 ++++++++++---------- src/widget/wslidercomposed.h | 4 ++-- src/widget/wstatuslight.cpp | 4 ++-- src/widget/wstatuslight.h | 2 +- src/widget/wvumeter.cpp | 10 +++++----- src/widget/wvumeter.h | 4 ++-- src/widget/wwidgetgroup.cpp | 6 +++--- src/widget/wwidgetgroup.h | 2 +- 16 files changed, 68 insertions(+), 70 deletions(-) (limited to 'src/widget') diff --git a/src/widget/wdisplay.cpp b/src/widget/wdisplay.cpp index ab9b72fec4..cd86e48590 100644 --- a/src/widget/wdisplay.cpp +++ b/src/widget/wdisplay.cpp @@ -86,12 +86,12 @@ void WDisplay::resetPositions() { m_disabledPixmaps.resize(0); } -void WDisplay::setPixmapBackground(PixmapSource* pSource, +void WDisplay::setPixmapBackground(PixmapSource source, Paintable::DrawMode mode) { - m_pPixmapBack = WPixmapStore::getPaintable(pSource, mode); + m_pPixmapBack = WPixmapStore::getPaintable(source, mode); if (m_pPixmapBack.isNull() || m_pPixmapBack->isNull()) { qDebug() << metaObject()->className() - << "Error loading background pixmap:" << pSource->getPath(); + << "Error loading background pixmap:" << source.getPath(); } } diff --git a/src/widget/wdisplay.h b/src/widget/wdisplay.h index a5feb15758..26433ee85d 100644 --- a/src/widget/wdisplay.h +++ b/src/widget/wdisplay.h @@ -48,7 +48,7 @@ class WDisplay : public WWidget { void setPixmap(QVector* pPixmaps, int iPos, const QString& filename); - void setPixmapBackground(PixmapSource* pSource, Paintable::DrawMode mode); + void setPixmapBackground(PixmapSource source, Paintable::DrawMode mode); void setPositions(int iNoPos); diff --git a/src/widget/wknobcomposed.cpp b/src/widget/wknobcomposed.cpp index 74b990308a..79337cafe6 100644 --- a/src/widget/wknobcomposed.cpp +++ b/src/widget/wknobcomposed.cpp @@ -43,20 +43,20 @@ void WKnobComposed::clear() { m_pKnob.clear(); } -void WKnobComposed::setPixmapBackground(PixmapSource* pSource, +void WKnobComposed::setPixmapBackground(PixmapSource source, Paintable::DrawMode mode) { - m_pPixmapBack = WPixmapStore::getPaintable(pSource, mode); + m_pPixmapBack = WPixmapStore::getPaintable(source, mode); if (m_pPixmapBack.isNull() || m_pPixmapBack->isNull()) { qDebug() << metaObject()->className() - << "Error loading background pixmap:" << pSource->getPath(); + << "Error loading background pixmap:" << source.getPath(); } } -void WKnobComposed::setPixmapKnob(PixmapSource* pSource) { - m_pKnob = WPixmapStore::getPaintable(pSource, Paintable::STRETCH); +void WKnobComposed::setPixmapKnob(PixmapSource source) { + m_pKnob = WPixmapStore::getPaintable(source, Paintable::STRETCH); if (m_pKnob.isNull() || m_pKnob->isNull()) { qDebug() << metaObject()->className() - << "Error loading knob pixmap:" << pSource->getPath(); + << "Error loading knob pixmap:" << source.getPath(); } } diff --git a/src/widget/wknobcomposed.h b/src/widget/wknobcomposed.h index e40577ed9a..decb5d2bbd 100644 --- a/src/widget/wknobcomposed.h +++ b/src/widget/wknobcomposed.h @@ -31,8 +31,8 @@ class WKnobComposed : public WWidget { private: void clear(); - void setPixmapBackground(PixmapSource* pSource, Paintable::DrawMode mode); - void setPixmapKnob(PixmapSource* pSource); + void setPixmapBackground(PixmapSource source, Paintable::DrawMode mode); + void setPixmapKnob(PixmapSource source); double m_dCurrentAngle; PaintablePointer m_pKnob; diff --git a/src/widget/wpixmapstore.cpp b/src/widget/wpixmapstore.cpp index a6e0801423..31f24363cc 100644 --- a/src/widget/wpixmapstore.cpp +++ b/src/widget/wpixmapstore.cpp @@ -70,16 +70,14 @@ Paintable::Paintable(const QString& fileName, DrawMode mode) } /**/ -Paintable::Paintable(PixmapSource* source, DrawMode mode) +Paintable::Paintable(PixmapSource source, DrawMode mode) : m_draw_mode(mode) { - if (source->isSVG()) { + if (source.isSVG()) { QSvgRenderer* pSvgRenderer = new QSvgRenderer(); - if( source->getData().isEmpty() ){ - // qWarning() << "Paintable stretch path" << source->getPath(); - pSvgRenderer->load(source->getPath()); + if( source.getData().isEmpty() ){ + pSvgRenderer->load(source.getPath()); } else { - // qWarning() << "Paintable stretch data" << source->getData(); - pSvgRenderer->load(source->getData()); + pSvgRenderer->load(source.getData()); } if (mode == STRETCH) { @@ -98,10 +96,10 @@ Paintable::Paintable(PixmapSource* source, DrawMode mode) } } else { QPixmap * pPixmap = new QPixmap(); - if (!source->getData().isEmpty()){ - pPixmap->loadFromData(source->getData()); + if (!source.getData().isEmpty()){ + pPixmap->loadFromData(source.getData()); } else { - pPixmap->load(source->getPath()); + pPixmap->load(source.getPath()); } m_pPixmap.reset(pPixmap); } @@ -251,19 +249,19 @@ PaintablePointer WPixmapStore::getPaintable(const QString& fileName, } // static -PaintablePointer WPixmapStore::getPaintable(PixmapSource* source, +PaintablePointer WPixmapStore::getPaintable(PixmapSource source, Paintable::DrawMode mode) { // See if we have a cached value for the pixmap. - PaintablePointer pPaintable = m_paintableCache.value(source->getId(), PaintablePointer()); + PaintablePointer pPaintable = m_paintableCache.value(source.getId(), PaintablePointer()); if (pPaintable) { return pPaintable; } // Otherwise, construct it with the pixmap loader. - qDebug() << "WPixmapStore Loading pixmap from file" << source->getPath(); + qDebug() << "WPixmapStore Loading pixmap from file" << source.getPath(); if (m_loader) { - QImage* pImage = m_loader->getImage(source->getPath()); + QImage* pImage = m_loader->getImage(source.getPath()); pPaintable = PaintablePointer(new Paintable(pImage, mode)); } else { pPaintable = PaintablePointer(new Paintable(source, mode)); @@ -273,14 +271,14 @@ PaintablePointer WPixmapStore::getPaintable(PixmapSource* source, // Only log if it looks like the user tried to specify a // pixmap. Otherwise we probably just have a widget that is calling // getPaintable without checking that the skinner actually wanted one. - if (!source->isEmpty()) { - qDebug() << "WPixmapStore couldn't load:" << source->getPath() + if (!source.isEmpty()) { + qDebug() << "WPixmapStore couldn't load:" << source.getPath() << pPaintable.isNull(); } return PaintablePointer(); } - m_paintableCache[source->getId()] = pPaintable; + m_paintableCache[source.getId()] = pPaintable; return pPaintable; } diff --git a/src/widget/wpixmapstore.h b/src/widget/wpixmapstore.h index 0ec0b8deab..26f7a1727c 100644 --- a/src/widget/wpixmapstore.h +++ b/src/widget/wpixmapstore.h @@ -44,7 +44,7 @@ class Paintable { // Takes ownership of QImage. Paintable(QImage* pImage, DrawMode mode); Paintable(const QString& fileName, DrawMode mode); - Paintable(PixmapSource* source, DrawMode mode); + Paintable(PixmapSource source, DrawMode mode); QSize size() const; int width() const; @@ -75,7 +75,7 @@ class WPixmapStore { public: static PaintablePointer getPaintable(const QString& fileName, Paintable::DrawMode mode); - static PaintablePointer getPaintable(PixmapSource* source, + static PaintablePointer getPaintable(PixmapSource source, Paintable::DrawMode mode); static QPixmap* getPixmapNoCache(const QString& fileName); static void setLoader(QSharedPointer ld); diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp index 65ddbe1800..52678c4677 100644 --- a/src/widget/wpushbutton.cpp +++ b/src/widget/wpushbutton.cpp @@ -59,8 +59,8 @@ void WPushButton::setup(QDomNode node, const SkinContext& context) { if (context.hasNode(node, "BackPath")) { QString mode_str = context.selectAttributeString( context.selectElement(node, "BackPath"), "scalemode", "TILE"); - PixmapSource* backgroundSource = context.getPixmapSource(context.selectNode(node, "BackPath")); - if (!backgroundSource->isEmpty()) { + PixmapSource backgroundSource = context.getPixmapSource(context.selectNode(node, "BackPath")); + if (!backgroundSource.isEmpty()) { setPixmapBackground(backgroundSource, Paintable::DrawModeFromString(mode_str)); } } @@ -76,15 +76,15 @@ void WPushButton::setup(QDomNode node, const SkinContext& context) { int iState = stateContext->selectInt(state, "Number"); if (iState < m_iNoStates) { QString pixmapPath; - PixmapSource* pixmapSource; + PixmapSource pixmapSource; pixmapSource = stateContext->getPixmapSource(stateContext->selectNode(state, "Unpressed")); - if (!pixmapSource->isEmpty()) { + if (!pixmapSource.isEmpty()) { setPixmap(iState, false, pixmapSource); } pixmapSource = stateContext->getPixmapSource(stateContext->selectNode(state, "Pressed")); - if (!pixmapSource->isEmpty()) { + if (!pixmapSource.isEmpty()) { setPixmap(iState, true, pixmapSource); } @@ -203,7 +203,7 @@ void WPushButton::setStates(int iStates) { m_align.resize(iStates); } -void WPushButton::setPixmap(int iState, bool bPressed, PixmapSource* source) { +void WPushButton::setPixmap(int iState, bool bPressed, PixmapSource source) { QVector& pixmaps = bPressed ? m_pressedPixmaps : m_unpressedPixmaps; @@ -216,8 +216,8 @@ void WPushButton::setPixmap(int iState, bool bPressed, PixmapSource* source) { if (pPixmap.isNull() || pPixmap->isNull()) { // Only log if it looks like the user tried to specify a pixmap. - if (!source->isEmpty()) { - qDebug() << "WPushButton: Error loading pixmap:" << source->getPath(); + if (!source.isEmpty()) { + qDebug() << "WPushButton: Error loading pixmap:" << source.getPath(); } } else { // Set size of widget equal to pixmap size @@ -226,14 +226,14 @@ void WPushButton::setPixmap(int iState, bool bPressed, PixmapSource* source) { pixmaps.replace(iState, pPixmap); } -void WPushButton::setPixmapBackground(PixmapSource* source, +void WPushButton::setPixmapBackground(PixmapSource source, Paintable::DrawMode mode) { // Load background pixmap m_pPixmapBack = WPixmapStore::getPaintable(source, mode); - if (!source->isEmpty() && + if (!source.isEmpty() && (m_pPixmapBack.isNull() || m_pPixmapBack->isNull())) { // Only log if it looks like the user tried to specify a pixmap. - qDebug() << "WPushButton: Error loading background pixmap:" << source->getPath(); + qDebug() << "WPushButton: Error loading background pixmap:" << source.getPath(); } } diff --git a/src/widget/wpushbutton.h b/src/widget/wpushbutton.h index b37f037e31..6937bf9d21 100644 --- a/src/widget/wpushbutton.h +++ b/src/widget/wpushbutton.h @@ -78,11 +78,11 @@ class WPushButton : public WWidget { private: // Associates a pixmap of a given state of the button with the widget - void setPixmap(int iState, bool bPressed, PixmapSource* source); + void setPixmap(int iState, bool bPressed, PixmapSource source); // Associates a background pixmap with the widget. This is only needed if // the button pixmaps contains alpha channel values. - void setPixmapBackground(PixmapSource* source, + void setPixmapBackground(PixmapSource source, Paintable::DrawMode mode); // True, if the button is currently pressed diff --git a/src/widget/wslidercomposed.cpp b/src/widget/wslidercomposed.cpp index 9657477df0..5395804759 100644 --- a/src/widget/wslidercomposed.cpp +++ b/src/widget/wslidercomposed.cpp @@ -50,13 +50,13 @@ void WSliderComposed::setup(QDomNode node, const SkinContext& context) { unsetPixmaps(); if (context.hasNode(node, "Slider")) { - PixmapSource* pSourceSlider = context.getPixmapSource(context.selectNode(node, "Slider")); - setSliderPixmap(pSourceSlider); + PixmapSource sourceSlider = context.getPixmapSource(context.selectNode(node, "Slider")); + setSliderPixmap(sourceSlider); } - PixmapSource* pSourceHandle = context.getPixmapSource(context.selectNode(node, "Handle")); + PixmapSource sourceHandle = context.getPixmapSource(context.selectNode(node, "Handle")); bool h = context.selectBool(node, "Horizontal", false); - setHandlePixmap(h, pSourceHandle); + setHandlePixmap(h, sourceHandle); if (context.hasNode(node, "EventWhileDrag")) { if (context.selectString(node, "EventWhileDrag").contains("no")) { @@ -76,23 +76,23 @@ void WSliderComposed::setup(QDomNode node, const SkinContext& context) { } } -void WSliderComposed::setSliderPixmap(PixmapSource* pSourceSlider) { - m_pSlider = WPixmapStore::getPaintable(pSourceSlider, +void WSliderComposed::setSliderPixmap(PixmapSource sourceSlider) { + m_pSlider = WPixmapStore::getPaintable(sourceSlider, Paintable::STRETCH); if (!m_pSlider) { - qDebug() << "WSliderComposed: Error loading slider pixmap:" << pSourceSlider->getPath(); + qDebug() << "WSliderComposed: Error loading slider pixmap:" << sourceSlider.getPath(); } else { // Set size of widget, using size of slider pixmap setFixedSize(m_pSlider->size()); } } -void WSliderComposed::setHandlePixmap(bool bHorizontal, PixmapSource* pSourceHandle) { +void WSliderComposed::setHandlePixmap(bool bHorizontal, PixmapSource sourceHandle) { m_bHorizontal = bHorizontal; - m_pHandle = WPixmapStore::getPaintable(pSourceHandle, + m_pHandle = WPixmapStore::getPaintable(sourceHandle, Paintable::STRETCH); if (!m_pHandle) { - qDebug() << "WSliderComposed: Error loading handle pixmap:" << pSourceHandle->getPath(); + qDebug() << "WSliderComposed: Error loading handle pixmap:" << sourceHandle.getPath(); } else { m_iHandleLength = m_bHorizontal ? m_pHandle->width() : m_pHandle->height(); diff --git a/src/widget/wslidercomposed.h b/src/widget/wslidercomposed.h index 65d69cbaf3..1c2acbe51a 100644 --- a/src/widget/wslidercomposed.h +++ b/src/widget/wslidercomposed.h @@ -43,8 +43,8 @@ class WSliderComposed : public WWidget { virtual ~WSliderComposed(); void setup(QDomNode node, const SkinContext& context); - void setSliderPixmap(PixmapSource* pSourceSlider); - void setHandlePixmap(bool bHorizontal, PixmapSource* pSourceHandle); + void setSliderPixmap(PixmapSource sourceSlider); + void setHandlePixmap(bool bHorizontal, PixmapSource sourceHandle); inline bool isHorizontal() const { return m_bHorizontal; }; public slots: diff --git a/src/widget/wstatuslight.cpp b/src/widget/wstatuslight.cpp index cbf8cde43c..f33553c908 100644 --- a/src/widget/wstatuslight.cpp +++ b/src/widget/wstatuslight.cpp @@ -86,7 +86,7 @@ void WStatusLight::setup(QDomNode node, const SkinContext& context) { } } -void WStatusLight::setPixmap(int iState, PixmapSource* source, SizeMode mode) { +void WStatusLight::setPixmap(int iState, PixmapSource source, SizeMode mode) { if (iState < 0 || iState >= m_pixmaps.size()) { return; } @@ -111,7 +111,7 @@ void WStatusLight::setPixmap(int iState, PixmapSource* source, SizeMode mode) { break; } } else { - qDebug() << "WStatusLight: Error loading pixmap:" << source->getPath() << iState; + qDebug() << "WStatusLight: Error loading pixmap:" << source.getPath() << iState; m_pixmaps[iState].clear(); } } diff --git a/src/widget/wstatuslight.h b/src/widget/wstatuslight.h index a4d5f15a44..4c241cd48f 100644 --- a/src/widget/wstatuslight.h +++ b/src/widget/wstatuslight.h @@ -52,7 +52,7 @@ class WStatusLight : public WWidget { void paintEvent(QPaintEvent *); private: - void setPixmap(int iState, PixmapSource* source, SizeMode mode); + void setPixmap(int iState, PixmapSource source, SizeMode mode); void setNoPos(int iNoPos); // Current position diff --git a/src/widget/wvumeter.cpp b/src/widget/wvumeter.cpp index ff71d11c4f..c4e2afcbbf 100644 --- a/src/widget/wvumeter.cpp +++ b/src/widget/wvumeter.cpp @@ -84,23 +84,23 @@ void WVuMeter::resetPositions() { m_pPixmapVu.clear(); } -void WVuMeter::setPixmapBackground(PixmapSource* source) { +void WVuMeter::setPixmapBackground(PixmapSource source) { m_pPixmapBack = WPixmapStore::getPaintable(source, Paintable::TILE); if (m_pPixmapBack.isNull() || m_pPixmapBack->isNull()) { qDebug() << metaObject()->className() - << "Error loading background pixmap:" << source->getPath(); + << "Error loading background pixmap:" << source.getPath(); } else { setFixedSize(m_pPixmapBack->size()); } } -void WVuMeter::setPixmaps(PixmapSource* vuSource, +void WVuMeter::setPixmaps(PixmapSource source, bool bHorizontal) { - m_pPixmapVu = WPixmapStore::getPaintable(vuSource, + m_pPixmapVu = WPixmapStore::getPaintable(source, Paintable::STRETCH); if (m_pPixmapVu.isNull() || m_pPixmapVu->isNull()) { - qDebug() << "WVuMeter: Error loading vu pixmap" << vuSource->getPath(); + qDebug() << "WVuMeter: Error loading vu pixmap" << source.getPath(); } else { m_bHorizontal = bHorizontal; if (m_bHorizontal) { diff --git a/src/widget/wvumeter.h b/src/widget/wvumeter.h index 585e425ef5..3ea70647f7 100644 --- a/src/widget/wvumeter.h +++ b/src/widget/wvumeter.h @@ -36,8 +36,8 @@ class WVuMeter : public WWidget { virtual ~WVuMeter(); void setup(QDomNode node, const SkinContext& context); - void setPixmapBackground(PixmapSource* source); - void setPixmaps(PixmapSource* vuSource, + void setPixmapBackground(PixmapSource source); + void setPixmaps(PixmapSource source, bool bHorizontal=false); void onConnectedControlChanged(double dParameter, double dValue); diff --git a/src/widget/wwidgetgroup.cpp b/src/widget/wwidgetgroup.cpp index fe34add5aa..3de66f80d9 100644 --- a/src/widget/wwidgetgroup.cpp +++ b/src/widget/wwidgetgroup.cpp @@ -132,11 +132,11 @@ void WWidgetGroup::setup(QDomNode node, const SkinContext& context) { } } -void WWidgetGroup::setPixmapBackground(PixmapSource* pSource, Paintable::DrawMode mode) { +void WWidgetGroup::setPixmapBackground(PixmapSource source, Paintable::DrawMode mode) { // Load background pixmap - m_pPixmapBack = WPixmapStore::getPaintable(pSource, mode); + m_pPixmapBack = WPixmapStore::getPaintable(source, mode); if (!m_pPixmapBack) { - qDebug() << "WWidgetGroup: Error loading background pixmap:" << pSource->getPath(); + qDebug() << "WWidgetGroup: Error loading background pixmap:" << source.getPath(); } } diff --git a/src/widget/wwidgetgroup.h b/src/widget/wwidgetgroup.h index 23e6792178..815ecfb3f5 100644 --- a/src/widget/wwidgetgroup.h +++ b/src/widget/wwidgetgroup.h @@ -43,7 +43,7 @@ class WWidgetGroup : public QFrame, public WBaseWidget { void setLayoutAlignment(int alignment); void setup(QDomNode node, const SkinContext& context); - void setPixmapBackground(PixmapSource* pSource, Paintable::DrawMode mode); + void setPixmapBackground(PixmapSource source, Paintable::DrawMode mode); void addWidget(QWidget* pChild); protected: -- cgit v1.2.3