TTKMusicPlayer  4.3.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 - 2026 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)
34 public:
35  enum Config
36  {
37  Null = -1,
38  ScreenSize = 0x1000,
39  WidgetPosition = 0x1001,
40  WidgetSize = 0x1002,
41  //
42  ConfigVersion = 0x2000,
43  PlayMode = 0x2001,
44  Volume = 0x2002,
45  LastPlayIndex = 0x2003,
46  UserPermission = 0x2004,
47  //
48  LanguageIndex = 0x3000,
49  StartUpMode = 0x3001,
50  StartUpPlayMode = 0x3002,
51  CloseEventMode = 0x3003,
52  CloseNetWorkMode = 0x3004,
53  FileAssociationMode = 0x3005,
54  FileAssociationValue = 0x3006,
55  WindowConciseMode = 0x3007,
56  RemoteWidgetMode = 0x3008,
57  WindowQuitMode = 0x3009,
58  ExtraDevicePath = 0x300A,
59  LastFileDialogPath = 0x300B,
60  MediaLibraryPath = 0x300C,
61  //
62  BackgroundThemeValue = 0x4000,
63  BackgroundTransparent = 0x4001,
64  BackgroundListTransparent = 0x4002,
65  BackgroundTransparentEnable = 0x4003,
66  //
67  HotkeyEnable = 0x5000,
68  HotkeyValue = 0x5001,
69  //
70  OtherCheckUpdateEnable = 0x6000,
71  OtherReadAlbumCover = 0x6001,
72  OtherReadFileInfo = 0x6002,
73  OtherWriteAlbumCover = 0x6003,
74  OtherWriteFileInfo = 0x6004,
75  OtherSideByMode = 0x6005,
76  OtherSideByInMode = 0x6006,
77  OtherLrcKTVMode = 0x6007,
78  OtherScreenSaverEnable = 0x6008,
79  OtherScreenSaverTime = 0x6009,
80  OtherScreenSaverIndex = 0x600A,
81  OtherPlaylistAutoSaveEnable = 0x600B,
82  OtherRandomShuffleMode = 0x600C,
83  OtherHighDpiScalingEnable = 0x600D,
84  OtherLogTrackEnable = 0x600E,
85  //
86  RippleLowPowerMode = 0x7000,
87  RippleSpectrumEnable = 0x7001,
88  RippleSpectrumColor = 0x7002,
89  RippleSpectrumTransparent = 0x7003,
90  //
91  ShowInteriorLrc = 0x8000,
92  LrcColor = 0x8001,
93  LrcSize = 0x8002,
94  LrcType = 0x8003,
95  LrcFamily = 0x8004,
96  LrcFrontgroundColor = 0x8005,
97  LrcBackgroundColor = 0x8006,
98  LrcColorTransparent = 0x8007,
99  //
100  ShowDesktopLrc = 0x9000,
101  DLrcColor = 0x9001,
102  DLrcSize = 0x9002,
103  DLrcType = 0x9003,
104  DLrcFamily = 0x9004,
105  DLrcFrontgroundColor = 0x9005,
106  DLrcBackgroundColor = 0x9006,
107  DLrcColorTransparent = 0x9007,
108  DLrcWindowMode = 0x9008,
109  DLrcSingleLineMode = 0x9009,
110  DLrcLockedMode = 0x900A,
111  DLrcGeometry = 0x900B,
112  //
113  EqualizerEnable = 0xA000,
114  EqualizerValue = 0xA001,
115  EqualizerIndex = 0xA002,
116  EnhancedMusicIndex = 0xA003,
117  EnhancedFadeEnable = 0xA004,
118  EnhancedFadeInValue = 0xA005,
119  EnhancedFadeOutValue = 0xA006,
120  EnhancedEffectValue = 0xA007,
121  //
122  TimerAutoIndex = 0xB000,
123  TimerAutoPlayMode = 0xB001,
124  TimerAutoPlayHour = 0xB002,
125  TimerAutoPlaySecond = 0xB003,
126  TimerAutoPlayRepeat = 0xB004,
127  TimerAutoPlayItemIndex = 0xB005,
128  TimerAutoPlaySongIndex = 0xB006,
129  TimerAutoStopMode = 0xB007,
130  TimerAutoStopHour = 0xB008,
131  TimerAutoStopSecond = 0xB009,
132  TimerAutoStopRepeat = 0xB00A,
133  TimerAutoShutdownMode = 0xB00B,
134  TimerAutoShutdownHour = 0xB00C,
135  TimerAutoShutdownSecond = 0xB00D,
136  TimerAutoShutdownRepeat = 0xB00E,
137  //
138  DownloadMusicDirPath = 0xC000,
139  DownloadLrcDirPath = 0xC001,
140  DownloadServerIndex = 0xC002,
141  DownloadCacheEnable = 0xC003,
142  DownloadCacheSize = 0xC004,
143  DownloadLimitEnable = 0xC005,
144  DownloadDownloadLimitSize = 0xC006,
145  DownloadUploadLimitSize = 0xC007,
146  DownloadFileNameRule = 0xC008,
147  DownloadServerPriority = 0xC009,
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:190
static constexpr wchar_t key[]
QVariant value(const QString &stype) const noexcept
Config stringToEnum(const QString &stype) const
TTK_MODULE_EXPORT MusicSettingManager * makeMusicSettingManager()
#define const
Definition: zconf.h:233
The class of the paramater setting manager.