File indexing completed on 2024-05-19 04:50:17

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org>                                *
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 "MagnatuneCollectionLocation.h"
0018 
0019 #include <QDialog>
0020 #include <QDialogButtonBox>
0021 #include <QLabel>
0022 #include <QVBoxLayout>
0023 
0024 #include <KLocalizedString>
0025 #include <KConfigGroup>
0026 
0027 using namespace Collections;
0028 
0029 MagnatuneCollectionLocation::MagnatuneCollectionLocation( MagnatuneSqlCollection *parentCollection )
0030     : ServiceCollectionLocation( parentCollection )
0031 {
0032 }
0033 
0034 
0035 MagnatuneCollectionLocation::~MagnatuneCollectionLocation()
0036 {
0037 }
0038 
0039 void MagnatuneCollectionLocation::showSourceDialog( const Meta::TrackList &tracks, bool removeSources )
0040 {
0041     QDialog dialog;
0042     dialog.setWindowTitle( i18n( "Preview Tracks" ) );
0043 
0044     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
0045     QVBoxLayout *mainLayout = new QVBoxLayout;
0046     dialog.setLayout(mainLayout);
0047 
0048     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0049     okButton->setDefault(true);
0050     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0051     connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
0052     connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
0053 
0054     QLabel *label = new QLabel( i18n( "The tracks you are about to copy are Magnatune.com preview streams. For better quality and advert free streams, consider buying an album download. Remember that when buying from Magnatune the artist gets 50%. Also if you buy using Amarok, you support the Amarok project with 10%." ) );
0055 
0056     label->setWordWrap ( true );
0057     label->setMaximumWidth( 400 );
0058     
0059     mainLayout->addWidget(label);
0060     mainLayout->addWidget(buttonBox);
0061     dialog.exec();
0062 
0063     if ( dialog.result() == QDialog::Rejected )
0064         abort();
0065 
0066     CollectionLocation::showSourceDialog( tracks, removeSources ); // to get transcoding dialog
0067 }