summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-14 21:39:35 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-14 21:39:35 +0000
commit6963d8ef73192b78503631587366a0110dddd161 (patch)
tree99a9b8458cf19320c9c8ebf8a54eb4c6e0fe1061
parent394f15165b9f431697a537b0a68a77eab4582f1c (diff)
downloadamarok-6963d8ef73192b78503631587366a0110dddd161.tar.gz
amarok-6963d8ef73192b78503631587366a0110dddd161.zip
Allow the Amarok OSD to use true transparency if it is available
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1247185 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r--amarok/src/Options5.ui1
-rw-r--r--amarok/src/Options5.ui.h41
-rw-r--r--amarok/src/app.cpp4
-rw-r--r--amarok/src/osd.cpp49
-rw-r--r--amarok/src/osd.h4
5 files changed, 77 insertions, 22 deletions
diff --git a/amarok/src/Options5.ui b/amarok/src/Options5.ui
index c5782df5..d0c7b32a 100644
--- a/amarok/src/Options5.ui
+++ b/amarok/src/Options5.ui
@@ -517,6 +517,7 @@
<Q_SLOTS>
<slot access="protected">slotPositionChanged()</slot>
<slot access="protected">useCustomColorsToggled( bool on )</slot>
+ <slot access="protected">useFakeTransparencyToggled( bool on )</slot>
</Q_SLOTS>
<functions>
<function access="private" specifier="non virtual">init()</function>
diff --git a/amarok/src/Options5.ui.h b/amarok/src/Options5.ui.h
index b24517f9..a9d5c050 100644
--- a/amarok/src/Options5.ui.h
+++ b/amarok/src/Options5.ui.h
@@ -25,6 +25,7 @@ email : [email protected]
#include "amarokconfig.h"
#include <klocale.h>
+#include <kapplication.h>
#include "qstringx.h"
#include <tqtooltip.h>
@@ -41,20 +42,22 @@ void Options5::init()
for( int i = 0; i < numScreens; i++ )
kcfg_OsdScreen->insertItem( TQString::number( i ) );
- connect( kcfg_OsdDrawShadow, TQT_SIGNAL( toggled(bool) ),
- m_pOSDPreview, TQT_SLOT( setDrawShadow(bool) ) );
- connect( kcfg_OsdTextColor, TQT_SIGNAL( changed(const TQColor&) ),
- m_pOSDPreview, TQT_SLOT( setTextColor(const TQColor&) ) );
- connect( kcfg_OsdUseCustomColors, TQT_SIGNAL( toggled(bool) ),
- this, TQT_SLOT( useCustomColorsToggled(bool) ) );
- connect( kcfg_OsdBackgroundColor, TQT_SIGNAL( changed(const TQColor&) ),
- m_pOSDPreview, TQT_SLOT( setBackgroundColor(const TQColor&) ) );
- connect( kcfg_OsdFont, TQT_SIGNAL( fontSelected(const TQFont&) ),
- m_pOSDPreview, TQT_SLOT( setFont(const TQFont&) ) );
- connect( kcfg_OsdScreen, TQT_SIGNAL( activated(int) ),
- m_pOSDPreview, TQT_SLOT( setScreen(int) ) );
- connect( kcfg_OsdEnabled, TQT_SIGNAL( toggled(bool) ),
- m_pOSDPreview, TQT_SLOT( setShown(bool) ) );
+ connect( kcfg_OsdDrawShadow, TQT_SIGNAL( toggled(bool) ),
+ m_pOSDPreview, TQT_SLOT( setDrawShadow(bool) ) );
+ connect( kcfg_OsdTextColor, TQT_SIGNAL( changed(const TQColor&) ),
+ m_pOSDPreview, TQT_SLOT( setTextColor(const TQColor&) ) );
+ connect( kcfg_OsdUseCustomColors, TQT_SIGNAL( toggled(bool) ),
+ this, TQT_SLOT( useCustomColorsToggled(bool) ) );
+ connect( kcfg_OsdUseFakeTranslucency, TQT_SIGNAL( toggled(bool) ),
+ this, TQT_SLOT( useFakeTransparencyToggled(bool) ) );
+ connect( kcfg_OsdBackgroundColor, TQT_SIGNAL( changed(const TQColor&) ),
+ m_pOSDPreview, TQT_SLOT( setBackgroundColor(const TQColor&) ) );
+ connect( kcfg_OsdFont, TQT_SIGNAL( fontSelected(const TQFont&) ),
+ m_pOSDPreview, TQT_SLOT( setFont(const TQFont&) ) );
+ connect( kcfg_OsdScreen, TQT_SIGNAL( activated(int) ),
+ m_pOSDPreview, TQT_SLOT( setScreen(int) ) );
+ connect( kcfg_OsdEnabled, TQT_SIGNAL( toggled(bool) ),
+ m_pOSDPreview, TQT_SLOT( setShown(bool) ) );
Amarok::QStringx text = i18n(
"<h3>Tags Displayed in OSD</h3>"
@@ -113,6 +116,7 @@ void
Options5::showEvent( TQShowEvent* )
{
useCustomColorsToggled( kcfg_OsdUseCustomColors->isChecked() );
+ useFakeTransparencyToggled( kcfg_OsdUseFakeTranslucency->isChecked() );
m_pOSDPreview->setFont( kcfg_OsdFont->font() );
m_pOSDPreview->setScreen( kcfg_OsdScreen->currentItem() );
@@ -124,3 +128,12 @@ Options5::useCustomColorsToggled( bool on )
{
m_pOSDPreview->setUseCustomColors( on, kcfg_OsdTextColor->color(), kcfg_OsdBackgroundColor->color() );
}
+
+void
+Options5::useFakeTransparencyToggled( bool on )
+{
+ if (kapp->isX11CompositionAvailable())
+ m_pOSDPreview->setTranslucency( on );
+ else
+ m_pOSDPreview->setTranslucency( false );
+} \ No newline at end of file
diff --git a/amarok/src/app.cpp b/amarok/src/app.cpp
index a517ac34..ee726662 100644
--- a/amarok/src/app.cpp
+++ b/amarok/src/app.cpp
@@ -120,12 +120,12 @@ appleEventProcessor(const AppleEvent *ae, AppleEvent *, long /*handlerRefCon*/)
LIBAMAROK_EXPORT KAboutData aboutData( "amarok",
I18N_NOOP( "Amarok" ), APP_VERSION,
I18N_NOOP( "The audio player for KDE" ), KAboutData::License_GPL,
- I18N_NOOP( "(C) 2002-2003, Mark Kretschmann\n(C) 2003-2007, The Amarok Development Squad" ),
+ I18N_NOOP( "(C) 2002-2003, Mark Kretschmann\n(C) 2003-2007, The Amarok Development Squad\n(C) 2007-2011, The Trinity Desktop Project" ),
I18N_NOOP( "IRC:\nirc.freenode.net - #amarok, #amarok.de, #amarok.es\n\nFeedback:\[email protected]\n\n(Build Date: " __DATE__ ")" ),
( "http://amarok.kde.org" ) );
App::App()
- : KApplication()
+ : KApplication(KApplication::openX11RGBADisplay())
, m_pPlayerWindow( 0 ) //will be created in applySettings()
{
DEBUG_BLOCK
diff --git a/amarok/src/osd.cpp b/amarok/src/osd.cpp
index cc475524..a9c2f517 100644
--- a/amarok/src/osd.cpp
+++ b/amarok/src/osd.cpp
@@ -139,7 +139,7 @@ OSDWidget::show() //virtual
newGeometry.width(), newGeometry.height() ));
- else if( m_translucency )
+ else if (( m_translucency ) && (!kapp->isX11CompositionAvailable()))
{
const TQRect unite = oldGeometry.unite( newGeometry );
KPixmap pix = TQPixmap(TQPixmap::grabWindow( qt_xrootwin(), unite.x(), unite.y(), unite.width(), unite.height() ));
@@ -158,7 +158,7 @@ OSDWidget::show() //virtual
render( M, newGeometry.size() );
setGeometry( newGeometry );
TQWidget::show();
- bitBlt( this, 0, 0, &m_buffer );
+ paintMe();
if( m_duration ) //duration 0 -> stay forever
m_timer->start( m_duration, true ); //calls hide()
@@ -308,7 +308,7 @@ OSDWidget::render( const uint M, const TQSize &size )
m_buffer.resize( rect.size() );
TQPainter p( &m_buffer );
- if( m_translucency )
+ if (( m_translucency ) && (!kapp->isX11CompositionAvailable()))
{
KPixmap background( m_screenshot );
KPixmapEffect::fade( background, 0.80, backgroundColor() );
@@ -386,7 +386,7 @@ OSDWidget::render( const uint M, const TQSize &size )
pixmapGradient.setMask( mask );
}
- if( m_translucency )
+ if (( m_translucency ) && (!kapp->isX11CompositionAvailable()))
{
KPixmap background( m_screenshot );
KPixmapEffect::fade( background, 0.80, backgroundColor() );
@@ -487,6 +487,45 @@ OSDWidget::render( const uint M, const TQSize &size )
p.end();
}
+void
+OSDWidget::paintMe()
+{
+ if ((m_translucency) && (kapp->isX11CompositionAvailable())) {
+ // We have true composition support, so make the OSD truly transparent
+ TQImage blendedImage = m_buffer.convertToImage();
+ blendedImage = blendedImage.convertDepth(32);
+ blendedImage.setAlphaBuffer(true);
+
+ int w = blendedImage.width();
+ int h = blendedImage.height();
+
+ for (int y = 0; y < h; ++y) {
+ TQRgb *ls = (TQRgb *)blendedImage.scanLine( y );
+ for (int x = 0; x < w; ++x) {
+ TQRgb l = ls[x];
+ //int desired_alpha = 127;
+ int desired_alpha = 204;
+ float alpha_adjust = (desired_alpha/256.0);
+ int r = int( tqRed( l ) * alpha_adjust );
+ int g = int( tqGreen( l ) * alpha_adjust );
+ int b = int( tqBlue( l ) * alpha_adjust );
+ int a = int( desired_alpha );
+ ls[x] = tqRgba( r, g, b, a );
+ }
+ }
+
+ // Finally, paint it
+ TQPainter p1;
+ p1.begin( this );
+ blendedImage.setAlphaBuffer(false);
+ p1.drawImage( 0, 0, blendedImage );
+ p1.end();
+ }
+ else {
+ bitBlt( this, 0, 0, &m_buffer );
+ }
+}
+
bool
OSDWidget::event( TQEvent *e )
{
@@ -497,7 +536,7 @@ OSDWidget::event( TQEvent *e )
unsetColors(); //use new palette's colours
return true;
case TQEvent::Paint:
- bitBlt( this, 0, 0, &m_buffer );
+ paintMe();
return true;
default:
return TQWidget::event( e );
diff --git a/amarok/src/osd.h b/amarok/src/osd.h
index cfa5cf70..625145d3 100644
--- a/amarok/src/osd.h
+++ b/amarok/src/osd.h
@@ -26,7 +26,7 @@
class OSDWidget : public TQWidget
{
Q_OBJECT
- TQ_OBJECT
+ TQ_OBJECT
public:
enum Alignment { Left, Middle, Center, Right };
@@ -81,6 +81,8 @@ class OSDWidget : public TQWidget
bool useMoodbar( void );
+ void paintMe();
+
/** distance from screen edge */
static const int MARGIN = 15;