TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkqtglobal.h
Go to the documentation of this file.
1 #ifndef TTKQTGLOBAL_H
2 #define TTKQTGLOBAL_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QMap>
23 #include <QSet>
24 #include <QVariant>
25 #include "ttkglobal.h"
26 #include "ttklogger.h"
27 
28 #ifdef QT_DEBUG
29 # define TTK_DEBUG
30 #endif
31 
32 #define TTK_QT_VERSION_CHECK(major, minor, patch) (QT_VERSION >= QT_VERSION_CHECK(major, minor, patch))
33 
34 
35 #ifndef qPrintable
36 # define qPrintable(s) QString(s).toLocal8Bit().constData()
37 #endif
38 
39 #ifndef qUtf8Printable
40 # define qUtf8Printable(s) QString(s).toUtf8().constData()
41 #endif
42 
43 
44 #if !TTK_QT_VERSION_CHECK(5,7,0)
45 # define TTK_AS_CONST
46 // this adds const to non-const objects (like std::as_const)
47 template <typename T>
48 Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
49 // prevent rvalue arguments:
50 template <typename T>
51 void qAsConst(const T &&) = delete;
52 #elif TTK_QT_VERSION_CHECK(6,6,0)
53 #define qAsConst std::as_const
54 #endif
55 
56 
57 #ifdef TTK_CAST
58 # define TTKObjectCast(x, y) (qobject_cast<x>(y))
59 #else
60 # define TTKObjectCast(x, y) ((x)(y))
61 #endif
62 
63 #if defined TTK_CAST && TTK_QT_VERSION_CHECK(5,15,0)
64 # define TTKVoidCast(x) (x)(void*)
65 #else
66 # define TTKVoidCast(x) (x)
67 #endif
68 
69 
70 // deprecated function
71 #ifdef Q_CC_MSVC
72 # define TTK_DEPRECATED __declspec(deprecated)
73 # define TTK_DEPRECATED_X(text) __declspec(deprecated(text))
74 #else
75 # define TTK_DEPRECATED __attribute__((__deprecated__))
76 # define TTK_DEPRECATED_X(text) __attribute__((__deprecated__(text)))
77 #endif
78 
79 
80 #if !TTK_QT_VERSION_CHECK(5,0,0) && defined(Q_CC_GNU)
81 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || TTK_HAS_CXX11
82 # define Q_COMPILER_DEFAULT_MEMBERS
83 # define Q_COMPILER_DELETE_MEMBERS
84 # define Q_COMPILER_NULLPTR
85 # define Q_COMPILER_EXPLICIT_OVERRIDES
86 # define Q_COMPILER_CONSTEXPR
87 # endif
88 #endif
89 
90 
91 // C++11 keywords and expressions
92 #ifdef Q_COMPILER_NULLPTR
93 # define TTK_NULLPTR nullptr
94 #else
95 # define TTK_NULLPTR NULL
96 #endif
97 
98 #ifdef Q_COMPILER_DEFAULT_MEMBERS
99 # define TTK_DEFAULT = default
100 #else
101 # define TTK_DEFAULT
102 #endif
103 
104 #ifdef Q_COMPILER_DELETE_MEMBERS
105 # define TTK_DELETE = delete
106 #else
107 # define TTK_DELETE
108 #endif
109 
110 #ifdef Q_COMPILER_EXPLICIT_OVERRIDES
111 # define TTK_OVERRIDE override
112 # define TTK_FINAL final
113 #else
114 # ifndef TTK_OVERRIDE
115 # define TTK_OVERRIDE
116 # endif
117 # ifndef TTK_FINAL
118 # define TTK_FINAL
119 # endif
120 #endif
121 
122 #if defined Q_CC_MSVC && _MSC_VER <= 1800
123 # define constexpr const
124 #endif
125 
126 #if defined Q_COMPILER_CONSTEXPR
127 # if defined(__cpp_constexpr) && __cpp_constexpr >= 201304L
128 # define TTK_CONSTEXPR constexpr
129 # define TTK_RCONSTEXPR constexpr
130 # else
131 # define TTK_CONSTEXPR constexpr
132 # define TTK_RCONSTEXPR const
133 # endif
134 #else
135 # define TTK_CONSTEXPR const
136 # define TTK_RCONSTEXPR const
137 #endif
138 
139 
140 // disable copy
141 #define TTK_DISABLE_COPY(Class) \
142 private: \
143  Class(const Class &) TTK_DELETE; \
144  Class &operator=(const Class &) TTK_DELETE;
145 
146 // disable init and copy
147 #define TTK_DISABLE_INIT_COPY(Class) \
148  TTK_DISABLE_COPY(Class) \
149  Class() TTK_DELETE;
150 
151 // make class name
152 #define TTK_DECLARE_MODULE(Class) \
153 public: \
154  inline static QString className() \
155  { \
156  return #Class; \
157  }
158 
159 
160 // declare list and enum flag
161 #define TTK_DECLARE_LIST(Class) using Class##List = QList<Class>
162 #define TTK_DECLARE_FLAG(Flags, Enum) using Flags = QFlags<Enum>
163 
164 #define TTK_SIGNAL SIGNAL
165 #define TTK_SLOT SLOT
166 
167 #if TTK_QT_VERSION_CHECK(6,0,0)
168 # define qint qintptr
169 #else
170 # define qint long
171 #endif
172 
173 #define TTK_FILE_SUFFIX(fin) fin.suffix().toLower()
174 
175 // marco timer single shot
176 #ifndef _MSC_VER
177 # define TTK_SIGNLE_SHOT(...) TTK_PP_OVERLOAD(__TTK_SIGNLE_SHOT__, __VA_ARGS__)(__VA_ARGS__)
178 #else
179 # define TTK_SIGNLE_SHOT(...) TTK_PP_CAT(TTK_PP_OVERLOAD(__TTK_SIGNLE_SHOT__, __VA_ARGS__)(__VA_ARGS__), TTK_PP_EMPTY())
180 #endif
181 #define __TTK_SIGNLE_SHOT__2(a, s) QTimer::singleShot(TTK_DN_ONCE, this, s(a()));
182 #define __TTK_SIGNLE_SHOT__3(a, b, s) QTimer::singleShot(TTK_DN_ONCE, a, s(b()));
183 #define __TTK_SIGNLE_SHOT__4(a, b, c, s) QTimer::singleShot(a, b, s(c()));
184 
185 
186 // Qt style format
187 using TTKIntSet = QSet<int>; /* int set */
188 using TTKIntList = QList<int>; /* int list */
189 using TTKVariantList = QList<QVariant>; /* variant list */
190 using TTKStringMap = QMap<QString, QString>; /* strings map */
191 using TTKVariantMap = QMap<QString, QVariant>; /* string variant map */
192 using TTKIntStringMap = QMap<qint64, QString>; /* int string map */
193 
194 #endif // TTKQTGLOBAL_H
#define T(v)
Definition: http_parser.c:237
QList< int > TTKIntList
Definition: ttkqtglobal.h:188
#define qAsConst
Definition: ttkqtglobal.h:53
QMap< qint64, QString > TTKIntStringMap
Definition: ttkqtglobal.h:192
QMap< QString, QVariant > TTKVariantMap
Definition: ttkqtglobal.h:191
QSet< int > TTKIntSet
Definition: ttkqtglobal.h:187
QList< QVariant > TTKVariantList
Definition: ttkqtglobal.h:189
QMap< QString, QString > TTKStringMap
Definition: ttkqtglobal.h:190