TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiccoreutils.cpp
Go to the documentation of this file.
1 #include "musiccoreutils.h"
2 
3 #include <QStringList>
4 
5 #ifdef Q_CC_MSVC
6 # define WIN32_LEAN_AND_MEAN
7 # include <qt_windows.h>
8 #elif defined Q_OS_UNIX || defined Q_CC_GNU
9 # include <unistd.h>
10 #endif
11 
12 static bool __BreakPoint__ = false;
13 static bool versionCheck(const QStringList &ol, const QStringList &dl, int depth)
14 {
15  if(depth >= ol.count())
16  {
17  return false;
18  }
19 
20  if(dl[depth].toInt() >= ol[depth].toInt())
21  {
22  if(dl[depth].toInt() == ol[depth].toInt())
23  {
24  return versionCheck(ol, dl, depth + 1);
25  }
26  else
27  {
28  return true;
29  }
30  }
31  else
32  {
33  return false;
34  }
35 }
36 
37 void TTK::Core::sleep(int ms)
38 {
39 #ifdef Q_CC_MSVC
40  ::Sleep(ms);
41 #elif defined Q_OS_UNIX || defined Q_CC_GNU
42  usleep(ms * TTK_DN_MS2US);
43 #endif
44 }
45 
46 bool TTK::Core::appVersionCheck(const QString &o, const QString &d)
47 {
48  const QStringList &ol = o.split(TTK_DOT);
49  const QStringList &dl = d.split(TTK_DOT);
50 
51  if(ol.isEmpty() || dl.isEmpty() || ol.count() != dl.count())
52  {
53  return false;
54  }
55 
56  return versionCheck(ol, dl, 0);
57 }
58 
60 {
61  __BreakPoint__ = false;
62 }
63 
64 void TTK::Core::enableBreakPoint(bool enable)
65 {
66  __BreakPoint__ = enable;
67 }
68 
70 {
71  return __BreakPoint__;
72 }
TTK_MODULE_EXPORT void enableBreakPoint(bool enable)
static bool versionCheck(const QStringList &ol, const QStringList &dl, int depth)
#define TTK_DN_MS2US
Definition: ttkglobal.h:271
#define TTK_DOT
Definition: ttkglobal.h:193
static bool __BreakPoint__
TTK_MODULE_EXPORT bool isBreakPointEnabled()
TTK_MODULE_EXPORT void sleep(int ms)
TTK_MODULE_EXPORT void resetBreakPoint()
TTK_MODULE_EXPORT bool appVersionCheck(const QString &o, const QString &d)