From f3d3f19ef8959afae6f4a85136581ac315d696a6 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 12 Jul 2012 08:35:29 +0200 Subject: [PATCH] * Provide convenience openUrl( url ) method in TomahawkUtilsGui, since QDesktopServices fail to work on Windows. --- src/libtomahawk/utils/TomahawkUtilsGui.cpp | 17 +++++++++++++++-- src/libtomahawk/utils/TomahawkUtilsGui.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp index 4dfef653b..e867cc4c1 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp +++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef Q_WS_X11 #include @@ -43,6 +44,7 @@ #ifdef Q_WS_WIN #include #include + #include #endif @@ -134,7 +136,7 @@ drawShadowText( QPainter* painter, const QRect& rect, const QString& text, const painter->save(); painter->drawText( rect, text, textOption ); - + /* QFont font = painter->font(); font.setPixelSize( font.pixelSize() + 2 ); painter->setFont( font ); @@ -182,7 +184,7 @@ drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& f painter->setPen( origpen ); painter->setPen( Qt::white ); painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, QTextOption( Qt::AlignCenter ) ); - + painter->restore(); } @@ -293,6 +295,17 @@ bringToFront() #endif +void +openUrl( const QUrl& url ) +{ +#ifdef Q_OS_WIN + ShellExecuteW( 0, 0, (TCHAR*)url.toString().utf16(), 0, 0, SW_SHOWNORMAL ); +#else + QDesktopServices::openUrl( url ); +#endif +} + + QPixmap createAvatarFrame( const QPixmap &avatar ) { diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.h b/src/libtomahawk/utils/TomahawkUtilsGui.h index 6e8f7d8bf..71e764074 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.h +++ b/src/libtomahawk/utils/TomahawkUtilsGui.h @@ -45,6 +45,8 @@ namespace TomahawkUtils /// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us DLLEXPORT void bringToFront(); + DLLEXPORT void openUrl( const QUrl& url ); + DLLEXPORT QPixmap createAvatarFrame( const QPixmap &avatar ); DLLEXPORT QColor alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity );