From 2020aad72572af765a73ffe243b6bba44d7a1170 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 15 Jan 2016 03:59:51 +0100 Subject: [PATCH 01/11] Download and branding improvements --- src/accounts/hatchet/CMakeLists.txt | 7 - src/libtomahawk/CMakeLists.txt | 2 +- src/libtomahawk/accounts/ResolverAccount.cpp | 118 ++++++----- src/libtomahawk/accounts/ResolverAccount.h | 7 +- src/libtomahawk/playlist/ContextView.cpp | 4 +- src/libtomahawk/playlist/GridItemDelegate.cpp | 197 +++++++++++++++++- src/libtomahawk/playlist/GridItemDelegate.h | 12 ++ src/libtomahawk/playlist/PlayableModel.cpp | 6 +- .../playlist/PlaylistItemDelegate.cpp | 145 +++++++++++-- .../playlist/PlaylistItemDelegate.h | 3 + src/libtomahawk/playlist/TrackDetailView.cpp | 99 ++++++++- src/libtomahawk/playlist/TrackDetailView.h | 12 ++ src/libtomahawk/playlist/TrackView.cpp | 47 +++++ src/libtomahawk/playlist/TrackView.h | 1 + src/libtomahawk/resolvers/ScriptEngine.cpp | 2 +- src/libtomahawk/utils/PluginLoader.cpp | 11 +- src/libtomahawk/utils/TomahawkStyle.cpp | 10 +- src/libtomahawk/utils/TomahawkStyle.h | 1 + src/libtomahawk/viewpages/AlbumViewPage.cpp | 4 +- src/libtomahawk/viewpages/ArtistViewPage.cpp | 1 + .../viewpages/CollectionViewPage.cpp | 59 +++++- .../viewpages/CollectionViewPage.h | 4 + src/libtomahawk/viewpages/SearchViewPage.cpp | 1 + src/libtomahawk/widgets/BasicHeader.cpp | 8 +- src/libtomahawk/widgets/BasicHeader.h | 3 +- src/libtomahawk/widgets/DropDownButton.cpp | 56 +++-- src/libtomahawk/widgets/DropDownButton.h | 2 +- src/tomahawk/CMakeLists.osx.cmake | 2 - src/tomahawk/CMakeLists.txt | 16 +- src/tomahawk/TomahawkApp.cpp | 6 +- src/tomahawk/TomahawkTrayIcon.cpp | 8 +- src/tomahawk/TomahawkWindow.cpp | 8 +- src/tomahawk/TomahawkWindow.ui | 2 +- src/tomahawk/dialogs/DiagnosticsDialog.cpp | 2 +- src/tomahawk/dialogs/DiagnosticsDialog.ui | 2 +- src/tomahawk/dialogs/SettingsDialog.cpp | 14 +- src/tomahawk/dialogs/Settings_Advanced.ui | 6 +- src/tomahawk/dialogs/Settings_Collection.ui | 2 +- src/tomahawk/mac/TomahawkApp_Mac.mm | 2 +- src/tomahawk/main.cpp | 3 +- src/tools/database-reader/CMakeLists.txt | 33 +-- .../tomahawk-test-musicscan/CMakeLists.txt | 14 +- src/viewpages/charts/CMakeLists.txt | 2 +- src/viewpages/dashboard/CMakeLists.txt | 2 +- src/viewpages/newreleases/CMakeLists.txt | 2 +- src/viewpages/whatsnew_0_8/CMakeLists.txt | 2 +- 46 files changed, 749 insertions(+), 201 deletions(-) diff --git a/src/accounts/hatchet/CMakeLists.txt b/src/accounts/hatchet/CMakeLists.txt index 86ebee449..5e74cabf1 100644 --- a/src/accounts/hatchet/CMakeLists.txt +++ b/src/accounts/hatchet/CMakeLists.txt @@ -24,13 +24,6 @@ include_directories( add_definitions(-D_WEBSOCKETPP_CPP11_STL_) -if(APPLE) - # http://stackoverflow.com/questions/7226753/osx-lion-xcode-4-1-how-do-i-setup-a-c0x-project/7236451#7236451 - add_definitions(-std=c++11 -stdlib=libc++ -U__STRICT_ANSI__) - set(PLATFORM_SPECIFIC_LINK_LIBRARIES "/usr/lib/libc++.dylib") -else() - add_definitions(-std=c++0x) -endif() tomahawk_add_plugin(hatchet TYPE account diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index f13891fe2..62314247e 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -418,7 +418,7 @@ include_directories( ${Boost_INCLUDE_DIR} ${LIBPORTFWD_INCLUDE_DIR} - ${QUAZIP_INCLUDE_DIR} + ${QUAZIP_INCLUDE_DIRS} ${QTKEYCHAIN_INCLUDE_DIRS} ) diff --git a/src/libtomahawk/accounts/ResolverAccount.cpp b/src/libtomahawk/accounts/ResolverAccount.cpp index 36835276f..00e56bb74 100644 --- a/src/libtomahawk/accounts/ResolverAccount.cpp +++ b/src/libtomahawk/accounts/ResolverAccount.cpp @@ -79,7 +79,7 @@ ResolverAccountFactory::createFromPath( const QString& path ) } -Account* +ResolverAccount* ResolverAccountFactory::createFromPath( const QString& path, const QString& factory, bool isAttica ) { qDebug() << "Creating ResolverAccount from path:" << path << "is attica" << isAttica; @@ -110,57 +110,8 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact if ( pathInfo.suffix() == "axe" ) { - QString uniqueName = uuid(); - QDir dir( TomahawkUtils::extractScriptPayload( pathInfo.filePath(), - uniqueName, - MANUALRESOLVERS_DIR ) ); - if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar + if ( !installAxe( realPath, configuration ) ) { - displayError( tr( "Resolver installation error: cannot open bundle." ) ); - return 0; - } - - if ( !dir.cd( "content" ) ) //more fubar - { - displayError( tr( "Resolver installation error: incomplete bundle." ) ); - return 0; - } - - QString metadataFilePath = dir.absoluteFilePath( "metadata.json" ); - configuration = metadataFromJsonFile( metadataFilePath ); - - configuration[ "bundleDir" ] = uniqueName; - - if ( !configuration[ "pluginName" ].isNull() && !configuration[ "pluginName" ].toString().isEmpty() ) - { - dir.cdUp(); - if ( !dir.cdUp() ) //we're in MANUALRESOLVERS_DIR - return 0; - - QString name = configuration[ "pluginName" ].toString(); - - QString namePath = dir.absoluteFilePath( name ); - QFileInfo npI( namePath ); - - if ( npI.exists() && npI.isDir() ) - { - TomahawkUtils::removeDirectory( namePath ); - } - - dir.rename( uniqueName, name ); - - configuration[ "bundleDir" ] = name; - - if ( !dir.cd( QString( "%1/content" ).arg( name ) ) ) //should work if it worked once - return 0; - } - - expandPaths( dir, configuration ); - - realPath = configuration[ "path" ].toString(); - if ( realPath.isEmpty() ) - { - displayError( tr( "Resolver installation error: bad metadata in bundle." ) ); return 0; } } @@ -221,6 +172,71 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact } +bool +ResolverAccountFactory::installAxe( QString& realPath, QVariantHash& configuration ) +{ + const QFileInfo pathInfo( realPath ); + QString uniqueName = uuid(); + QDir dir( TomahawkUtils::extractScriptPayload( pathInfo.filePath(), + uniqueName, + MANUALRESOLVERS_DIR ) ); + if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar + { + JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( + tr( "Resolver installation error: cannot open bundle." ) ) ); + return 0; + } + + if ( !dir.cd( "content" ) ) //more fubar + { + JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( + tr( "Resolver installation error: incomplete bundle." ) ) ); + return 0; + } + + QString metadataFilePath = dir.absoluteFilePath( "metadata.json" ); + configuration = metadataFromJsonFile( metadataFilePath ); + + configuration[ "bundleDir" ] = uniqueName; + + if ( !configuration[ "pluginName" ].isNull() && !configuration[ "pluginName" ].toString().isEmpty() ) + { + dir.cdUp(); + if ( !dir.cdUp() ) //we're in MANUALRESOLVERS_DIR + return 0; + + QString name = configuration[ "pluginName" ].toString(); + + QString namePath = dir.absoluteFilePath( name ); + QFileInfo npI( namePath ); + + if ( npI.exists() && npI.isDir() ) + { + TomahawkUtils::removeDirectory( namePath ); + } + + dir.rename( uniqueName, name ); + + configuration[ "bundleDir" ] = name; + + if ( !dir.cd( QString( "%1/content" ).arg( name ) ) ) //should work if it worked once + return 0; + } + + expandPaths( dir, configuration ); + + realPath = configuration[ "path" ].toString(); + if ( realPath.isEmpty() ) + { + JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( + tr( "Resolver installation error: bad metadata in bundle." ) ) ); + return 0; + } + + return true; +} + + QVariantHash ResolverAccountFactory::metadataFromJsonFile( const QString& path ) { diff --git a/src/libtomahawk/accounts/ResolverAccount.h b/src/libtomahawk/accounts/ResolverAccount.h index 433e726ec..d57d4c6ce 100644 --- a/src/libtomahawk/accounts/ResolverAccount.h +++ b/src/libtomahawk/accounts/ResolverAccount.h @@ -33,6 +33,8 @@ class ExternalResolverGui; namespace Accounts { +class ResolverAccount; + class DLLEXPORT ResolverAccountFactory : public AccountFactory { Q_OBJECT @@ -53,7 +55,10 @@ public: Account* createFromPath( const QString& path ) override; // Internal use - static Account* createFromPath( const QString& path, const QString& factoryId, bool isAttica ); + static ResolverAccount* createFromPath( const QString& path, const QString& factoryId, bool isAttica ); + // YES, non const parameters! + static bool installAxe( QString& realPath, QVariantHash& configuration ); + private: static void displayError( const QString& error ); diff --git a/src/libtomahawk/playlist/ContextView.cpp b/src/libtomahawk/playlist/ContextView.cpp index f0f9fce8e..6904683c2 100644 --- a/src/libtomahawk/playlist/ContextView.cpp +++ b/src/libtomahawk/playlist/ContextView.cpp @@ -96,8 +96,10 @@ ContextView::ContextView( QWidget* parent, const QString& caption ) connect( m_captionLabel, SIGNAL( clicked() ), SIGNAL( closeClicked() ) ); connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), SLOT( onQuerySelected( Tomahawk::query_ptr ) ) ); - connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), m_detailView, SLOT( setQuery( Tomahawk::query_ptr ) ) ); connect( m_trackView, SIGNAL( modelChanged() ), SLOT( onModelChanged() ) ); + connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), m_detailView, SLOT( setQuery( Tomahawk::query_ptr ) ) ); + connect( m_detailView, SIGNAL( downloadAll() ), SLOT( onDownloadAll() ) ); + connect( m_detailView, SIGNAL( downloadCancel() ), SLOT( onDownloadCancel() ) ); TomahawkUtils::fixMargins( this ); } diff --git a/src/libtomahawk/playlist/GridItemDelegate.cpp b/src/libtomahawk/playlist/GridItemDelegate.cpp index 8ca97010d..498695f49 100644 --- a/src/libtomahawk/playlist/GridItemDelegate.cpp +++ b/src/libtomahawk/playlist/GridItemDelegate.cpp @@ -20,11 +20,15 @@ #include "GridItemDelegate.h" #include +#include #include #include #include #include +#include "DownloadManager.h" +#include "DownloadJob.h" + #include "Artist.h" #include "Query.h" #include "Result.h" @@ -35,12 +39,14 @@ #include "playlist/PlayableItem.h" #include "playlist/PlayableProxyModel.h" #include "widgets/HoverControls.h" +#include "widgets/DropDownButton.h" #include "widgets/ImageButton.h" #include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" #include "utils/PixmapDelegateFader.h" #include "utils/Closure.h" #include "utils/AnimatedSpinner.h" +#include "utils/WebPopup.h" #include "utils/DpiScaler.h" #include "utils/Logger.h" @@ -55,6 +61,7 @@ GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyMode , m_model( proxy ) , m_itemWidth( 0 ) , m_showPosition( false ) + , m_showBuyButtons( false ) , m_wordWrapping( false ) , m_margin( TomahawkUtils::DpiScaler::scaledY( parent, 32 ) ) { @@ -93,7 +100,8 @@ GridItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelInde if ( !m_wordWrapping ) return QSize( m_itemWidth, m_itemWidth + fm.height() + m_margin * 0.8 ); - return QSize( m_itemWidth, m_itemWidth + fm.height() + fms.height() + m_margin * 0.8 ); + const int buyButtonHeight = m_showBuyButtons ? 40 : 0; + return QSize( m_itemWidth, m_itemWidth + fm.height() + fms.height() + buyButtonHeight + m_margin * 0.8 ); } } @@ -275,6 +283,11 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, painter->setFont( f ); } + if ( m_showBuyButtons && !item->query().isNull() ) + { + textRect.adjust( 0, 0, 0, -40 ); + } + to.setAlignment( Qt::AlignLeft | Qt::AlignTop ); text = painter->fontMetrics().elidedText( top, Qt::ElideRight, textRect.width() - m_margin / 4 ); painter->drawText( textRect, text, to ); @@ -286,6 +299,7 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, } painter->restore(); + painter->save(); painter->setOpacity( 0.6 ); painter->setFont( m_smallFont ); @@ -304,6 +318,48 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, // Calculate rect of artist on-hover button click area m_artistNameRects[ index ] = painter->fontMetrics().boundingRect( textRect, Qt::AlignLeft | Qt::AlignBottom, text ); + painter->restore(); + + if ( m_showBuyButtons && !item->query().isNull() ) + { + QRect r = textRect; + r.setY( textRect.y() + textRect.height() + 8 ); + r.setHeight( 32 ); + m_buyButtonRects[ index ] = r; + + QString text; + if ( item->result() && + ( ( !item->result()->downloadFormats().isEmpty() && !DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ).isEmpty() ) || + ( item->result()->downloadJob() && item->result()->downloadJob()->state() == DownloadJob::Finished ) ) ) + { + text = tr( "View in Finder" ); + } + else if ( item->query() && item->query()->numResults( true ) && !item->query()->results().first()->downloadFormats().isEmpty() ) + { + text = tr( "Download %1" ).arg( item->query()->results().first()->downloadFormats().first().extension.toUpper() ); + } + else if ( item->query()->numResults( true ) && !item->query()->results().first()->purchaseUrl().isEmpty() ) + { + text = tr( "Buy" ); + } + + if ( !item->result() || !item->result()->downloadJob() ) + { + if ( !text.isEmpty() ) + DropDownButton::drawPrimitive( painter, r, text, m_hoveringOverBuyButton == index, false ); + } + else + { + painter->setPen( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND.darker() ); + painter->setBrush( TomahawkStyle::PLAYLIST_PROGRESS_BACKGROUND ); + painter->drawRect( r.adjusted( 2, 2, -2, -2 ) ); + painter->setPen( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND ); + painter->setBrush( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND ); + QRect fillp = r.adjusted( 3, 3, -3, -3 ); + fillp.setWidth( float(fillp.width()) * ( float(item->result()->downloadJob()->progressPercentage()) / 100.0 ) ); + painter->drawRect( fillp ); + } + } } painter->restore(); @@ -362,6 +418,7 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); bool hoveringArtist = false; bool hoveringAlbum = false; + bool hoveringBuyButton = false; if ( m_artistNameRects.contains( index ) ) { const QRect artistNameRect = m_artistNameRects[ index ]; @@ -372,6 +429,11 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q const QRect albumNameRect = m_albumNameRects[ index ]; hoveringAlbum = albumNameRect.contains( ev->pos() ); } + if ( m_buyButtonRects.contains( index ) ) + { + const QRect buyButtonRect = m_buyButtonRects[ index ]; + hoveringBuyButton = buyButtonRect.contains( ev->pos() ); + } QRect coverRect = m_view->visualRect( index ); coverRect.setHeight( coverRect.width() ); @@ -379,7 +441,7 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q if ( event->type() == QEvent::MouseMove ) { - if ( hoveringArtist || hoveringAlbum ) + if ( hoveringArtist || hoveringAlbum || hoveringBuyButton ) m_view->setCursor( Qt::PointingHandCursor ); else m_view->setCursor( Qt::ArrowCursor ); @@ -435,6 +497,17 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q emit updateIndex( index ); } + if ( m_hoveringOverBuyButton != index || ( !hoveringBuyButton && m_hoveringOverBuyButton.isValid() ) ) + { + emit updateIndex( m_hoveringOverBuyButton ); + + if ( hoveringBuyButton ) + m_hoveringOverBuyButton = index; + else + m_hoveringOverBuyButton = QPersistentModelIndex(); + + emit updateIndex( index ); + } if ( m_hoverIndex != index || !hoveringCover ) { @@ -544,6 +617,27 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q } } + if ( hoveringBuyButton ) + { + if ( event->type() == QEvent::MouseButtonRelease ) + { + PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) ); + if ( !item ) + return false; + + if ( item->query() && item->query()->numResults( true ) && !item->query()->results().first()->downloadFormats().isEmpty() ) + { + m_view->edit( index ); + return true; + } + else + { + WebPopup* popup = new WebPopup( item->query()->results().first()->purchaseUrl(), QSize( 400, 800 ) ); + connect( item->query()->results().first().data(), SIGNAL( destroyed() ), popup, SLOT( close() ) ); + } + } + } + return false; } @@ -555,6 +649,7 @@ GridItemDelegate::modelChanged() m_albumNameRects.clear(); m_hoveringOverArtist = QPersistentModelIndex(); m_hoveringOverAlbum = QPersistentModelIndex(); + m_hoveringOverBuyButton = QPersistentModelIndex(); m_hoverIndex = QPersistentModelIndex(); clearButtons(); @@ -687,6 +782,10 @@ GridItemDelegate::resetHoverIndex() idx = m_hoveringOverAlbum; m_hoveringOverAlbum = QPersistentModelIndex(); doUpdateIndex( idx ); + + idx = m_hoveringOverBuyButton; + m_hoveringOverBuyButton = QPersistentModelIndex(); + doUpdateIndex( idx ); } @@ -758,3 +857,97 @@ GridItemDelegate::eventFilter( QObject* obj, QEvent* event ) else return QObject::eventFilter( obj, event ); } + + +QWidget* +GridItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); + Q_ASSERT( item ); + + if ( item->result() && !item->result()->downloadFormats().isEmpty() && + !DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ).isEmpty() ) + { + QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ) ).absolutePath() ) ); + } + else if ( item->result() && item->result()->downloadJob() && item->result()->downloadJob()->state() == DownloadJob::Finished ) + { + QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( item->result()->downloadJob()->localFile() ).absolutePath() ) ); + } + else if ( item->result() && + !item->result()->downloadFormats().isEmpty() && !item->result()->downloadJob() ) + { + QStringList formats; + foreach ( const DownloadFormat& format, item->result()->downloadFormats() ) + { + formats << tr( "Download %1" ).arg( format.extension.toUpper() ); + } + + DropDownButton* editor = new DropDownButton( parent ); + editor->addItems( formats ); + + NewClosure( editor, SIGNAL( clicked() ), + const_cast(this), SLOT( addDownloadJob( const QModelIndex&, QWidget* ) ), index, (QWidget*)editor ); + + NewClosure( editor, SIGNAL( activated( int ) ), + const_cast(this), SLOT( addDownloadJob( const QModelIndex&, QWidget* ) ), index, (QWidget*)editor ); + return editor; + } + + return 0; +} + + +void +GridItemDelegate::addDownloadJob( const QModelIndex& index, QWidget* editor ) +{ + PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); + Q_ASSERT( item ); + + m_view->closePersistentEditor( index ); + + DropDownButton* cb = static_cast< DropDownButton* >(editor); + if ( !item->result()->downloadFormats().isEmpty() ) + DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().at( cb->currentIndex() ) ) ); +} + + +void +GridItemDelegate::closeEditor( const QModelIndex& index, QWidget* editor ) +{ + PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); + Q_ASSERT( item ); + + m_view->closePersistentEditor( index ); + + DropDownButton* cb = static_cast< DropDownButton* >(editor); + editor->deleteLater(); +} + + +void +GridItemDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + QStyledItemDelegate::updateEditorGeometry( editor, option, index ); + + DropDownButton* comboBox = static_cast(editor); + comboBox->resize( option.rect.size() - QSize( 8, 0 ) ); + comboBox->move( option.rect.x() + 4, option.rect.y() ); + + if ( m_downloadDropDownRects.contains( index ) ) + { + editor->setGeometry( m_downloadDropDownRects.value( index ) ); + } + + if ( !comboBox->property( "shownPopup" ).toBool() ) + { + comboBox->showPopup(); + comboBox->setProperty( "shownPopup", true ); + } +} + + +void +GridItemDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const +{ +} diff --git a/src/libtomahawk/playlist/GridItemDelegate.h b/src/libtomahawk/playlist/GridItemDelegate.h index dc4eba050..1f2b49234 100644 --- a/src/libtomahawk/playlist/GridItemDelegate.h +++ b/src/libtomahawk/playlist/GridItemDelegate.h @@ -48,6 +48,7 @@ public: QSize itemSize() const; void setItemWidth( int width ) { m_itemWidth = width; } + void setShowBuyButtons( bool enabled ) { m_showBuyButtons = enabled; } public slots: void resetHoverIndex(); @@ -61,6 +62,10 @@ protected: bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ); bool eventFilter( QObject* obj, QEvent* event ); + QWidget* createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const; + void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const; + void setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const; + signals: void updateIndex( const QModelIndex& idx ); @@ -82,6 +87,9 @@ private slots: void fadingFrameChanged( const QPersistentModelIndex& ); void fadingFrameFinished( const QPersistentModelIndex& ); + void closeEditor( const QModelIndex& index, QWidget* editor ); + void addDownloadJob( const QModelIndex& index, QWidget* editor ); + private: QTimeLine* createTimeline( QTimeLine::Direction direction, int startFrame = 0 ); void clearButtons(); @@ -90,15 +98,19 @@ private: PlayableProxyModel* m_model; int m_itemWidth; bool m_showPosition; + bool m_showBuyButtons; bool m_wordWrapping; mutable QHash< QPersistentModelIndex, QRect > m_artistNameRects; mutable QHash< QPersistentModelIndex, QRect > m_albumNameRects; + mutable QHash< QPersistentModelIndex, QRect > m_buyButtonRects; + mutable QHash< QPersistentModelIndex, QRect > m_downloadDropDownRects; mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_covers; QPersistentModelIndex m_hoverIndex; QPersistentModelIndex m_hoveringOverArtist; QPersistentModelIndex m_hoveringOverAlbum; + QPersistentModelIndex m_hoveringOverBuyButton; mutable QHash< QPersistentModelIndex, QWidget* > m_spinner; mutable QHash< QPersistentModelIndex, HoverControls* > m_hoverControls; diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index df34ddee1..7784ba312 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -1027,7 +1027,7 @@ PlayableModel::appendAlbums( const QList< Tomahawk::album_ptr >& albums ) void PlayableModel::appendAlbums( const Tomahawk::collection_ptr& collection ) { - emit loadingStarted(); + startLoading(); insertAlbums( collection, rowCount( QModelIndex() ) ); } @@ -1042,7 +1042,7 @@ PlayableModel::appendQueries( const QList< Tomahawk::query_ptr >& queries ) void PlayableModel::appendTracks( const QList< Tomahawk::track_ptr >& tracks, const QList< Tomahawk::PlaybackLog >& logs ) { - emit loadingStarted(); + startLoading(); QList< Tomahawk::query_ptr > queries; foreach ( const track_ptr& track, tracks ) { @@ -1056,7 +1056,7 @@ PlayableModel::appendTracks( const QList< Tomahawk::track_ptr >& tracks, const Q void PlayableModel::appendTracks( const Tomahawk::collection_ptr& collection ) { - emit loadingStarted(); + startLoading(); insertTracks( collection, rowCount( QModelIndex() ) ); } diff --git a/src/libtomahawk/playlist/PlaylistItemDelegate.cpp b/src/libtomahawk/playlist/PlaylistItemDelegate.cpp index e29afdfde..d3d7998c4 100644 --- a/src/libtomahawk/playlist/PlaylistItemDelegate.cpp +++ b/src/libtomahawk/playlist/PlaylistItemDelegate.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include "utils/Closure.h" #include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" +#include "utils/WebPopup.h" #include "utils/Logger.h" using namespace Tomahawk; @@ -123,16 +125,16 @@ PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); - if ( index.column() == PlayableModel::Download && item->result() && !item->result()->downloadFormats().isEmpty() && + if ( /*index.column() == PlayableModel::Download &&*/ item->result() && !item->result()->downloadFormats().isEmpty() && !DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ).isEmpty() ) { QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ) ).absolutePath() ) ); } - else if ( index.column() == PlayableModel::Download && item->result() && item->result()->downloadJob() && item->result()->downloadJob()->state() == DownloadJob::Finished ) + else if ( /*index.column() == PlayableModel::Download &&*/ item->result() && item->result()->downloadJob() && item->result()->downloadJob()->state() == DownloadJob::Finished ) { QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( item->result()->downloadJob()->localFile() ).absolutePath() ) ); } - else if ( index.column() == PlayableModel::Download && item->result() && + else if ( /*index.column() == PlayableModel::Download &&*/ item->result() && !item->result()->downloadFormats().isEmpty() && !item->result()->downloadJob() ) { QStringList formats; @@ -192,9 +194,14 @@ PlaylistItemDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionV comboBox->resize( option.rect.size() - QSize( 8, 0 ) ); comboBox->move( option.rect.x() + 4, option.rect.y() ); + if ( m_downloadDropDownRects.contains( index ) ) + { + editor->setGeometry( m_downloadDropDownRects.value( index ) ); + } + if ( !comboBox->property( "shownPopup" ).toBool() ) { -// comboBox->showPopup(); + comboBox->showPopup(); comboBox->setProperty( "shownPopup", true ); } } @@ -291,7 +298,8 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt } else if ( !item->result()->downloadJob() ) { - DropDownButton::drawPrimitive( painter, optc.rect, optc.currentText ); + DropDownButton::drawPrimitive( painter, optc.rect, optc.currentText, hoveringOver() == index, true ); + /* QApplication::style()->drawComplexControl( QStyle::CC_ComboBox, &optc, painter, 0 ); optc.rect.adjust( 4, 0, 0, 0 ); QApplication::style()->drawControl( QStyle::CE_ComboBoxLabel, &optc, painter, 0 );*/ @@ -604,6 +612,7 @@ QRect PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QRect& rect, PlayableItem* item ) const { const track_ptr track = item->query()->track(); + const bool hasOnlineResults = ( item->query()->numResults( true ) > 0 ); painter->save(); painter->setRenderHint( QPainter::TextAntialiasing ); @@ -630,21 +639,87 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem& QRect numberRect = QRect( r.x(), r.y(), numberWidth, r.height() ); QRect extraRect = QRect( r.x() + r.width() - durationWidth, r.y(), durationWidth, r.height() ); - QRect stateRect; - if ( option.state & QStyle::State_Selected || hoveringOver() == index ) + QRect stateRect = extraRect.adjusted( 0, 0, 0, 0 ); + + if ( option.state & QStyle::State_Selected || hoveringOver() == index ) { + int h = extraRect.height() / 3; + if ( track->loved() ) { + painter->save(); painter->setOpacity( 0.5 ); - int h = extraRect.height() / 3; - stateRect = extraRect.adjusted( -16, extraRect.height() / 2 - h / 2, 0, 0 ); - stateRect.setHeight( h ); - stateRect.setWidth( stateRect.height() ); - painter->drawPixmap( stateRect, ImageRegistry::instance()->pixmap( RESPATH "images/love.svg", stateRect.size() ) ); + QRect r = stateRect.adjusted( -16, extraRect.height() / 2 - h / 2, 0, 0 ); + r.setHeight( h ); + r.setWidth( r.height() ); + painter->drawPixmap( r, ImageRegistry::instance()->pixmap( RESPATH "images/love.svg", r.size() ) ); + painter->restore(); - stateWidth = stateRect.width() + 16; + stateWidth += r.width() + 16; + } + + if ( hasOnlineResults && !item->query()->results().first()->purchaseUrl().isEmpty() ) + { + QRect r = stateRect.adjusted( -stateWidth -144, 6, 0, -6 ); + r.setWidth( 144 ); + DropDownButton::drawPrimitive( painter, r, tr( "Buy" ), m_hoveringOverBuyButton == index, false ); + + m_buyButtonRects[ index ] = r; + + stateWidth += r.width() + 16; } } + + if ( hasOnlineResults && !item->query()->results().first()->downloadFormats().isEmpty() ) + { + painter->save(); + QStyleOptionComboBox optc; + optc.rect = stateRect.adjusted( -stateWidth -144, 6, 0, -6 ); + optc.rect.setWidth( 144 ); + m_downloadDropDownRects[ index ] = optc.rect; + stateWidth += optc.rect.width() + 16; + optc.editable = false; + optc.currentText = tr( "Download %1" ).arg( item->query()->results().first()->downloadFormats().first().extension.toUpper() ); + optc.palette = m_view->palette(); + + if ( option.state & QStyle::State_Selected && option.state & QStyle::State_Active ) + optc.state = QStyle::State_Active | QStyle::State_Selected | QStyle::State_Enabled; + else + optc.state = QStyle::State_Active | QStyle::State_Enabled; + + if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + { + painter->setPen( optc.palette.text().color() ); + const QString text = painter->fontMetrics().elidedText( tr( "View in Finder" ), Qt::ElideRight, optc.rect.width() - 3 ); + painter->drawText( optc.rect, text, QTextOption( Qt::AlignCenter ) ); + } + else if ( !item->query()->results().first()->downloadJob() ) + { + DropDownButton::drawPrimitive( painter, optc.rect, optc.currentText, hoveringOver() == index, true ); + } + else + { + if ( item->query()->results().first()->downloadJob()->state() == DownloadJob::Finished ) + { + painter->setPen( optc.palette.text().color() ); + const QString text = painter->fontMetrics().elidedText( tr( "View in Finder" ), Qt::ElideRight, optc.rect.width() - 3 ); + painter->drawText( optc.rect, text, QTextOption( Qt::AlignCenter ) ); + } + else + { + painter->setPen( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND.darker() ); + painter->setBrush( TomahawkStyle::PLAYLIST_PROGRESS_BACKGROUND ); + painter->drawRect( optc.rect.adjusted( 2, 2, -2, -2 ) ); + painter->setPen( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND ); + painter->setBrush( TomahawkStyle::PLAYLIST_PROGRESS_FOREGROUND ); + QRect fillp = optc.rect.adjusted( 3, 3, -3, -3 ); + fillp.setWidth( float(fillp.width()) * ( float(item->query()->results().first()->downloadJob()->progressPercentage()) / 100.0 ) ); + painter->drawRect( fillp ); + } + } + painter->restore(); + } + const int remWidth = r.width() - numberWidth - durationWidth; QRect titleRect = QRect( numberRect.x() + numberRect.width(), r.y(), (double)remWidth * 0.5, r.height() ); @@ -708,6 +783,7 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem& int h = extraRect.height() / 2; QRect playIconRect = extraRect.adjusted( extraRect.width() - h - 8, h / 2, -8, -h / 2 ); + playIconRect.setWidth( playIconRect.height() ); painter->drawPixmap( playIconRect, ImageRegistry::instance()->pixmap( RESPATH "images/play.svg", playIconRect.size() ) ); double duration = (double)AudioEngine::instance()->currentTrackTotalTime(); @@ -759,8 +835,11 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con bool hoveringArtist = false; bool hoveringInfo = false; bool hoveringLove = false; + bool hoveringBuy = false; + bool hoveringDownloadDropDown = false; Tomahawk::source_ptr hoveredAvatar; QRect hoveredAvatarRect; + if ( m_infoButtonRects.contains( index ) ) { const QRect infoRect = m_infoButtonRects[ index ]; @@ -779,6 +858,18 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); hoveringLove = loveRect.contains( ev->pos() ); } + if ( m_buyButtonRects.contains( index ) ) + { + const QRect buyRect = m_buyButtonRects[ index ]; + const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); + hoveringBuy = buyRect.contains( ev->pos() ); + } + if ( m_downloadDropDownRects.contains( index ) ) + { + const QRect downloadDropDownRect = m_downloadDropDownRects[ index ]; + const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); + hoveringDownloadDropDown = downloadDropDownRect.contains( ev->pos() ); + } if ( m_avatarBoxRects.contains( index ) ) { const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); @@ -796,7 +887,7 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con if ( event->type() == QEvent::MouseMove ) { - if ( hoveringInfo || hoveringLove || hoveringArtist ) + if ( hoveringInfo || hoveringLove || hoveringArtist || hoveringBuy ) m_view->setCursor( Qt::PointingHandCursor ); else m_view->setCursor( Qt::ArrowCursor ); @@ -820,6 +911,23 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con emit updateIndex( m_hoveringOverArtist ); m_hoveringOverArtist = QModelIndex(); } + if ( hoveringBuy && m_hoveringOverBuyButton != index ) + { + QPersistentModelIndex ti = m_hoveringOverBuyButton; + m_hoveringOverBuyButton = index; + + PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( ti ) ); + item->requestRepaint(); + emit updateIndex( m_hoveringOverBuyButton ); + } + if ( !hoveringBuy && m_hoveringOverBuyButton.isValid() ) + { + QPersistentModelIndex ti = m_hoveringOverBuyButton; + m_hoveringOverBuyButton = QModelIndex(); + + PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( ti ) ); + item->requestRepaint(); + } if ( m_hoveringOver != index ) { @@ -849,6 +957,11 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con { item->query()->queryTrack()->setLoved( !item->query()->queryTrack()->loved() ); } + else if ( hoveringBuy ) + { + WebPopup* popup = new WebPopup( item->query()->results().first()->purchaseUrl(), QSize( 400, 800 ) ); + connect( item->query()->results().first().data(), SIGNAL( destroyed() ), popup, SLOT( close() ) ); + } else if ( hoveringInfo ) { if ( m_model->style() == PlayableProxyModel::SingleColumn ) @@ -883,7 +996,7 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con } } } - else if ( m_view->proxyModel()->style() == PlayableProxyModel::Locker && index.column() == PlayableModel::Download ) + else if ( ( m_view->proxyModel()->style() == PlayableProxyModel::Locker && index.column() == PlayableModel::Download ) || hoveringDownloadDropDown ) { m_model->sourceModel()->setAllColumnsEditable( true ); m_view->edit( index ); @@ -909,8 +1022,10 @@ PlaylistItemDelegate::resetHoverIndex() m_hoveringOver = QModelIndex(); m_hoveringOverArtist = QModelIndex(); + m_hoveringOverBuyButton = QModelIndex(); m_infoButtonRects.clear(); m_loveButtonRects.clear(); + m_buyButtonRects.clear(); m_artistNameRects.clear(); QModelIndex itemIdx = m_model->mapToSource( idx ); diff --git a/src/libtomahawk/playlist/PlaylistItemDelegate.h b/src/libtomahawk/playlist/PlaylistItemDelegate.h index 825ed6d02..4f3dad0ea 100644 --- a/src/libtomahawk/playlist/PlaylistItemDelegate.h +++ b/src/libtomahawk/playlist/PlaylistItemDelegate.h @@ -116,10 +116,13 @@ private: mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps; mutable QHash< QPersistentModelIndex, QRect > m_infoButtonRects; mutable QHash< QPersistentModelIndex, QRect > m_loveButtonRects; + mutable QHash< QPersistentModelIndex, QRect > m_buyButtonRects; + mutable QHash< QPersistentModelIndex, QRect > m_downloadDropDownRects; mutable QHash< QPersistentModelIndex, QRect > m_artistNameRects; mutable QHash< QPersistentModelIndex, QHash< Tomahawk::source_ptr, QRect > > m_avatarBoxRects; QPersistentModelIndex m_hoveringOver; QPersistentModelIndex m_hoveringOverArtist; + QPersistentModelIndex m_hoveringOverBuyButton; mutable QPersistentModelIndex m_nowPlaying; TrackView* m_view; diff --git a/src/libtomahawk/playlist/TrackDetailView.cpp b/src/libtomahawk/playlist/TrackDetailView.cpp index aeae73f38..da3c490a2 100644 --- a/src/libtomahawk/playlist/TrackDetailView.cpp +++ b/src/libtomahawk/playlist/TrackDetailView.cpp @@ -19,6 +19,7 @@ #include "TrackDetailView.h" #include +#include #include #include #include @@ -35,6 +36,7 @@ #include "utils/ImageRegistry.h" #include "utils/TomahawkUtilsGui.h" #include "utils/Closure.h" +#include "utils/WebPopup.h" #include "utils/Logger.h" using namespace Tomahawk; @@ -42,6 +44,7 @@ using namespace Tomahawk; TrackDetailView::TrackDetailView( QWidget* parent ) : QWidget( parent ) , DpiScaler( this ) + , m_buyButtonVisible( false ) { setFixedWidth( scaledX( 200 ) ); setContentsMargins( 0, 0, 0, 0 ); @@ -118,11 +121,21 @@ TrackDetailView::TrackDetailView( QWidget* parent ) TomahawkStyle::styleScrollBar( m_resultsScrollArea->verticalScrollBar() ); m_resultsScrollArea->hide(); + m_buyButton = new QPushButton; + m_buyButton->setStyleSheet( "QPushButton:hover { font-size: 12px; color: #ffffff; background: #000000; border-style: solid; border-radius: 0px; border-width: 2px; border-color: #2b2b2b; }" + "QPushButton { font-size: 12px; color: #ffffff; background-color: #000000; border-style: solid; border-radius: 0px; border-width: 0px; }" ); + m_buyButton->setMinimumHeight( 30 ); + m_buyButton->setText( tr( "Buy Album" ) ); + m_buyButton->setVisible( false ); + connect( m_buyButton, SIGNAL( clicked() ), SLOT( onBuyButtonClicked() ) ); + QVBoxLayout* layout = new QVBoxLayout; TomahawkUtils::unmarginLayout( layout ); layout->addWidget( m_playableCover ); layout->addSpacerItem( new QSpacerItem( 0, 8, QSizePolicy::Minimum, QSizePolicy::Fixed ) ); layout->addWidget( m_nameLabel ); + layout->addSpacerItem( new QSpacerItem( 0, 4, QSizePolicy::Minimum, QSizePolicy::Fixed ) ); + layout->addWidget( m_buyButton ); layout->addWidget( m_dateLabel ); layout->addWidget( m_infoBox ); layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::Fixed ) ); @@ -134,6 +147,9 @@ TrackDetailView::TrackDetailView( QWidget* parent ) setLayout( layout ); setQuery( query_ptr() ); + + connect( DownloadManager::instance(), SIGNAL( stateChanged( DownloadManager::DownloadManagerState, DownloadManager::DownloadManagerState ) ), + SLOT( onDownloadManagerStateChanged( DownloadManager::DownloadManagerState, DownloadManager::DownloadManagerState ) ) ); } @@ -154,6 +170,10 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query ) { if ( m_query ) { + if ( m_query->track()->albumPtr() && !m_query->track()->albumPtr()->name().isEmpty() ) + { + disconnect( m_query->track()->albumPtr().data(), SIGNAL( updated() ), this, SLOT( onAlbumUpdated() ) ); + } disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) ); disconnect( m_query->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) ); disconnect( m_query.data(), SIGNAL( resultsChanged() ), this, SLOT( onResultsChanged() ) ); @@ -164,6 +184,7 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query ) onResultsChanged(); setSocialActions(); onCoverUpdated(); + onAlbumUpdated(); if ( !query ) { @@ -174,20 +195,85 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query ) m_dateLabel->setText( tr( "Unknown Release-Date" ) ); + connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) ); + connect( m_query->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) ); + connect( m_query.data(), SIGNAL( resultsChanged() ), SLOT( onResultsChanged() ) ); + connect( m_query.data(), SIGNAL( resultsChanged() ), SLOT( onAlbumUpdated() ) ); +} + + +void +TrackDetailView::onAlbumUpdated() +{ + if ( !m_query ) + return; + if ( m_query->track()->albumPtr() && !m_query->track()->albumPtr()->name().isEmpty() ) { m_nameLabel->setType( QueryLabel::Album ); m_nameLabel->setAlbum( m_query->track()->albumPtr() ); + + connect( m_query->track()->albumPtr().data(), SIGNAL( updated() ), SLOT( onAlbumUpdated() ), Qt::UniqueConnection ); + + if ( m_buyButtonVisible ) + { + if ( m_query->track()->albumPtr()->purchased() ) + { + m_buyButton->setText( tr( "Download Album" ) ); + m_buyButton->setVisible( true ); + } + else + { + m_buyButton->setText( tr( "Buy Album" ) ); + m_buyButton->setVisible( !m_query->track()->albumPtr()->purchaseUrl().isEmpty() ); + } + } } else { m_nameLabel->setType( QueryLabel::Artist ); m_nameLabel->setArtist( m_query->track()->artistPtr() ); + m_buyButton->setVisible( false ); + } +} + + +void +TrackDetailView::onBuyButtonClicked() +{ + if ( DownloadManager::instance()->state() == DownloadManager::Running ) + { + emit downloadCancel(); + return; } - connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) ); - connect( m_query->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) ); - connect( m_query.data(), SIGNAL( resultsChanged() ), SLOT( onResultsChanged() ) ); + if ( m_query && m_query->track()->albumPtr() ) + { + if ( m_query->track()->albumPtr()->purchased() ) + { + emit downloadAll(); + } + else + { + WebPopup* popup = new WebPopup( m_query->track()->albumPtr()->purchaseUrl(), QSize( 400, 800 ) ); + connect( m_query->track()->albumPtr().data(), SIGNAL( destroyed() ), popup, SLOT( close() ) ); + } + } +} + + +void +TrackDetailView::onDownloadManagerStateChanged( DownloadManager::DownloadManagerState newState, DownloadManager::DownloadManagerState oldState ) +{ + tDebug() << Q_FUNC_INFO; + if ( newState == DownloadManager::Running ) + { + m_buyButton->setText( tr( "Cancel Download" ) ); + } + else + { + onAlbumUpdated(); + } } @@ -304,3 +390,10 @@ TrackDetailView::onResultsChanged() m_resultsScrollArea->hide(); } } + + +void +TrackDetailView::setBuyButtonVisible( bool visible ) +{ + m_buyButtonVisible = visible; +} diff --git a/src/libtomahawk/playlist/TrackDetailView.h b/src/libtomahawk/playlist/TrackDetailView.h index a3dd9191c..77c189bff 100644 --- a/src/libtomahawk/playlist/TrackDetailView.h +++ b/src/libtomahawk/playlist/TrackDetailView.h @@ -23,6 +23,7 @@ #include "Query.h" #include "utils/DpiScaler.h" +#include "DownloadManager.h" #include "DllMacro.h" class QLabel; @@ -30,6 +31,7 @@ class CaptionLabel; class PlayableCover; class QueryLabel; class QScrollArea; +class QPushButton; class DLLEXPORT TrackDetailView : public QWidget, private TomahawkUtils::DpiScaler { @@ -39,21 +41,29 @@ public: explicit TrackDetailView( QWidget* parent = 0 ); ~TrackDetailView(); + void setBuyButtonVisible( bool visible ); + public slots: virtual void setQuery( const Tomahawk::query_ptr& query ); void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface ); signals: + void downloadAll(); + void downloadCancel(); protected: protected slots: private slots: + void onAlbumUpdated(); void onCoverUpdated(); void onSocialActionsLoaded(); void onResultsChanged(); + void onBuyButtonClicked(); + void onDownloadManagerStateChanged( DownloadManager::DownloadManagerState newState, DownloadManager::DownloadManagerState oldState ); + private: void setSocialActions(); @@ -65,6 +75,8 @@ private: QLabel* m_lovedIcon; QLabel* m_lovedLabel; CaptionLabel* m_resultsBoxLabel; + QPushButton* m_buyButton; + bool m_buyButtonVisible; QWidget* m_infoBox; QWidget* m_resultsBox; diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index cbf342e51..bedde7a41 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -23,7 +23,9 @@ #include "PlayableModel.h" #include "PlayableProxyModel.h" #include "PlayableItem.h" +#include "DownloadManager.h" #include "DropJob.h" +#include "Result.h" #include "Source.h" #include "TomahawkSettings.h" #include "audio/AudioEngine.h" @@ -773,6 +775,26 @@ TrackView::onCustomContextMenu( const QPoint& pos ) m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened | ContextMenu::ActionDelete ); + if ( proxyModel()->style() == PlayableProxyModel::Locker ) + { + bool allDownloaded = true; + foreach ( const QModelIndex& index, selectedIndexes() ) + { + if ( index.column() ) + continue; + + PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) ); + if ( DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + { + allDownloaded = false; + break; + } + } + + if ( !allDownloaded ) + m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDownload ); + } + QList queries; foreach ( const QModelIndex& index, selectedIndexes() ) { @@ -804,6 +826,10 @@ TrackView::onMenuTriggered( int action ) deleteSelectedItems(); break; + case ContextMenu::ActionDownload: + downloadSelectedItems(); + break; + default: break; } @@ -879,6 +905,27 @@ TrackView::deleteSelectedItems() } +void +TrackView::downloadSelectedItems() +{ + foreach ( const QModelIndex& index, selectedIndexes() ) + { + if ( index.column() ) + continue; + + PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) ); + + if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + continue; + if ( !item ) + continue; + + if ( !item->result()->downloadFormats().isEmpty() ) + DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) ); + } +} + + void TrackView::verifySize() { diff --git a/src/libtomahawk/playlist/TrackView.h b/src/libtomahawk/playlist/TrackView.h index fd323d55a..8509c26ab 100644 --- a/src/libtomahawk/playlist/TrackView.h +++ b/src/libtomahawk/playlist/TrackView.h @@ -89,6 +89,7 @@ public: public slots: virtual void onItemActivated( const QModelIndex& index ); + virtual void downloadSelectedItems(); virtual void deleteSelectedItems(); void playItem(); diff --git a/src/libtomahawk/resolvers/ScriptEngine.cpp b/src/libtomahawk/resolvers/ScriptEngine.cpp index e544344ec..38f981bb6 100644 --- a/src/libtomahawk/resolvers/ScriptEngine.cpp +++ b/src/libtomahawk/resolvers/ScriptEngine.cpp @@ -99,7 +99,7 @@ ScriptEngine::sslErrorHandler( QNetworkReply* qnr, const QList& errli QMessageBox question( TomahawkUtils::tomahawkWindow() ); question.setWindowTitle( tr( "SSL Error" ) ); - question.setText( tr( "You have asked Tomahawk to connect securely to %1, but we can't confirm that your connection is secure:

" + question.setText( tr( "You have asked %applicationName to connect securely to %1, but we can't confirm that your connection is secure:

" "%2

" "Do you want to trust this connection?" ) .arg( qnr->url().host() ) diff --git a/src/libtomahawk/utils/PluginLoader.cpp b/src/libtomahawk/utils/PluginLoader.cpp index d5ccf2a81..9dec9218a 100644 --- a/src/libtomahawk/utils/PluginLoader.cpp +++ b/src/libtomahawk/utils/PluginLoader.cpp @@ -24,6 +24,7 @@ #include "PluginLoader_p.h" #include "config.h" +#include "TomahawkVersion.h" #include "utils/Logger.h" @@ -153,7 +154,7 @@ PluginLoader::pluginFilenames( const QString& name ) const QStringList fileNames; foreach( const QString& extension, extensions ) { - fileNames << QString("libtomahawk_%1_%2.%3") + fileNames << QString("lib" TOMAHAWK_TARGET_NAME "_%1_%2.%3") .arg( d_ptr->type ) .arg( name ) .arg( extension ); @@ -174,12 +175,8 @@ PluginLoader::pluginPaths( const QString& name ) const tDebug() << Q_FUNC_INFO << "Checking directory for" << type << "plugins:" << pluginDir.absolutePath(); foreach ( QString fileName, pluginDir.entryList( pluginFilenames( name ), QDir::Files ) ) { - //TODO: do we really need to check this?! - if ( fileName.startsWith( QString( "libtomahawk_%1" ).arg( type ) ) ) - { - const QString path = pluginDir.absoluteFilePath( fileName ); - paths << path; - } + const QString path = pluginDir.absoluteFilePath( fileName ); + paths << path; } } diff --git a/src/libtomahawk/utils/TomahawkStyle.cpp b/src/libtomahawk/utils/TomahawkStyle.cpp index d4a36e7c2..0cb0eb82c 100644 --- a/src/libtomahawk/utils/TomahawkStyle.cpp +++ b/src/libtomahawk/utils/TomahawkStyle.cpp @@ -211,11 +211,19 @@ TomahawkStyle::styleScrollBar( QScrollBar* scrollBar ) void TomahawkStyle::loadFonts() { +#ifdef Q_OS_MAC + QDir dir( QCoreApplication::applicationDirPath() + "/../Resources/Fonts" ); +#else QDir dir( ":/data/fonts" ); +#endif foreach ( const QString& fileName, dir.entryList() ) { - tDebug( LOGVERBOSE ) << "Trying to add font resource:" << fileName; + tDebug( LOGVERBOSE ) << "Trying to add font resource:" << dir.absolutePath() << fileName; +#ifdef Q_OS_MAC + const int id = QFontDatabase::addApplicationFont( dir.absolutePath() + "/" + fileName ); +#else const int id = QFontDatabase::addApplicationFont( ":/data/fonts/" + fileName ); +#endif if ( id >= 0 ) { tDebug( LOGVERBOSE ) << "Added font:" << id << QFontDatabase::applicationFontFamilies( id ).first(); diff --git a/src/libtomahawk/utils/TomahawkStyle.h b/src/libtomahawk/utils/TomahawkStyle.h index 81ed1a2f7..9c8f1b8ff 100644 --- a/src/libtomahawk/utils/TomahawkStyle.h +++ b/src/libtomahawk/utils/TomahawkStyle.h @@ -102,6 +102,7 @@ namespace TomahawkStyle static const QColor PLAYLIST_BUTTON_BACKGROUND = QColor( "#111111" ); static const QColor PLAYLIST_BUTTON_FOREGROUND = QColor( "#ffffff" ); + static const QColor PLAYLIST_BUTTON_HOVER_BACKGROUND = QColor( "#111111" ); static const QColor PLAYLIST_PROGRESS_BACKGROUND = QColor( "#ffffff" ); static const QColor PLAYLIST_PROGRESS_FOREGROUND = QColor( "#E61878" ); diff --git a/src/libtomahawk/viewpages/AlbumViewPage.cpp b/src/libtomahawk/viewpages/AlbumViewPage.cpp index a912241b6..f29377ea5 100644 --- a/src/libtomahawk/viewpages/AlbumViewPage.cpp +++ b/src/libtomahawk/viewpages/AlbumViewPage.cpp @@ -29,6 +29,7 @@ #include "Source.h" #include "MetaPlaylistInterface.h" #include "playlist/TrackView.h" +#include "playlist/TrackDetailView.h" #include "widgets/BasicHeader.h" #include "database/DatabaseCommand_AllTracks.h" @@ -58,6 +59,7 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* par m_tracksModel->setMode( Mixed ); // We need to set the model on the view before loading the playlist, so spinners & co are connected + ui->albumView->trackDetailView()->setBuyButtonVisible( true ); ui->albumView->trackView()->setPlayableModel( m_tracksModel ); ui->albumView->setCaption( tr( "Album Details" ) ); @@ -186,4 +188,4 @@ AlbumInfoWidget::pixmap() const return Tomahawk::ViewPage::pixmap(); else return m_pixmap; -} +} \ No newline at end of file diff --git a/src/libtomahawk/viewpages/ArtistViewPage.cpp b/src/libtomahawk/viewpages/ArtistViewPage.cpp index 420548d58..c2dc512fb 100644 --- a/src/libtomahawk/viewpages/ArtistViewPage.cpp +++ b/src/libtomahawk/viewpages/ArtistViewPage.cpp @@ -107,6 +107,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* ui->topHits->setItemWidth( scaledX( 140 ) ); ui->topHits->proxyModel()->setHideDupeItems( true ); ui->topHits->delegate()->setWordWrapping( true ); + ui->topHits->delegate()->setShowBuyButtons( true ); ui->topHits->setFixedHeight( ui->topHits->itemSize().height() + ui->topHits->spacing() * 2 ); m_topHitsModel = new PlayableModel( ui->topHits ); diff --git a/src/libtomahawk/viewpages/CollectionViewPage.cpp b/src/libtomahawk/viewpages/CollectionViewPage.cpp index 295fad1cf..c388c7362 100644 --- a/src/libtomahawk/viewpages/CollectionViewPage.cpp +++ b/src/libtomahawk/viewpages/CollectionViewPage.cpp @@ -20,6 +20,7 @@ #include "CollectionViewPage.h" #include +#include #include #include @@ -32,7 +33,6 @@ #include "playlist/GridView.h" #include "playlist/PlayableProxyModelPlaylistInterface.h" #include "resolvers/ScriptCollection.h" -#include "DownloadManager.h" #include "TomahawkSettings.h" #include "utils/ImageRegistry.h" #include "utils/TomahawkStyle.h" @@ -58,6 +58,7 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" ); m_header->setBackground( ImageRegistry::instance()->pixmap( RESPATH "images/collection_background.png", QSize( 0, 0 ) ), false ); + setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultCollection, TomahawkUtils::Original, QSize( 256, 256 ) ) ); m_columnView->proxyModel()->setStyle( PlayableProxyModel::SingleColumn ); @@ -130,8 +131,11 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti if ( collection->backendType() == Collection::ScriptCollectionType ) { - QAbstractButton* downloadButton = m_header->addButton( tr( "Download All" ) ); - connect( downloadButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) ); + m_downloadAllButton = m_header->addButton( tr( "Download All" ) ); + connect( m_downloadAllButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) ); + + connect( DownloadManager::instance(), SIGNAL( stateChanged( DownloadManager::DownloadManagerState, DownloadManager::DownloadManagerState ) ), + SLOT( onDownloadManagerStateChanged( DownloadManager::DownloadManagerState, DownloadManager::DownloadManagerState ) ) ); m_header->setRefreshVisible( true ); connect( m_header, SIGNAL( refresh() ), SLOT( onCollectionChanged() ) ); @@ -389,6 +393,8 @@ CollectionViewPage::restoreViewMode() } else { setCurrentMode( mode ); } + + onCollectionChanged(); } @@ -445,14 +451,38 @@ CollectionViewPage::onCollectionChanged() void CollectionViewPage::onDownloadAll() { - for ( int i = 0; i < m_flatModel->rowCount( QModelIndex() ); i++ ) + if ( DownloadManager::instance()->state() == DownloadManager::Running ) { - PlayableItem* item = m_flatModel->itemFromIndex( m_flatModel->index( i, 0, QModelIndex() ) ); - if ( !item ) - continue; + DownloadManager::instance()->cancelAll(); + } + else + { + for ( int i = 0; i < m_trackView->proxyModel()->rowCount( QModelIndex() ); i++ ) + { + PlayableItem* item = m_trackView->proxyModel()->itemFromIndex( m_trackView->proxyModel()->mapToSource( m_trackView->proxyModel()->index( i, 0, QModelIndex() ) ) ); + if ( !item ) + continue; + if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + continue; - if ( !item->result()->downloadFormats().isEmpty() ) - DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) ); + if ( !item->result()->downloadFormats().isEmpty() ) + DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) ); + } + } +} + + +void +CollectionViewPage::onDownloadManagerStateChanged( DownloadManager::DownloadManagerState newState, DownloadManager::DownloadManagerState oldState ) +{ + tDebug() << Q_FUNC_INFO; + if ( newState == DownloadManager::Running ) + { + m_downloadAllButton->setText( tr( "Cancel Download" ) ); + } + else + { + m_downloadAllButton->setText( tr( "Download All" ) ); } } @@ -467,5 +497,14 @@ CollectionViewPage::isTemporaryPage() const bool CollectionViewPage::isBeingPlayed() const { - return m_playlistInterface->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ); + if ( !playlistInterface() ) + return false; + + if ( playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) + return true; + + if ( playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) ) + return true; + + return false; } diff --git a/src/libtomahawk/viewpages/CollectionViewPage.h b/src/libtomahawk/viewpages/CollectionViewPage.h index f424fdcf6..bf025b834 100644 --- a/src/libtomahawk/viewpages/CollectionViewPage.h +++ b/src/libtomahawk/viewpages/CollectionViewPage.h @@ -22,8 +22,10 @@ #include "ViewPage.h" #include "PlaylistInterface.h" +#include "DownloadManager.h" #include "DllMacro.h" +class QPushButton; class QStackedWidget; class GridView; @@ -83,10 +85,12 @@ private slots: void onCollectionChanged(); void onDownloadAll(); + void onDownloadManagerStateChanged( DownloadManager::DownloadManagerState newState, DownloadManager::DownloadManagerState oldState ); private: FilterHeader* m_header; QPixmap m_pixmap; + QPushButton* m_downloadAllButton; ColumnView* m_columnView; TrackView* m_trackView; diff --git a/src/libtomahawk/viewpages/SearchViewPage.cpp b/src/libtomahawk/viewpages/SearchViewPage.cpp index 5e039d08f..b7df5638b 100644 --- a/src/libtomahawk/viewpages/SearchViewPage.cpp +++ b/src/libtomahawk/viewpages/SearchViewPage.cpp @@ -100,6 +100,7 @@ SearchWidget::SearchWidget( const QString& search, QWidget* parent ) ui->tracks->setItemWidth( TomahawkUtils::DpiScaler::scaledX( this, 140 ) ); // ui->tracks->proxyModel()->setHideDupeItems( true ); ui->tracks->delegate()->setWordWrapping( true ); + ui->tracks->delegate()->setShowBuyButtons( true ); ui->tracks->setFixedHeight( ui->tracks->itemSize().height() + ui->tracks->spacing() * 2 ); m_resultsModel = new PlayableModel( ui->tracks ); diff --git a/src/libtomahawk/widgets/BasicHeader.cpp b/src/libtomahawk/widgets/BasicHeader.cpp index 631bc0b02..b8a6c7138 100644 --- a/src/libtomahawk/widgets/BasicHeader.cpp +++ b/src/libtomahawk/widgets/BasicHeader.cpp @@ -132,10 +132,16 @@ BasicHeader::setPixmap( const QPixmap& pixmap, bool tinted ) } -QAbstractButton* +QPushButton* BasicHeader::addButton( const QString& text ) { QPushButton* button = new QPushButton( this ); + + button->setStyleSheet( "QPushButton:hover { font-size: 12px; color: #2b2b2b; background: #f8f8f8; border-style: solid; border-radius: 0px; border-width: 2px; border-color: #2b2b2b; }" + "QPushButton { font-size: 12px; color: #ffffff; background-color: #000000; border-style: solid; border-radius: 0px; border-width: 0px; }" ); + button->setMinimumHeight( 30 ); + button->setMinimumWidth( 132 ); + button->setText( text ); ui->horizontalLayout->addSpacing( 8 ); diff --git a/src/libtomahawk/widgets/BasicHeader.h b/src/libtomahawk/widgets/BasicHeader.h index 063fe993b..d2d9abb72 100644 --- a/src/libtomahawk/widgets/BasicHeader.h +++ b/src/libtomahawk/widgets/BasicHeader.h @@ -26,6 +26,7 @@ #include "widgets/BackgroundWidget.h" #include "DllMacro.h" +class QPushButton; class QLabel; class ElidedLabel; class QPaintEvent; @@ -40,7 +41,7 @@ public: QScopedPointer ui; - QAbstractButton* addButton( const QString& text ); + QPushButton* addButton( const QString& text ); public slots: virtual void setCaption( const QString& s ); diff --git a/src/libtomahawk/widgets/DropDownButton.cpp b/src/libtomahawk/widgets/DropDownButton.cpp index 4dc6f425f..8f315b718 100644 --- a/src/libtomahawk/widgets/DropDownButton.cpp +++ b/src/libtomahawk/widgets/DropDownButton.cpp @@ -46,44 +46,56 @@ DropDownButton::paintEvent( QPaintEvent* event ) { // QComboBox::paintEvent( event ); QPainter p( this ); - drawPrimitive( &p, contentsRect(), currentText() ); + drawPrimitive( &p, contentsRect(), currentText(), true, true ); } void -DropDownButton::drawPrimitive( QPainter* p, const QRect& rect, const QString& text ) +DropDownButton::drawPrimitive( QPainter* p, const QRect& rect, const QString& text, bool hovering, bool itemsAvailable ) { p->save(); + QFont f = p->font(); + f.setPointSize( 8 ); p->setRenderHint( QPainter::TextAntialiasing ); QRect r = rect.adjusted( 2, 2, -2, -2 ); - p->setPen( TomahawkStyle::PLAYLIST_BUTTON_BACKGROUND.darker() ); - p->setBrush( TomahawkStyle::PLAYLIST_BUTTON_BACKGROUND ); + QColor bgColor = hovering ? TomahawkStyle::PLAYLIST_BUTTON_HOVER_BACKGROUND : TomahawkStyle::PLAYLIST_BUTTON_BACKGROUND; + + p->setOpacity( 1.0 ); + p->setPen( bgColor ); + p->setBrush( bgColor ); p->drawRect( r ); - - // paint divider p->setPen( TomahawkStyle::PLAYLIST_BUTTON_FOREGROUND ); - p->drawLine( QPoint( r.right() - 24, r.top() + 3 ), QPoint( r.right() - 24, r.bottom() - 3 ) ); + + int dropdownWidth = 0; - // paint drop-down arrow - p->save(); - QPainterPath dropPath; - dropPath.moveTo( QPointF( r.right() - 14, float(r.top()) + float(r.height()) * 0.5 - 1.5 ) ); - QPointF currentPosition = dropPath.currentPosition(); - dropPath.lineTo( currentPosition.x() + 6, currentPosition.y() ); - dropPath.lineTo( currentPosition.x() + 3, currentPosition.y() + 3 ); - dropPath.closeSubpath(); - p->setPen( TomahawkStyle::PLAYLIST_BUTTON_FOREGROUND ); - p->setBrush( TomahawkStyle::PLAYLIST_BUTTON_FOREGROUND ); - p->setRenderHint( QPainter::Antialiasing, false ); - p->drawPath( dropPath ); - p->restore(); + if ( itemsAvailable ) + { + // paint divider + p->drawLine( QPoint( r.right() - 24, r.top() + 3 ), QPoint( r.right() - 24, r.bottom() - 3 ) ); + + // paint drop-down arrow + p->save(); + QPainterPath dropPath; + dropPath.moveTo( QPointF( r.right() - 14, float(r.top()) + float(r.height()) * 0.5 - 1.5 ) ); + QPointF currentPosition = dropPath.currentPosition(); + dropPath.lineTo( currentPosition.x() + 6, currentPosition.y() ); + dropPath.lineTo( currentPosition.x() + 3, currentPosition.y() + 3 ); + dropPath.closeSubpath(); + p->setPen( TomahawkStyle::PLAYLIST_BUTTON_FOREGROUND ); + p->setBrush( TomahawkStyle::PLAYLIST_BUTTON_FOREGROUND ); + p->setRenderHint( QPainter::Antialiasing, false ); + p->drawPath( dropPath ); + p->restore(); + + dropdownWidth = 24; + } // paint label const QFontMetrics fm( p->font() ); - r.adjust( 0, 0, -24, 0 ); // center-align left of the divider - p->drawText( r, Qt::AlignCenter, fm.elidedText( text, Qt::ElideRight, r.width() ) ); + r.adjust( 0, 0, -dropdownWidth, 0 ); // center-align left of the divider + p->drawText( r, Qt::AlignCenter, fm.elidedText( text.toUpper(), Qt::ElideRight, r.width() ) ); p->restore(); } diff --git a/src/libtomahawk/widgets/DropDownButton.h b/src/libtomahawk/widgets/DropDownButton.h index 903c4b23d..b0d2c6415 100644 --- a/src/libtomahawk/widgets/DropDownButton.h +++ b/src/libtomahawk/widgets/DropDownButton.h @@ -32,7 +32,7 @@ public: explicit DropDownButton( QWidget* parent = 0 ); virtual ~DropDownButton(); - static void drawPrimitive( QPainter* p, const QRect& rect, const QString& text ); + static void drawPrimitive( QPainter* p, const QRect& rect, const QString& text, bool hovering, bool itemsAvailable ); public slots: diff --git a/src/tomahawk/CMakeLists.osx.cmake b/src/tomahawk/CMakeLists.osx.cmake index a2c59728d..01ed1c5e2 100644 --- a/src/tomahawk/CMakeLists.osx.cmake +++ b/src/tomahawk/CMakeLists.osx.cmake @@ -1,5 +1,3 @@ -SET( TOMAHAWK_LIBRARIES tomahawklib ) - SET( OS_SPECIFIC_LINK_LIBRARIES ${OS_SPECIFIC_LINK_LIBRARIES} ${COREAUDIO_LIBRARY} diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt index 897d6a46a..5e2da4940 100644 --- a/src/tomahawk/CMakeLists.txt +++ b/src/tomahawk/CMakeLists.txt @@ -1,5 +1,3 @@ -set(TOMAHAWK_APPLICATION_TARGET "tomahawk-bin") - include( ECMAddAppIcon ) # SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) @@ -9,6 +7,8 @@ IF( NOT CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT CMAKE_BUILD_TYPE STREQUAL "R MESSAGE( "Building in debug mode, enabling all debug updates" ) ENDIF() +set(TOMAHAWK_APPLICATION_TARGET ${TOMAHAWK_TARGET_NAME}-bin) + # build plugins # use glob, but hardcoded list for now: #FILE( GLOB plugindirs "src/plugins/*" ) @@ -154,19 +154,18 @@ else() ecm_add_app_icon(tomahawkSources ICONS ${TOMAHAWK_ICONS}) endif() - qt_add_resources( RC_SRCS "../../resources.qrc" ) SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMoc} ${tomahawkSources} ${RC_SRCS} ) -if(APPLE) - set(TOMAHAWK_RUNTIME_OUTPUT_NAME "Tomahawk") +if(APPLE OR WIN32) + set(TOMAHAWK_RUNTIME_OUTPUT_NAME "${TOMAHAWK_APPLICATION_NAME}") else() - set(TOMAHAWK_RUNTIME_OUTPUT_NAME "tomahawk") + set(TOMAHAWK_RUNTIME_OUTPUT_NAME "${TOMAHAWK_TARGET_NAME}") endif() ADD_EXECUTABLE( ${TOMAHAWK_APPLICATION_TARGET} WIN32 MACOSX_BUNDLE ${final_src} ) -SET_TARGET_PROPERTIES(${TOMAHAWK_APPLICATION_TARGET} +SET_TARGET_PROPERTIES( ${TOMAHAWK_APPLICATION_TARGET} PROPERTIES AUTOMOC TRUE MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/Info.plist" @@ -210,8 +209,7 @@ TARGET_LINK_LIBRARIES( ${TOMAHAWK_APPLICATION_TARGET} IF( APPLE ) IF( HAVE_SPARKLE ) MESSAGE("Sparkle Found, installing framekwork in bundle") - INSTALL(DIRECTORY "${SPARKLE}/Versions/Current/Resources" DESTINATION "${CMAKE_BINARY_DIR}/Tomahawk.app/Contents/Frameworks/Sparkle.framework") - + INSTALL(DIRECTORY "${SPARKLE}/Versions/Current/Resources" DESTINATION "${CMAKE_BINARY_DIR}/${TOMAHAWK_APPLICATION_NAME}.app/Contents/Frameworks/Sparkle.framework") ENDIF( HAVE_SPARKLE ) ENDIF( APPLE ) diff --git a/src/tomahawk/TomahawkApp.cpp b/src/tomahawk/TomahawkApp.cpp index 3cfd41316..0dfa0070e 100644 --- a/src/tomahawk/TomahawkApp.cpp +++ b/src/tomahawk/TomahawkApp.cpp @@ -608,14 +608,14 @@ TomahawkApp::initSIP() void TomahawkApp::onShutdownDelayed() { - QProgressDialog* d = new QProgressDialog( tr( "Tomahawk is updating the database. Please wait, this may take a minute!" ), QString(), + QProgressDialog* d = new QProgressDialog( tr( "%applicationName is updating the database. Please wait, this may take a minute!" ), QString(), 0, 0, 0, Qt::Tool | Qt::WindowTitleHint | Qt::CustomizeWindowHint ); d->setModal( true ); d->setAutoClose( false ); d->setAutoReset( false ); - d->setWindowTitle( tr( "Tomahawk" ) ); + d->setWindowTitle( tr( "%applicationName" ) ); #ifdef Q_OS_MAC d->setAttribute( Qt::WA_MacAlwaysShowToolWindow ); @@ -642,7 +642,7 @@ TomahawkApp::onInfoSystemReady() { tDebug() << "Init MainWindow."; m_mainwindow = new TomahawkWindow(); - m_mainwindow->setWindowTitle( "Tomahawk" ); + m_mainwindow->setWindowTitle( tr( "%applicationName" ) ); m_mainwindow->setObjectName( "TH_Main_Window" ); if ( !arguments().contains( "--hide" ) ) { diff --git a/src/tomahawk/TomahawkTrayIcon.cpp b/src/tomahawk/TomahawkTrayIcon.cpp index 98595bc84..0d34c86b0 100644 --- a/src/tomahawk/TomahawkTrayIcon.cpp +++ b/src/tomahawk/TomahawkTrayIcon.cpp @@ -67,13 +67,15 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent ) m_contextMenu->addSeparator(); m_contextMenu->addAction( ac->getAction( "previousTrack" ) ); m_contextMenu->addAction( ac->getAction( "nextTrack" ) ); + /* m_contextMenu->addSeparator(); m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) ); + */ #ifdef Q_OS_MAC // On mac you can close the windows while leaving the app open. We then need a way to show the main window again m_contextMenu->addSeparator(); - m_showWindowAction = m_contextMenu->addAction( tr( "Hide Tomahawk Window" ) ); + m_showWindowAction = m_contextMenu->addAction( tr( "Hide %applicationName Window" ) ); m_showWindowAction->setData( true ); connect( m_showWindowAction, SIGNAL( triggered() ), this, SLOT( showWindow() ) ); @@ -112,12 +114,12 @@ TomahawkTrayIcon::setShowHideWindow( bool show ) { if ( show ) { - m_showWindowAction->setText( tr( "Hide Tomahawk Window" ) ); + m_showWindowAction->setText( tr( "Hide %applicationName Window" ) ); m_showWindowAction->setData( show ); } else { - m_showWindowAction->setText( tr( "Show Tomahawk Window" ) ); + m_showWindowAction->setText( tr( "Show %applicationName Window" ) ); } m_showWindowAction->setData( show ); diff --git a/src/tomahawk/TomahawkWindow.cpp b/src/tomahawk/TomahawkWindow.cpp index 57e25a48e..c63978c55 100644 --- a/src/tomahawk/TomahawkWindow.cpp +++ b/src/tomahawk/TomahawkWindow.cpp @@ -84,6 +84,8 @@ #include "dialogs/LoadPlaylistDialog.h" #include "utils/ImageRegistry.h" #include "utils/Logger.h" +#include "utils/GuiHelpers.h" +#include "libtomahawk/widgets/ImageButton.h" #include "config.h" @@ -1269,11 +1271,11 @@ TomahawkWindow::showAboutTomahawk() QString head, desc; #ifdef QT_DEBUG - head = tr( "

Tomahawk %1
(%2)

" ) + head = tr( "

%applicationName %1
(%2)

" ) .arg( TomahawkUtils::appFriendlyVersion() ) .arg( qApp->applicationVersion() ); #else - head = tr( "

Tomahawk %1

" ) + head = tr( "

%applicationName %1

" ) .arg( TomahawkUtils::appFriendlyVersion() ); #endif @@ -1285,7 +1287,7 @@ TomahawkWindow::showAboutTomahawk() .arg( copyright ) .arg( thanksto ); - QMessageBox::about( this, tr( "About Tomahawk" ), head + desc ); + QMessageBox::about( this, tr( "About %applicationName" ), head + desc ); } diff --git a/src/tomahawk/TomahawkWindow.ui b/src/tomahawk/TomahawkWindow.ui index 1afb6f9a3..43919596d 100644 --- a/src/tomahawk/TomahawkWindow.ui +++ b/src/tomahawk/TomahawkWindow.ui @@ -11,7 +11,7 @@ - Tomahawk + %applicationName diff --git a/src/tomahawk/dialogs/DiagnosticsDialog.cpp b/src/tomahawk/dialogs/DiagnosticsDialog.cpp index de681b601..f14622aa5 100644 --- a/src/tomahawk/dialogs/DiagnosticsDialog.cpp +++ b/src/tomahawk/dialogs/DiagnosticsDialog.cpp @@ -68,7 +68,7 @@ DiagnosticsDialog::updateLogView() { QString log; - log.append( QString( "TOMAHAWK DIAGNOSTICS LOG -%1 \n\n" ).arg( QDateTime::currentDateTime().toString() ) ); + log.append( QString( "%applicationName DIAGNOSTICS LOG -%1 \n\n" ).arg( QDateTime::currentDateTime().toString() ) ); log.append( "TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n" ); log.append( "PLATFORM: " TOMAHAWK_SYSTEM "\n"); log.append( QString( "DBID: %1\n\n" ).arg( Tomahawk::Database::instance()->impl()->dbid() ) ); diff --git a/src/tomahawk/dialogs/DiagnosticsDialog.ui b/src/tomahawk/dialogs/DiagnosticsDialog.ui index c3e249d67..e76385c4e 100644 --- a/src/tomahawk/dialogs/DiagnosticsDialog.ui +++ b/src/tomahawk/dialogs/DiagnosticsDialog.ui @@ -17,7 +17,7 @@ - Tomahawk Diagnostics + %applicationName Diagnostics diff --git a/src/tomahawk/dialogs/SettingsDialog.cpp b/src/tomahawk/dialogs/SettingsDialog.cpp index 81c33b055..9b3c1aa45 100644 --- a/src/tomahawk/dialogs/SettingsDialog.cpp +++ b/src/tomahawk/dialogs/SettingsDialog.cpp @@ -267,20 +267,20 @@ SettingsDialog::SettingsDialog(QObject *parent ) // #endif m_dialog->addTab( m_accountsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AccountSettings ), - tr( "Plug-Ins" ), tr( "Configure the accounts and services used by Tomahawk " + tr( "Plug-Ins" ), tr( "Configure the accounts and services used by %applicationName " "to search and retrieve music, find your friends and " "update your status." ) ); m_dialog->addTab( m_collectionWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::MusicSettings ), - tr( "Collection" ), tr( "Manage how Tomahawk finds music on your computer." ) ); + tr( "Collection" ), tr( "Manage how %applicationName finds music on your computer." ) ); m_dialog->addTab( m_advancedWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AdvancedSettings ), - tr( "Advanced" ), tr( "Configure Tomahawk's advanced settings, including " + tr( "Advanced" ), tr( "Configure %applicationName advanced settings, including " "network connectivity settings, browser interaction " "and more." ) ); m_dialog->addTab( m_downloadsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::DownloadsSettings ), - tr( "Downloads" ), tr( "Configure Tomahawk's integrated download manager." ) ); + tr( "Downloads" ), tr( "Configure %applicationName's integrated download manager." ) ); m_dialog->setCurrentIndex( 0 ); @@ -333,7 +333,7 @@ SettingsDialog::saveSettings() s->sync(); if ( m_restartRequired ) - QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) ); + QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until %applicationName is restarted" ) ); // m_collectionWidgetUi->dirTree->cleanup(); @@ -586,9 +586,9 @@ SettingsDialog::openAccountConfig( Account* account, bool showDelete ) void SettingsDialog::installFromFile() { - const QString resolver = QFileDialog::getOpenFileName( m_accountsWidget, tr( "Install resolver from file" ), + const QString resolver = QFileDialog::getOpenFileName( m_accountsWidget, tr( "Install plug-in from file" ), TomahawkSettings::instance()->scriptDefaultPath(), - tr( "Tomahawk Resolvers (*.axe *.js);;" + tr( "%applicationName Plug-Ins (*.axe *.js);;" "All files (*)" ), 0, QFileDialog::ReadOnly ); diff --git a/src/tomahawk/dialogs/Settings_Advanced.ui b/src/tomahawk/dialogs/Settings_Advanced.ui index 9941f1a04..ec6c74dbd 100644 --- a/src/tomahawk/dialogs/Settings_Advanced.ui +++ b/src/tomahawk/dialogs/Settings_Advanced.ui @@ -177,7 +177,7 @@ Qt::LeftToRight - Allow web browsers to interact with Tomahawk (recommended) + Allow web browsers to interact with %applicationName (recommended) true @@ -190,7 +190,7 @@ Qt::LeftToRight - Allow other computers to interact with Tomahawk (not recommended yet) + Allow other computers to interact with %applicationName (not recommended yet) false @@ -203,7 +203,7 @@ Qt::LeftToRight - Send Tomahawk Crash Reports + Send %applicationName Crash Reports true diff --git a/src/tomahawk/dialogs/Settings_Collection.ui b/src/tomahawk/dialogs/Settings_Collection.ui index e0a437cfe..c3e53d44d 100644 --- a/src/tomahawk/dialogs/Settings_Collection.ui +++ b/src/tomahawk/dialogs/Settings_Collection.ui @@ -50,7 +50,7 @@ - Due to the unique way Tomahawk works, your music files must at least have Artist & Title metadata/ID3 tags to be added to your Collection. + Due to the unique way %applicationName works, your music files must at least have Artist & Title metadata/ID3 tags to be added to your Collection. true diff --git a/src/tomahawk/mac/TomahawkApp_Mac.mm b/src/tomahawk/mac/TomahawkApp_Mac.mm index 2f876a98f..cdcfa2d78 100644 --- a/src/tomahawk/mac/TomahawkApp_Mac.mm +++ b/src/tomahawk/mac/TomahawkApp_Mac.mm @@ -211,7 +211,7 @@ #ifdef HAVE_SPARKLE - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update { - tLog() << "NSApp in willInstallUpdate, deleting Phonon objects"; +// tLog() << "NSApp in willInstallUpdate, deleting Phonon objects"; AudioEngine::instance()->stop(); delete AudioEngine::instance(); } diff --git a/src/tomahawk/main.cpp b/src/tomahawk/main.cpp index 3782827fd..c98ea3219 100644 --- a/src/tomahawk/main.cpp +++ b/src/tomahawk/main.cpp @@ -41,6 +41,7 @@ #endif #ifdef WITH_CRASHREPORTER + #include "TomahawkVersion.h" #include "libcrashreporter-handler/Handler.h" #endif @@ -186,7 +187,7 @@ main( int argc, char *argv[] ) TomahawkApp a( argc, argv ); #ifdef WITH_CRASHREPORTER - CrashReporter::Handler* handler = new CrashReporter::Handler( QDir::tempPath(), !TomahawkUtils::headless(), "tomahawk_crash_reporter" ); + CrashReporter::Handler* handler = new CrashReporter::Handler( QDir::tempPath(), !TomahawkUtils::headless(), TOMAHAWK_TARGET_NAME "_crash_reporter" ); #endif // MUST register StateHash ****before*** initing TomahawkSettingsGui as constructor of settings does upgrade before Gui subclass registers type diff --git a/src/tools/database-reader/CMakeLists.txt b/src/tools/database-reader/CMakeLists.txt index d5fad61ec..72bb1e0db 100644 --- a/src/tools/database-reader/CMakeLists.txt +++ b/src/tools/database-reader/CMakeLists.txt @@ -1,40 +1,21 @@ +set(TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET ${TOMAHAWK_TARGET_NAME}-db-list-artists) + set( tomahawk_db_list_artists_src listartists.cpp ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -add_executable( tomahawk_db_list_artists_bin WIN32 MACOSX_BUNDLE +add_executable( ${TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET} WIN32 MACOSX_BUNDLE ${tomahawk_db_list_artists_src} ) -set_target_properties( tomahawk_db_list_artists_bin +set_target_properties( ${TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET} PROPERTIES AUTOMOC TRUE - RUNTIME_OUTPUT_NAME tomahawk-db-list-artists ) -target_link_libraries( tomahawk_db_list_artists_bin +target_link_libraries( ${TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET} ${TOMAHAWK_LIBRARIES} ) -qt5_use_modules(tomahawk_db_list_artists_bin Core) -install( TARGETS tomahawk_db_list_artists_bin BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - -set( tomahawk_db_fuzzysearch_src - fuzzysearch.cpp -) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_executable( tomahawk_db_fuzzysearch_bin WIN32 MACOSX_BUNDLE - ${tomahawk_db_fuzzysearch_src} ) -set_target_properties( tomahawk_db_fuzzysearch_bin - PROPERTIES - AUTOMOC TRUE - RUNTIME_OUTPUT_NAME tomahawk-db-fuzzysearch -) -target_link_libraries( tomahawk_db_fuzzysearch_bin - ${TOMAHAWK_LIBRARIES} -) - -qt5_use_modules(tomahawk_db_list_artists_bin Core) -install( TARGETS tomahawk_db_list_artists_bin BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) +qt5_use_modules(${TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET} Core) +install( TARGETS ${TOMAHAWK_TOOL_DB_LIST_ARTISTS_TARGET} BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/src/tools/tomahawk-test-musicscan/CMakeLists.txt b/src/tools/tomahawk-test-musicscan/CMakeLists.txt index d12d380da..097e3fc08 100644 --- a/src/tools/tomahawk-test-musicscan/CMakeLists.txt +++ b/src/tools/tomahawk-test-musicscan/CMakeLists.txt @@ -1,17 +1,19 @@ +set(TOMAHAWK_TOOL_MUSICSCAN_TARGET ${TOMAHAWK_TARGET_NAME}-musicscan) + set( tomahawk_test_musicscan_src main.cpp ) -add_executable( tomahawk_test_musicscan_bin WIN32 MACOSX_BUNDLE +add_executable( ${TOMAHAWK_TOOL_MUSICSCAN_TARGET} WIN32 MACOSX_BUNDLE ${tomahawk_test_musicscan_src} ) -set_target_properties( tomahawk_test_musicscan_bin +set_target_properties( ${TOMAHAWK_TOOL_MUSICSCAN_TARGET} PROPERTIES AUTOMOC TRUE - RUNTIME_OUTPUT_NAME tomahawk-test-musicscan ) -target_link_libraries( tomahawk_test_musicscan_bin + +target_link_libraries( ${TOMAHAWK_TOOL_MUSICSCAN_TARGET} ${TOMAHAWK_LIBRARIES} ) -qt5_use_modules(tomahawk_test_musicscan_bin Core Gui Network Widgets) -install( TARGETS tomahawk_test_musicscan_bin BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) +qt5_use_modules(${TOMAHAWK_TOOL_MUSICSCAN_TARGET} Core Gui Network Widgets) +install( TARGETS ${TOMAHAWK_TOOL_MUSICSCAN_TARGET} BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/src/viewpages/charts/CMakeLists.txt b/src/viewpages/charts/CMakeLists.txt index e6653fde4..7ceec74bf 100644 --- a/src/viewpages/charts/CMakeLists.txt +++ b/src/viewpages/charts/CMakeLists.txt @@ -6,5 +6,5 @@ tomahawk_add_plugin(charts UI ChartsWidget.ui LINK_LIBRARIES - tomahawk-widgets + ${TOMAHAWK_WIDGETS_LIBRARIES} ) diff --git a/src/viewpages/dashboard/CMakeLists.txt b/src/viewpages/dashboard/CMakeLists.txt index f3cadb023..08ed901fa 100644 --- a/src/viewpages/dashboard/CMakeLists.txt +++ b/src/viewpages/dashboard/CMakeLists.txt @@ -6,5 +6,5 @@ tomahawk_add_plugin(dashboard UI DashboardWidget.ui LINK_LIBRARIES - tomahawk-widgets + ${TOMAHAWK_WIDGETS_LIBRARIES} ) diff --git a/src/viewpages/newreleases/CMakeLists.txt b/src/viewpages/newreleases/CMakeLists.txt index 70291205b..3d4dfb8db 100644 --- a/src/viewpages/newreleases/CMakeLists.txt +++ b/src/viewpages/newreleases/CMakeLists.txt @@ -6,5 +6,5 @@ tomahawk_add_plugin(newreleases UI NewReleasesWidget.ui LINK_LIBRARIES - tomahawk-widgets + ${TOMAHAWK_WIDGETS_LIBRARIES} ) diff --git a/src/viewpages/whatsnew_0_8/CMakeLists.txt b/src/viewpages/whatsnew_0_8/CMakeLists.txt index dc3ae1ab5..50fa3ef3c 100644 --- a/src/viewpages/whatsnew_0_8/CMakeLists.txt +++ b/src/viewpages/whatsnew_0_8/CMakeLists.txt @@ -6,5 +6,5 @@ tomahawk_add_plugin(whatsnew_0_8 UI WhatsNewWidget_0_8.ui LINK_LIBRARIES - tomahawk-widgets + ${TOMAHAWK_WIDGETS_LIBRARIES} ) From fc413ac1036e1956dde2475e135c3685d8825789 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 15 Jan 2016 04:07:06 +0100 Subject: [PATCH 02/11] Fix download all assert/crash --- src/libtomahawk/viewpages/CollectionViewPage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/viewpages/CollectionViewPage.cpp b/src/libtomahawk/viewpages/CollectionViewPage.cpp index c388c7362..af343281f 100644 --- a/src/libtomahawk/viewpages/CollectionViewPage.cpp +++ b/src/libtomahawk/viewpages/CollectionViewPage.cpp @@ -462,7 +462,9 @@ CollectionViewPage::onDownloadAll() PlayableItem* item = m_trackView->proxyModel()->itemFromIndex( m_trackView->proxyModel()->mapToSource( m_trackView->proxyModel()->index( i, 0, QModelIndex() ) ) ); if ( !item ) continue; - if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + + QList< DownloadFormat > formats = item->query()->results().first()->downloadFormats(); + if ( formats.isEmpty() || !DownloadManager::instance()->localFileForDownload( formats.first().url.toString() ).isEmpty() ) continue; if ( !item->result()->downloadFormats().isEmpty() ) From 996d112ebbcec3b0b503e48ca17f7189707503a2 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 17 Jan 2016 03:33:05 +0100 Subject: [PATCH 03/11] Fix DropDownButton font size and boldness --- src/libtomahawk/widgets/DropDownButton.cpp | 17 +++++++++++++++-- src/libtomahawk/widgets/DropDownButton.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/widgets/DropDownButton.cpp b/src/libtomahawk/widgets/DropDownButton.cpp index 8f315b718..72161c6cb 100644 --- a/src/libtomahawk/widgets/DropDownButton.cpp +++ b/src/libtomahawk/widgets/DropDownButton.cpp @@ -46,6 +46,9 @@ DropDownButton::paintEvent( QPaintEvent* event ) { // QComboBox::paintEvent( event ); QPainter p( this ); + + setupPainter( &p ); + drawPrimitive( &p, contentsRect(), currentText(), true, true ); } @@ -54,8 +57,8 @@ void DropDownButton::drawPrimitive( QPainter* p, const QRect& rect, const QString& text, bool hovering, bool itemsAvailable ) { p->save(); - QFont f = p->font(); - f.setPointSize( 8 ); + + setupPainter( p ); p->setRenderHint( QPainter::TextAntialiasing ); QRect r = rect.adjusted( 2, 2, -2, -2 ); @@ -113,3 +116,13 @@ DropDownButton::mousePressEvent( QMouseEvent* event ) event->accept(); emit clicked(); } + + +void +DropDownButton::setupPainter( QPainter* p ) +{ + QFont f = p->font(); + f.setPointSize( TomahawkUtils::defaultFontSize() - 1 ); + f.setBold( true ); + p->setFont( f ); +} diff --git a/src/libtomahawk/widgets/DropDownButton.h b/src/libtomahawk/widgets/DropDownButton.h index b0d2c6415..e192b67c7 100644 --- a/src/libtomahawk/widgets/DropDownButton.h +++ b/src/libtomahawk/widgets/DropDownButton.h @@ -46,6 +46,7 @@ protected: private slots: private: + static void setupPainter( QPainter* p ); }; #endif // DROPDOWNBUTTON_H From f95bd4aab8c381acd5273f7c72db6fe5d41a0e60 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 17 Jan 2016 05:17:15 +0100 Subject: [PATCH 04/11] Correctly paint hover state in DropDownButton --- src/libtomahawk/widgets/DropDownButton.cpp | 20 +++++++++++++++++++- src/libtomahawk/widgets/DropDownButton.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/widgets/DropDownButton.cpp b/src/libtomahawk/widgets/DropDownButton.cpp index 72161c6cb..74aa344d1 100644 --- a/src/libtomahawk/widgets/DropDownButton.cpp +++ b/src/libtomahawk/widgets/DropDownButton.cpp @@ -32,7 +32,9 @@ using namespace Tomahawk; DropDownButton::DropDownButton( QWidget* parent ) : QComboBox( parent ) + , m_hovering( false ) { + setAttribute( Qt::WA_Hover, true ); } @@ -49,7 +51,7 @@ DropDownButton::paintEvent( QPaintEvent* event ) setupPainter( &p ); - drawPrimitive( &p, contentsRect(), currentText(), true, true ); + drawPrimitive( &p, contentsRect(), currentText(), m_hovering, true ); } @@ -118,6 +120,22 @@ DropDownButton::mousePressEvent( QMouseEvent* event ) } +void +DropDownButton::enterEvent( QEvent * event ) +{ + m_hovering = true; + QWidget::enterEvent(event); +} + + +void +DropDownButton::leaveEvent( QEvent* event ) +{ + m_hovering = false; + QWidget::leaveEvent(event); +} + + void DropDownButton::setupPainter( QPainter* p ) { diff --git a/src/libtomahawk/widgets/DropDownButton.h b/src/libtomahawk/widgets/DropDownButton.h index e192b67c7..48de535d4 100644 --- a/src/libtomahawk/widgets/DropDownButton.h +++ b/src/libtomahawk/widgets/DropDownButton.h @@ -42,11 +42,15 @@ signals: protected: void paintEvent( QPaintEvent* event ); void mousePressEvent( QMouseEvent* event ); + void enterEvent( QEvent* event ); + void leaveEvent( QEvent* event ); private slots: private: static void setupPainter( QPainter* p ); + + bool m_hovering; }; #endif // DROPDOWNBUTTON_H From 6416b34e8c651ad3443f39a04d8abbe7473fe040 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 18 Jan 2016 03:52:53 +0100 Subject: [PATCH 05/11] Don't reset column sort order on collection updated --- src/libtomahawk/viewpages/CollectionViewPage.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/viewpages/CollectionViewPage.cpp b/src/libtomahawk/viewpages/CollectionViewPage.cpp index af343281f..33c8c1b90 100644 --- a/src/libtomahawk/viewpages/CollectionViewPage.cpp +++ b/src/libtomahawk/viewpages/CollectionViewPage.cpp @@ -79,8 +79,9 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Score ), true ); m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Bitrate ), true ); - m_trackView->setGuid( QString( "trackview/flat" ) ); + m_trackView->setSortingEnabled( true ); + m_trackView->sortByColumn( 0, Qt::AscendingOrder ); { m_albumView->setAutoResize( false ); @@ -204,8 +205,6 @@ CollectionViewPage::setFlatModel( PlayableModel* model ) m_flatModel = model; m_trackView->setPlayableModel( model ); - m_trackView->setSortingEnabled( true ); - m_trackView->sortByColumn( 0, Qt::AscendingOrder ); if ( oldModel ) { From a5693d6663f4c837a72e803193ed302d30874d25 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 18 Jan 2016 06:14:51 +0100 Subject: [PATCH 06/11] Workaround preview widget flicker in column view --- src/libtomahawk/playlist/ColumnView.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libtomahawk/playlist/ColumnView.cpp b/src/libtomahawk/playlist/ColumnView.cpp index 7ba196492..08eb6962c 100644 --- a/src/libtomahawk/playlist/ColumnView.cpp +++ b/src/libtomahawk/playlist/ColumnView.cpp @@ -118,6 +118,10 @@ ColumnView::setModel( QAbstractItemModel* model ) void ColumnView::setTreeModel( TreeModel* model ) { + // HACK: without setting a new preview widget, the old preview widget is shown in the first column while loading the artists. + m_previewWidget = new ColumnViewPreviewWidget( this ); + setPreviewWidget( m_previewWidget ); + m_model = model; if ( m_proxyModel ) From 87278456f4319574556eb8213d96f36d015c219d Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 3 Feb 2016 13:28:43 +0100 Subject: [PATCH 07/11] Add download context menu to all playlist views but database collections --- src/libtomahawk/playlist/TrackView.cpp | 35 ++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index bedde7a41..fd8241d0b 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -775,24 +775,42 @@ TrackView::onCustomContextMenu( const QPoint& pos ) m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened | ContextMenu::ActionDelete ); - if ( proxyModel()->style() == PlayableProxyModel::Locker ) + if ( proxyModel()->style() != PlayableProxyModel::Collection ) { bool allDownloaded = true; + bool noneDownloadable = true; + bool downloadable = false; foreach ( const QModelIndex& index, selectedIndexes() ) { if ( index.column() ) continue; PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) ); - if ( DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + + if( item->query()->results().isEmpty() ) + continue; + + downloadable = !item->query()->results().first()->downloadFormats().isEmpty(); + if ( downloadable ) + { + noneDownloadable = false; + } + + if ( downloadable && DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) { allDownloaded = false; + } + + if ( !allDownloaded || !noneDownloadable ) + { break; } } - if ( !allDownloaded ) + if ( !allDownloaded || !noneDownloadable ) + { m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDownload ); + } } QList queries; @@ -915,13 +933,16 @@ TrackView::downloadSelectedItems() PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) ); - if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) - continue; if ( !item ) continue; - if ( !item->result()->downloadFormats().isEmpty() ) - DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) ); + if ( item->query()->results().isEmpty() || item->query()->results().first()->downloadFormats().isEmpty() ) + continue; + + if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() ) + continue; + + DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) ); } } From 0bdb8061e2233cb6d14d8b77a20b12595628c1de Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 11 Feb 2016 00:55:23 +0100 Subject: [PATCH 08/11] Do not set empty mimetype on results --- src/libtomahawk/resolvers/ScriptAccount.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/resolvers/ScriptAccount.cpp b/src/libtomahawk/resolvers/ScriptAccount.cpp index 0d2f3ebdb..11156b210 100644 --- a/src/libtomahawk/resolvers/ScriptAccount.cpp +++ b/src/libtomahawk/resolvers/ScriptAccount.cpp @@ -370,11 +370,17 @@ ScriptAccount::parseResultVariantList( const QVariantList& reslist ) // rp->track()->setAttributes( attr ); } - rp->setMimetype( m.value( "mimetype" ).toString() ); - if ( rp->mimetype().isEmpty() ) + + QString mimetype = m.value( "mimetype" ).toString(); + if ( mimetype.isEmpty() ) { - rp->setMimetype( TomahawkUtils::extensionToMimetype( m.value( "extension" ).toString() ) ); - Q_ASSERT( !rp->mimetype().isEmpty() ); + mimetype = TomahawkUtils::extensionToMimetype( m.value( "extension" ).toString() ); + } + Q_ASSERT( !mimetype.isEmpty() ); + + if ( !mimetype.isEmpty() ) + { + rp->setMimetype( mimetype ); } rp->setFriendlySource( name() ); From 3808e230d49d5cb0a11bf0e0c77864007c959a6c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 11 Feb 2016 02:10:05 +0100 Subject: [PATCH 09/11] Make result more thread safe --- src/libtomahawk/Result.cpp | 115 +++++++++++++++++++++++++++++++------ src/libtomahawk/Result.h | 3 + 2 files changed, 101 insertions(+), 17 deletions(-) diff --git a/src/libtomahawk/Result.cpp b/src/libtomahawk/Result.cpp index 6c4f7c347..04f5587de 100644 --- a/src/libtomahawk/Result.cpp +++ b/src/libtomahawk/Result.cpp @@ -132,6 +132,8 @@ Result::deleteLater() void Result::onResolverRemoved( Tomahawk::Resolver* resolver ) { + QMutexLocker lock( &m_mutex ); + if ( m_resolver.data() == resolver ) { m_resolver = 0; @@ -143,6 +145,8 @@ Result::onResolverRemoved( Tomahawk::Resolver* resolver ) collection_ptr Result::resolvedByCollection() const { + QMutexLocker lock( &m_mutex ); + return m_collection; } @@ -150,6 +154,8 @@ Result::resolvedByCollection() const QString Result::url() const { + QMutexLocker lock( &m_mutex ); + return m_url; } @@ -157,6 +163,8 @@ Result::url() const bool Result::checked() const { + QMutexLocker lock( &m_mutex ); + return m_checked; } @@ -164,6 +172,8 @@ Result::checked() const bool Result::isPreview() const { + QMutexLocker lock( &m_mutex ); + return m_isPreview; } @@ -171,6 +181,8 @@ Result::isPreview() const QString Result::mimetype() const { + QMutexLocker lock( &m_mutex ); + return m_mimetype; } @@ -178,6 +190,8 @@ Result::mimetype() const RID Result::id() const { + QMutexLocker lock( &m_mutex ); + if ( m_rid.isEmpty() ) m_rid = uuid(); @@ -194,6 +208,8 @@ Result::isOnline() const } else { + QMutexLocker lock( &m_mutex ); + return !m_resolver.isNull(); } } @@ -214,24 +230,26 @@ Result::playable() const QVariant Result::toVariant() const { + track_ptr t = track(); + QVariantMap m; - m.insert( "artist", m_track->artist() ); - m.insert( "album", m_track->album() ); - m.insert( "track", m_track->track() ); + m.insert( "artist", t->artist() ); + m.insert( "album", t->album() ); + m.insert( "track", t->track() ); m.insert( "source", friendlySource() ); m.insert( "mimetype", mimetype() ); m.insert( "size", size() ); m.insert( "bitrate", bitrate() ); - m.insert( "duration", m_track->duration() ); + m.insert( "duration", t->duration() ); // m.insert( "score", score() ); m.insert( "sid", id() ); - m.insert( "discnumber", m_track->discnumber() ); - m.insert( "albumpos", m_track->albumpos() ); + m.insert( "discnumber", t->discnumber() ); + m.insert( "albumpos", t->albumpos() ); m.insert( "preview", isPreview() ); m.insert( "purchaseUrl", purchaseUrl() ); - if ( !m_track->composer().isEmpty() ) - m.insert( "composer", m_track->composer() ); + if ( !t->composer().isEmpty() ) + m.insert( "composer", t->composer() ); return m; } @@ -240,20 +258,25 @@ Result::toVariant() const QString Result::toString() const { - if ( m_track ) + m_mutex.lock(); + track_ptr track = m_track; + QString url = m_url; + m_mutex.unlock(); + + if ( track ) { return QString( "Result(%1) %2 - %3%4 (%5)" ) .arg( id() ) - .arg( m_track->artist() ) - .arg( m_track->track() ) - .arg( m_track->album().isEmpty() ? QString() : QString( " on %1" ).arg( m_track->album() ) ) - .arg( m_url ); + .arg( track->artist() ) + .arg( track->track() ) + .arg( track->album().isEmpty() ? QString() : QString( " on %1" ).arg( track->album() ) ) + .arg( url ); } else { return QString( "Result(%1) (%2)" ) .arg( id() ) - .arg( m_url ); + .arg( url ); } } @@ -261,6 +284,8 @@ Result::toString() const Tomahawk::query_ptr Result::toQuery() { + QMutexLocker l( &m_mutex ); + if ( m_query.isNull() ) { query_ptr query = Tomahawk::Query::get( m_track ); @@ -270,12 +295,15 @@ Result::toQuery() m_query = query->weakRef(); QList rl; - rl << weakRef().toStrongRef(); + rl << m_ownRef.toStrongRef(); + m_mutex.unlock(); query->addResults( rl ); + m_mutex.lock(); query->setResolveFinished( true ); return query; } + return m_query.toStrongRef(); } @@ -297,7 +325,10 @@ Result::onOffline() void Result::setResolvedByCollection( const Tomahawk::collection_ptr& collection , bool emitOnlineEvents ) { + m_mutex.lock(); m_collection = collection; + m_mutex.unlock(); + if ( emitOnlineEvents ) { Q_ASSERT( !collection.isNull() ); @@ -311,6 +342,8 @@ Result::setResolvedByCollection( const Tomahawk::collection_ptr& collection , bo void Result::setFriendlySource( const QString& s ) { + QMutexLocker lock( &m_mutex ); + m_friendlySource = s; } @@ -318,6 +351,8 @@ Result::setFriendlySource( const QString& s ) void Result::setPreview( bool isPreview ) { + QMutexLocker lock( &m_mutex ); + m_isPreview = isPreview; } @@ -325,6 +360,8 @@ Result::setPreview( bool isPreview ) void Result::setPurchaseUrl( const QString& u ) { + QMutexLocker lock( &m_mutex ); + m_purchaseUrl = u; } @@ -332,6 +369,8 @@ Result::setPurchaseUrl( const QString& u ) void Result::setLinkUrl( const QString& u ) { + QMutexLocker lock( &m_mutex ); + m_linkUrl = u; } @@ -339,6 +378,8 @@ Result::setLinkUrl( const QString& u ) void Result::setChecked( bool checked ) { + QMutexLocker lock( &m_mutex ); + m_checked = checked; } @@ -346,6 +387,8 @@ Result::setChecked( bool checked ) void Result::setMimetype( const QString& mimetype ) { + QMutexLocker lock( &m_mutex ); + m_mimetype = mimetype; } @@ -353,6 +396,8 @@ Result::setMimetype( const QString& mimetype ) void Result::setBitrate( unsigned int bitrate ) { + QMutexLocker lock( &m_mutex ); + m_bitrate = bitrate; } @@ -360,6 +405,8 @@ Result::setBitrate( unsigned int bitrate ) void Result::setSize( unsigned int size ) { + QMutexLocker lock( &m_mutex ); + m_size = size; } @@ -367,6 +414,8 @@ Result::setSize( unsigned int size ) void Result::setModificationTime( unsigned int modtime ) { + QMutexLocker lock( &m_mutex ); + m_modtime = modtime; } @@ -374,6 +423,8 @@ Result::setModificationTime( unsigned int modtime ) void Result::setTrack( const track_ptr& track ) { + QMutexLocker lock( &m_mutex ); + m_track = track; } @@ -381,6 +432,8 @@ Result::setTrack( const track_ptr& track ) unsigned int Result::fileId() const { + QMutexLocker lock( &m_mutex ); + return m_fileId; } @@ -390,6 +443,8 @@ Result::friendlySource() const { if ( resolvedByCollection().isNull() ) { + QMutexLocker lock( &m_mutex ); + return m_friendlySource; } else @@ -400,6 +455,8 @@ Result::friendlySource() const QString Result::purchaseUrl() const { + QMutexLocker lock( &m_mutex ); + return m_purchaseUrl; } @@ -407,6 +464,8 @@ Result::purchaseUrl() const QString Result::linkUrl() const { + QMutexLocker lock( &m_mutex ); + return m_linkUrl; } @@ -416,6 +475,8 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c { if ( resolvedByCollection().isNull() ) { + //QMutexLocker lock( &m_mutex ); + const ExternalResolver* resolver = qobject_cast< ExternalResolver* >( m_resolver.data() ); if ( !resolver ) { @@ -466,6 +527,8 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c unsigned int Result::bitrate() const { + QMutexLocker lock( &m_mutex ); + return m_bitrate; } @@ -473,6 +536,8 @@ Result::bitrate() const unsigned int Result::size() const { + QMutexLocker lock( &m_mutex ); + return m_size; } @@ -480,6 +545,8 @@ Result::size() const unsigned int Result::modificationTime() const { + QMutexLocker lock( &m_mutex ); + return m_modtime; } @@ -487,6 +554,8 @@ Result::modificationTime() const void Result::setFileId( unsigned int id ) { + QMutexLocker lock( &m_mutex ); + m_fileId = id; } @@ -494,6 +563,8 @@ Result::setFileId( unsigned int id ) Tomahawk::Resolver* Result::resolvedBy() const { + QMutexLocker lock( &m_mutex ); + if ( !m_collection.isNull() ) return m_collection.data(); @@ -504,12 +575,16 @@ Result::resolvedBy() const void Result::setResolvedByResolver( Tomahawk::Resolver* resolver ) { + QMutexLocker lock( &m_mutex ); + m_resolver = QPointer< Tomahawk::Resolver >( resolver ); } QPointer< Resolver > Result::resolvedByResolver() const { + QMutexLocker lock( &m_mutex ); + return m_resolver; } @@ -525,6 +600,8 @@ Result::doneEditing() track_ptr Result::track() const { + QMutexLocker lock( &m_mutex ); + return m_track; } @@ -532,7 +609,7 @@ Result::track() const QList< DownloadFormat > Result::downloadFormats() const { - QMutexLocker lock( &s_mutex ); + QMutexLocker lock( &m_mutex ); return m_formats; } @@ -544,7 +621,7 @@ Result::setDownloadFormats( const QList& formats ) if ( formats.isEmpty() ) return; - QMutexLocker lock( &s_mutex ); + QMutexLocker lock( &m_mutex ); m_formats.clear(); foreach ( const DownloadFormat& format, formats ) @@ -610,6 +687,8 @@ Result::onDownloadJobStateChanged( DownloadJob::TrackState newState, DownloadJob QWeakPointer Result::weakRef() { + QMutexLocker lock( &m_mutex ); + return m_ownRef; } @@ -617,5 +696,7 @@ Result::weakRef() void Result::setWeakRef( QWeakPointer weakRef ) { + QMutexLocker lock( &m_mutex ); + m_ownRef = weakRef; } diff --git a/src/libtomahawk/Result.h b/src/libtomahawk/Result.h index 8f7a8624d..25f623c1a 100644 --- a/src/libtomahawk/Result.h +++ b/src/libtomahawk/Result.h @@ -31,6 +31,7 @@ #include #include #include +#include class MetadataEditor; @@ -161,6 +162,8 @@ private: explicit Result( const QString& url, const Tomahawk::track_ptr& track ); explicit Result(); + mutable QMutex m_mutex; + mutable RID m_rid; collection_wptr m_collection; QPointer< Tomahawk::Resolver > m_resolver; From 1b7b7ca4b3a3ccf9e6c895a1940f04382d3bb519 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 17 Feb 2016 14:27:43 +0100 Subject: [PATCH 10/11] Bump snorenotify requirement --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 768d2185b..50e44eed6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,7 @@ if( WIN32 ) endif( WIN32 ) if( WIN32 OR APPLE ) - macro_optional_find_package(LibsnoreQt5 0.5.70 QUIET) + macro_optional_find_package(LibsnoreQt5 0.6.0 QUIET) macro_log_feature(LibsnoreQt5_FOUND "Libsnore" "Library for notifications" "https://projects.kde.org/projects/playground/libs/snorenotify" FALSE "" "") endif() From 93745b19efcd6cfb1a8be92a7fea420f2b2bd065 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 17 Feb 2016 14:28:06 +0100 Subject: [PATCH 11/11] Deployment scripts branding update --- CMakeModules/NSIS.template.in | 7 +++---- TomahawkCPack.cmake | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeModules/NSIS.template.in b/CMakeModules/NSIS.template.in index 36d8d9a06..75c78e863 100644 --- a/CMakeModules/NSIS.template.in +++ b/CMakeModules/NSIS.template.in @@ -18,11 +18,10 @@ !ifndef MINGW_ROOT !define MINGW_ROOT "/usr/i686-w64-mingw32/sys-root/mingw" !endif - -!define APPLICATION_NAME "Tomahawk" -!define TARGET_NAME "tomahawk" +!define APPLICATION_NAME "@CPACK_PACKAGE_NAME@" +!define TARGET_NAME "@CPACK_PACKAGE_TARGET_NAME@" ;define app id needed for Windows 8 notifications -!define AppUserModelId @TOMAHAWK_APPLICATION_PACKAGE_NAME@ +!define AppUserModelId "@TOMAHAWK_APPLICATION_PACKAGE_NAME@" !define MINGW_BIN "${MINGW_ROOT}/bin" !define MINGW_LIB "${MINGW_ROOT}/lib" diff --git a/TomahawkCPack.cmake b/TomahawkCPack.cmake index 50fe6643c..2178d136b 100644 --- a/TomahawkCPack.cmake +++ b/TomahawkCPack.cmake @@ -13,7 +13,9 @@ SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY ${TOMAHAWK_DESCRIPTION_SUMMARY} ) # Des SET( CPACK_PACKAGE_INSTALL_DIRECTORY ${TOMAHAWK_APPLICATION_NAME} ) # Installation directory on the target system -> C:\Program Files\fellody SET( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${TOMAHAWK_APPLICATION_NAME} ) # Registry key used when installing this project CMake 2.5.0 SET( CPACK_PACKAGE_NAME ${TOMAHAWK_APPLICATION_NAME} ) # Package name, defaults to the project name +SET( CPACK_PACKAGE_TARGET_NAME ${TOMAHAWK_TARGET_NAME} ) # Used to build library and executable names SET( CPACK_PACKAGE_VENDOR ${TOMAHAWK_ORGANIZATION_NAME} ) # Package vendor name +SET( TOMAHAWK_APPLICATION_PACKAGE_NAME ${TOMAHAWK_APPLICATION_PACKAGE_NAME} ) SET( CPACK_PACKAGE_VERSION_MAJOR ${TOMAHAWK_VERSION_MAJOR} ) SET( CPACK_PACKAGE_VERSION_MINOR ${TOMAHAWK_VERSION_MINOR} ) SET( CPACK_PACKAGE_VERSION_PATCH ${TOMAHAWK_VERSION_PATCH} )