author | simon <simon> | 2002-12-11 12:21:55 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 12:21:55 (UTC) |
commit | d24ad11763335834718485f14e90d8dab2611fa2 (patch) (side-by-side diff) | |
tree | c2ad64ecd8f2e217a3816f57c3dec20aaac4e421 | |
parent | 381de1a3cfcc32dd7c0350329413f55dd9de9bb8 (diff) | |
download | opie-d24ad11763335834718485f14e90d8dab2611fa2.zip opie-d24ad11763335834718485f14e90d8dab2611fa2.tar.gz opie-d24ad11763335834718485f14e90d8dab2611fa2.tar.bz2 |
- moved the remaining pieces of image/pixmap loading to the Skin class
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.h | 2 |
4 files changed, 23 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 2031b4d..4de7ea9 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -45,5 +45,5 @@ MediaWidget::~MediaWidget() void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, - const QString &imagePrefix, const QSize &buttonAreaSize ) + const Skin &skin, const QSize &buttonAreaSize ) { buttonMask = QImage( buttonAreaSize, 8, 255 ); @@ -54,10 +54,10 @@ void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount for ( uint i = 0; i < buttonCount; ++i ) { - Button button = setupButton( skinInfo[ i ], imagePrefix ); + Button button = setupButton( skinInfo[ i ], skin ); buttons.push_back( button ); } } -MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) +MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) { Button button; @@ -65,15 +65,12 @@ MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, button.type = buttonInfo.type; - QString fileName = imagePrefix + buttonInfo.fileName + ".png"; - - button.mask = setupButtonMask( button.command, fileName ); + button.mask = setupButtonMask( button.command, skin.buttonMaskImage( buttonInfo.fileName ) ); return button; } -QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) +QBitmap MediaWidget::setupButtonMask( const Command &command, const QImage &maskImage ) { - QImage imgMask( Resource::findPixmap( fileName ) ); - if ( imgMask.isNull() ) + if ( maskImage.isNull() ) return QBitmap(); @@ -82,10 +79,10 @@ QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fil uchar *line = dest[y]; for ( int x = 0; x < buttonMask.width(); x++ ) - if ( !qRed( imgMask.pixel( x, y ) ) ) + if ( !qRed( maskImage.pixel( x, y ) ) ) line[x] = command + 1; } // ### grmbl qt2. use constructor when switching to qt3. - QBitmap bm; bm = imgMask; + QBitmap bm; bm = maskImage; return bm; } @@ -109,6 +106,5 @@ void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, co buttonDownImage = skin.buttonDownImage(); - setupButtons( skinInfo, buttonCount, - skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() ); + setupButtons( skinInfo, buttonCount, skin, buttonUpImage.size() ); } diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 52b9fcb..0d635aa 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -44,4 +44,6 @@ namespace } +class Skin; + class MediaWidget : public QWidget { @@ -101,7 +103,7 @@ signals: protected: void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, - const QString &imagePrefix, const QSize &buttonAreaSize ); - Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); - QBitmap setupButtonMask( const Command &command, const QString &fileName ); + const Skin &skin, const QSize &buttonAreaSize ); + Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ); + QBitmap setupButtonMask( const Command &command, const QImage &maskImage ); void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null ); diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index 352368f..fb1c9c4 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp @@ -25,4 +25,11 @@ QImage Skin::buttonDownImage() const } +QImage Skin::buttonMaskImage( const QString &fileName ) const +{ + QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); + QString path = prefix + fileName + ".png"; + return QImage( Resource::findPixmap( path ) ); +} + /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h index 85f9e57..f160b3c 100644 --- a/noncore/multimedia/opieplayer2/skin.h +++ b/noncore/multimedia/opieplayer2/skin.h @@ -14,4 +14,6 @@ public: QImage buttonDownImage() const; + QImage buttonMaskImage( const QString &fileName ) const; + private: QString m_name; |