TTKMusicPlayer  3.7.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 - 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 "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,15,0)
87 # define QtProcessConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QProcess::ProcessError)), q, s(f(QProcess::ProcessError)))
88 #else
89 # define QtProcessConnect(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,15,0)
94 # define QtProcessVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(errorOccurred(QProcess::ProcessError)), q, s(f()))
95 #else
96 # define QtProcessVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(error(QProcess::ProcessError)), q, s(f()))
97 #endif
98 
100 #if TTK_QT_VERSION_CHECK(5,15,0)
101 # define QtButtonGroupConnect(p, q, f, s) QObject::connect(p, SIGNAL(idClicked(int)), q, s(f(int)))
102 #else
103 # define QtButtonGroupConnect(p, q, f, s) QObject::connect(p, SIGNAL(buttonClicked(int)), q, s(f(int)))
104 #endif
105 
107 #if TTK_QT_VERSION_CHECK(5,15,0)
108 # define QtButtonGroupVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(idClicked(int)), q, s(f()))
109 #else
110 # define QtButtonGroupVoidConnect(p, q, f, s) QObject::connect(p, SIGNAL(buttonClicked(int)), q, s(f()))
111 #endif
112 
114 #if TTK_QT_VERSION_CHECK(5,15,0)
115 # define QtStreamEndLine(p) p << Qt::endl
116 #else
117 # define QtStreamEndLine(p) p << endl
118 #endif
119 
121 #if TTK_QT_VERSION_CHECK(5,15,0)
122 # define QtLablePixmap(p) p->pixmap(Qt::ReturnByValue)
123 #else
124 # define QtLablePixmap(p) p->pixmap() ? *p->pixmap() : QPixmap();
125 #endif
126 
128 #if TTK_QT_VERSION_CHECK(5,15,0)
129 # define QtSkipEmptyParts Qt::SkipEmptyParts
130 #else
131 # define QtSkipEmptyParts QString::SkipEmptyParts
132 #endif
133 
135 #if TTK_QT_VERSION_CHECK(5,15,0)
136 # define QtWheelDelta(p) p->angleDelta().y()
137 #else
138 # define QtWheelDelta(p) p->delta()
139 #endif
140 
142 #if TTK_QT_VERSION_CHECK(6,0,0)
143 # define QtMouseX(p) p->position().x()
144 # define QtMouseY(p) p->position().y()
145 # define QtMousePos(p) p->position()
146 # define QtMouseGlobalX(p) p->globalPosition().x()
147 # define QtMouseGlobalY(p) p->globalPosition().y()
148 # define QtMouseGlobalPos(p) p->globalPosition().toPoint()
149 #else
150 # define QtMouseX(p) p->x()
151 # define QtMouseY(p) p->y()
152 # define QtMousePos(p) p->pos()
153 # define QtMouseGlobalX(p) p->globalX()
154 # define QtMouseGlobalY(p) p->globalY()
155 # define QtMouseGlobalPos(p) p->globalPos()
156 #endif
157 
159 #if TTK_QT_VERSION_CHECK(6,0,0)
160 # define QtEnterEvent QEnterEvent
161 #else
162 # define QtEnterEvent QEvent
163 #endif
164 
166 #if TTK_QT_VERSION_CHECK(6,0,0)
167 # define QtVariantType(p) p.typeId()
168 #else
169 # define QtVariantType(p) p.type()
170 #endif
171 
173 #if TTK_QT_VERSION_CHECK(6,0,0)
174 # define QtKeySequence(k, m) QKeySequence(QKeyCombination(m, k))
175 #else
176 # define QtKeySequence(k, m) QKeySequence(k + m)
177 #endif
178 
180 #if TTK_QT_VERSION_CHECK(6,0,0)
181 # define QtKeyCombine(p) p.toCombined()
182 #else
183 # define QtKeyCombine(p) p
184 #endif
185 }
186 
187 #endif // TTKQTCOMPAT_H
The namespace of the qt compat function wrapper.
Definition: ttkqtcompat.h:27