TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsettingmanager.h
Go to the documentation of this file.
1 #ifndef MUSICSETTINGMANAGER
2 #define MUSICSETTINGMANAGER
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2025 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QMetaEnum>
23 #include "musicobject.h"
24 #include "ttksingleton.h"
25 
29 class TTK_MODULE_EXPORT MusicSettingManager : public QObject
30 {
31  Q_OBJECT
32  Q_ENUMS(Config)
35 public:
36  enum Config
37  {
38  Null = -1,
39  ScreenSize = 0x1000,
40  WidgetPosition = 0x1001,
41  WidgetSize = 0x1002,
42  UserPermission = 0x1003,
43  //
44  ConfigVersion = 0x2000,
45  PlayMode = 0x2001,
46  Volume = 0x2002,
47  LastPlayIndex = 0x2003,
48  //
49  LanguageIndex = 0x3000,
50  StartUpMode = 0x3001,
51  StartUpPlayMode = 0x3002,
52  CloseEventMode = 0x3003,
53  CloseNetWorkMode = 0x3004,
54  FileAssociationMode = 0x3005,
55  FileAssociationValue = 0x3006,
56  WindowConciseMode = 0x3007,
57  RemoteWidgetMode = 0x3008,
58  WindowQuitMode = 0x3009,
59  ExtraDevicePath = 0x300A,
60  LastFileDialogPath = 0x300B,
61  MediaLibraryPath = 0x300C,
62  //
63  BackgroundThemeValue = 0x4000,
64  BackgroundTransparent = 0x4001,
65  BackgroundListTransparent = 0x4002,
66  BackgroundTransparentEnable = 0x4003,
67  //
68  HotkeyEnable = 0x5000,
69  HotkeyValue = 0x5001,
70  //
71  OtherCheckUpdateEnable = 0x6000,
72  OtherReadAlbumCover = 0x6001,
73  OtherReadFileInfo = 0x6002,
74  OtherWriteAlbumCover = 0x6003,
75  OtherWriteFileInfo = 0x6004,
76  OtherSideByMode = 0x6005,
77  OtherSideByInMode = 0x6006,
78  OtherLrcKTVMode = 0x6007,
79  OtherScreenSaverEnable = 0x6008,
80  OtherScreenSaverTime = 0x6009,
81  OtherScreenSaverIndex = 0x600A,
82  OtherPlaylistAutoSaveEnable = 0x600B,
83  OtherRandomShuffleMode = 0x600C,
84  OtherHighDpiScalingEnable = 0x600D,
85  OtherLogTrackEnable = 0x600E,
86  //
87  RippleLowPowerMode = 0x7000,
88  RippleSpectrumEnable = 0x7001,
89  RippleSpectrumColor = 0x7002,
90  RippleSpectrumTransparent = 0x7003,
91  //
92  ShowInteriorLrc = 0x8000,
93  LrcColor = 0x8001,
94  LrcSize = 0x8002,
95  LrcType = 0x8003,
96  LrcFamily = 0x8004,
97  LrcFrontgroundColor = 0x8005,
98  LrcBackgroundColor = 0x8006,
99  LrcColorTransparent = 0x8007,
100  //
101  ShowDesktopLrc = 0x9000,
102  DLrcColor = 0x9001,
103  DLrcSize = 0x9002,
104  DLrcType = 0x9003,
105  DLrcFamily = 0x9004,
106  DLrcFrontgroundColor = 0x9005,
107  DLrcBackgroundColor = 0x9006,
108  DLrcColorTransparent = 0x9007,
109  DLrcWindowMode = 0x9008,
110  DLrcSingleLineMode = 0x9009,
111  DLrcLockedMode = 0x900A,
112  DLrcGeometry = 0x900B,
113  //
114  EqualizerEnable = 0xA000,
115  EqualizerValue = 0xA001,
116  EqualizerIndex = 0xA002,
117  EnhancedMusicIndex = 0xA003,
118  EnhancedFadeEnable = 0xA004,
119  EnhancedFadeInValue = 0xA005,
120  EnhancedFadeOutValue = 0xA006,
121  EnhancedEffectValue = 0xA007,
122  //
123  TimerAutoIndex = 0xB000,
124  TimerAutoPlayMode = 0xB001,
125  TimerAutoPlayHour = 0xB002,
126  TimerAutoPlaySecond = 0xB003,
127  TimerAutoPlayRepeat = 0xB004,
128  TimerAutoPlayItemIndex = 0xB005,
129  TimerAutoPlaySongIndex = 0xB006,
130  TimerAutoStopMode = 0xB007,
131  TimerAutoStopHour = 0xB008,
132  TimerAutoStopSecond = 0xB009,
133  TimerAutoStopRepeat = 0xB00A,
134  TimerAutoShutdownMode = 0xB00B,
135  TimerAutoShutdownHour = 0xB00C,
136  TimerAutoShutdownSecond = 0xB00D,
137  TimerAutoShutdownRepeat = 0xB00E,
138  //
139  DownloadMusicDirPath = 0xC000,
140  DownloadLrcDirPath = 0xC001,
141  DownloadServerIndex = 0xC002,
142  DownloadCacheEnable = 0xC003,
143  DownloadCacheSize = 0xC004,
144  DownloadLimitEnable = 0xC005,
145  DownloadDownloadLimitSize = 0xC006,
146  DownloadUploadLimitSize = 0xC007,
147  DownloadFileNameRule = 0xC008,
148  };
149 
153  inline void setValue(Config type, const QVariant &var) noexcept
154  {
155  m_parameter[type] = var;
156  }
157 
161  inline void setValue(const QString &stype, const QVariant &var) noexcept
162  {
163  m_parameter[stringToEnum(stype)] = var;
164  }
165 
169  inline QVariant value(Config type) const noexcept
170  {
171  return m_parameter[type];
172  }
173 
177  inline QVariant value(const QString &stype) const noexcept
178  {
179  return m_parameter[stringToEnum(stype)];
180  }
181 
185  inline int count() const noexcept
186  {
187  return m_parameter.count();
188  }
189 
193  inline bool isEmpty() const noexcept
194  {
195  return m_parameter.isEmpty();
196  }
197 
201  inline bool contains(Config type) const noexcept
202  {
203  return m_parameter.contains(type);
204  }
205 
206 private:
210  inline Config stringToEnum(const QString &stype) const
211  {
212  const int index = staticMetaObject.indexOfEnumerator("Config");
213  const QMetaEnum &metaEnum = staticMetaObject.enumerator(index);
214  const int key = metaEnum.keyToValue(stype.toStdString().c_str());
215  return TTKStaticCast(Config, key);
216  }
217 
218  QVariant m_variant;
219  QMap<Config, QVariant> m_parameter;
220 
221 };
222 
223 #define G_SETTING_PTR makeMusicSettingManager()
225 
226 #endif // MUSICSETTINGMANAGER
227 
bool isEmpty() const noexcept
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:231
#define TTK_MODULE_EXPORT
QMap< Config, QVariant > m_parameter
void setValue(const QString &stype, const QVariant &var) noexcept
QVariant value(Config type) const noexcept
The Volume class provides asbtract volume interface.
Definition: volume.h:51
bool contains(Config type) const noexcept
void setValue(Config type, const QVariant &var) noexcept
int count() const noexcept
#define TTK_DECLARE_SINGLETON_CLASS(Class)
// Singleton Macro // //
Definition: ttksingleton.h:86
PlayMode
Definition: musicobject.h:185
static constexpr wchar_t key[]
QVariant value(const QString &stype) const noexcept
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:164
Config stringToEnum(const QString &stype) const
TTK_MODULE_EXPORT MusicSettingManager * makeMusicSettingManager()
#define const
Definition: zconf.h:233
The class of the paramater setting manager.