File indexing completed on 2024-05-05 04:49:24

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 #ifndef TRANSCODINGSELECTCONFIGWIDGET_H
0018 #define TRANSCODINGSELECTCONFIGWIDGET_H
0019 
0020 #include "amarok_transcoding_export.h"
0021 #include "core/transcoding/TranscodingConfiguration.h"
0022 
0023 #include <QComboBox>
0024 
0025 namespace Transcoding
0026 {
0027 
0028     /**
0029      * Convenience QComboBox subclass that can be used in collection configuration dialogs
0030      * to let user change/unset current transcoding preference for transferring tracks.
0031      */
0032     class AMAROK_TRANSCODING_EXPORT SelectConfigWidget : public QComboBox
0033     {
0034         Q_OBJECT
0035 
0036         public:
0037             explicit SelectConfigWidget( QWidget *parent = nullptr );
0038 
0039             /**
0040              * Fills the combobox widget with appropriate transcoding configurations.
0041              * "Just copy" and "Ask every time" options are always present.
0042              *
0043              * @param savedConfiguration current saved configuration or invalid one if no
0044              * saved config exists.
0045              */
0046             void fillInChoices( const Configuration &savedConfiguration );
0047 
0048             /**
0049              * Get current choice. Will return invalid configuration if called before
0050              * @see fillInChoices()
0051              */
0052             Configuration currentChoice() const;
0053 
0054             /**
0055              * Return true if currently selected choice is different from one that was
0056              * passed to fillInChoices()
0057              */
0058             bool hasChanged() const;
0059 
0060         private:
0061             enum Choice {
0062                 TranscodeAll,
0063                 TranscodeUnlessSameType,
0064                 TranscodeOnlyIfNeeded,
0065                 JustCopy,
0066                 Invalid
0067             };
0068 
0069             Q_DISABLE_COPY(SelectConfigWidget)
0070             Configuration m_passedChoice;
0071     };
0072 
0073 } // namespace Transcoding
0074 
0075 #endif // TRANSCODINGSELECTCONFIGWIDGET_H