summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 11:52:24 (UTC)
committer simon <simon>2002-12-11 11:52:24 (UTC)
commit9ae7f1a1b5fbadf4ea40f8d7bf07a637299a091a (patch) (unidiff)
tree08bfee61215df1af5c0a9a7e2068ea3f4fb8045c
parent03ac4af4d6014bbd46b12d5fe89ee2cc73941080 (diff)
downloadopie-9ae7f1a1b5fbadf4ea40f8d7bf07a637299a091a.zip
opie-9ae7f1a1b5fbadf4ea40f8d7bf07a637299a091a.tar.gz
opie-9ae7f1a1b5fbadf4ea40f8d7bf07a637299a091a.tar.bz2
- less qimage<>qpixmap conversions
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 865ff91..70ef8d9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -43,78 +43,79 @@ MediaWidget::~MediaWidget()
43} 43}
44 44
45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
46 const QString &imagePrefix, const QSize &buttonAreaSize ) 46 const QString &imagePrefix, const QSize &buttonAreaSize )
47{ 47{
48 buttonMask = QImage( buttonAreaSize, 8, 255 ); 48 buttonMask = QImage( buttonAreaSize, 8, 255 );
49 buttonMask.fill( 0 ); 49 buttonMask.fill( 0 );
50 50
51 buttons.clear(); 51 buttons.clear();
52 buttons.reserve( buttonCount ); 52 buttons.reserve( buttonCount );
53 53
54 for ( uint i = 0; i < buttonCount; ++i ) { 54 for ( uint i = 0; i < buttonCount; ++i ) {
55 Button button = setupButton( skinInfo[ i ], imagePrefix ); 55 Button button = setupButton( skinInfo[ i ], imagePrefix );
56 buttons.push_back( button ); 56 buttons.push_back( button );
57 } 57 }
58} 58}
59 59
60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) 60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
61{ 61{
62 Button button; 62 Button button;
63 button.command = buttonInfo.command; 63 button.command = buttonInfo.command;
64 button.type = buttonInfo.type; 64 button.type = buttonInfo.type;
65 65
66 QString fileName = imagePrefix + buttonInfo.fileName + ".png"; 66 QString fileName = imagePrefix + buttonInfo.fileName + ".png";
67 67
68 button.mask = setupButtonMask( button.command, fileName ); 68 button.mask = setupButtonMask( button.command, fileName );
69 69
70 return button; 70 return button;
71} 71}
72 72
73QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) 73QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
74{ 74{
75 QBitmap mask( Resource::findPixmap( fileName ) ); 75 QImage imgMask( Resource::findPixmap( fileName ) );
76 if ( mask.isNull() ) 76 if ( imgMask.isNull() )
77 return mask; 77 return QBitmap();
78 78
79 QImage imgMask = mask.convertToImage();
80 uchar **dest = buttonMask.jumpTable(); 79 uchar **dest = buttonMask.jumpTable();
81 for ( int y = 0; y < buttonMask.height(); y++ ) { 80 for ( int y = 0; y < buttonMask.height(); y++ ) {
82 uchar *line = dest[y]; 81 uchar *line = dest[y];
83 for ( int x = 0; x < buttonMask.width(); x++ ) 82 for ( int x = 0; x < buttonMask.width(); x++ )
84 if ( !qRed( imgMask.pixel( x, y ) ) ) 83 if ( !qRed( imgMask.pixel( x, y ) ) )
85 line[x] = command + 1; 84 line[x] = command + 1;
86 } 85 }
87 86
88 return mask; 87 // ### grmbl qt2. use constructor when switching to qt3.
88 QBitmap bm; bm = imgMask;
89 return bm;
89} 90}
90 91
91void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) 92void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix )
92{ 93{
93 Config cfg( "OpiePlayer" ); 94 Config cfg( "OpiePlayer" );
94 cfg.setGroup( "Options" ); 95 cfg.setGroup( "Options" );
95 QString skin = cfg.readEntry( "Skin","default" ); 96 QString skin = cfg.readEntry( "Skin","default" );
96 97
97 loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); 98 loadSkin( skinInfo, buttonCount, skin, fileNameInfix );
98} 99}
99 100
100void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) 101void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix )
101{ 102{
102 QString skinPath = "opieplayer2/skins/" + name; 103 QString skinPath = "opieplayer2/skins/" + name;
103 backgroundPixmap = QPixmap( Resource::loadPixmap( QString( "%1/background" ).arg( skinPath ) ) ); 104 backgroundPixmap = QPixmap( Resource::loadPixmap( QString( "%1/background" ).arg( skinPath ) ) );
104 buttonUpImage = QImage( Resource::loadImage( QString( "%1/skin%2_up" ).arg( skinPath ).arg( fileNameInfix ) ) ); 105 buttonUpImage = QImage( Resource::loadImage( QString( "%1/skin%2_up" ).arg( skinPath ).arg( fileNameInfix ) ) );
105 buttonDownImage = QImage( Resource::loadImage( QString( "%1/skin%2_down" ).arg( skinPath ).arg( fileNameInfix ) ) ); 106 buttonDownImage = QImage( Resource::loadImage( QString( "%1/skin%2_down" ).arg( skinPath ).arg( fileNameInfix ) ) );
106 107
107 setupButtons( skinInfo, buttonCount, 108 setupButtons( skinInfo, buttonCount,
108 skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() ); 109 skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() );
109} 110}
110 111
111void MediaWidget::closeEvent( QCloseEvent * ) 112void MediaWidget::closeEvent( QCloseEvent * )
112{ 113{
113 mediaPlayerState.setList(); 114 mediaPlayerState.setList();
114} 115}
115 116
116void MediaWidget::paintEvent( QPaintEvent *pe ) 117void MediaWidget::paintEvent( QPaintEvent *pe )
117{ 118{
118 QPainter p( this ); 119 QPainter p( this );
119 120
120 if ( mediaPlayerState.isFullscreen() ) { 121 if ( mediaPlayerState.isFullscreen() ) {