Skip to content

Commit

Permalink
FIX(client): Fix build with Qt 6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
botanegg committed Nov 5, 2024
1 parent 70dea60 commit 7787e5b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 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;
}

0 comments on commit 7787e5b

Please sign in to comment.