-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathprofiles.h
More file actions
192 lines (141 loc) · 6.6 KB
/
profiles.h
File metadata and controls
192 lines (141 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* Flacon - audio File Encoder
* https://github.com/flacon/flacon
*
* Copyright: 2019-2020
* Alexander Sokoloff <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef PROFILES_H
#define PROFILES_H
#include <QString>
#include <QVariant>
#include <QVector>
#include "formats_out/outformat.h"
#include "types.h"
class QSettings;
class Profile
{
using EncoderValues = QHash<QString, QVariant>;
public:
Profile() = default;
Profile(const Profile &other) = default;
Profile &operator=(const Profile &other) = default;
virtual ~Profile() = default;
Profile(const QString &formatId, const QString &id = "");
bool isValid() const noexcept;
QString id() const { return mId; }
QString name() const { return mName; }
void setName(const QString &value);
QString outFileDir() const { return mOutFileDir; }
void setOutFileDir(const QString &value);
QString outFilePattern() const { return mOutFilePattern; }
void setOutFilePattern(const QString &value);
GainType gainType() const { return mGainType; }
void setGainType(GainType value);
BitsPerSample bitsPerSample() const { return mBitsPerSample; }
void setBitsPerSample(BitsPerSample value);
SampleRate sampleRate() const { return mSampleRate; }
void setSampleRate(SampleRate value);
bool isCreateCue() const { return mCreateCue; }
void setCreateCue(bool value);
bool isEmbedCue() const { return mEmbedCue; }
void setEmbedCue(bool value);
bool isWriteSingleDiskNum() const { return mWriteSingleDiskNum; }
void setWriteSingleDiskNum(bool value);
QString cueFileName() const { return mCueFileName; }
void setCueFileName(const QString &value);
PreGapType pregapType() const { return mPregapType; }
void setPregapType(PreGapType value);
CoverOptions copyCoverOptions() const { return mCopyCoverOptions; }
void setCopyCoverOptions(const CoverOptions &value);
CoverOptions embedCoverOptions() const { return mEmbedCoverOptions; }
void setEmbedCoverOptions(const CoverOptions &value);
EncoderValues encoderValues() const { return mEncoderValues; }
void setEncoderValues(const EncoderValues &values);
QVariant encoderValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
void setEncoderValue(const QString &key, const QVariant &value);
const OutFormat *outFormat() const { return mFormat; }
QString formatId() const { return mFormat->id(); }
QString formatName() const { return mFormat->name(); }
QString ext() const { return mFormat->ext(); }
FormatOptions formatOptions() const { return mFormat->options(); }
BitsPerSample maxBitPerSample() const { return mFormat->maxBitPerSample(); }
SampleRate maxSampleRate() const { return mFormat->maxSampleRate(); }
QString tmpDir() const { return globalParams().mTmpDir; }
void setTmpDir(const QString &value);
uint encoderThreadsCount() const { return globalParams().mEncoderThreadsCount; }
void setEncoderThreadsCount(uint value);
static bool isSplitTrackTitle() { return globalParams().splitTrackTitle; }
static void setSplitTrackTitle(bool value);
QString resultFileName(const Track *track) const;
QString resultFileDir(const Track *track) const;
QString resultFilePath(const Track *track) const;
ProxyType proxyType() const { return globalParams().proxyType; }
void setProxyType(ProxyType value) { globalParams().proxyType = value; }
QString proxyHost() const { return globalParams().proxyHost; }
void setProxyHost(const QString &value) { globalParams().proxyHost = value; }
uint proxyPort() const { return globalParams().proxyPort; }
void setProxyPort(uint value) { globalParams().proxyPort = value; }
QString proxyUserName() const { return globalParams().proxyUserName; }
void setProxyUserName(const QString &value) { globalParams().proxyUserName = value; }
QString proxyPassword() const { return globalParams().proxyPassword; }
void setProxyPassword(const QString &value) { globalParams().proxyPassword = value; }
private:
QString mId;
QString mName;
QString mOutFileDir = defaultOutFileDir();
QString mOutFilePattern = "%a/{%y - }%A/%n - %t";
QString mCueFileName = "%a-%A.cue";
GainType mGainType = GainType::Disable;
BitsPerSample mBitsPerSample = BitsPerSample::AsSourcee;
SampleRate mSampleRate = SampleRate::AsSource;
PreGapType mPregapType = PreGapType::ExtractToFile;
bool mCreateCue = false;
bool mEmbedCue = false;
bool mWriteSingleDiskNum = true;
OutFormat *mFormat = nullptr;
CoverOptions mCopyCoverOptions = { CoverMode::Disable, 1024 };
CoverOptions mEmbedCoverOptions = { CoverMode::Disable, 1024 };
EncoderValues mEncoderValues;
struct GlobalParams
{
QString mTmpDir;
uint mEncoderThreadsCount = defaultEncoderThreadCount();
bool splitTrackTitle = true;
ProxyType proxyType = ProxyType::NoProxy;
QString proxyHost;
QString proxyUserName;
QString proxyPassword;
uint proxyPort = 0;
};
static GlobalParams &globalParams();
static QString defaultOutFileDir();
static uint defaultEncoderThreadCount();
QString calcResultFilePath(const Track *track) const;
};
class Profiles : public QVector<Profile>
{
public:
int indexOf(const QString &id, int from = 0) const;
Profile *find(const QString &id);
const Profile *find(const QString &id) const;
};
Profiles createStandardProfiles();
QDebug operator<<(QDebug dbg, const Profile &profile);
QDebug operator<<(QDebug dbg, const Profiles &profiles);
#endif // PROFILES_H