TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicconfigobject.cpp
Go to the documentation of this file.
1 #include "musicconfigobject.h"
2 
3 #include <QProcess>
4 
6  : QObject(parent)
7 {
8 
9 }
10 
12 {
15 }
16 
18 {
19  valid();
20 
21  copyFileOverwrite(":/data/config.xml", TTK_COFIG_PATH_FULL);
22  copyFileOverwrite(":/data/playlist.tkpl", TTK_PLAYLIST_PATH_FULL);
23  copyFileOverwrite(":/data/download.tkf", TTK_NORMAL_DOWN_PATH_FULL);
24  copyFileOverwrite(":/data/cdownload.tkf", TTK_CLOUD_DOWN_PATH_FULL);
25  copyFileOverwrite(":/data/cupload.tkf", TTK_CLOUD_UP_PATH_FULL);
26  copyFileOverwrite(":/data/search.tkf", TTK_SEARCH_PATH_FULL);
27 }
28 
30 {
31  copyFileOverwrite(":/data/config.xml", TTK_COFIG_PATH_FULL);
32 }
33 
34 void MusicConfigObject::directoryExist(const QString &name) const
35 {
36  QDir dir;
37  if(!dir.exists(name))
38  {
39  dir.mkpath(name);
40  }
41 }
42 
44 {
47 
51 
53 
57 }
58 
60 {
61  copyFile(":/data/config.xml", TTK_COFIG_PATH_FULL);
62  copyFile(":/data/playlist.tkpl", TTK_PLAYLIST_PATH_FULL);
63  copyFile(":/data/download.tkf", TTK_NORMAL_DOWN_PATH_FULL);
64  copyFile(":/data/cdownload.tkf", TTK_CLOUD_DOWN_PATH_FULL);
65  copyFile(":/data/cupload.tkf", TTK_CLOUD_UP_PATH_FULL);
66  copyFile(":/data/search.tkf", TTK_SEARCH_PATH_FULL);
67 
68  copyFile(":/data/playlist", TTK_RESOURCE_DIR_FULL + "playlist");
69  copyFile(":/data/toplist", TTK_RESOURCE_DIR_FULL + "toplist");
70  copyFile(":/data/artistlist", TTK_RESOURCE_DIR_FULL + "artistlist");
71  copyFile(":/data/movielist", TTK_RESOURCE_DIR_FULL + "movielist");
72  copyFile(":/data/fmlist", TTK_RESOURCE_DIR_FULL + "fmlist");
73 
74 #ifdef Q_OS_UNIX
75  if(!QFile::exists(MAIN_DIR_FULL + "ttk_runtime"))
76  {
77  copyLinuxShellFile(":/data/TTKRoutine.sh", TTK_ROUTINE_FULL);
78  copyLinuxShellFile(":/data/TTKMusicPlayer.sh", TTK_APP_MAIN_FULL);
79  copyLinuxShellFile(":/data/TTKRoutineCopy.sh", TTK_ROUTINECOPY_FULL);
80  copyLinuxShellFile(":/data/TTKInit.sh", TTK_INIT_FULL);
81  copyLinuxShellFile(":/data/TTKConsole.sh", TTK_CONSOLE_FULL);
82  copyLinuxShellFile(":/data/TTKService.sh", TTK_SERVICE_FULL);
83  }
84 #endif
85 }
86 
87 void MusicConfigObject::copyFileOverwrite(const QString &origin, const QString &des) const
88 {
89  if(QFile::exists(des))
90  {
91  QFile::remove(des);
92  }
93 
94  QFile::copy(origin, des);
95  QFile::setPermissions(des, QFile::ReadOwner | QFile::WriteOwner);
96 }
97 
98 void MusicConfigObject::copyFile(const QString &origin, const QString &des) const
99 {
100  if(!QFile::exists(des))
101  {
102  QFile::copy(origin, des);
103  QFile::setPermissions(des, QFile::ReadOwner | QFile::WriteOwner);
104  }
105 }
106 
107 #ifdef Q_OS_UNIX
108 void MusicConfigObject::copyLinuxShellFile(const QString &name, const QString &path) const
109 {
110  copyFileOverwrite(name, path);
111  QProcess::execute("chmod", {"+x", path});
112 }
113 #endif
#define TTK_CLOUD_UP_PATH_FULL
#define TTK_MUSIC_DIR_FULL
#define TTK_NORMAL_DOWN_PATH_FULL
#define TTK_USER_THEME_DIR_FULL
#define TTK_PLUGINS_DIR_FULL
#define TTK_RESOURCE_DIR_FULL
voidpf uLong int origin
Definition: ioapi.h:142
#define TTK_THEME_DIR_FULL
#define TTK_BACKGROUND_DIR_FULL
TTK_MODULE_EXPORT bool execute(const QString &path)
void initialize() const
#define TTK_COFIG_PATH_FULL
#define MAIN_DIR_FULL
Definition: musicobject.h:117
#define TTK_SERVICE_FULL
Definition: ttkqtobject.h:25
void copyFile(const QString &origin, const QString &des) const
#define TTK_CACHE_DIR_FULL
void copyFileOverwrite(const QString &origin, const QString &des) const
const char * name
Definition: http_parser.c:458
#define TTK_LRC_DIR_FULL
#define TTK_APP_MAIN_FULL
Definition: ttkqtobject.h:26
#define TTK_PLAYLIST_PATH_FULL
void checkDirectoryExist() const
#define TTK_ART_DIR_FULL
MusicConfigObject(QObject *parent=nullptr)
void checkFileNeededExist() const
#define TTK_LANGUAGE_DIR_FULL
#define TTK_CLOUD_DOWN_PATH_FULL
void directoryExist(const QString &name) const
#define TTK_SEARCH_PATH_FULL