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 | |
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') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 43 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 25 |
4 files changed, 50 insertions, 48 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 23d12ec..fd18dbb 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -96,36 +96,13 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
96 | 96 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 97 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
101 | 101 | ||
102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 102 | setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() ); |
103 | buttonMask.fill( 0 ); | ||
104 | |||
105 | for ( uint i = 0; i < buttonCount; i++ ) { | ||
106 | Button button; | ||
107 | button.command = skinInfo[ i ].command; | ||
108 | button.type = skinInfo[ i ].type; | ||
109 | |||
110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); | ||
111 | button.mask =QBitmap( filename ); | ||
112 | |||
113 | if ( !button.mask.isNull() ) { | ||
114 | QImage imgMask = button.mask.convertToImage(); | ||
115 | uchar **dest = buttonMask.jumpTable(); | ||
116 | for ( int y = 0; y < imgUp.height(); y++ ) { | ||
117 | uchar *line = dest[y]; | ||
118 | for ( int x = 0; x < imgUp.width(); x++ ) | ||
119 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
120 | line[x] = button.command + 1; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | buttons.push_back( button ); | ||
125 | } | ||
126 | 103 | ||
127 | setBackgroundPixmap( backgroundPixmap ); | 104 | setBackgroundPixmap( backgroundPixmap ); |
128 | 105 | ||
129 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 106 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
130 | // changeTextColor( &songInfo ); | 107 | // changeTextColor( &songInfo ); |
131 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 108 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
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 | |||
@@ -36,12 +36,55 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
36 | } | 36 | } |
37 | 37 | ||
38 | MediaWidget::~MediaWidget() | 38 | 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(); |
45 | } | 88 | } |
46 | 89 | ||
47 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 90 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 8031371..148948a 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -80,12 +80,17 @@ signals: | |||
80 | void forwardClicked(); | 80 | void forwardClicked(); |
81 | void backClicked(); | 81 | void backClicked(); |
82 | void moreClicked(); | 82 | void moreClicked(); |
83 | void lessClicked(); | 83 | void lessClicked(); |
84 | 84 | ||
85 | protected: | 85 | protected: |
86 | void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | ||
87 | const QString &imagePrefix, const QSize &buttonAreaSize ); | ||
88 | Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); | ||
89 | QBitmap setupButtonMask( const Command &command, const QString &fileName ); | ||
90 | |||
86 | virtual void closeEvent( QCloseEvent * ); | 91 | virtual void closeEvent( QCloseEvent * ); |
87 | 92 | ||
88 | virtual void paintEvent( QPaintEvent *pe ); | 93 | virtual void paintEvent( QPaintEvent *pe ); |
89 | 94 | ||
90 | Button *buttonAt( const QPoint &position ); | 95 | Button *buttonAt( const QPoint &position ); |
91 | 96 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 4901e47..d1efaad 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -91,36 +91,13 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
91 | 91 | ||
92 | QString skinPath = "opieplayer2/skins/" + skin; | 92 | QString skinPath = "opieplayer2/skins/" + skin; |
93 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
94 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
95 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
96 | 96 | ||
97 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 97 | setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() ); |
98 | buttonMask.fill( 0 ); | ||
99 | |||
100 | for ( uint i = 0; i < buttonCount; i++ ) { | ||
101 | Button button; | ||
102 | button.command = skinInfo[ i ].command; | ||
103 | button.type = skinInfo[ i ].type; | ||
104 | |||
105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); | ||
106 | button.mask =QBitmap( filename ); | ||
107 | |||
108 | if ( !button.mask.isNull() ) { | ||
109 | QImage imgMask = button.mask.convertToImage(); | ||
110 | uchar **dest = buttonMask.jumpTable(); | ||
111 | for ( int y = 0; y < imgUp.height(); y++ ) { | ||
112 | uchar *line = dest[y]; | ||
113 | for ( int x = 0; x < imgUp.width(); x++ ) | ||
114 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
115 | line[x] = button.command + 1; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | buttons.push_back( button ); | ||
120 | } | ||
121 | 98 | ||
122 | setBackgroundPixmap( backgroundPixmap ); | 99 | setBackgroundPixmap( backgroundPixmap ); |
123 | 100 | ||
124 | slider = new QSlider( Qt::Horizontal, this ); | 101 | slider = new QSlider( Qt::Horizontal, this ); |
125 | slider->setMinValue( 0 ); | 102 | slider->setMinValue( 0 ); |
126 | slider->setMaxValue( 1 ); | 103 | slider->setMaxValue( 1 ); |