Skip to content

Commit

Permalink
Merge PR #6618: FIX(client, server): Fix build with Qt 6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici authored Nov 6, 2024
2 parents 65462b4 + 759339d commit c7d902b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/mumble/BanEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <cassert>

#include <QtCore/QTimeZone>

BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p), maskDefaultValue(32) {
setupUi(this);

Expand All @@ -28,7 +30,11 @@ BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p),
b.qsHash = u8(be.hash());
b.qsReason = u8(be.reason());
b.qdtStart = QDateTime::fromString(u8(be.start()), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
b.qdtStart.setTimeZone(QTimeZone::UTC);
#else
b.qdtStart.setTimeSpec(Qt::UTC);
#endif
if (!b.qdtStart.isValid())
b.qdtStart = QDateTime::currentDateTime();
b.iDuration = be.duration();
Expand Down
19 changes: 19 additions & 0 deletions src/mumble/PluginUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ void PluginUpdater::promptAndUpdate() {

setWindowIcon(QIcon(QLatin1String("skin:mumble.svg")));

#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
// checkStateChanged was introduced in Qt 6.7
QObject::connect(qcbSelectAll, &QCheckBox::checkStateChanged, this, &PluginUpdater::on_selectAll);
#else
QObject::connect(qcbSelectAll, &QCheckBox::stateChanged, this, &PluginUpdater::on_selectAll);
#endif

QObject::connect(this, &QDialog::finished, this, &PluginUpdater::on_finished);

if (exec() == QDialog::Accepted) {
Expand Down Expand Up @@ -117,7 +123,12 @@ void PluginUpdater::populateUI() {
UpdateWidgetPair pair = { checkBox, urlLabel };
m_pluginUpdateWidgets << pair;

#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
// checkStateChanged was introduced in Qt 6.7
QObject::connect(checkBox, &QCheckBox::checkStateChanged, this, &PluginUpdater::on_singleSelectionChanged);
#else
QObject::connect(checkBox, &QCheckBox::stateChanged, this, &PluginUpdater::on_singleSelectionChanged);
#endif
}

// sort the plugins alphabetically
Expand Down Expand Up @@ -147,7 +158,11 @@ void PluginUpdater::clearUI() {
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void PluginUpdater::on_selectAll(Qt::CheckState checkState) {
#else
void PluginUpdater::on_selectAll(int checkState) {
#endif
// failsafe for partially selected state (shouldn't happen though)
if (checkState == Qt::PartiallyChecked) {
checkState = Qt::Unchecked;
Expand All @@ -161,7 +176,11 @@ void PluginUpdater::on_selectAll(int checkState) {
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void PluginUpdater::on_singleSelectionChanged(Qt::CheckState checkState) {
#else
void PluginUpdater::on_singleSelectionChanged(int checkState) {
#endif
bool isChecked = checkState == Qt::Checked;

// Block signals for the selectAll checkBox in order to not trigger its
Expand Down
7 changes: 7 additions & 0 deletions src/mumble/PluginUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,17 @@ class PluginUpdater : public QDialog, public Ui::PluginUpdater {
public slots:
/// Clears the UI from the widgets created for the individual plugins.
void clearUI();
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
/// Slot triggered if the user changes the state of the selectAll CheckBox.
void on_selectAll(Qt::CheckState checkState);
/// Slot triggered if the user toggles the CheckBox for any individual plugin.
void on_singleSelectionChanged(Qt::CheckState checkState);
#else
/// Slot triggered if the user changes the state of the selectAll CheckBox.
void on_selectAll(int checkState);
/// Slot triggered if the user toggles the CheckBox for any individual plugin.
void on_singleSelectionChanged(int checkState);
#endif
/// Slot triggered when the dialog is being closed.
void on_finished(int result);
/// Slot that can be triggered to ask for the update process to be interrupted.
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/SocketRPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ void SocketRPCClient::readyRead() {

void SocketRPCClient::processXml() {
QDomDocument qdd;
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
qdd.setContent(qbaOutput, QDomDocument::ParseOption::Default);
#else
qdd.setContent(qbaOutput, false);
#endif

QDomElement request = qdd.firstChildElement();

Expand Down
6 changes: 6 additions & 0 deletions src/mumble/UserListModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <vector>

#include <QtCore/QTimeZone>

UserListModel::UserListModel(const MumbleProto::UserList &userList, QObject *parent_)
: QAbstractTableModel(parent_), m_legacyMode(false) {
m_userList.reserve(userList.users_size());
Expand Down Expand Up @@ -296,6 +298,10 @@ QString UserListModel::pathForChannelId(const unsigned int channelId) const {

QDateTime UserListModel::isoUTCToDateTime(const std::string &isoTime) const {
QDateTime dt = QDateTime::fromString(u8(isoTime), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
dt.setTimeZone(QTimeZone::UTC);
#else
dt.setTimeSpec(Qt::UTC);
#endif
return dt;
}
11 changes: 8 additions & 3 deletions src/murmur/Messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
#include "Version.h"
#include "crypto/CryptState.h"

#include <QtCore/QStack>
#include <QtCore/QtEndian>

#include <cassert>
#include <unordered_map>

#include <QtCore/QStack>
#include <QtCore/QTimeZone>
#include <QtCore/QtEndian>

#include <tracy/Tracy.hpp>

#define RATELIMIT(user) \
Expand Down Expand Up @@ -687,7 +688,11 @@ void Server::msgBanList(ServerUser *uSource, MumbleProto::BanList &msg) {
b.qsReason = u8(be.reason());
if (be.has_start()) {
b.qdtStart = QDateTime::fromString(u8(be.start()), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
b.qdtStart.setTimeZone(QTimeZone::UTC);
#else
b.qdtStart.setTimeSpec(Qt::UTC);
#endif
} else {
b.qdtStart = QDateTime::currentDateTime().toUTC();
}
Expand Down
26 changes: 21 additions & 5 deletions src/murmur/ServerDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include <QtCore/QtGlobal>
#include "ServerDB.h"

#ifdef Q_OS_WIN
# include "win.h"
#endif

#include "ServerDB.h"

#include "ACL.h"
#include "Channel.h"
#include "Connection.h"
Expand All @@ -22,12 +20,14 @@
#include "ServerUser.h"
#include "User.h"

#include <cstdint>

#include <QtCore/QCoreApplication>
#include <QtCore/QTimeZone>
#include <QtCore/QtGlobal>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>

#include <cstdint>

#ifdef Q_OS_WIN
# include <winsock2.h>
#else
Expand Down Expand Up @@ -1210,7 +1210,11 @@ QList< UserInfo > Server::getRegisteredUsersEx() {
userinfo.name = query.value(1).toString();
userinfo.last_channel = query.value(2).toInt();
userinfo.last_active = QDateTime::fromString(query.value(3).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
userinfo.last_active.setTimeZone(QTimeZone::UTC);
#else
userinfo.last_active.setTimeSpec(Qt::UTC);
#endif

users << userinfo;
}
Expand Down Expand Up @@ -2220,14 +2224,22 @@ int Server::readLastChannel(int id) {
}

QDateTime last_active = QDateTime::fromString(query.value(1).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
last_active.setTimeZone(QTimeZone::UTC);
#else
last_active.setTimeSpec(Qt::UTC);
#endif
QDateTime last_disconnect;

// NULL column for last_disconnect will yield an empty invalid QDateTime object.
// Using that object with QDateTime::secsTo() will return 0 as per Qt specification.
if (!query.value(2).isNull()) {
last_disconnect = QDateTime::fromString(query.value(2).toString(), Qt::ISODate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
last_disconnect.setTimeZone(QTimeZone::UTC);
#else
last_disconnect.setTimeSpec(Qt::UTC);
#endif
}

if (last_active.secsTo(last_disconnect) <= 0) {
Expand Down Expand Up @@ -2312,7 +2324,11 @@ void Server::getBans() {
ban.qsHash = query.value(3).toString();
ban.qsReason = query.value(4).toString();
ban.qdtStart = query.value(5).toDateTime();
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
ban.qdtStart.setTimeZone(QTimeZone::UTC);
#else
ban.qdtStart.setTimeSpec(Qt::UTC);
#endif
ban.iDuration = query.value(6).toUInt();

if (ban.isValid())
Expand Down

0 comments on commit c7d902b

Please sign in to comment.