1 /* BEGIN_COMMON_COPYRIGHT_HEADER 2 * (c)LGPL2+ 3 * 4 * Flacon - audio File Encoder 5 * https://github.com/flacon/flacon 6 * 7 * Copyright: 2019-2020 8 * Alexander Sokoloff <sokoloff.a@gmail.com> 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 * END_COMMON_COPYRIGHT_HEADER */ 25 26 #ifndef PROFILES_H 27 #define PROFILES_H 28 29 #include <QString> 30 #include <QVariant> 31 #include <QVector> 32 33 #include "formats_out/outformat.h" 34 class QSettings; 35 36 class Profile 37 { 38 friend QDebug operator<<(QDebug dbg, const Profile &profile); 39 40 public: 41 Profile(); 42 explicit Profile(const QString &id); 43 explicit Profile(OutFormat &format, const QString &id = ""); 44 Profile(const Profile &other) = default; 45 Profile &operator=(const Profile &other) = default; 46 id()47 QString id() const { return mId; } 48 name()49 QString name() const { return mName; } 50 void setName(const QString &value); 51 52 QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; 53 void setValue(const QString &key, const QVariant &value); 54 55 bool isValid() const noexcept; 56 57 QString outFileDir() const; 58 void setOutFileDir(const QString &value); 59 60 QString outFilePattern() const; 61 void setOutFilePattern(const QString &value); 62 63 GainType gainType() const; 64 void setGainType(GainType value); 65 66 int bitsPerSample() const; 67 void setBitsPerSample(int value); 68 69 SampleRate sampleRate() const; 70 void setSampleRate(SampleRate value); 71 72 bool isCreateCue() const; 73 void setCreateCue(bool value); 74 75 bool isEmbedCue() const; 76 void setEmbedCue(bool value); 77 78 QString cueFileName() const; 79 void setCueFileName(const QString &value); 80 81 PreGapType preGapType() const; 82 void setPregapType(PreGapType value); 83 outFormat()84 const OutFormat *outFormat() const { return mFormat; } formatId()85 QString formatId() const { return mFormat->id(); } formatName()86 QString formatName() const { return mFormat->name(); } ext()87 QString ext() const { return mFormat->ext(); } formatOptions()88 FormatOptions formatOptions() const { return mFormat->options(); } maxBitPerSample()89 BitsPerSample maxBitPerSample() const { return mFormat->maxBitPerSample(); } maxSampleRate()90 SampleRate maxSampleRate() const { return mFormat->maxSampleRate(); } 91 EncoderConfigPage *configPage(QWidget *parent) const; check(QStringList * errors)92 bool check(QStringList *errors) const { return mFormat->check(*this, errors); } 93 94 // Cover options ............................ 95 CoverOptions copyCoverOptions() const; 96 void setCopyCoverOptions(const CoverOptions ©CoverOptions); 97 98 CoverOptions embedCoverOptions() const; 99 void setEmbedCoverOptions(const CoverOptions &embedCoverOptions); 100 101 void load(QSettings &settings, const QString &group); 102 void save(QSettings &settings, const QString &group) const; 103 104 static constexpr const char *OUT_DIRECTORY_KEY = "OutDirectory"; 105 static constexpr const char *OUT_PATTERN_KEY = "OutPattern"; 106 static constexpr const char *BITS_PER_SAMPLE_KEY = "BitsPerSample"; 107 static constexpr const char *SAMPLE_RATE_KEY = "SampleRate"; 108 static constexpr const char *CREATE_CUE_KEY = "CreateCue"; 109 static constexpr const char *EMBED_CUE_KEY = "EmbedCue"; 110 static constexpr const char *CUE_FILE_NAME_KEY = "CueFileName"; 111 static constexpr const char *PREGAP_TYPE_KEY = "PregapType"; 112 static constexpr const char *REPLAY_GAIN_KEY = "ReplayGain"; 113 static constexpr const char *COVER_FILE_MODE_KEY = "CoverFile/Mode"; 114 static constexpr const char *COVER_FILE_SIZE_KEY = "CoverFile/Size"; 115 static constexpr const char *COVER_EMBED_MODE_KEY = "CoverEmbed/Mode"; 116 static constexpr const char *COVER_EMBED_SIZE_KEY = "CoverEmbed/Size"; 117 118 private: 119 QString mId; 120 const OutFormat *mFormat; 121 QString mName; 122 QHash<QString, QVariant> mValues; 123 void setDefaultValues(); 124 125 CoverOptions mCopyCoverOptions; 126 CoverOptions mEmbedCoverOptions; 127 bool mSupportEmbedCover = false; 128 }; 129 130 Profile &NullProfile(); 131 132 class Profiles : public QVector<Profile> 133 { 134 public: 135 int indexOf(const QString &id, int from = 0) const; 136 bool update(const Profile &profile); 137 }; 138 139 QDebug operator<<(QDebug dbg, const Profile &profile); 140 QDebug operator<<(QDebug dbg, const Profiles &profiles); 141 142 #endif // PROFILES_H 143