author | simon <simon> | 2002-12-09 21:29:21 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 21:29:21 (UTC) |
commit | a9015ff25ddec67983f78f2a75346f21b7d062c5 (patch) (unidiff) | |
tree | a7f4e0e536f4394bf0392079484ca96592b62183 /noncore/multimedia/opieplayer2/mediawidget.cpp | |
parent | e95602de0209b1add5f394ce8b87d5f67213643d (diff) | |
download | opie-a9015ff25ddec67983f78f2a75346f21b7d062c5.zip opie-a9015ff25ddec67983f78f2a75346f21b7d062c5.tar.gz opie-a9015ff25ddec67983f78f2a75346f21b7d062c5.tar.bz2 |
- the skin loading code is now centralized. no more duplicated code :)
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 4c4cead..db16b44 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -39,6 +39,49 @@ MediaWidget::~MediaWidget() | |||
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | ||
43 | const QString &imagePrefix, const QSize &buttonAreaSize ) | ||
44 | { | ||
45 | buttonMask = QImage( buttonAreaSize, 8, 255 ); | ||
46 | buttonMask.fill( 0 ); | ||
47 | |||
48 | for ( uint i = 0; i < buttonCount; ++i ) { | ||
49 | Button button = setupButton( skinInfo[ i ], imagePrefix ); | ||
50 | buttons.push_back( button ); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) | ||
55 | { | ||
56 | Button button; | ||
57 | button.command = buttonInfo.command; | ||
58 | button.type = buttonInfo.type; | ||
59 | |||
60 | QString fileName = imagePrefix + buttonInfo.fileName + ".png"; | ||
61 | |||
62 | button.mask = setupButtonMask( button.command, fileName ); | ||
63 | |||
64 | return button; | ||
65 | } | ||
66 | |||
67 | QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) | ||
68 | { | ||
69 | QBitmap mask( fileName ); | ||
70 | if ( mask.isNull() ) | ||
71 | return mask; | ||
72 | |||
73 | QImage imgMask = mask.convertToImage(); | ||
74 | uchar **dest = buttonMask.jumpTable(); | ||
75 | for ( int y = 0; y < buttonMask.height(); y++ ) { | ||
76 | uchar *line = dest[y]; | ||
77 | for ( int x = 0; x < buttonMask.width(); x++ ) | ||
78 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
79 | line[x] = command + 1; | ||
80 | } | ||
81 | |||
82 | return mask; | ||
83 | } | ||
84 | |||
42 | void MediaWidget::closeEvent( QCloseEvent * ) | 85 | void MediaWidget::closeEvent( QCloseEvent * ) |
43 | { | 86 | { |
44 | mediaPlayerState.setList(); | 87 | mediaPlayerState.setList(); |