TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkqtcompat.h
Go to the documentation of this file.
1 #ifndef TTKQTCOMPAT_H
2 #define TTKQTCOMPAT_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module 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 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 "ttkqtglobal.h"
23 
27 namespace QtCompat
28 {
30 #if TTK_QT_VERSION_CHECK(5,11,0)
31 # define QtFontWidth(p, t) p.horizontalAdvance(t)
32 #else
33 # define QtFontWidth(p, t) p.width(t)
34 #endif
35 
37 #if TTK_QT_VERSION_CHECK(5,10,0)
38 # define QtImageBytes(p) p.sizeInBytes()
39 #else
40 # define QtImageBytes(p) p.byteCount()
41 #endif
42 
44 #if TTK_QT_VERSION_CHECK(6,4,0)
45 # define QtItemSetTextAlignment(p, a) p->setTextAlignment(Qt::Alignment(a));
46 #else
47 # define QtItemSetTextAlignment(p, a) p->setTextAlignment(a);
48 #endif
49 
51 #if TTK_QT_VERSION_CHECK(5,13,0)
52 # define QtContainerSwap(p, i, j) p->swapItemsAt(i, j)
53 #else
54 # define QtContainerSwap(p, i, j) p->swap(i, j)
55 #endif
56 
58 #if TTK_QT_VERSION_CHECK(5,15,0)
59 # define QtNetworkErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), q, s(f(QNetworkReply::NetworkError)))
60 #else
61 # define QtNetworkErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QNetworkReply::NetworkError)), q, s(f(QNetworkReply::NetworkError)))
62 #endif
63 
65 #if TTK_QT_VERSION_CHECK(5,15,0)
66 # define QtNetworkErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), q, s(f()))
67 #else
68 # define QtNetworkErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QNetworkReply::NetworkError)), q, s(f()))
69 #endif
70 
72 #if TTK_QT_VERSION_CHECK(5,15,0)
73 # define QtSocketErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), q, s(f(QAbstractSocket::SocketError)))
74 #else
75 # define QtSocketErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QAbstractSocket::SocketError)), q, s(f(QAbstractSocket::SocketError)))
76 #endif
77 
79 #if TTK_QT_VERSION_CHECK(5,15,0)
80 # define QtSocketErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), q, s(f()))
81 #else
82 # define QtSocketErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QAbstractSocket::SocketError)), q, s(f()))
83 #endif
84 
86 #if TTK_QT_VERSION_CHECK(5,6,0)
87 # define QtProcessErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QProcess::ProcessError)), q, s(f(QProcess::ProcessError)))
88 #else
89 # define QtProcessErrorConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QProcess::ProcessError)), q, s(f(QProcess::ProcessError)))
90 #endif
91 
93 #if TTK_QT_VERSION_CHECK(5,6,0)
94 # define QtProcessErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QProcess::ProcessError)), q, s(f()))
95 #else
96 # define QtProcessErrorVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QProcess::ProcessError)), q, s(f()))
97 #endif
98 
100 #if TTK_QT_VERSION_CHECK(5,13,0)
101 # define QtProcessFinishConnect(p, q, f, s) QObject::connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), q, s(f(int)))
102 #else
103 # define QtProcessFinishConnect(p, q, f, s) QObject::connect(p, SIGNAL(finished(int)), q, s(f(int)))
104 #endif
105 
107 #if TTK_QT_VERSION_CHECK(5,13,0)
108 # define QtProcessFinishVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), q, s(f()))
109 #else
110 # define QtProcessFinishVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(finished(int)), q, s(f()))
111 #endif
112 
114 #if TTK_QT_VERSION_CHECK(5,15,0)
115 # define QtButtonGroupConnect(p, q, f, s) QObject::connect(p, SIGNAL(idClicked(int)), q, s(f(int)))
116 #else
117 # define QtButtonGroupConnect(p, q, f, s) QObject::connect(p, SIGNAL(buttonClicked(int)), q, s(f(int)))
118 #endif
119 
121 #if TTK_QT_VERSION_CHECK(5,15,0)
122 # define QtButtonGroupVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(idClicked(int)), q, s(f()))
123 #else
124 # define QtButtonGroupVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(buttonClicked(int)), q, s(f()))
125 #endif
126 
128 #if TTK_QT_VERSION_CHECK(5,15,0)
129 # define QtNamespace(p) Qt::p
130 #else
131 # define QtNamespace(p) p
132 #endif
133 
135 #if TTK_QT_VERSION_CHECK(5,15,0)
136 # define QtLablePixmap(p) p->pixmap(Qt::ReturnByValue)
137 #else
138 # define QtLablePixmap(p) p->pixmap() ? *p->pixmap() : QPixmap();
139 #endif
140 
142 #if TTK_QT_VERSION_CHECK(5,15,0)
143 # define QtSkipEmptyParts Qt::SkipEmptyParts
144 #else
145 # define QtSkipEmptyParts QString::SkipEmptyParts
146 #endif
147 
149 #if TTK_QT_VERSION_CHECK(5,14,0)
150 # define QtWheelDelta(p) p->angleDelta().y()
151 #else
152 # define QtWheelDelta(p) p->delta()
153 #endif
154 
156 #if TTK_QT_VERSION_CHECK(6,0,0)
157 # define QtPosition(p) p->position().toPoint()
158 # define QtPositionF(p) p->position()
159 # define QtPositionX(p) p->position().x()
160 # define QtPositionY(p) p->position().y()
161 # define QtGlobalPosition(p) p->globalPosition().toPoint()
162 # define QtGlobalPositionF(p) p->globalPosition()
163 # define QtGlobalPositionX(p) p->globalPosition().x()
164 # define QtGlobalPositionY(p) p->globalPosition().y()
165 #else
166 # define QtPosition(p) p->pos()
167 # define QtPositionF(p) p->pos()
168 # define QtPositionX(p) p->x()
169 # define QtPositionY(p) p->y()
170 # define QtGlobalPosition(p) p->globalPos()
171 # define QtGlobalPositionF(p) p->globalPos()
172 # define QtGlobalPositionX(p) p->globalX()
173 # define QtGlobalPositionY(p) p->globalY()
174 #endif
175 
177 #if TTK_QT_VERSION_CHECK(6,0,0)
178 # define QtEnterEvent QEnterEvent
179 #else
180 # define QtEnterEvent QEvent
181 #endif
182 
184 #if TTK_QT_VERSION_CHECK(6,0,0)
185 # define QtVariantType(p) p.typeId()
186 #else
187 # define QtVariantType(p) p.type()
188 #endif
189 
191 #if TTK_QT_VERSION_CHECK(6,0,0)
192 # define QtKeySequence(k, m) QKeySequence(QKeyCombination(m, k))
193 #else
194 # define QtKeySequence(k, m) QKeySequence(k + m)
195 #endif
196 
198 #if TTK_QT_VERSION_CHECK(6,0,0)
199 # define QtKeyCombine(p) p.toCombined()
200 #else
201 # define QtKeyCombine(p) p
202 #endif
203 
205 #if TTK_QT_VERSION_CHECK(6,0,0)
206 # define QtFontFamilies() QFontDatabase::families()
207 #else
208 # define QtFontFamilies() QFontDatabase().families()
209 #endif
210 }
211 
212 
214 #if !TTK_QT_VERSION_CHECK(5,7,0)
215 template <typename... Args>
216 struct QNonConstOverload
217 {
218  template <typename R, typename T>
219  Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr)
220  { return ptr; }
221 
222  template <typename R, typename T>
223  static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr)
224  { return ptr; }
225 };
226 
227 template <typename... Args>
228 struct QConstOverload
229 {
230  template <typename R, typename T>
231  Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr)
232  { return ptr; }
233 
234  template <typename R, typename T>
235  static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr)
236  { return ptr; }
237 };
238 
239 template <typename... Args>
240 struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
241 {
242  using QConstOverload<Args...>::of;
243  using QConstOverload<Args...>::operator();
244  using QNonConstOverload<Args...>::of;
245  using QNonConstOverload<Args...>::operator();
246 
247  template <typename R>
248  Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr)
249  { return ptr; }
250 
251  template <typename R>
252  static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr)
253  { return ptr; }
254 };
255 
256 #if TTK_HAS_CXX14
257 template <typename... Args> TTK_CONSTEXPR TTK_DECL_UNUSED QOverload<Args...> qOverload = {};
258 template <typename... Args> TTK_CONSTEXPR TTK_DECL_UNUSED QConstOverload<Args...> qConstOverload = {};
259 template <typename... Args> TTK_CONSTEXPR TTK_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
260 #endif
261 
262 #endif
263 
264 #endif // TTKQTCOMPAT_H
#define T(v)
Definition: http_parser.c:237
#define TTK_CONSTEXPR
Definition: ttkqtglobal.h:147
#define TTK_DECL_UNUSED
Definition: ttkglobal.h:196
The namespace of the qt compat function wrapper.
Definition: ttkqtcompat.h:27
#define const
Definition: zconf.h:233