diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-04-18 03:28:57 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-04-18 03:28:57 +0000 |
commit | 1d9d9f5ce46f0220f7b1b350f5ad4e6dc5079ac6 (patch) | |
tree | 728d80ad748a95d7aa27ee020706dbe985e0e8cb /amarok/src/osd.cpp | |
parent | e9db3e45ed0189bbe18125b120da394a5bc8a832 (diff) | |
download | amarok-1d9d9f5ce46f0220f7b1b350f5ad4e6dc5079ac6.tar.gz amarok-1d9d9f5ce46f0220f7b1b350f5ad4e6dc5079ac6.zip |
Finish TQt4 porting of Amarok
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1228394 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'amarok/src/osd.cpp')
-rw-r--r-- | amarok/src/osd.cpp | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/amarok/src/osd.cpp b/amarok/src/osd.cpp index ff9c0cb8..ae9b1042 100644 --- a/amarok/src/osd.cpp +++ b/amarok/src/osd.cpp @@ -45,11 +45,11 @@ namespace ShadowEngine #define MOODBAR_HEIGHT 20 -OSDWidget::OSDWidget( TQWidget *parent, const char *name ) - : TQWidget( parent, name, WType_TopLevel | WNoAutoErase | WStyle_Customize | WX11BypassWM | WStyle_StaysOnTop ) +OSDWidget::OSDWidget( TQWidget *tqparent, const char *name ) + : TQWidget( tqparent, name, WType_TopLevel | WNoAutoErase | WStyle_Customize | WX11BypassWM | WStyle_StaysOnTop ) , m_duration( 2000 ) , m_timer( new TQTimer( this ) ) - , m_alignment( Middle ) + , m_tqalignment( Middle ) , m_screen( 0 ) , m_y( MARGIN ) , m_drawShadow( false ) @@ -57,7 +57,7 @@ OSDWidget::OSDWidget( TQWidget *parent, const char *name ) , m_rating( 0 ) , m_volume( false ) { - setFocusPolicy( NoFocus ); + setFocusPolicy( TQ_NoFocus ); setBackgroundMode( NoBackground ); unsetColors(); @@ -72,7 +72,7 @@ OSDWidget::OSDWidget( TQWidget *parent, const char *name ) void OSDWidget::show( const TQString &text, TQImage newImage ) { -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 m_text = text; if ( !newImage.isNull() ) { @@ -115,7 +115,7 @@ OSDWidget::volChanged( unsigned char volume ) { m_volume = true; m_newvolume = volume; - m_text = m_newvolume ? i18n("Volume: %1%").arg( m_newvolume ) : i18n("Mute"); + m_text = m_newvolume ? i18n("Volume: %1%").tqarg( m_newvolume ) : i18n("Mute"); show(); } @@ -124,7 +124,7 @@ OSDWidget::volChanged( unsigned char volume ) void OSDWidget::show() //virtual { -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 if ( !isEnabled() || m_text.isEmpty() ) return; @@ -134,15 +134,15 @@ OSDWidget::show() //virtual const TQRect newGeometry = determineMetrics( M ); if( m_translucency && !isShown() || !newGeometry.intersects( oldGeometry ) ) - m_screenshot = TQPixmap::grabWindow( qt_xrootwin(), + m_screenshot = TQPixmap(TQPixmap::grabWindow( qt_xrootwin(), newGeometry.x(), newGeometry.y(), - newGeometry.width(), newGeometry.height() ); + newGeometry.width(), newGeometry.height() )); else if( m_translucency ) { const TQRect unite = oldGeometry.unite( newGeometry ); - KPixmap pix = TQPixmap::grabWindow( qt_xrootwin(), unite.x(), unite.y(), unite.width(), unite.height() ); + KPixmap pix = TQPixmap(TQPixmap::grabWindow( qt_xrootwin(), unite.x(), unite.y(), unite.width(), unite.height() )); TQPoint p = oldGeometry.topLeft() - unite.topLeft(); bitBlt( &pix, p, &m_screenshot ); @@ -168,7 +168,7 @@ OSDWidget::show() //virtual #endif } -QRect +TQRect OSDWidget::determineMetrics( const uint M ) { // sometimes we only have a tiddly cover @@ -179,10 +179,10 @@ OSDWidget::determineMetrics( const uint M ) const TQSize image = m_cover.isNull() ? TQSize( 0, 0 ) : minImageSize; const TQSize max = TQApplication::desktop()->screen( m_screen )->size() - margin; - // If we don't do that, the boundingRect() might not be suitable for drawText() (Qt issue N67674) - m_text.replace( TQRegExp(" +\n"), "\n" ); + // If we don't do that, the boundingRect() might not be suitable for drawText() (TQt issue N67674) + m_text.tqreplace( TQRegExp(" +\n"), "\n" ); // remove consecutive line breaks - m_text.replace( TQRegExp("\n+"), "\n" ); + m_text.tqreplace( TQRegExp("\n+"), "\n" ); // The osd cannot be larger than the screen TQRect rect = fontMetrics().boundingRect( 0, 0, @@ -219,9 +219,9 @@ OSDWidget::determineMetrics( const uint M ) const int availableWidth = max.width() - rect.width() - M; //WILL be >= (minImageSize.width() - M) m_scaledCover = m_cover.smoothScale( - QMIN( availableWidth, m_cover.width() ), - QMIN( rect.height(), m_cover.height() ), - TQImage::ScaleMin ); //this will force us to be with our bounds + TQMIN( availableWidth, m_cover.width() ), + TQMIN( rect.height(), m_cover.height() ), + TQ_ScaleMin ); //this will force us to be with our bounds int shadowWidth = 0; if( m_drawShadow && !m_scaledCover.hasAlpha() && @@ -243,7 +243,7 @@ OSDWidget::determineMetrics( const uint M ) const TQRect screen = TQApplication::desktop()->screenGeometry( m_screen ); TQPoint newPos( MARGIN, m_y ); - switch( m_alignment ) + switch( m_tqalignment ) { case Left: break; @@ -284,26 +284,26 @@ OSDWidget::render( const uint M, const TQSize &size ) const uint xround = (M * 200) / size.width(); const uint yround = (M * 200) / size.height(); - { /// apply the mask - static TQBitmap mask; + { /// apply the tqmask + static TQBitmap tqmask; - mask.resize( size ); - mask.fill( Qt::black ); + tqmask.resize( size ); + tqmask.fill( TQt::black ); - TQPainter p( &mask ); - p.setBrush( Qt::white ); + TQPainter p( &tqmask ); + p.setBrush( TQt::white ); p.drawRoundRect( rect, xround, yround ); - setMask( mask ); + setMask( tqmask ); } TQColor shadowColor; { int h,s,v; foregroundColor().getHsv( &h, &s, &v ); - shadowColor = v > 128 ? Qt::black : Qt::white; + shadowColor = v > 128 ? TQt::black : TQt::white; } - int align = Qt::AlignCenter | WordBreak; + int align = TQt::AlignCenter | WordBreak; m_buffer.resize( rect.size() ); TQPainter p( &m_buffer ); @@ -335,8 +335,8 @@ OSDWidget::render( const uint M, const TQSize &size ) const uint shadowSize = static_cast<uint>( m_scaledCover.width() / 100.0 * 6.0 ); const TQString folder = Amarok::saveLocation( "covershadow-cache/" ); - const TQString file = TQString( "shadow_albumcover%1x%2.png" ).arg( m_scaledCover.width() + shadowSize ) - .arg( m_scaledCover.height() + shadowSize ); + const TQString file = TQString( "shadow_albumcover%1x%2.png" ).tqarg( m_scaledCover.width() + shadowSize ) + .tqarg( m_scaledCover.height() + shadowSize ); if ( TQFile::exists( folder + file ) ) shadow.load( folder + file ); else { @@ -370,20 +370,20 @@ OSDWidget::render( const uint M, const TQSize &size ) KPixmap pixmapGradient; { // gradient - TQBitmap mask; - mask.resize( vol.size() ); - mask.fill( Qt::black ); + TQBitmap tqmask; + tqmask.resize( vol.size() ); + tqmask.fill( TQt::black ); - TQPainter p( &mask ); - p.setBrush( Qt::white ); + TQPainter p( &tqmask ); + p.setBrush( TQt::white ); p.drawRoundRect ( 3, 3, vol.width() - 6, vol.height() - 6, M * 300 / vol.width(), 99 ); p.end(); pixmapGradient = TQPixmap( vol.size() ); - KPixmapEffect::gradient( pixmapGradient, colorGroup().background(), - colorGroup().highlight(), KPixmapEffect::EllipticGradient ); - pixmapGradient.setMask( mask ); + KPixmapEffect::gradient( pixmapGradient, tqcolorGroup().background(), + tqcolorGroup().highlight(), KPixmapEffect::EllipticGradient ); + pixmapGradient.setMask( tqmask ); } if( m_translucency ) @@ -396,19 +396,19 @@ OSDWidget::render( const uint M, const TQSize &size ) vol.fill( backgroundColor() ); { // vol ( bg-alpha ) - static TQBitmap mask; - mask.resize( vol.size() ); - mask.fill( Qt::white ); + static TQBitmap tqmask; + tqmask.resize( vol.size() ); + tqmask.fill( TQt::white ); - TQPainter p( &mask ); - p.setBrush( Qt::black ); + TQPainter p( &tqmask ); + p.setBrush( TQt::black ); p.drawRoundRect ( 1, 1, rect.width()-2, rect.height() + fontMetrics().height() / 4 - 2, M * 300 / vol.width(), 99 ); - p.setBrush( Qt::white ); + p.setBrush( TQt::white ); p.drawRoundRect ( 3, 3, vol.width() - 6, vol.height() - 6, M * 300 / vol.width(), 99 ); p.end(); - vol.setMask( mask ); + vol.setMask( tqmask ); } buf.fill( backgroundColor().dark() ); @@ -468,13 +468,13 @@ OSDWidget::render( const uint M, const TQSize &size ) if( m_drawShadow ) { TQPixmap pixmap( rect.size() + TQSize(10,10) ); - pixmap.fill( Qt::black ); + pixmap.fill( TQt::black ); pixmap.setMask( pixmap.createHeuristicMask( true ) ); TQPainter p2( &pixmap ); p2.setFont( font() ); - p2.setPen( Qt::white ); - p2.setBrush( Qt::white ); + p2.setPen( TQt::white ); + p2.setBrush( TQt::white ); p2.drawText( TQRect(TQPoint(5,5), rect.size()), align , m_text ); p2.end(); @@ -513,7 +513,7 @@ OSDWidget::mousePressEvent( TQMouseEvent* ) void OSDWidget::unsetColors() { - const TQColorGroup c = TQApplication::palette().active(); + const TQColorGroup c = TQApplication::tqpalette().active(); setPaletteForegroundColor( c.highlightedText() ); setPaletteBackgroundColor( c.highlight() ); @@ -544,8 +544,8 @@ namespace Amarok TQImage icon() { return TQImage( KIconLoader().iconPath( "amarok", -KIcon::SizeHuge ) ); } } -OSDPreviewWidget::OSDPreviewWidget( TQWidget *parent ) - : OSDWidget( parent, "osdpreview" ) +OSDPreviewWidget::OSDPreviewWidget( TQWidget *tqparent ) + : OSDWidget( tqparent, "osdpreview" ) , m_dragging( false ) { m_text = i18n( "OSD Preview - drag to reposition" ); @@ -557,7 +557,7 @@ void OSDPreviewWidget::mousePressEvent( TQMouseEvent *event ) { m_dragOffset = event->pos(); - if( event->button() == LeftButton && !m_dragging ) { + if( event->button() == Qt::LeftButton && !m_dragging ) { grabMouse( KCursor::sizeAllCursor() ); m_dragging = true; } @@ -603,11 +603,11 @@ void OSDPreviewWidget::mouseMoveEvent( TQMouseEvent *e ) if( destination.y() > maxY ) destination.ry() = maxY; if( eGlobalPosX < (hcenter-snapZone) ) { - m_alignment = Left; + m_tqalignment = Left; destination.rx() = MARGIN; } else if( eGlobalPosX > (hcenter+snapZone) ) { - m_alignment = Right; + m_tqalignment = Right; destination.rx() = screen.width() - MARGIN - width(); } else { @@ -618,10 +618,10 @@ void OSDPreviewWidget::mouseMoveEvent( TQMouseEvent *e ) if( eGlobalPosY >= (vcenter-snapZone) && eGlobalPosY <= (vcenter+snapZone) ) { - m_alignment = Center; + m_tqalignment = Center; destination.ry() = vcenter - height()/2; } - else m_alignment = Middle; + else m_tqalignment = Middle; } destination += screen.topLeft(); @@ -649,7 +649,7 @@ Amarok::OSD::OSD(): OSDWidget( 0 ) void Amarok::OSD::show( const MetaBundle &bundle ) //slot { -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 TQString text = ""; if( bundle.url().isEmpty() ) text = i18n( "No track playing" ); @@ -662,13 +662,13 @@ Amarok::OSD::show( const MetaBundle &bundle ) //slot tags.append(bundle.prettyText( i )); if( bundle.length() <= 0 ) - tags[PlaylistItem::Length+1] = TQString::null; + tags[PlaylistItem::Length+1] = TQString(); if( AmarokConfig::osdUsePlaylistColumns() ) { TQString tag; TQValueVector<int> availableTags; //eg, ones that aren't empty - static const TQValueList<int> parens = //display these in parentheses + static const TQValueList<int> parens = //display these in tqparentheses TQValueList<int>() << PlaylistItem::PlayCount << PlaylistItem::Year << PlaylistItem::Comment << PlaylistItem::Genre << PlaylistItem::Length << PlaylistItem::Bitrate << PlaylistItem::LastPlayed << PlaylistItem::Score << PlaylistItem::Filesize; @@ -690,10 +690,10 @@ Amarok::OSD::show( const MetaBundle &bundle ) //slot const int column = availableTags.at( i ); TQString append = ( i == 0 ) ? "" : ( n > 1 && i == n / 2 ) ? "\n" - : ( parens.contains( column ) || parens.contains( availableTags.at( i - 1 ) ) ) ? " " + : ( parens.tqcontains( column ) || parens.tqcontains( availableTags.at( i - 1 ) ) ) ? " " : i18n(" - "); - append += ( parens.contains( column ) ? "(%1)" : "%1" ); - text += append.arg( tags.at( column + 1 ) ); + append += ( parens.tqcontains( column ) ? "(%1)" : "%1" ); + text += append.tqarg( tags.at( column + 1 ) ); } } else @@ -704,7 +704,7 @@ Amarok::OSD::show( const MetaBundle &bundle ) //slot args[bundle.exactColumnName( i ).lower()] = bundle.prettyText( i ); if( bundle.length() <= 0 ) - args["length"] = TQString::null; + args["length"] = TQString(); uint time=EngineController::instance()->engine()->position(); @@ -725,37 +725,37 @@ Amarok::OSD::show( const MetaBundle &bundle ) //slot timeformat +="0"; timeformat +=TQString::number(sec); args["elapsed"]=timeformat; - QStringx osd = AmarokConfig::osdText(); + TQStringx osd = AmarokConfig::osdText(); // hacky, but works... - if( osd.contains( "%rating" ) ) + if( osd.tqcontains( "%rating" ) ) OSDWidget::setRating( AmarokConfig::useRatings() ? bundle.rating() : 0 ); else OSDWidget::setRating( 0 ); - osd.replace( "%rating", "" ); + osd.tqreplace( "%rating", "" ); - if( osd.contains( "%moodbar" ) && AmarokConfig::showMoodbar() ) + if( osd.tqcontains( "%moodbar" ) && AmarokConfig::showMoodbar() ) OSDWidget::setMoodbar( bundle ); - osd.replace( "%moodbar", "" ); + osd.tqreplace( "%moodbar", "" ); text = osd.namedOptArgs( args ); // KDE 3.3 rejects \n in the .kcfg file, and KConfig turns \n into \\n, so... - text.replace( "\\n", "\n" ); + text.tqreplace( "\\n", "\n" ); } if ( AmarokConfig::osdCover() ) { //avoid showing the generic cover. we can overwrite this by passing an arg. //get large cover for scaling if big cover needed - TQString location = TQString::null; + TQString location = TQString(); if( bundle.podcastBundle() ) location = CollectionDB::instance()->podcastImage( bundle, false, 0 ); else location = CollectionDB::instance()->albumImage( bundle, false, 0 ); - if ( location.find( "nocover" ) != -1 ) + if ( location.tqfind( "nocover" ) != -1 ) setImage( Amarok::icon() ); else setImage( location ); @@ -782,9 +782,9 @@ Amarok::OSD::show( const MetaBundle &bundle ) //slot void Amarok::OSD::applySettings() { - setAlignment( static_cast<OSDWidget::Alignment>( AmarokConfig::osdAlignment() ) ); + tqsetAlignment( static_cast<OSDWidget::Alignment>( AmarokConfig::osdAlignment() ) ); setDuration( AmarokConfig::osdDuration() ); -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 setEnabled( AmarokConfig::osdEnabled() ); #else setEnabled( false ); @@ -806,7 +806,7 @@ Amarok::OSD::applySettings() void Amarok::OSD::forceToggleOSD() { -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 if ( !isShown() ) { const bool b = isEnabled(); setEnabled( true ); @@ -826,7 +826,7 @@ Amarok::OSD::slotCoverChanged( const TQString &artist, const TQString &album ) { TQString location = CollectionDB::instance()->albumImage( artist, album, false, 0 ); - if( location.find( "nocover" ) != -1 ) + if( location.tqfind( "nocover" ) != -1 ) setImage( Amarok::icon() ); else setImage( location ); @@ -841,7 +841,7 @@ Amarok::OSD::slotImageChanged( const TQString &remoteURL ) if( CollectionDB::instance()->getPodcastEpisodeBundle( url, &peb ) ) { PodcastChannelBundle pcb; - if( CollectionDB::instance()->getPodcastChannelBundle( peb.parent().url(), &pcb ) ) + if( CollectionDB::instance()->getPodcastChannelBundle( peb.tqparent().url(), &pcb ) ) { if( pcb.imageURL().url() == remoteURL ) { @@ -918,7 +918,7 @@ namespace ShadowEngine { alphaShadow = (int) decay( img, i, j ); - result.setPixel( i,j, qRgba( bgr, bgg , bgb, QMIN( MAX_OPACITY, alphaShadow ) ) ); + result.setPixel( i,j, tqRgba( bgr, bgg , bgb, TQMIN( MAX_OPACITY, alphaShadow ) ) ); } } @@ -931,15 +931,15 @@ namespace ShadowEngine // return 0; double alphaShadow; - alphaShadow =(qGray(source.pixel(i-1,j-1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i-1,j )) * AXIS_FACTOR + - qGray(source.pixel(i-1,j+1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i ,j-1)) * AXIS_FACTOR + + alphaShadow =(tqGray(source.pixel(i-1,j-1)) * DIAGONAL_FACTOR + + tqGray(source.pixel(i-1,j )) * AXIS_FACTOR + + tqGray(source.pixel(i-1,j+1)) * DIAGONAL_FACTOR + + tqGray(source.pixel(i ,j-1)) * AXIS_FACTOR + 0 + - qGray(source.pixel(i ,j+1)) * AXIS_FACTOR + - qGray(source.pixel(i+1,j-1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i+1,j )) * AXIS_FACTOR + - qGray(source.pixel(i+1,j+1)) * DIAGONAL_FACTOR) / MULTIPLICATION_FACTOR; + tqGray(source.pixel(i ,j+1)) * AXIS_FACTOR + + tqGray(source.pixel(i+1,j-1)) * DIAGONAL_FACTOR + + tqGray(source.pixel(i+1,j )) * AXIS_FACTOR + + tqGray(source.pixel(i+1,j+1)) * DIAGONAL_FACTOR) / MULTIPLICATION_FACTOR; return alphaShadow; } |