diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 723730dc8..f5577de71 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -391,7 +391,8 @@ IF( APPLE ) SET( libSources ${libSources} utils/TomahawkUtils_Mac.mm mac/FileHelpers.mm - thirdparty/Qocoa/qsearchfield_mac.mm ) + thirdparty/Qocoa/qsearchfield_mac.mm + widgets/SourceTreePopupDialog_mac.mm ) SET_SOURCE_FILES_PROPERTIES(utils/TomahawkUtils_Mac.mm PROPERTIES COMPILE_FLAGS "-fvisibility=default") diff --git a/src/libtomahawk/widgets/SourceTreePopupDialog.cpp b/src/libtomahawk/widgets/SourceTreePopupDialog.cpp index cabdc73a7..062171a72 100644 --- a/src/libtomahawk/widgets/SourceTreePopupDialog.cpp +++ b/src/libtomahawk/widgets/SourceTreePopupDialog.cpp @@ -28,6 +28,10 @@ #include #include +#ifdef QT_MAC_USE_COCOA +#include "SourceTreePopupDialog_mac.h" +#endif + SourceTreePopupDialog::SourceTreePopupDialog( SourceTreeView* parent ) : QWidget( 0 ) , m_result( false ) @@ -127,6 +131,13 @@ SourceTreePopupDialog::paintEvent( QPaintEvent* event ) p.drawPath( outline ); p.fillPath( outline, QColor( "#D6E3F1" ) ); + +#ifdef QT_MAC_USE_COCOA + // Work around bug in Qt/Mac Cocoa where opening subsequent popups + // would incorrectly calculate the background due to it not being + // invalidated. + SourceTreePopupHelper::clearBackground( this ); +#endif } diff --git a/src/libtomahawk/widgets/SourceTreePopupDialog_mac.h b/src/libtomahawk/widgets/SourceTreePopupDialog_mac.h new file mode 100644 index 000000000..86649cbb5 --- /dev/null +++ b/src/libtomahawk/widgets/SourceTreePopupDialog_mac.h @@ -0,0 +1,29 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2012 Leo Franchi + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef SOURCETREE_POPUP_DIALOG_MAC_H +#define SOURCETREE_POPUP_DIALOG_MAC_H + +class QWidget; + +namespace SourceTreePopupHelper { + +void clearBackground( QWidget* widget ); + +} +#endif diff --git a/src/libtomahawk/widgets/SourceTreePopupDialog_mac.mm b/src/libtomahawk/widgets/SourceTreePopupDialog_mac.mm new file mode 100644 index 000000000..8ae495eaf --- /dev/null +++ b/src/libtomahawk/widgets/SourceTreePopupDialog_mac.mm @@ -0,0 +1,35 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2012 Leo Franchi + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "SourceTreePopupDialog_mac.h" + +#include + +#import +#import +#import + +void +SourceTreePopupHelper::clearBackground( QWidget* widget ) +{ + Q_ASSERT( widget ); + // Workaround from QTBUG-15368 + NSView* view = reinterpret_cast< NSView* >( widget->winId() ); + NSWindow* cocoaWindow = [view window]; + [cocoaWindow invalidateShadow]; +}