File indexing completed on 2024-05-19 04:48:58
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "AlbumActionsCapability.h" 0018 0019 #include "core/meta/Meta.h" 0020 #include "covermanager/CoverFetchingActions.h" 0021 0022 #include <QIcon> 0023 #include <KLocalizedString> 0024 0025 class CompilationAction : public QAction 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 CompilationAction( QObject* parent, const Meta::AlbumPtr &album ) 0031 : QAction( parent ) 0032 , m_album( album ) 0033 { 0034 connect( this, &CompilationAction::triggered, this, &CompilationAction::slotTriggered ); 0035 if( m_album->isCompilation() ) 0036 { 0037 setIcon( QIcon::fromTheme( QStringLiteral("filename-artist-amarok") ) ); 0038 setText( i18n( "Do not show under Various Artists" ) ); 0039 } 0040 else 0041 { 0042 setIcon( QIcon::fromTheme( QStringLiteral("similarartists-amarok") ) ); 0043 setText( i18n( "Show under Various Artists" ) ); 0044 } 0045 setEnabled( m_album->canUpdateCompilation() ); 0046 } 0047 0048 private Q_SLOTS: 0049 void slotTriggered() 0050 { 0051 if( !m_album->canUpdateCompilation() ) 0052 return; 0053 m_album->setCompilation( !m_album->isCompilation() ); 0054 } 0055 0056 private: 0057 Meta::AlbumPtr m_album; 0058 }; 0059 0060 using namespace Capabilities; 0061 0062 AlbumActionsCapability::AlbumActionsCapability( const Meta::AlbumPtr &album, const QList<QAction *> &actions ) 0063 : ActionsCapability() 0064 { 0065 m_actions.append( new DisplayCoverAction( nullptr, album ) ); 0066 m_actions.append( new FetchCoverAction( nullptr, album ) ); 0067 m_actions.append( new SetCustomCoverAction( nullptr, album ) ); 0068 m_actions.append( new UnsetCoverAction( nullptr, album ) ); 0069 0070 QAction *separator = new QAction( nullptr ); 0071 separator->setSeparator( true ); 0072 m_actions.append( separator ); 0073 m_actions.append( new CompilationAction( nullptr, album ) ); 0074 0075 if( actions.isEmpty() ) 0076 return; 0077 separator = new QAction( nullptr ); 0078 separator->setSeparator( true ); 0079 m_actions.append( separator ); 0080 m_actions.append( actions ); 0081 } 0082 0083 AlbumActionsCapability::~AlbumActionsCapability() 0084 { 0085 // nothing to do 0086 } 0087 0088 #include "AlbumActionsCapability.moc"