diff --git a/qmake/builddir.pri b/qmake/builddir.pri index 84c319a1e..9d1a3a2c3 100644 --- a/qmake/builddir.pri +++ b/qmake/builddir.pri @@ -12,21 +12,15 @@ # "$$PWD/.." is the top of the source tree. # # clean_path() is used to clean the path. -# It's not available on Qt 4. -greaterThan(QT_MAJOR_VERSION, 4) { - TOP_SRCDIR = $$clean_path($$PWD/..) -} +TOP_SRCDIR = $$clean_path($$PWD/..) -# In case absolute_path() doesn't return anything. +# In case clean_path() doesn't return anything. isEmpty(TOP_SRCDIR) { TOP_SRCDIR = $$PWD/.. } # shadowed() is used to retrieve the shadowed build path. -# It's not available on Qt 4. -greaterThan(QT_MAJOR_VERSION, 4) { - TOP_BUILDDIR = $$shadowed($$TOP_SRCDIR) -} +TOP_BUILDDIR = $$shadowed($$TOP_SRCDIR) # In case shadowed() doesn't return anything. isEmpty(TOP_BUILDDIR) { diff --git a/qmake/compiler.pri b/qmake/compiler.pri index 1dc60840e..47a8ea07f 100644 --- a/qmake/compiler.pri +++ b/qmake/compiler.pri @@ -23,18 +23,13 @@ QMAKE_RESOURCE_FLAGS += -compress 9 # architecture of the compiler via the # force-x86_64-toolchain and force-x86-toolchain # CONFIG options. Because we have these, qmake's -# QMAKE_TARGET.arch doesn't suffice any longer, and +# QT_ARCH doesn't suffice any longer, and # we define MUMBLE_ARCH to be used in its place. -MUMBLE_ARCH = $$QMAKE_TARGET.arch -# When using Qt 5, use QT_ARCH instead of QMAKE_TARGET. -# It also works for cross-builds. -isEqual(QT_MAJOR_VERSION, 5) { - MUMBLE_ARCH = $$QT_ARCH - # QT_ARCH uses 'i386' instead of 'x86', - # so map that value back to what we expect. - equals(MUMBLE_ARCH, i386) { - MUMBLE_ARCH=x86 - } +MUMBLE_ARCH = $$QT_ARCH +# QT_ARCH uses 'i386' instead of 'x86', +# so map that value back to what we expect. +equals(MUMBLE_ARCH, i386) { + MUMBLE_ARCH=x86 } win32-g++ { @@ -344,20 +339,7 @@ macx { !CONFIG(universal) { CONFIG += no-pch - # Qt 5.1 and greater want short-form OS X SDKs. - isEqual(QT_MAJOR_VERSION, 5) { - QMAKE_MAC_SDK = macosx - } else { - QMAKE_MAC_SDK = $$system(xcrun --sdk macosx --show-sdk-path 2>/dev/null) - isEmpty(QMAKE_MAC_SDK) { - QMAKE_MAC_SDK = $$system(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk - !exists($$QMAKE_MAC_SDK) { - message("Unable to find usable OS X SDK") - error("Aborting build") - } - } - } - + QMAKE_MAC_SDK = macosx QMAKE_CC = $$system(xcrun -find clang) QMAKE_CXX = $$system(xcrun -find clang++) QMAKE_LINK = $$system(xcrun -find clang++) diff --git a/qmake/cplusplus.pri b/qmake/cplusplus.pri index dbbe008ad..4e0ff3b4b 100644 --- a/qmake/cplusplus.pri +++ b/qmake/cplusplus.pri @@ -18,17 +18,13 @@ # adds c++11, c++14 or c++1z to CONFIG. If none of # these are available, it adds c++03 to CONFIG. # -# In Qt 5, qmake understands the c++11, c++14, and c++1z +# qmake understands the c++11, c++14, and c++1z # CONFIG options, and will automatically populate # QMAKE_CXXFLAGS and QMAKE_LFLAGS with the appropriate # -std=c++XX values for the chosen C++ standard. -# For Qt 4, this .pri files will add the proper flags, -# because Qt 4's qmake doesn't know of the c++XX CONFIG -# options. # -# The c++03 option is unknown for both Qt 4 and Qt 5. -# We handle setting up the proper CXXFLAGS and LFLAGS for -# both versions of Qt when c++03 is in CONFIG. +# The c++03 option is unknown for Qt. +# We handle setting up the proper CXXFLAGS and LFLAGS when c++03 is in CONFIG. # First, auto-populate CONFIG with the latest C++ standard # that Qt has detected support for. @@ -78,26 +74,9 @@ CONFIG(c++14) { # Unix-specific handling of modern C++ features. unix { - # Qt 4, as opposed to Qt 5, doesn't automatically - # populate QMAKE_CXXFLAGS and QMAKE_LFLAGS with the - # appropriate -std=c++XX flags. So, for Qt 4, we'll - # have to set them up manually. - lessThan(QT_MAJOR_VERSION, 5) { - CONFIG(c++1z) { - QMAKE_CXXFLAGS += -std=c++1z - QMAKE_LFLAGS += -std=c++1z - } else:CONFIG(c++14) { - QMAKE_CXXFLAGS += -std=c++14 - QMAKE_LFLAGS += -std=c++14 - } else:CONFIG(c++11) { - QMAKE_CXXFLAGS += -std=c++11 - QMAKE_LFLAGS += -std=c++11 - } - } # No Qt versions know about CONFIG(c++03), since # its our own internal hint -- so for CONFIG(c++03) - # we set QMAKE_CXXFLAGS and QMAKE_LFLAGS for both Qt 4 - # and Qt 5. + # we set QMAKE_CXXFLAGS and QMAKE_LFLAGS. CONFIG(c++03):!CONFIG(c++11):!CONFIG(c++14):!CONFIG(c++1z) { # Note: we use -std=c++98 to support # older compilers. In GCC, the following diff --git a/qmake/pkgconfig.pri b/qmake/pkgconfig.pri index 44bd32f31..06011bc07 100644 --- a/qmake/pkgconfig.pri +++ b/qmake/pkgconfig.pri @@ -5,13 +5,7 @@ # Allow cross-building by making a call to return the pkg-config # that the user supplied to the build. -# pkgConfigExecutable() is part of Qt5. -# If building with Qt4, pkg-config is called instead -isEqual(QT_MAJOR_VERSION, 5) { - PKG_CONFIG = $$pkgConfigExecutable() -} else { - PKG_CONFIG = "pkg-config" -} +PKG_CONFIG = $$pkgConfigExecutable() # must_pkgconfig(pkg) # diff --git a/src/Connection.h b/src/Connection.h index 534d2b8e8..9bc24ab05 100644 --- a/src/Connection.h +++ b/src/Connection.h @@ -14,15 +14,9 @@ #include "CryptState.h" -#include - -#if QT_VERSION >= 0x040700 -# include -#else -# include -#endif - +#include #include +#include #include #include @@ -42,11 +36,7 @@ class Connection : public QObject { Q_DISABLE_COPY(Connection) protected: QSslSocket *qtsSocket; -#if QT_VERSION >= 0x040700 QElapsedTimer qtLastPacket; -#else - QTime qtLastPacket; -#endif unsigned int uiType; int iPacketLength; #ifdef Q_OS_WIN @@ -100,8 +90,4 @@ class Connection : public QObject { #endif }; -#if QT_VERSION < 0x050000 -Q_DECLARE_METATYPE(QAbstractSocket::SocketError) -#endif - #endif diff --git a/src/QAtomicIntCompat.h b/src/QAtomicIntCompat.h deleted file mode 100644 index 7fb08d16e..000000000 --- a/src/QAtomicIntCompat.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2005-2019 The Mumble Developers. All rights reserved. -// Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file at the root of the -// Mumble source tree or at . - -#ifndef MUMBLE_QATOMICINTCOMPAT_H_ -#define MUMBLE_QATOMICINTCOMPAT_H_ - -// Portably (between Qt 4 and Qt 5) load the value -// of a QAtomicInt. -inline int QAtomicIntLoad(const QAtomicInt &ai) { -#if QT_VERSION >= 0x050000 - return ai.load(); -#else - return int(ai); -#endif -} - -#endif diff --git a/src/Qt4Compat.h b/src/Qt4Compat.h deleted file mode 100644 index 32d185b33..000000000 --- a/src/Qt4Compat.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2005-2019 The Mumble Developers. All rights reserved. -// Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file at the root of the -// Mumble source tree or at . - -#ifndef MUMBLE_QT4COMPAT_H_ -#define MUMBLE_QT4COMPAT_H_ - -namespace Qt { - -inline QString escape(const QString &plain) { - return plain.toHtmlEscaped(); -} - -} - -#endif \ No newline at end of file diff --git a/src/SSL.cpp b/src/SSL.cpp index 6b803204b..c7d9ed145 100644 --- a/src/SSL.cpp +++ b/src/SSL.cpp @@ -108,120 +108,7 @@ out: } void MumbleSSL::addSystemCA() { -#if QT_VERSION < 0x040700 && !defined(NO_SYSTEM_CA_OVERRIDE) -#if defined(Q_OS_WIN) - QStringList qsl; - qsl << QLatin1String("Ca"); - qsl << QLatin1String("Root"); - qsl << QLatin1String("AuthRoot"); - foreach(const QString &store, qsl) { - HCERTSTORE hCertStore; - PCCERT_CONTEXT pCertContext = NULL; - - bool found = false; - - hCertStore = CertOpenSystemStore(NULL, store.utf16()); - if (! hCertStore) { - qWarning("SSL: Failed to open CA store %s", qPrintable(store)); - continue; - } - - while (pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)) { - QByteArray qba(reinterpret_cast(pCertContext->pbCertEncoded), pCertContext->cbCertEncoded); - - QList ql = QSslCertificate::fromData(qba, QSsl::Pem); - ql += QSslCertificate::fromData(qba, QSsl::Der); - if (! ql.isEmpty()) { - found = true; - QSslSocket::addDefaultCaCertificates(ql); - } - } - if (found) - qWarning("SSL: Added CA certificates from system store '%s'", qPrintable(store)); - - CertCloseStore(hCertStore, 0); - } - -#elif defined(Q_OS_MAC) - CFArrayRef certs = NULL; - bool found = false; - - if (SecTrustCopyAnchorCertificates(&certs) == noErr) { - int ncerts = CFArrayGetCount(certs); - for (int i = 0; i < ncerts; i++) { - CFDataRef data = NULL; - - SecCertificateRef cert = reinterpret_cast(const_cast(CFArrayGetValueAtIndex(certs, i))); - if (! cert) - continue; - - if (SecKeychainItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data) == noErr) { - const char *ptr = reinterpret_cast(CFDataGetBytePtr(data)); - int len = CFDataGetLength(data); - QByteArray qba(ptr, len); - - QList ql = QSslCertificate::fromData(qba, QSsl::Pem); - if (! ql.isEmpty()) { - found = true; - QSslSocket::addDefaultCaCertificates(ql); - } - } - } - - CFRelease(certs); - - if (found) - qWarning("SSL: Added CA certificates from 'System Roots' store."); - } -#elif defined(Q_OS_UNIX) - QStringList qsl; - -#ifdef SYSTEM_CA_DIR - QSslSocket::addDefaultCaCertificates(QLatin1String(MUMTEXT(SYSTEM_CA_DIR))); -#else -#ifdef SYSTEM_CA_BUNDLE - qsl << QLatin1String(MUMTEXT(SYSTEM_CA_BUNDLE)); -#else -#ifdef __FreeBSD__ - qsl << QLatin1String("/usr/local/share/certs/ca-root-nss.crt"); -#else - qsl << QLatin1String("/etc/pki/tls/certs/ca-bundle.crt"); - qsl << QLatin1String("/etc/ssl/certs/ca-certificates.crt"); -#endif -#endif - - foreach(const QString &filename, qsl) { - QFile f(filename); - if (f.exists() && f.open(QIODevice::ReadOnly)) { - QList ql = QSslCertificate::fromDevice(&f, QSsl::Pem); - ql += QSslCertificate::fromDevice(&f, QSsl::Der); - if (! ql.isEmpty()) { - qWarning("SSL: Added CA certificates from '%s'", qPrintable(filename)); - QSslSocket::addDefaultCaCertificates(ql); - } - } - } -#endif // SYSTEM_CA_DIR -#endif // Q_OS_UNIX - - QSet digests; - QList ql; - foreach(const QSslCertificate &crt, QSslSocket::defaultCaCertificates()) { - QByteArray digest = crt.digest(QCryptographicHash::Sha1); - if (! digests.contains(digest) && crt.isValid()) { - ql << crt; - digests.insert(digest); - } - } - QSslSocket::setDefaultCaCertificates(ql); -#endif // NO_SYSTEM_CA_OVERRIDE - - // Don't perform on-demand loading of root certificates -#if QT_VERSION >= 0x050500 QSslSocket::addDefaultCaCertificates(QSslConfiguration::systemCaCertificates()); -#elif QT_VERSION >= 0x040800 - QSslSocket::addDefaultCaCertificates(QSslSocket::systemCaCertificates()); -#endif #ifdef Q_OS_WIN // Work around issue #1271. @@ -233,7 +120,6 @@ void MumbleSSL::addSystemCA() { QList filteredCaList; foreach (QSslCertificate cert, caList) { -#if QT_VERSION >= 0x050000 QStringList orgs = cert.subjectInfo(QSslCertificate::Organization); bool skip = false; foreach (QString ou, orgs) { @@ -245,12 +131,7 @@ void MumbleSSL::addSystemCA() { if (skip) { continue; } -#else - QString ou = cert.subjectInfo(QSslCertificate::Organization); - if (ou.contains(QLatin1String("Skype"), Qt::CaseInsensitive)) { - continue; - } -#endif + filteredCaList.append(cert); } @@ -266,21 +147,15 @@ QString MumbleSSL::protocolToString(QSsl::SslProtocol protocol) { switch(protocol) { case QSsl::SslV3: return QLatin1String("SSL 3"); case QSsl::SslV2: return QLatin1String("SSL 2"); -#if QT_VERSION >= 0x050000 case QSsl::TlsV1_0: return QLatin1String("TLS 1.0"); case QSsl::TlsV1_1: return QLatin1String("TLS 1.1"); case QSsl::TlsV1_2: return QLatin1String("TLS 1.2"); #if QT_VERSION >= 0x050C00 case QSsl::TlsV1_3: return QLatin1String("TLS 1.3"); -#endif -#else - case QSsl::TlsV1: return QLatin1String("TLS 1.0"); #endif case QSsl::AnyProtocol: return QLatin1String("AnyProtocol"); -#if QT_VERSION >= 0x040800 case QSsl::TlsV1SslV3: return QLatin1String("TlsV1SslV3"); case QSsl::SecureProtocols: return QLatin1String("SecureProtocols"); -#endif default: case QSsl::UnknownProtocol: return QLatin1String("UnknownProtocol"); } diff --git a/src/ServerResolver_qt5.cpp b/src/ServerResolver.cpp similarity index 99% rename from src/ServerResolver_qt5.cpp rename to src/ServerResolver.cpp index 299ba6a07..55bbf7cf9 100644 --- a/src/ServerResolver_qt5.cpp +++ b/src/ServerResolver.cpp @@ -157,4 +157,4 @@ QList ServerResolver::records() { return QList(); } -#include "ServerResolver_qt5.moc" +#include "ServerResolver.moc" diff --git a/src/ServerResolver_nosrv.cpp b/src/ServerResolver_nosrv.cpp deleted file mode 100644 index 07b62bdfb..000000000 --- a/src/ServerResolver_nosrv.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2005-2019 The Mumble Developers. All rights reserved. -// Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file at the root of the -// Mumble source tree or at . - -#include "ServerResolver.h" - -#include - -class ServerResolverPrivate : public QObject { - private: - Q_OBJECT - Q_DISABLE_COPY(ServerResolverPrivate) - public: - ServerResolverPrivate(QObject *parent); - - void resolve(QString hostname, quint16 port); - QList records(); - - QString m_origHostname; - quint16 m_origPort; - - QList m_resolved; - - signals: - void resolved(); - - public slots: - void hostResolved(QHostInfo hostInfo); -}; - -ServerResolverPrivate::ServerResolverPrivate(QObject *parent) - : QObject(parent) - , m_origPort(0) { -} - -void ServerResolverPrivate::resolve(QString hostname, quint16 port) { - m_origHostname = hostname; - m_origPort = port; - - QHostInfo::lookupHost(hostname, this, SLOT(hostResolved(QHostInfo))); -} - -QList ServerResolverPrivate::records() { - return m_resolved; -} - -void ServerResolverPrivate::hostResolved(QHostInfo hostInfo) { - if (hostInfo.error() == QHostInfo::NoError) { - QList resolvedAddresses = hostInfo.addresses(); - - // Convert QHostAddress -> HostAddress. - QList addresses; - foreach (QHostAddress ha, resolvedAddresses) { - addresses << HostAddress(ha); - } - - m_resolved << ServerResolverRecord(m_origHostname, m_origPort, 0, addresses); - } - - emit resolved(); -} - -ServerResolver::ServerResolver(QObject *parent) - : QObject(parent) { - - d = new ServerResolverPrivate(this); -} - -QString ServerResolver::hostname() { - if (d) { - return d->m_origHostname; - } - - return QString(); -} - -quint16 ServerResolver::port() { - if (d) { - return d->m_origPort; - } - - return 0; -} - -void ServerResolver::resolve(QString hostname, quint16 port) { - if (d) { - connect(d, SIGNAL(resolved()), this, SIGNAL(resolved())); - d->resolve(hostname, port); - } -} - -QList ServerResolver::records() { - if (d) { - return d->records(); - } - return QList(); -} - -#include "ServerResolver_nosrv.moc" diff --git a/src/Utils.h b/src/Utils.h index a1a66e2f6..5de584299 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -8,9 +8,6 @@ #ifndef MUMBLE_UTILS_H_ #define MUMBLE_UTILS_H_ -#include "QAtomicIntCompat.h" -#include "Qt4Compat.h" - #include #define iroundf(x) ( static_cast(x) ) diff --git a/src/mumble.pri b/src/mumble.pri index 878e590b9..630f7e12d 100644 --- a/src/mumble.pri +++ b/src/mumble.pri @@ -72,7 +72,7 @@ SOURCES *= \ EnvUtils.cpp \ UnresolvedServerAddress.cpp \ ServerAddress.cpp \ - ServerResolver_qt5.cpp \ + ServerResolver.cpp \ ServerResolverRecord.cpp \ SelfSignedCertificate.cpp \ SSLLocks.cpp \ @@ -80,16 +80,6 @@ SOURCES *= \ LIBS *= -lmumble_proto -equals(QT_MAJOR_VERSION, 4) { - CONFIG *= no-srv -} - -CONFIG(no-srv) { - DEFINES += USE_NO_SRV - SOURCES -= ServerResolver_qt5.cpp - SOURCES *= ServerResolver_nosrv.cpp -} - # Add arc4random_uniform INCLUDEPATH *= ../../3rdparty/arc4random-src SOURCES *= ../../3rdparty/arc4random-src/arc4random_uniform.cpp @@ -130,13 +120,6 @@ unix { QMAKE_CXXFLAGS *= "-I../mumble_proto" "-isystem ../mumble_proto" } -# Make Q_DECL_OVERRIDE and Q_DECL_FINAL no-ops -# for Qt 4. -isEqual(QT_MAJOR_VERSION, 4) { - DEFINES *= Q_DECL_OVERRIDE= - DEFINES *= Q_DECL_FINAL= -} - CONFIG(debug, debug|release) { CONFIG += console } diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp index 06b282f9e..9f5173017 100644 --- a/src/mumble/ALSAAudio.cpp +++ b/src/mumble/ALSAAudio.cpp @@ -338,7 +338,7 @@ void ALSAAudioInput::run() { snd_pcm_close(capture_handle); capture_handle = NULL; } - g.mw->msgBox(tr("Opening chosen ALSA Input failed: %1").arg(Qt::escape(QLatin1String(snd_strerror(err))))); + g.mw->msgBox(tr("Opening chosen ALSA Input failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped())); return; } @@ -476,7 +476,7 @@ void ALSAAudioOutput::run() { snd_pcm_writei(pcm_handle, zerobuff, period_size); if (! bOk) { - g.mw->msgBox(tr("Opening chosen ALSA Output failed: %1").arg(Qt::escape(QLatin1String(snd_strerror(err))))); + g.mw->msgBox(tr("Opening chosen ALSA Output failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped())); if (pcm_handle) { snd_pcm_close(pcm_handle); pcm_handle = NULL; diff --git a/src/mumble/ASIOInput.cpp b/src/mumble/ASIOInput.cpp index e6fc34e9f..49cbd0aff 100644 --- a/src/mumble/ASIOInput.cpp +++ b/src/mumble/ASIOInput.cpp @@ -256,7 +256,7 @@ void ASIOConfig::on_qpbQuery_clicked() { char err[255]; iasio->getErrorMessage(err); SleepEx(10, false); - QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(Qt::escape(QLatin1String(err))), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(QString::fromLatin1(err).toHtmlEscaped()), QMessageBox::Ok, QMessageBox::NoButton); } iasio->Release(); } else { @@ -281,7 +281,7 @@ void ASIOConfig::on_qpbConfig_clicked() { char err[255]; iasio->getErrorMessage(err); SleepEx(10, false); - QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(Qt::escape(QLatin1String(err))), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(QString::fromLatin1(err).toHtmlEscaped()), QMessageBox::Ok, QMessageBox::NoButton); } iasio->Release(); } else { diff --git a/src/mumble/About.cpp b/src/mumble/About.cpp index eef2f44e4..9885e9deb 100644 --- a/src/mumble/About.cpp +++ b/src/mumble/About.cpp @@ -36,9 +36,9 @@ AboutDialog::AboutDialog(QWidget *p) : QDialog(p) { QList thirdPartyLicenses = License::thirdPartyLicenses(); foreach(LicenseInfo li, thirdPartyLicenses) { qtb3rdPartyLicense->append(QString::fromLatin1("

%1 (%2)

%3
") - .arg(Qt::escape(li.name)) - .arg(Qt::escape(li.url)) - .arg(Qt::escape(li.license))); + .arg(li.name.toHtmlEscaped()) + .arg(li.url.toHtmlEscaped()) + .arg(li.license.toHtmlEscaped())); } qtb3rdPartyLicense->moveCursor(QTextCursor::Start); diff --git a/src/mumble/About.h b/src/mumble/About.h index 06476b266..73cda9c18 100644 --- a/src/mumble/About.h +++ b/src/mumble/About.h @@ -8,11 +8,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include class AboutDialog : public QDialog { private: diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp index 96405be4a..e19a5c36f 100644 --- a/src/mumble/AudioConfigDialog.cpp +++ b/src/mumble/AudioConfigDialog.cpp @@ -371,7 +371,7 @@ void AudioInputDialog::on_qcbSystem_currentIndexChanged(int) { foreach(audioDevice d, ql) { qcbDevice->addItem(d.first, d.second); - qcbDevice->setItemData(idx, Qt::escape(d.first), Qt::ToolTipRole); + qcbDevice->setItemData(idx, d.first.toHtmlEscaped(), Qt::ToolTipRole); ++idx; } @@ -524,7 +524,7 @@ void AudioOutputDialog::on_qcbSystem_currentIndexChanged(int) { foreach(audioDevice d, ql) { qcbDevice->addItem(d.first, d.second); - qcbDevice->setItemData(idx, Qt::escape(d.first), Qt::ToolTipRole); + qcbDevice->setItemData(idx, d.first.toHtmlEscaped(), Qt::ToolTipRole); ++idx; } bool canmute = aor->canMuteOthers(); diff --git a/src/mumble/AudioOutputSample.cpp b/src/mumble/AudioOutputSample.cpp index 099e4b0f0..a6217eba7 100644 --- a/src/mumble/AudioOutputSample.cpp +++ b/src/mumble/AudioOutputSample.cpp @@ -194,7 +194,7 @@ QString AudioOutputSample::browseForSndfile(QString defaultpath) { if (sf == NULL) { QMessageBox::critical(NULL, tr("Invalid sound file"), - tr("The file '%1' cannot be used by Mumble. Please select a file with a compatible format and encoding.").arg(Qt::escape(file))); + tr("The file '%1' cannot be used by Mumble. Please select a file with a compatible format and encoding.").arg(file.toHtmlEscaped())); return QString(); } delete sf; diff --git a/src/mumble/AudioStats.h b/src/mumble/AudioStats.h index 46e91be79..e67f9bc73 100644 --- a/src/mumble/AudioStats.h +++ b/src/mumble/AudioStats.h @@ -9,11 +9,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include class AudioBar : public QWidget { private: diff --git a/src/mumble/AudioWizard.h b/src/mumble/AudioWizard.h index ddd500fce..12b76bd85 100644 --- a/src/mumble/AudioWizard.h +++ b/src/mumble/AudioWizard.h @@ -7,13 +7,8 @@ #define MUMBLE_MUMBLE_AUDIOWIZARD_H_ #include -#if QT_VERSION >= 0x050000 -# include -# include -#else -# include -# include -#endif +#include +#include #include "AudioStats.h" #include "AudioOutput.h" diff --git a/src/mumble/Cert.cpp b/src/mumble/Cert.cpp index fabcfb956..f07dcda47 100644 --- a/src/mumble/Cert.cpp +++ b/src/mumble/Cert.cpp @@ -79,7 +79,6 @@ void CertView::setCert(const QList &cert) { } else { QSslCertificate qscCert = qlCert.at(0); -#if QT_VERSION >= 0x050000 const QStringList &names = qscCert.subjectInfo(QSslCertificate::CommonName); QString name; if (names.count() > 0) { @@ -87,10 +86,6 @@ void CertView::setCert(const QList &cert) { } QStringList emails = qscCert.subjectAlternativeNames().values(QSsl::EmailEntry); -#else - const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName); - QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry)); -#endif QString tmpName = name; tmpName = tmpName.replace(QLatin1String("\\x"), QLatin1String("%")); @@ -104,22 +99,19 @@ void CertView::setCert(const QList &cert) { qlSubjectEmail->setText(tr("(none)")); if (qscCert.expiryDate() <= QDateTime::currentDateTime()) - qlExpiry->setText(QString::fromLatin1("%1").arg(Qt::escape(qscCert.expiryDate().toString(Qt::SystemLocaleDate)))); + qlExpiry->setText(QString::fromLatin1("%1").arg(qscCert.expiryDate().toString(Qt::SystemLocaleDate).toHtmlEscaped())); else qlExpiry->setText(qscCert.expiryDate().toString(Qt::SystemLocaleDate)); if (qlCert.count() > 1) qscCert = qlCert.last(); -#if QT_VERSION >= 0x050000 const QStringList &issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName); QString issuerName; if (issuerNames.count() > 0) { issuerName = issuerNames.at(0); } -#else - const QString &issuerName = qscCert.issuerInfo(QSslCertificate::CommonName); -#endif + qlIssuerName->setText((issuerName == name) ? tr("Self-signed") : issuerName); } } diff --git a/src/mumble/Cert.h b/src/mumble/Cert.h index 729b0f5e5..a62ca44ab 100644 --- a/src/mumble/Cert.h +++ b/src/mumble/Cert.h @@ -8,11 +8,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include #include #include diff --git a/src/mumble/ConfigWidget.h b/src/mumble/ConfigWidget.h index d5379b0f7..34c4f95a1 100644 --- a/src/mumble/ConfigWidget.h +++ b/src/mumble/ConfigWidget.h @@ -8,11 +8,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include struct Settings; class ConfigDialog; diff --git a/src/mumble/ConnectDialog.cpp b/src/mumble/ConnectDialog.cpp index aa622162d..56adf2c75 100644 --- a/src/mumble/ConnectDialog.cpp +++ b/src/mumble/ConnectDialog.cpp @@ -415,16 +415,10 @@ ServerItem *ServerItem::fromMimeData(const QMimeData *mime, bool default_name, Q } if (default_name) { -#if QT_VERSION >= 0x050000 QUrlQuery query(url); if (! query.hasQueryItem(QLatin1String("title"))) { query.addQueryItem(QLatin1String("title"), url.host()); } -#else - if (! url.hasQueryItem(QLatin1String("title"))) { - url.addQueryItem(QLatin1String("title"), url.host()); - } -#endif } if (! url.isValid()) { @@ -454,9 +448,7 @@ ServerItem *ServerItem::fromUrl(QUrl url, QWidget *p) { return NULL; } -#if QT_VERSION >= 0x050000 QUrlQuery query(url); -#endif if (url.userName().isEmpty()) { if (g.s.qsUsername.isEmpty()) { @@ -471,17 +463,10 @@ ServerItem *ServerItem::fromUrl(QUrl url, QWidget *p) { url.setUserName(g.s.qsUsername); } -#if QT_VERSION >= 0x050000 ServerItem *si = new ServerItem(query.queryItemValue(QLatin1String("title")), url.host(), static_cast(url.port(DEFAULT_MUMBLE_PORT)), url.userName(), url.password()); if (query.hasQueryItem(QLatin1String("url"))) si->qsUrl = query.queryItemValue(QLatin1String("url")); -#else - ServerItem *si = new ServerItem(url.queryItemValue(QLatin1String("title")), url.host(), static_cast(url.port(DEFAULT_MUMBLE_PORT)), url.userName(), url.password()); - - if (url.hasQueryItem(QLatin1String("url"))) - si->qsUrl = url.queryItemValue(QLatin1String("url")); -#endif return si; } @@ -521,7 +506,8 @@ QVariant ServerItem::data(int column, int role) const { } else if (role == Qt::ToolTipRole) { QStringList qsl; foreach(const ServerAddress &addr, qlAddresses) { - qsl << Qt::escape(addr.host.toString() + QLatin1String(":") + QString::number(static_cast(addr.port))); + const QString qsAddress = addr.host.toString() + QLatin1String(":") + QString::number(static_cast(addr.port)); + qsl << qsAddress.toHtmlEscaped(); } double ploss = 100.0; @@ -532,18 +518,18 @@ QVariant ServerItem::data(int column, int role) const { QString qs; qs += QLatin1String("") + - QString::fromLatin1("").arg(ConnectDialog::tr("Servername"), Qt::escape(qsName)) + - QString::fromLatin1("").arg(ConnectDialog::tr("Hostname"), Qt::escape(qsHostname)); + QString::fromLatin1("").arg(ConnectDialog::tr("Servername"), qsName.toHtmlEscaped()) + + QString::fromLatin1("").arg(ConnectDialog::tr("Hostname"), qsHostname.toHtmlEscaped()); if (! qsBonjourHost.isEmpty()) - qs += QString::fromLatin1("").arg(ConnectDialog::tr("Bonjour name"), Qt::escape(qsBonjourHost)); + qs += QString::fromLatin1("").arg(ConnectDialog::tr("Bonjour name"), qsBonjourHost.toHtmlEscaped()); qs += QString::fromLatin1("").arg(ConnectDialog::tr("Port")).arg(usPort) + QString::fromLatin1("").arg(ConnectDialog::tr("Addresses"), qsl.join(QLatin1String(", "))); if (! qsUrl.isEmpty()) - qs += QString::fromLatin1("").arg(ConnectDialog::tr("Website"), Qt::escape(qsUrl)); + qs += QString::fromLatin1("").arg(ConnectDialog::tr("Website"), qsUrl.toHtmlEscaped()); if (uiSent > 0) { qs += QString::fromLatin1("").arg(ConnectDialog::tr("Packet loss"), QString::fromLatin1("%1% (%2/%3)").arg(ploss, 0, 'f', 1).arg(uiRecv).arg(uiSent)); @@ -671,15 +657,10 @@ QMimeData *ServerItem::toMimeData(const QString &name, const QString &host, unsi url.setPort(port); url.setPath(channel); -#if QT_VERSION >= 0x050000 QUrlQuery query; query.addQueryItem(QLatin1String("title"), name); query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); url.setQuery(query); -#else - url.addQueryItem(QLatin1String("title"), name); - url.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); -#endif QString qs = QLatin1String(url.toEncoded()); @@ -723,7 +704,7 @@ QMimeData *ServerItem::toMimeData(const QString &name, const QString &host, unsi mime->setUrls(urls); mime->setText(qs); - mime->setHtml(QString::fromLatin1("%2").arg(qs).arg(Qt::escape(name))); + mime->setHtml(QString::fromLatin1("%2").arg(qs).arg(name.toHtmlEscaped())); return mime; } @@ -1011,7 +992,6 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo qtwServers->sortItems(1, Qt::AscendingOrder); -#if QT_VERSION >= 0x050000 qtwServers->header()->setSectionResizeMode(0, QHeaderView::Stretch); if (qtwServers->columnCount() >= 2) { qtwServers->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); @@ -1019,15 +999,6 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo if (qtwServers->columnCount() >= 3) { qtwServers->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); } -#else - qtwServers->header()->setResizeMode(0, QHeaderView::Stretch); - if (qtwServers->columnCount() >= 2) { - qtwServers->header()->setResizeMode(1, QHeaderView::ResizeToContents); - } - if (qtwServers->columnCount() >= 3) { - qtwServers->header()->setResizeMode(2, QHeaderView::ResizeToContents); - } -#endif connect(qtwServers->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(OnSortChanged(int, Qt::SortOrder))); @@ -1379,13 +1350,10 @@ void ConnectDialog::initList() { QUrl url; url.setPath(QLatin1String("/v1/list")); -#if QT_VERSION >= 0x050000 + QUrlQuery query; query.addQueryItem(QLatin1String("version"), QLatin1String(MUMTEXT(MUMBLE_VERSION_STRING))); url.setQuery(query); -#else - url.addQueryItem(QLatin1String("version"), QLatin1String(MUMTEXT(MUMBLE_VERSION_STRING))); -#endif WebFetch::fetch(QLatin1String("publist"), url, this, SLOT(fetched(QByteArray,QUrl,QMap))); } diff --git a/src/mumble/ConnectDialog.h b/src/mumble/ConnectDialog.h index b2194f957..0463a40c6 100644 --- a/src/mumble/ConnectDialog.h +++ b/src/mumble/ConnectDialog.h @@ -14,15 +14,9 @@ #include #include #include -#if QT_VERSION >= 0x050000 -# include -# include -# include -#else -# include -# include -# include -#endif +#include +#include +#include #include diff --git a/src/mumble/CrashReporter.h b/src/mumble/CrashReporter.h index c64ee83e2..45e6baa7a 100644 --- a/src/mumble/CrashReporter.h +++ b/src/mumble/CrashReporter.h @@ -9,18 +9,10 @@ #include #include #include - -#if QT_VERSION >= 0x050000 -# include -# include -# include -# include -#else -# include -# include -# include -# include -#endif +#include +#include +#include +#include class CrashReporter : QDialog { Q_OBJECT diff --git a/src/mumble/CustomElements.h b/src/mumble/CustomElements.h index 985ec929a..59067201f 100644 --- a/src/mumble/CustomElements.h +++ b/src/mumble/CustomElements.h @@ -7,16 +7,9 @@ #define MUMBLE_MUMBLE_CUSTOMELEMENTS_H_ #include - -#if QT_VERSION >= 0x050000 -# include -# include -# include -#else -# include -# include -# include -#endif +#include +#include +#include class LogTextBrowser : public QTextBrowser { private: diff --git a/src/mumble/DBus.cpp b/src/mumble/DBus.cpp index 646be653d..108797e71 100644 --- a/src/mumble/DBus.cpp +++ b/src/mumble/DBus.cpp @@ -46,13 +46,9 @@ void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) { u.setPort(port); u.setUserName(user); -#if QT_VERSION >= 0x050000 QUrlQuery query; query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); u.setQuery(query); -#else - u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); -#endif QStringList path; Channel *c = ClientUser::get(g.uiSession)->cChannel; diff --git a/src/mumble/Database.cpp b/src/mumble/Database.cpp index 941bb8080..da2ef6f34 100644 --- a/src/mumble/Database.cpp +++ b/src/mumble/Database.cpp @@ -47,11 +47,7 @@ Database::Database(const QString &dbname) { int i; datapaths << g.qdBasePath.absolutePath(); -#if QT_VERSION >= 0x050000 datapaths << QStandardPaths::writableLocation(QStandardPaths::DataLocation); -#else - datapaths << QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif #if defined(Q_OS_UNIX) && ! defined(Q_OS_MAC) datapaths << QDir::homePath() + QLatin1String("/.config/Mumble"); #endif @@ -100,7 +96,7 @@ Database::Database(const QString &dbname) { QFileInfo fi(db.databaseName()); if (! fi.isWritable()) { - QMessageBox::critical(NULL, QLatin1String("Mumble"), tr("The database '%1' is read-only. Mumble cannot store server settings (i.e. SSL certificates) until you fix this problem.").arg(Qt::escape(fi.filePath())), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); + QMessageBox::critical(NULL, QLatin1String("Mumble"), tr("The database '%1' is read-only. Mumble cannot store server settings (i.e. SSL certificates) until you fix this problem.").arg(fi.filePath().toHtmlEscaped()), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); qWarning("Database: Database is read-only"); } diff --git a/src/mumble/DeveloperConsole.h b/src/mumble/DeveloperConsole.h index 9c1573165..2f72fef98 100644 --- a/src/mumble/DeveloperConsole.h +++ b/src/mumble/DeveloperConsole.h @@ -8,12 +8,8 @@ #include #include -# include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include +#include class DeveloperConsole : public QObject { private: diff --git a/src/mumble/Global.cpp b/src/mumble/Global.cpp index 41ec60e17..f3b82aa85 100644 --- a/src/mumble/Global.cpp +++ b/src/mumble/Global.cpp @@ -20,11 +20,7 @@ Global *Global::g_global_struct; static void migrateDataDir() { #ifdef Q_OS_MAC QString olddir = QDir::homePath() + QLatin1String("/Library/Preferences/Mumble"); -#if QT_VERSION >= 0x050000 QString newdir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); -#else - QString newdir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif // QT_VERSION QString linksTo = QFile::symLinkTarget(olddir); if (!QFile::exists(newdir) && QFile::exists(olddir) && linksTo.isEmpty()) { QDir d; @@ -49,7 +45,6 @@ static void migrateDataDir() { // Qt4 used another data directory on Unix-like systems, to ensure a seamless // transition we must first move the users data to the new directory. #if defined(Q_OS_UNIX) && ! defined(Q_OS_MAC) -#if QT_VERSION >= 0x050000 QString olddir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/data/Mumble"); QString newdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/Mumble"); @@ -66,7 +61,6 @@ static void migrateDataDir() { } qWarning("Application data migration failed."); -#endif // QT_VERSION #endif // defined(Q_OS_UNIX) && ! defined(Q_OS_MAC) } #endif // Q_OS_WIN @@ -121,11 +115,8 @@ Global::Global() { QStringList qsl; qsl << QCoreApplication::instance()->applicationDirPath(); -#if QT_VERSION >= 0x050000 qsl << QStandardPaths::writableLocation(QStandardPaths::DataLocation); -#else - qsl << QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif + #if defined(Q_OS_WIN) QString appdata; wchar_t appData[MAX_PATH]; @@ -155,11 +146,7 @@ Global::Global() { qdBasePath.setPath(appdata); #else migrateDataDir(); -#if QT_VERSION >= 0x050000 qdBasePath.setPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); -#else - qdBasePath.setPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); -#endif #endif if (! qdBasePath.exists()) { QDir::root().mkpath(qdBasePath.absolutePath()); diff --git a/src/mumble/GlobalShortcut.cpp b/src/mumble/GlobalShortcut.cpp index 26c5b5e19..6272285da 100644 --- a/src/mumble/GlobalShortcut.cpp +++ b/src/mumble/GlobalShortcut.cpp @@ -529,20 +529,11 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) { qtwShortcuts->setColumnCount(canSuppress ? 4 : 3); qtwShortcuts->setItemDelegate(new ShortcutDelegate(qtwShortcuts)); -#if QT_VERSION >= 0x050000 qtwShortcuts->header()->setSectionResizeMode(0, QHeaderView::Fixed); qtwShortcuts->header()->resizeSection(0, 150); qtwShortcuts->header()->setSectionResizeMode(2, QHeaderView::Stretch); if (canSuppress) qtwShortcuts->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); -#else - qtwShortcuts->header()->setResizeMode(0, QHeaderView::Fixed); - qtwShortcuts->header()->resizeSection(0, 150); - qtwShortcuts->header()->setResizeMode(2, QHeaderView::Stretch); - if (canSuppress) - qtwShortcuts->header()->setResizeMode(3, QHeaderView::ResizeToContents); -#endif - qcbEnableGlobalShortcuts->setVisible(canDisable); diff --git a/src/mumble/GlobalShortcut.h b/src/mumble/GlobalShortcut.h index 7ed07efaa..e1d1edbb1 100644 --- a/src/mumble/GlobalShortcut.h +++ b/src/mumble/GlobalShortcut.h @@ -8,13 +8,8 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -# include -#else -# include -# include -#endif +#include +#include #include "ConfigDialog.h" #include "Timer.h" diff --git a/src/mumble/LCD.cpp b/src/mumble/LCD.cpp index 62385eaf9..8a909c4c4 100644 --- a/src/mumble/LCD.cpp +++ b/src/mumble/LCD.cpp @@ -88,7 +88,7 @@ LCDConfig::LCDConfig(Settings &st) : ConfigWidget(st) { qtwi->setFlags(Qt::ItemIsEnabled |Qt::ItemIsUserCheckable); qtwi->setText(0, d->name()); - qtwi->setToolTip(0, Qt::escape(d->name())); + qtwi->setToolTip(0, d->name().toHtmlEscaped()); QSize lcdsize = d->size(); QString qsSize = QString::fromLatin1("%1x%2").arg(lcdsize.width()).arg(lcdsize.height()); diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 274da974d..3e39be694 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -39,21 +39,12 @@ LogConfig::LogConfig(Settings &st) : ConfigWidget(st) { qgbTTS->setDisabled(true); #endif -#if QT_VERSION >= 0x050000 qtwMessages->header()->setSectionResizeMode(ColMessage, QHeaderView::Stretch); qtwMessages->header()->setSectionResizeMode(ColConsole, QHeaderView::ResizeToContents); qtwMessages->header()->setSectionResizeMode(ColNotification, QHeaderView::ResizeToContents); qtwMessages->header()->setSectionResizeMode(ColHighlight, QHeaderView::ResizeToContents); qtwMessages->header()->setSectionResizeMode(ColTTS, QHeaderView::ResizeToContents); qtwMessages->header()->setSectionResizeMode(ColStaticSound, QHeaderView::ResizeToContents); -#else - qtwMessages->header()->setResizeMode(ColMessage, QHeaderView::Stretch); - qtwMessages->header()->setResizeMode(ColConsole, QHeaderView::ResizeToContents); - qtwMessages->header()->setResizeMode(ColNotification, QHeaderView::ResizeToContents); - qtwMessages->header()->setResizeMode(ColHighlight, QHeaderView::ResizeToContents); - qtwMessages->header()->setResizeMode(ColTTS, QHeaderView::ResizeToContents); - qtwMessages->header()->setResizeMode(ColStaticSound, QHeaderView::ResizeToContents); -#endif QTreeWidgetItem *twi; for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) { @@ -301,7 +292,7 @@ QString Log::msgColor(const QString &text, LogColorType t) { } QString Log::formatChannel(::Channel *c) { - return QString::fromLatin1("%2").arg(c->iId).arg(Qt::escape(c->qsName)).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64())); + return QString::fromLatin1("%2").arg(c->iId).arg(c->qsName.toHtmlEscaped()).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64())); } QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &displayName) { @@ -313,7 +304,7 @@ QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &dis } if (cu) { - QString name = Qt::escape(displayName.isNull() ? cu->qsName : displayName); + QString name = (displayName.isNull() ? cu->qsName : displayName).toHtmlEscaped(); if (cu->qsHash.isEmpty()) { return QString::fromLatin1("%3").arg(className).arg(cu->uiSession).arg(name).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64())); } else { @@ -489,7 +480,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own if (qdDate != dt.date()) { qdDate = dt.date(); tc.insertBlock(); - tc.insertHtml(tr("[Date changed to %1]\n").arg(Qt::escape(qdDate.toString(Qt::DefaultLocaleShortDate)))); + tc.insertHtml(tr("[Date changed to %1]\n").arg(qdDate.toString(Qt::DefaultLocaleShortDate).toHtmlEscaped())); tc.movePosition(QTextCursor::End); } @@ -502,7 +493,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own } else if (! g.mw->qteLog->document()->isEmpty()) { tc.insertBlock(); } - tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(Qt::escape(dt.time().toString())), Log::Time)); + tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(dt.time().toString().toHtmlEscaped()), Log::Time)); validHtml(console, &tc); tc.movePosition(QTextCursor::End); g.mw->qteLog->setTextCursor(tc); diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 83911c152..5459778d7 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -135,11 +135,6 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) { qwPTTButtonWidget = NULL; -#if QT_VERSION < 0x050000 - cuContextUser = QWeakPointer(); - cContextChannel = QWeakPointer(); -#endif - qtReconnect = new QTimer(this); qtReconnect->setInterval(10000); qtReconnect->setSingleShot(true); @@ -356,9 +351,7 @@ void MainWindow::setupGui() { updateTransmitModeComboBox(); -// For Qt >= 5, enable this call (only) for Windows. -// For Qt < 5, enable for anything but macOS. -#if (QT_VERSION >= 0x050000 && defined(Q_OS_WIN)) || (QT_VERSION < 0x050000 && !defined(Q_OS_MAC)) +#ifdef Q_OS_WIN setupView(false); #endif @@ -383,12 +376,6 @@ void MainWindow::setupGui() { #ifdef Q_OS_MAC setWindowOpacity(1.0f); -#if QT_VERSION < 0x040700 - // Process pending events. This is done to force the unified - // toolbar to show up as soon as possible (and not wait until - // we are back into the Cocoa mainloop) - qApp->processEvents(); -#endif #endif } @@ -437,12 +424,8 @@ void MainWindow::msgBox(QString msg) { } #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050000 bool MainWindow::nativeEvent(const QByteArray &, void *message, long *) { MSG *msg = reinterpret_cast(message); -#else -bool MainWindow::winEvent(MSG *msg, long *) { -#endif if (msg->message == WM_DEVICECHANGE && msg->wParam == DBT_DEVNODES_CHANGED) uiNewHardware++; @@ -795,17 +778,13 @@ void MainWindow::saveImageAs() { updateImagePath(fname); if (!ok) { - g.l->log(Log::Warning, tr("Could not save image: %1").arg(Qt::escape(fname))); + g.l->log(Log::Warning, tr("Could not save image: %1").arg(fname.toHtmlEscaped())); } } QString MainWindow::getImagePath(QString filename) const { if (g.s.qsImagePath.isEmpty() || ! QDir(g.s.qsImagePath).exists()) { -#if QT_VERSION >= 0x050000 g.s.qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); -#else - g.s.qsImagePath = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); -#endif } if (filename.isEmpty()) { return g.s.qsImagePath; @@ -841,7 +820,7 @@ static void recreateServerHandler() { } void MainWindow::openUrl(const QUrl &url) { - g.l->log(Log::Information, tr("Opening URL %1").arg(Qt::escape(url.toString()))); + g.l->log(Log::Information, tr("Opening URL %1").arg(url.toString().toHtmlEscaped())); if (url.scheme() == QLatin1String("file")) { QFile f(url.toLocalFile()); if (! f.exists() || ! f.open(QIODevice::ReadOnly)) { @@ -878,12 +857,8 @@ void MainWindow::openUrl(const QUrl &url) { minor = 2; patch = 0; -#if QT_VERSION >= 0x050000 QUrlQuery query(url); QString version = query.queryItemValue(QLatin1String("version")); -#else - QString version = url.queryItemValue(QLatin1String("version")); -#endif MumbleVersion::get(&major, &minor, &patch, version); if ((major < 1) || // No pre 1.2.0 @@ -902,13 +877,8 @@ void MainWindow::openUrl(const QUrl &url) { qsDesiredChannel = url.path(); QString name; -#if QT_VERSION >= 0x050000 if (query.hasQueryItem(QLatin1String("title"))) name = query.queryItemValue(QLatin1String("title")); -#else - if (url.hasQueryItem(QLatin1String("title"))) - name = url.queryItemValue(QLatin1String("title")); -#endif if (g.sh && g.sh->isRunning()) { QString oHost, oUser, oPw; @@ -942,7 +912,7 @@ void MainWindow::openUrl(const QUrl &url) { rtLast = MumbleProto::Reject_RejectType_None; bRetryServer = true; qaServerDisconnect->setEnabled(true); - g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(Qt::escape(host), Log::Server))); + g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(host.toHtmlEscaped(), Log::Server))); g.sh->setConnectionInfo(host, port, user, pw); g.sh->start(QThread::TimeCriticalPriority); } @@ -1163,7 +1133,7 @@ void MainWindow::on_qaServerConnect_triggered(bool autoconnect) { rtLast = MumbleProto::Reject_RejectType_None; bRetryServer = true; qaServerDisconnect->setEnabled(true); - g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(Qt::escape(cd->qsServer), Log::Server))); + g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(cd->qsServer.toHtmlEscaped(), Log::Server))); g.sh->setConnectionInfo(cd->qsServer, cd->usPort, cd->qsUsername, cd->qsPassword); g.sh->start(QThread::TimeCriticalPriority); } @@ -1239,7 +1209,7 @@ void MainWindow::on_qaSelfRegister_triggered() { return; QMessageBox::StandardButton result; - result = QMessageBox::question(this, tr("Register yourself as %1").arg(p->qsName), tr("

You are about to register yourself on this server. This action cannot be undone, and your username cannot be changed once this is done. You will forever be known as '%1' on this server.

Are you sure you want to register yourself?

").arg(Qt::escape(p->qsName)), QMessageBox::Yes|QMessageBox::No); + result = QMessageBox::question(this, tr("Register yourself as %1").arg(p->qsName), tr("

You are about to register yourself on this server. This action cannot be undone, and your username cannot be changed once this is done. You will forever be known as '%1' on this server.

Are you sure you want to register yourself?

").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes|QMessageBox::No); if (result == QMessageBox::Yes) g.sh->registerUser(p->uiSession); @@ -1351,7 +1321,7 @@ void MainWindow::on_qaServerInformation_triggered() { qsVersion.append(tr("

No build information or OS version available

")); } else { qsVersion.append(tr("

%1 (%2)
%3

") - .arg(Qt::escape(g.sh->qsRelease), Qt::escape(g.sh->qsOS), Qt::escape(g.sh->qsOSVersion))); + .arg(g.sh->qsRelease.toHtmlEscaped(), g.sh->qsOS.toHtmlEscaped(), g.sh->qsOSVersion.toHtmlEscaped())); } QString host, uname, pw; @@ -1403,12 +1373,12 @@ void MainWindow::on_qaServerInformation_triggered() { "%3" "

%4 ms average latency (%5 deviation)

" "

Remote host %6 (port %7)

").arg( - Qt::escape(c->sessionProtocolString()), + c->sessionProtocolString().toHtmlEscaped(), cipherDescription, cipherPFSInfo, QString::fromLatin1("%1").arg(boost::accumulators::mean(g.sh->accTCP), 0, 'f', 2), QString::fromLatin1("%1").arg(sqrt(boost::accumulators::variance(g.sh->accTCP)),0,'f',2), - Qt::escape(host), + host.toHtmlEscaped(), QString::number(port)); if (g.uiMaxUsers) { qsControl += tr("

Connected users: %1/%2

").arg(ModelItem::c_qhUsers.count()).arg(g.uiMaxUsers); @@ -1688,9 +1658,9 @@ void MainWindow::on_qaUserRegister_triggered() { QMessageBox::StandardButton result; if (session == g.uiSession) - result = QMessageBox::question(this, tr("Register yourself as %1").arg(p->qsName), tr("

You are about to register yourself on this server. This action cannot be undone, and your username cannot be changed once this is done. You will forever be known as '%1' on this server.

Are you sure you want to register yourself?

").arg(Qt::escape(p->qsName)), QMessageBox::Yes|QMessageBox::No); + result = QMessageBox::question(this, tr("Register yourself as %1").arg(p->qsName), tr("

You are about to register yourself on this server. This action cannot be undone, and your username cannot be changed once this is done. You will forever be known as '%1' on this server.

Are you sure you want to register yourself?

").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes|QMessageBox::No); else - result = QMessageBox::question(this, tr("Register user %1").arg(p->qsName), tr("

You are about to register %1 on the server. This action cannot be undone, the username cannot be changed, and as a registered user, %1 will have access to the server even if you change the server password.

From this point on, %1 will be authenticated with the certificate currently in use.

Are you sure you want to register %1?

").arg(Qt::escape(p->qsName)), QMessageBox::Yes|QMessageBox::No); + result = QMessageBox::question(this, tr("Register user %1").arg(p->qsName), tr("

You are about to register %1 on the server. This action cannot be undone, the username cannot be changed, and as a registered user, %1 will have access to the server even if you change the server password.

From this point on, %1 will be authenticated with the certificate currently in use.

Are you sure you want to register %1?

").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes|QMessageBox::No); if (result == QMessageBox::Yes) { p = ClientUser::get(session); @@ -1826,7 +1796,7 @@ void MainWindow::on_qaUserCommentReset_triggered() { unsigned int session = p->uiSession; int ret = QMessageBox::question(this, QLatin1String("Mumble"), - tr("Are you sure you want to reset the comment of user %1?").arg(Qt::escape(p->qsName)), + tr("Are you sure you want to reset the comment of user %1?").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes, QMessageBox::No); if (ret == QMessageBox::Yes) { g.sh->setUserComment(session, QString()); @@ -1842,7 +1812,7 @@ void MainWindow::on_qaUserTextureReset_triggered() { unsigned int session = p->uiSession; int ret = QMessageBox::question(this, QLatin1String("Mumble"), - tr("Are you sure you want to reset the avatar of user %1?").arg(Qt::escape(p->qsName)), + tr("Are you sure you want to reset the avatar of user %1?").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes, QMessageBox::No); if (ret == QMessageBox::Yes) { g.sh->setUserTexture(session, QByteArray()); @@ -1873,11 +1843,7 @@ void MainWindow::sendChatbarMessage(QString qsText) { ClientUser *p = pmModel->getUser(qtvUsers->currentIndex()); Channel *c = pmModel->getChannel(qtvUsers->currentIndex()); -#if QT_VERSION >= 0x050000 qsText = qsText.toHtmlEscaped(); -#else - qsText = Qt::escape(qsText); -#endif qsText = TextMessage::autoFormat(qsText); if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) { @@ -2074,7 +2040,7 @@ void MainWindow::on_qaChannelRemove_triggered() { int id = c->iId; - ret=QMessageBox::question(this, QLatin1String("Mumble"), tr("Are you sure you want to delete %1 and all its sub-channels?").arg(Qt::escape(c->qsName)), QMessageBox::Yes, QMessageBox::No); + ret=QMessageBox::question(this, QLatin1String("Mumble"), tr("Are you sure you want to delete %1 and all its sub-channels?").arg(c->qsName.toHtmlEscaped()), QMessageBox::Yes, QMessageBox::No); c = Channel::get(id); if (!c) @@ -2965,7 +2931,7 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re if (! g.sh->qlErrors.isEmpty()) { foreach(QSslError e, g.sh->qlErrors) - g.l->log(Log::Warning, tr("SSL Verification failed: %1").arg(Qt::escape(e.errorString()))); + g.l->log(Log::Warning, tr("SSL Verification failed: %1").arg(e.errorString().toHtmlEscaped())); if (! g.sh->qscCert.isEmpty()) { QSslCertificate c = g.sh->qscCert.at(0); QString basereason; @@ -2980,7 +2946,7 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re } QStringList qsl; foreach(QSslError e, g.sh->qlErrors) - qsl << QString::fromLatin1("
  • %1
  • ").arg(Qt::escape(e.errorString())); + qsl << QString::fromLatin1("
  • %1
  • ").arg(e.errorString().toHtmlEscaped()); QMessageBox qmb(QMessageBox::Warning, QLatin1String("Mumble"), tr("

    %1

      %2

    The specific errors with this certificate are:

      %3
    " @@ -3013,7 +2979,7 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re if (! reason.isEmpty()) { - g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(Qt::escape(reason))); + g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped())); } else { g.l->log(Log::ServerDisconnected, tr("Disconnected from server.")); } @@ -3072,7 +3038,7 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re void MainWindow::resolverError(QAbstractSocket::SocketError, QString reason) { if (! reason.isEmpty()) { - g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(Qt::escape(reason))); + g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped())); } else { g.l->log(Log::ServerDisconnected, tr("Server connection failed.")); } @@ -3160,10 +3126,10 @@ void MainWindow::updateChatBar() { if (!g.s.bChatBarUseSelection || c == NULL) // If no channel selected fallback to current one c = ClientUser::get(g.uiSession)->cChannel; - qteChat->setDefaultText(tr("
    Type message to channel '%1' here
    ").arg(Qt::escape(c->qsName))); + qteChat->setDefaultText(tr("
    Type message to channel '%1' here
    ").arg(c->qsName.toHtmlEscaped())); } else { // User target - qteChat->setDefaultText(tr("
    Type message to user '%1' here
    ").arg(Qt::escape(p->qsName))); + qteChat->setDefaultText(tr("
    Type message to user '%1' here
    ").arg(p->qsName.toHtmlEscaped())); } updateMenuPermissions(); diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 2616fa5ab..ae8de533d 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -7,16 +7,9 @@ #define MUMBLE_MUMBLE_MAINWINDOW_H_ #include -#if QT_VERSION >= 0x050000 -# include -# include -# include -#else -# include -# include -# include -#endif - +#include +#include +#include #include #include "CustomElements.h" @@ -101,13 +94,8 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin /// save when activating the "Save Image As..." context menu item. QTextCursor qtcSaveImageCursor; -#if QT_VERSION >= 0x050000 QPointer cContextChannel; QPointer cuContextUser; -#else - QWeakPointer cContextChannel; - QWeakPointer cuContextUser; -#endif QPoint qpContextPosition; @@ -126,11 +114,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void openUserLocalVolumeDialog(ClientUser *p); #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050000 bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; -#else - bool winEvent(MSG *, long *) Q_DECL_OVERRIDE; -#endif unsigned int uiNewHardware; #endif protected: diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp index e0f4fc266..0bdd5a338 100644 --- a/src/mumble/ManualPlugin.cpp +++ b/src/mumble/ManualPlugin.cpp @@ -7,11 +7,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include #include #include "ManualPlugin.h" diff --git a/src/mumble/ManualPlugin.h b/src/mumble/ManualPlugin.h index c439d97cf..73f359900 100644 --- a/src/mumble/ManualPlugin.h +++ b/src/mumble/ManualPlugin.h @@ -7,15 +7,9 @@ #define MUMBLE_MUMBLE_MANUALPLUGIN_H_ #include -#if QT_VERSION >= 0x050000 -# include -# include -# include -#else -# include -# include -# include -#endif +#include +#include +#include #include "ui_ManualPlugin.h" diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index b6f210e5a..1a1c9d3d3 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -83,7 +83,7 @@ void MainWindow::msgReject(const MumbleProto::Reject &msg) { reason = tr("Your account information can not be verified currently. Please try again later"); break; default: - reason = Qt::escape(u8(msg.reason())); + reason = u8(msg.reason()).toHtmlEscaped(); break; } @@ -138,7 +138,7 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) { connect(user, SIGNAL(prioritySpeakerStateChanged()), this, SLOT(userStateChanged())); connect(user, SIGNAL(recordingStateChanged()), this, SLOT(userStateChanged())); - qstiIcon->setToolTip(tr("Mumble: %1").arg(Qt::escape(Channel::get(0)->qsName))); + qstiIcon->setToolTip(tr("Mumble: %1").arg(Channel::get(0)->qsName.toHtmlEscaped())); // Update QActions and menues on_qmServer_aboutToShow(); @@ -205,7 +205,7 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { g.s.bTTS = true; quint32 oflags = g.s.qmMessages.value(Log::PermissionDenied); g.s.qmMessages[Log::PermissionDenied] = (oflags | Settings::LogTTS) & (~Settings::LogSoundfile); - g.l->log(Log::PermissionDenied, QString::fromUtf8(g.ccHappyEaster + 39).arg(Qt::escape(g.s.qsUsername))); + g.l->log(Log::PermissionDenied, QString::fromUtf8(g.ccHappyEaster + 39).arg(g.s.qsUsername.toHtmlEscaped())); g.s.qmMessages[Log::PermissionDenied] = oflags; g.s.bDeaf = bold; g.s.bTTS = bold2; @@ -230,7 +230,7 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { break; case MumbleProto::PermissionDenied_DenyType_UserName: { if (msg.has_name()) - g.l->log(Log::PermissionDenied, tr("Invalid username: %1.").arg(Qt::escape(u8(msg.name())))); + g.l->log(Log::PermissionDenied, tr("Invalid username: %1.").arg(u8(msg.name()).toHtmlEscaped())); else g.l->log(Log::PermissionDenied, tr("Invalid username.")); } @@ -249,7 +249,7 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { break; default: { if (msg.has_reason()) - g.l->log(Log::PermissionDenied, tr("Denied: %1.").arg(Qt::escape(u8(msg.reason())))); + g.l->log(Log::PermissionDenied, tr("Denied: %1.").arg(u8(msg.reason()).toHtmlEscaped())); else g.l->log(Log::PermissionDenied, tr("Permission denied.")); } @@ -575,7 +575,7 @@ void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) { ACTOR_INIT; SELF_INIT; - QString reason = Qt::escape(u8(msg.reason())); + QString reason = u8(msg.reason()).toHtmlEscaped(); if (pDst == pSelf) { bRetryServer = false; diff --git a/src/mumble/MumbleApplication.cpp b/src/mumble/MumbleApplication.cpp index c338fc805..e90f0ec8d 100644 --- a/src/mumble/MumbleApplication.cpp +++ b/src/mumble/MumbleApplication.cpp @@ -91,7 +91,6 @@ static bool gswForward(MSG *msg) { return false; } -# if QT_VERSION >= 0x050000 bool MumbleApplication::nativeEventFilter(const QByteArray &, void *message, long *) { MSG *msg = reinterpret_cast(message); if (QThread::currentThread() == thread()) { @@ -102,15 +101,4 @@ bool MumbleApplication::nativeEventFilter(const QByteArray &, void *message, lon } return false; } -# else -bool MumbleApplication::winEventFilter(MSG *msg, long *result) { - if (QThread::currentThread() == thread()) { - bool suppress = gswForward(msg); - if (suppress) { - return true; - } - } - return QApplication::winEventFilter(msg, result); -} -# endif #endif diff --git a/src/mumble/MumbleApplication.h b/src/mumble/MumbleApplication.h index a67f62f61..cfe5a3031 100644 --- a/src/mumble/MumbleApplication.h +++ b/src/mumble/MumbleApplication.h @@ -9,14 +9,14 @@ #include #include -#if QT_VERSION >= 0x050000 && defined(Q_OS_WIN) -# include +#ifdef Q_OS_WIN +#include #endif /** * @brief Implements custom system shutdown behavior as well as event filtering. */ -#if QT_VERSION >= 0x050000 && defined(Q_OS_WIN) +#ifdef Q_OS_WIN class MumbleApplication : public QApplication, public QAbstractNativeEventFilter { #else class MumbleApplication : public QApplication { @@ -50,11 +50,7 @@ class MumbleApplication : public QApplication { bool event(QEvent *e) Q_DECL_OVERRIDE; #ifdef Q_OS_WIN -# if QT_VERSION >= 0x050000 bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; -# else - bool winEventFilter(MSG *msg, long *result) Q_DECL_OVERRIDE; -# endif #endif QUrl quLaunchURL; diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp index 62c77b673..2b47db766 100644 --- a/src/mumble/Overlay.cpp +++ b/src/mumble/Overlay.cpp @@ -141,12 +141,8 @@ OverlayAppInfo OverlayAppInfo::applicationInfoForId(const QString &identifier) { HINSTANCE qWinAppInstValue = GetModuleHandle(NULL); HICON icon = ExtractIcon(qWinAppInstValue, identifier.toStdWString().c_str(), 0); if (icon) { -#if QT_VERSION >= 0x050000 extern QPixmap qt_pixmapFromWinHICON(HICON icon); qiAppIcon = QIcon(qt_pixmapFromWinHICON(icon)); -#else - qiAppIcon = QIcon(QPixmap::fromWinHICON(icon)); -#endif DestroyIcon(icon); } #endif @@ -220,7 +216,7 @@ Overlay::Overlay() : QObject() { #endif if (! qlsServer->listen(pipepath)) { - QMessageBox::warning(NULL, QLatin1String("Mumble"), tr("Failed to create communication with overlay at %2: %1. No overlay will be available.").arg(Qt::escape(qlsServer->errorString()), Qt::escape(pipepath)), QMessageBox::Ok, QMessageBox::NoButton); + QMessageBox::warning(NULL, QLatin1String("Mumble"), tr("Failed to create communication with overlay at %2: %1. No overlay will be available.").arg(qlsServer->errorString().toHtmlEscaped(), pipepath.toHtmlEscaped()), QMessageBox::Ok, QMessageBox::NoButton); } else { qWarning() << "Overlay: Listening on" << qlsServer->fullServerName(); connect(qlsServer, SIGNAL(newConnection()), this, SLOT(newConnection())); diff --git a/src/mumble/Overlay.h b/src/mumble/Overlay.h index 55dd320d1..c334b9e53 100644 --- a/src/mumble/Overlay.h +++ b/src/mumble/Overlay.h @@ -9,11 +9,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include #include "ConfigDialog.h" #include "OverlayText.h" diff --git a/src/mumble/OverlayClient.cpp b/src/mumble/OverlayClient.cpp index 735d6c88e..bd369edd9 100644 --- a/src/mumble/OverlayClient.cpp +++ b/src/mumble/OverlayClient.cpp @@ -137,19 +137,11 @@ void OverlayClient::updateMouse() { QPixmap pm; HICON c = ::GetCursor(); -#if QT_VERSION < 0x050000 - if (c == NULL) - c = qgv.viewport()->cursor().handle(); -#endif - ICONINFO info; ZeroMemory(&info, sizeof(info)); if (c != NULL && ::GetIconInfo(c, &info)) { -#if QT_VERSION >= 0x050000 extern QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int format = 0); -#else -# define qt_pixmapFromWinHBITMAP(bmp) QPixmap::fromWinHBITMAP(bmp) -#endif + if (info.hbmColor) { pm = qt_pixmapFromWinHBITMAP(info.hbmColor); pm.setMask(QBitmap(qt_pixmapFromWinHBITMAP(info.hbmMask))); @@ -195,19 +187,11 @@ void OverlayClient::updateMouse() { } #endif -#if QT_VERSION < 0x050000 && (defined(Q_OS_WIN) || defined(Q_OS_MAC)) -extern bool Q_GUI_EXPORT qt_use_native_dialogs; -#endif - // Qt gets very very unhappy if we embed or unmbed the widget that an event is called from. // This means that if any modal dialog is open, we'll be in a event loop of an object // that we're about to reparent. void OverlayClient::showGui() { -#if defined(QT3_SUPPORT) || (defined(Q_OS_WIN) && QT_VERSION < 0x050000) - if (QCoreApplication::loopLevel() > 1) - return; -#else int count = 0; { @@ -221,7 +205,6 @@ void OverlayClient::showGui() { // If there's more than one window up, we're likely deep in a message loop. if (count > 1) return; -#endif g.ocIntercept = this; @@ -294,10 +277,6 @@ outer: setupScene(true); -#if QT_VERSION < 0x050000 && (defined(Q_OS_WIN) || defined(Q_OS_MAC)) - qt_use_native_dialogs = false; -#endif - OverlayMsg om; om.omh.uiMagic = OVERLAY_MAGIC_NUMBER; om.omh.uiType = OVERLAY_MSGTYPE_INTERACTIVE; @@ -309,14 +288,6 @@ outer: } void OverlayClient::hideGui() { -#if defined(QT3_SUPPORT) || (defined(Q_OS_WIN) && QT_VERSION < 0x050000) - if (QCoreApplication::loopLevel() > 1) { - QCoreApplication::exit_loop(); - QMetaObject::invokeMethod(this, "hideGui", Qt::QueuedConnection); - return; - } -#endif - ougUsers.bShowExamples = false; QList widgetlist; @@ -367,9 +338,6 @@ void OverlayClient::hideGui() { setupScene(false); qgv.setAttribute(Qt::WA_WState_Hidden, true); -#if QT_VERSION < 0x050000 && (defined(Q_OS_WIN) || defined(Q_OS_MAC)) - qt_use_native_dialogs = true; -#endif OverlayMsg om; om.omh.uiMagic = OVERLAY_MAGIC_NUMBER; diff --git a/src/mumble/OverlayEditorScene.h b/src/mumble/OverlayEditorScene.h index d9cdf8e25..329db34c9 100644 --- a/src/mumble/OverlayEditorScene.h +++ b/src/mumble/OverlayEditorScene.h @@ -7,11 +7,7 @@ #define MUMBLE_MUMBLE_OVERLAYEDITORSCENE_H_ #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include #include "Settings.h" diff --git a/src/mumble/OverlayPositionableItem.h b/src/mumble/OverlayPositionableItem.h index ae13be676..5ade1a071 100644 --- a/src/mumble/OverlayPositionableItem.h +++ b/src/mumble/OverlayPositionableItem.h @@ -7,11 +7,7 @@ #define MUMBLE_MUMBLE_OVERLAYPOSITIONABLEITEM_H #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include class OverlayPositionableItem : public QObject, public QGraphicsPixmapItem { Q_OBJECT diff --git a/src/mumble/Overlay_macx.mm b/src/mumble/Overlay_macx.mm index 0f1994692..9aca57298 100644 --- a/src/mumble/Overlay_macx.mm +++ b/src/mumble/Overlay_macx.mm @@ -212,13 +212,6 @@ void OverlayClient::updateMouse() { cgimg = [(NSBitmapImageRep *)rep CGImage]; } } - -#if QT_VERSION < 0x050000 - if (cgimg) { - pm = QPixmap::fromMacCGImageRef(cgimg); - qmCursors.insert(csShape, pm); - } -#endif } NSPoint p = [cursor hotSpot]; diff --git a/src/mumble/Plugins.cpp b/src/mumble/Plugins.cpp index fca8876bf..1addf2643 100644 --- a/src/mumble/Plugins.cpp +++ b/src/mumble/Plugins.cpp @@ -73,13 +73,8 @@ struct PluginFetchMeta { PluginConfig::PluginConfig(Settings &st) : ConfigWidget(st) { setupUi(this); -#if QT_VERSION >= 0x050000 qtwPlugins->header()->setSectionResizeMode(0, QHeaderView::Stretch); qtwPlugins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); -#else - qtwPlugins->header()->setResizeMode(0, QHeaderView::Stretch); - qtwPlugins->header()->setResizeMode(1, QHeaderView::ResizeToContents); -#endif refillPluginList(); } @@ -177,7 +172,7 @@ void PluginConfig::refillPluginList() { i->setCheckState(1, pi->enabled ? Qt::Checked : Qt::Unchecked); i->setText(0, pi->description); if (pi->p->longdesc) - i->setToolTip(0, Qt::escape(QString::fromStdWString(pi->p->longdesc()))); + i->setToolTip(0, QString::fromStdWString(pi->p->longdesc()).toHtmlEscaped()); i->setData(0, Qt::UserRole, pi->filename); } qtwPlugins->setCurrentItem(qtwPlugins->topLevelItem(0)); @@ -430,7 +425,7 @@ void Plugins::on_Timer_timeout() { QReadLocker lock(&qrwlPlugins); if (prevlocked) { - g.l->log(Log::Information, tr("%1 lost link.").arg(Qt::escape(prevlocked->shortname))); + g.l->log(Log::Information, tr("%1 lost link.").arg(prevlocked->shortname.toHtmlEscaped())); prevlocked = NULL; } @@ -553,7 +548,7 @@ void Plugins::on_Timer_timeout() { if (pi->enabled) { if (pi->p2 ? pi->p2->trylock(pids) : pi->p->trylock()) { pi->shortname = QString::fromStdWString(pi->p->shortname); - g.l->log(Log::Information, tr("%1 linked.").arg(Qt::escape(pi->shortname))); + g.l->log(Log::Information, tr("%1 linked.").arg(pi->shortname.toHtmlEscaped())); pi->locked = true; bUnlink = false; locked = pi; @@ -586,16 +581,10 @@ void Plugins::checkUpdates() { #ifdef QT_NO_DEBUG -#if QT_VERSION >= 0x050000 QUrlQuery query; query.setQueryItems(queryItems); url.setQuery(query); -#else - for (int i = 0; i < queryItems.size(); i++) { - const QPair &queryPair = queryItems.at(i); - url.addQueryItem(queryPair.first, queryPair.second); - } -#endif + WebFetch::fetch(QLatin1String("update"), url, this, SLOT(fetchedUpdatePAPlugins(QByteArray,QUrl))); #else g.mw->msgBox(tr("Skipping plugin update in debug mode.")); @@ -766,15 +755,15 @@ void Plugins::fetchedPAPluginDL(QByteArray data, QUrl url) { if (f.open(QIODevice::WriteOnly)) { f.write(data); f.close(); - g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(Qt::escape(f.fileName()))); + g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped())); } else { f.setFileName(qsUserPlugins + QLatin1String("/") + fname); if (f.open(QIODevice::WriteOnly)) { f.write(data); f.close(); - g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(Qt::escape(f.fileName()))); + g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped())); } else { - g.mw->msgBox(tr("Failed to install new plugin to %1.").arg(Qt::escape(f.fileName()))); + g.mw->msgBox(tr("Failed to install new plugin to %1.").arg(f.fileName().toHtmlEscaped())); } } diff --git a/src/mumble/RichTextEditor.cpp b/src/mumble/RichTextEditor.cpp index 20c5d5ace..15f96eabe 100644 --- a/src/mumble/RichTextEditor.cpp +++ b/src/mumble/RichTextEditor.cpp @@ -130,13 +130,9 @@ void RichTextHtmlEdit::insertFromMimeData(const QMimeData *source) { if (! uri.isEmpty()) { if (title.isEmpty()) title = uri; -#if QT_VERSION >= 0x050000 + uri = uri.toHtmlEscaped(); title = title.toHtmlEscaped(); -#else - uri = Qt::escape(uri); - title = Qt::escape(title); -#endif insertHtml(QString::fromLatin1("%2").arg(uri, title)); return; @@ -163,11 +159,7 @@ QString RichTextEditorLink::text() const { QUrl url(qleUrl->text(), QUrl::StrictMode); QString txt = qleText->text(); -#if QT_VERSION >= 0x050000 txt = txt.toHtmlEscaped(); -#else - txt = Qt::escape(txt); -#endif if (url.isValid() && ! url.isRelative() && ! txt.isEmpty()) { return QString::fromLatin1("%2").arg(url.toString(), txt); diff --git a/src/mumble/RichTextEditor.h b/src/mumble/RichTextEditor.h index 5d43c98e6..ce73c6b21 100644 --- a/src/mumble/RichTextEditor.h +++ b/src/mumble/RichTextEditor.h @@ -7,11 +7,7 @@ #define MUMBLE_MUMBLE_RICHTEXTEDITOR_H_ #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include class LogDocument; diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 6498e1391..b5606acef 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -379,11 +379,10 @@ void ServerHandler::run() { // In Qt 5.4, QSsl::SecureProtocols is equivalent // to "TLSv1.0 or later", which we require. qtsSock->setProtocol(QSsl::SecureProtocols); - #elif QT_VERSION >= 0x050000 - qtsSock->setProtocol(QSsl::TlsV1_0); #else - qtsSock->setProtocol(QSsl::TlsV1); + qtsSock->setProtocol(QSsl::TlsV1_0); #endif + qtsSock->connectToHost(saTargetServer.host.toAddress(), saTargetServer.port); tTimestamp.restart(); diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index 298aab6ee..008bc3e2e 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -282,11 +282,7 @@ Settings::Settings() { bPluginCheck = true; #endif -#if QT_VERSION >= 0x050000 qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); -#else - qsImagePath = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); -#endif ceExpand = ChannelsWithUsers; ceChannelDrag = Ask; @@ -379,11 +375,7 @@ Settings::Settings() { bHighContrast = false; // Recording -#if QT_VERSION >= 0x050000 qsRecordingPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); -#else - qsRecordingPath = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); -#endif qsRecordingFile = QLatin1String("Mumble-%date-%time-%host-%user"); rmRecordingMode = RecordingMixdown; iRecordingFormat = 0; diff --git a/src/mumble/SocketRPC.cpp b/src/mumble/SocketRPC.cpp index 8a220b928..86234c5af 100644 --- a/src/mumble/SocketRPC.cpp +++ b/src/mumble/SocketRPC.cpp @@ -176,13 +176,9 @@ void SocketRPCClient::processXml() { u.setPort(port); u.setUserName(user); -#if QT_VERSION >= 0x050000 QUrlQuery query; query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); u.setQuery(query); -#else - u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); -#endif QStringList path; Channel *c = ClientUser::get(g.uiSession)->cChannel; diff --git a/src/mumble/TaskList.cpp b/src/mumble/TaskList.cpp index 58e37dedc..ffde41380 100644 --- a/src/mumble/TaskList.cpp +++ b/src/mumble/TaskList.cpp @@ -39,15 +39,10 @@ void TaskList::addToRecentList(QString name, QString user, QString host, int por url.setHost(host); url.setPort(port); -#if QT_VERSION >= 0x050000 QUrlQuery query; query.addQueryItem(QLatin1String("title"), name); query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); url.setQuery(query); -#else - url.addQueryItem(QLatin1String("title"), name); - url.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); -#endif QSettings settings(QLatin1String("HKEY_CLASSES_ROOT"), QSettings::NativeFormat); diff --git a/src/mumble/UserEdit.cpp b/src/mumble/UserEdit.cpp index d1305dcf9..972bdaf9f 100644 --- a/src/mumble/UserEdit.cpp +++ b/src/mumble/UserEdit.cpp @@ -37,20 +37,12 @@ UserEdit::UserEdit(const MumbleProto::UserList &userList, QWidget *p) qtvUserList->setFocus(); qtvUserList->setContextMenuPolicy(Qt::CustomContextMenu); - -#if QT_VERSION >= 0x050000 qtvUserList->header()->setSectionResizeMode(UserListModel::COL_NICK, QHeaderView::Stretch); + if (!m_model->isLegacy()) { qtvUserList->header()->setSectionResizeMode(UserListModel::COL_INACTIVEDAYS, QHeaderView::ResizeToContents); qtvUserList->header()->setSectionResizeMode(UserListModel::COL_LASTCHANNEL, QHeaderView::Stretch); } -#else - qtvUserList->header()->setResizeMode(UserListModel::COL_NICK, QHeaderView::Stretch); - if (!m_model->isLegacy()) { - qtvUserList->header()->setResizeMode(UserListModel::COL_INACTIVEDAYS, QHeaderView::ResizeToContents); - qtvUserList->header()->setResizeMode(UserListModel::COL_LASTCHANNEL, QHeaderView::Stretch); - } -#endif if (m_model->isLegacy()) { qlInactive->hide(); diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp index 4fb5d2ce9..c93c7c544 100644 --- a/src/mumble/UserInformation.cpp +++ b/src/mumble/UserInformation.cpp @@ -21,14 +21,12 @@ static QString decode_utf8_qssl_string(const QString &input) { return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1()); } -#if QT_VERSION >= 0x050000 static QString decode_utf8_qssl_string(const QStringList &list) { if (list.count() > 0) { return decode_utf8_qssl_string(list.at(0)); } return QString(); } -#endif UserInformation::UserInformation(const MumbleProto::UserStats &msg, QWidget *p) : QDialog(p) { setupUi(this); @@ -115,12 +113,7 @@ void UserInformation::update(const MumbleProto::UserStats &msg) { qpbCertificate->setEnabled(true); const QSslCertificate &cert = qlCerts.last(); - -#if QT_VERSION >= 0x050000 const QMultiMap &alts = cert.subjectAlternativeNames(); -#else - const QMultiMap &alts = cert.alternateSubjectNames(); -#endif if (alts.contains(QSsl::EmailEntry)) qlCertificate->setText(QStringList(alts.values(QSsl::EmailEntry)).join(tr(", "))); else diff --git a/src/mumble/UserListModel.cpp b/src/mumble/UserListModel.cpp index 2f5d41596..6534e80a8 100644 --- a/src/mumble/UserListModel.cpp +++ b/src/mumble/UserListModel.cpp @@ -93,7 +93,7 @@ QVariant UserListModel::data(const QModelIndex &dataIndex, int role) const { switch (dataIndex.column()) { case COL_INACTIVEDAYS: return tr("Last seen: %1").arg(user.last_seen().empty() ? tr("Never") - : Qt::escape(u8(user.last_seen()))); + : u8(user.last_seen()).toHtmlEscaped()); case COL_LASTCHANNEL: return tr("Channel ID: %1").arg(user.last_channel()); default: return QVariant(); } diff --git a/src/mumble/UserView.cpp b/src/mumble/UserView.cpp index fdcd5afd2..121808376 100644 --- a/src/mumble/UserView.cpp +++ b/src/mumble/UserView.cpp @@ -41,12 +41,7 @@ void UserDelegate::paint(QPainter * painter, const QStyleOptionViewItem &option, painter->save(); -#if QT_VERSION >= 0x050000 QStyleOptionViewItem o = option; -#else - QStyleOptionViewItemV4 o = option; -#endif - initStyleOption(&o, index); QStyle *style = o.widget->style(); @@ -375,12 +370,7 @@ void UserView::updateChannel(const QModelIndex &idx) { } } -#if QT_VERSION >= 0x050000 -void UserView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector &) -#else -void UserView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight) -#endif -{ +void UserView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector &) { UserModel *um = static_cast(model()); int nRowCount = um->rowCount(); int i; @@ -389,4 +379,3 @@ void UserView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bo QTreeView::dataChanged(topLeft,bottomRight); } - diff --git a/src/mumble/UserView.h b/src/mumble/UserView.h index f84d9cd03..8c50cd82b 100644 --- a/src/mumble/UserView.h +++ b/src/mumble/UserView.h @@ -7,13 +7,8 @@ #define MUMBLE_MUMBLE_USERVIEW_H_ #include -#if QT_VERSION >= 0x050000 -# include -# include -#else -# include -# include -#endif +#include +#include #include "Timer.h" @@ -52,12 +47,7 @@ class UserView : public QTreeView { public: UserView(QWidget *); void keyboardSearch(const QString &search) Q_DECL_OVERRIDE; -#if QT_VERSION >= 0x050000 void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector & roles = QVector ()) Q_DECL_OVERRIDE; -#else - void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight) Q_DECL_OVERRIDE; -#endif - public slots: void nodeActivated(const QModelIndex &idx); void selectSearchResult(); diff --git a/src/mumble/VersionCheck.cpp b/src/mumble/VersionCheck.cpp index a14af8ab6..b2c1a25b3 100644 --- a/src/mumble/VersionCheck.cpp +++ b/src/mumble/VersionCheck.cpp @@ -67,16 +67,10 @@ VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p) } } -#if QT_VERSION >= 0x050000 QUrlQuery query; query.setQueryItems(queryItems); url.setQuery(query); -#else - for (int i = 0; i < queryItems.size(); i++) { - const QPair &queryPair = queryItems.at(i); - url.addQueryItem(queryPair.first, queryPair.second); - } -#endif + WebFetch::fetch(QLatin1String("update"), url, this, SLOT(fetched(QByteArray,QUrl))); } @@ -173,7 +167,7 @@ void VersionCheck::fetched(QByteArray a, QUrl url) { file.remove(); } } else { - g.mw->msgBox(tr("Downloading new snapshot from %1 to %2").arg(Qt::escape(fetch.toString()), Qt::escape(filename))); + g.mw->msgBox(tr("Downloading new snapshot from %1 to %2").arg(fetch.toString().toHtmlEscaped(), filename.toHtmlEscaped())); WebFetch::fetch(QLatin1String("dl"), fetch, this, SLOT(fetched(QByteArray,QUrl))); return; } diff --git a/src/mumble/ViewCert.cpp b/src/mumble/ViewCert.cpp index 6aa6d539f..3768b4396 100644 --- a/src/mumble/ViewCert.cpp +++ b/src/mumble/ViewCert.cpp @@ -18,7 +18,6 @@ static QString decode_utf8_qssl_string(const QString &input) { return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1()); } -#if QT_VERSION >= 0x050000 static QStringList processQSslCertificateInfo(QStringList in) { QStringList list; foreach (QString str, in) { @@ -26,13 +25,6 @@ static QStringList processQSslCertificateInfo(QStringList in) { } return list; } -#else -static QStringList processQSslCertificateInfo(QString in) { - QStringList out; - out << decode_utf8_qssl_string(in); - return out; -} -#endif static void addQSslCertificateInfo(QStringList &l, const QString &label, const QStringList &items) { foreach (const QString &item, items) { @@ -132,17 +124,10 @@ void ViewCert::on_Chain_currentRowChanged(int idx) { l << tr("Serial: %1").arg(QString::fromLatin1(c.serialNumber().toHex())); l << tr("Public Key: %1 bits %2").arg(c.publicKey().length()).arg((c.publicKey().algorithm() == QSsl::Rsa) ? tr("RSA") : tr("DSA")); l << tr("Digest (SHA-1): %1").arg(prettifyDigest(QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex()))); -#if QT_VERSION >= 0x050000 l << tr("Digest (SHA-256): %1").arg(prettifyDigest(QString::fromLatin1(c.digest(QCryptographicHash::Sha256).toHex()))); -#endif -#if QT_VERSION >= 0x050000 const QMultiMap &alts = c.subjectAlternativeNames(); QMultiMap::const_iterator i; -#else - const QMultiMap &alts = c.alternateSubjectNames(); - QMultiMap::const_iterator i; -#endif for (i=alts.constBegin(); i != alts.constEnd(); ++i) { switch (i.key()) { diff --git a/src/mumble/ViewCert.h b/src/mumble/ViewCert.h index ef4875c14..c74162b36 100644 --- a/src/mumble/ViewCert.h +++ b/src/mumble/ViewCert.h @@ -9,12 +9,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif - +#include #include class QListWidget; diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index b0b810d34..69613fa67 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -55,18 +55,6 @@ // We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name (like protobuf 3.7 does). As such, for now, we have to make this our last include. #include "Global.h" -#if defined(USE_STATIC_QT_PLUGINS) && QT_VERSION < 0x050000 -Q_IMPORT_PLUGIN(qtaccessiblewidgets) -# ifdef Q_OS_WIN - Q_IMPORT_PLUGIN(qico) -# endif -Q_IMPORT_PLUGIN(qsvg) -Q_IMPORT_PLUGIN(qsvgicon) -# ifdef Q_OS_MAC - Q_IMPORT_PLUGIN(qicnsicon) -# endif -#endif - #ifdef BOOST_NO_EXCEPTIONS namespace boost { void throw_exception(std::exception const &) { @@ -120,7 +108,7 @@ int main(int argc, char **argv) { a.setAttribute(Qt::AA_UseHighDpiPixmaps); #endif -#if QT_VERSION >= 0x050000 && defined(Q_OS_WIN) +#ifdef Q_OS_WIN a.installNativeEventFilter(&a); #endif @@ -508,12 +496,7 @@ int main(int argc, char **argv) { g.s.uiUpdateCounter = 2; if (! CertWizard::validateCert(g.s.kpCertificate)) { -#if QT_VERSION >= 0x050000 QDir qd(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); -#else - QDir qd(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); -#endif - QFile qf(qd.absoluteFilePath(QLatin1String("MumbleAutomaticCertificateBackup.p12"))); if (qf.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { Settings::KeyPair kp = CertWizard::importCert(qf.readAll()); diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp index cabbdc8ac..59d2f3061 100644 --- a/src/mumble/mumble_pch.hpp +++ b/src/mumble/mumble_pch.hpp @@ -31,10 +31,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include "Qt4Compat.h" -# include -#endif +#include #include #ifdef USE_DBUS diff --git a/src/mumble/os_macx.mm b/src/mumble/os_macx.mm index 616b5251b..e8a42682c 100644 --- a/src/mumble/os_macx.mm +++ b/src/mumble/os_macx.mm @@ -60,16 +60,10 @@ static void mumbleMessageOutputQString(QtMsgType type, const QString &msg) { } } -#if QT_VERSION < 0x050000 -static void mumbleMessageOutput(QtMsgType type, const char *msg) { - mumbleMessageOutputQString(type, QString::fromUtf8(msg)); -} -#elif QT_VERSION >= 0x050000 static void mumbleMessageOutputWithContext(QtMsgType type, const QMessageLogContext &ctx, const QString &msg) { Q_UNUSED(ctx); mumbleMessageOutputQString(type, msg); } -#endif void query_language() { CFPropertyListRef cfaLangs; @@ -154,11 +148,7 @@ void os_init() { strcat(buff, logpath); fConsole = fopen(buff, "a+"); if (fConsole) { -#if QT_VERSION >= 0x050000 - qInstallMessageHandler(mumbleMessageOutputWithContext); -#else - qInstallMsgHandler(mumbleMessageOutput); -#endif + qInstallMessageHandler(mumbleMessageOutputWithContext); } } diff --git a/src/mumble/os_unix.cpp b/src/mumble/os_unix.cpp index dc14de63d..669d907f6 100644 --- a/src/mumble/os_unix.cpp +++ b/src/mumble/os_unix.cpp @@ -38,16 +38,10 @@ static void mumbleMessageOutputQString(QtMsgType type, const QString &msg) { } } -#if QT_VERSION < 0x050000 -static void mumbleMessageOutput(QtMsgType type, const char *msg) { - mumbleMessageOutputQString(type, QString::fromUtf8(msg)); -} -#elif QT_VERSION >= 0x050000 static void mumbleMessageOutputWithContext(QtMsgType type, const QMessageLogContext &ctx, const QString &msg) { Q_UNUSED(ctx); mumbleMessageOutputQString(type, msg); } -#endif void os_init() { // Make a copy of the global LogEmitter, such that @@ -55,9 +49,5 @@ void os_init() { // of the Global object and its LogEmitter object. le = g.le; -#if QT_VERSION >= 0x050000 qInstallMessageHandler(mumbleMessageOutputWithContext); -#else - qInstallMsgHandler(mumbleMessageOutput); -#endif } diff --git a/src/mumble/os_win.cpp b/src/mumble/os_win.cpp index ba107c7ef..2633cb929 100644 --- a/src/mumble/os_win.cpp +++ b/src/mumble/os_win.cpp @@ -81,18 +81,10 @@ static void mumbleMessageOutputQString(QtMsgType type, const QString &msg) { } } -#if QT_VERSION < 0x050000 -static void mumbleMessageOutput(QtMsgType type, const char *msg) { - mumbleMessageOutputQString(type, QString::fromUtf8(msg)); -} -#endif - -#if QT_VERSION >= 0x050000 static void mumbleMessageOutputWithContext(QtMsgType type, const QMessageLogContext &ctx, const QString &msg) { Q_UNUSED(ctx); mumbleMessageOutputQString(type, msg); } -#endif static LONG WINAPI MumbleUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo) { MINIDUMP_EXCEPTION_INFORMATION i; @@ -269,11 +261,7 @@ void os_init() { fConsole = _wfsopen(console.toStdWString().c_str(), L"a+", _SH_DENYWR); if (fConsole) { -#if QT_VERSION >= 0x050000 qInstallMessageHandler(mumbleMessageOutputWithContext); -#else - qInstallMsgHandler(mumbleMessageOutput); -#endif } QString hash; diff --git a/src/murmur/About.cpp b/src/murmur/About.cpp index 1a72af15b..18f2c661a 100644 --- a/src/murmur/About.cpp +++ b/src/murmur/About.cpp @@ -38,9 +38,9 @@ AboutDialog::AboutDialog(QWidget *p, AboutDialogOptions options) : QDialog(p) { QList thirdPartyLicenses = License::thirdPartyLicenses(); foreach(LicenseInfo li, thirdPartyLicenses) { qtb3rdPartyLicense->append(QString::fromLatin1("

    %1 (%2)

    %3
    ") - .arg(Qt::escape(li.name)) - .arg(Qt::escape(li.url)) - .arg(Qt::escape(li.license))); + .arg(li.name.toHtmlEscaped()) + .arg(li.url.toHtmlEscaped()) + .arg(li.license.toHtmlEscaped())); } qtb3rdPartyLicense->moveCursor(QTextCursor::Start); diff --git a/src/murmur/About.h b/src/murmur/About.h index fb21a1708..0467a5b74 100644 --- a/src/murmur/About.h +++ b/src/murmur/About.h @@ -8,11 +8,7 @@ #include #include -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include enum AboutDialogOptions { AboutDialogOptionsShowAbout, diff --git a/src/murmur/Cert.cpp b/src/murmur/Cert.cpp index 3a1fe10b1..80883cca8 100644 --- a/src/murmur/Cert.cpp +++ b/src/murmur/Cert.cpp @@ -129,14 +129,11 @@ void Server::initializeCert() { #endif QString issuer; -#if QT_VERSION >= 0x050000 + QStringList issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName); if (! issuerNames.isEmpty()) { issuer = issuerNames.first(); } -#else - issuer = qscCert.issuerInfo(QSslCertificate::CommonName); -#endif // Really old certs/keys are no good, throw them away so we can // generate a new one below. diff --git a/src/murmur/Meta.cpp b/src/murmur/Meta.cpp index 3baac7a7b..f52620167 100644 --- a/src/murmur/Meta.cpp +++ b/src/murmur/Meta.cpp @@ -140,11 +140,7 @@ void MetaParams::read(QString fname) { QStringList datapaths; #if defined(Q_OS_WIN) -#if QT_VERSION >= 0x050000 datapaths << QStandardPaths::writableLocation(QStandardPaths::DataLocation); -#else - datapaths << QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif QDir appdir = QDir(QDir::fromNativeSeparators(EnvUtils::getenv(QLatin1String("APPDATA")))); datapaths << appdir.absolutePath() + QLatin1String("/Mumble"); @@ -188,9 +184,8 @@ void MetaParams::read(QString fname) { } QDir::setCurrent(qdBasePath.absolutePath()); qsSettings = new QSettings(qsAbsSettingsFilePath, QSettings::IniFormat); -#if QT_VERSION >= 0x040500 qsSettings->setIniCodec("UTF-8"); -#endif + qWarning("Initializing settings from %s (basepath %s)", qPrintable(qsSettings->fileName()), qPrintable(qdBasePath.absolutePath())); QString qsHost = qsSettings->value("host", QString()).toString(); @@ -258,7 +253,6 @@ void MetaParams::read(QString fname) { hasipv4 = true; } -#if QT_VERSION >= 0x050000 if (hasipv6) { if (SslServer::hasDualStackSupport() && hasipv4) { qlBind << QHostAddress(QHostAddress::Any); @@ -271,23 +265,6 @@ void MetaParams::read(QString fname) { if (hasipv4) { qlBind << QHostAddress(QHostAddress::AnyIPv4); } -#else // QT_VERSION < 0x050000 - // For Qt 4 AnyIPv6 resulted in a dual stack socket on dual stack - // capable systems while Any resulted in an IPv4 only socket. For - // Qt 5 this has been reworked so that AnyIPv6/v4 are now exclusive - // IPv6/4 sockets while Any is the dual stack socket. - - if (hasipv6) { - qlBind << QHostAddress(QHostAddress::AnyIPv6); - if (SslServer::hasDualStackSupport() && hasipv4) { - hasipv4 = false; // No need to add a separate ipv4 socket - } - } - - if (hasipv4) { - qlBind << QHostAddress(QHostAddress::Any); - } -#endif } qsPassword = typeCheckedFromSettings("serverpassword", qsPassword); @@ -444,9 +421,7 @@ void MetaParams::read(QString fname) { bool MetaParams::loadSSLSettings() { QSettings updatedSettings(qsAbsSettingsFilePath, QSettings::IniFormat); -#if QT_VERSION >= 0x040500 updatedSettings.setIniCodec("UTF-8"); -#endif QString tmpCiphersStr = typeCheckedFromSettings("sslCiphers", qsCiphers); diff --git a/src/murmur/MurmurIce.cpp b/src/murmur/MurmurIce.cpp index 14d4b336f..8cf319e63 100644 --- a/src/murmur/MurmurIce.cpp +++ b/src/murmur/MurmurIce.cpp @@ -123,7 +123,7 @@ static void userToUser(const ::User *p, Murmur::User &mp) { mp.udpPing = u->dUDPPingAvg; mp.tcpPing = u->dTCPPingAvg; - mp.tcponly = QAtomicIntLoad(u->aiUdpFlag) == 0; + mp.tcponly = u->aiUdpFlag.load() == 0; ::Murmur::NetAddress addr(16, 0); const Q_IPV6ADDR &a = u->haAddress.qip6; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 84e5b4ebe..15037c5c5 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -95,11 +95,7 @@ bool SslServer::hasDualStackSupport() { return result; } -#if QT_VERSION >= 0x050000 void SslServer::incomingConnection(qintptr v) { -#else -void SslServer::incomingConnection(int v) { -#endif QSslSocket *s = new QSslSocket(this); s->setSocketDescriptor(v); qlSockets.append(s); @@ -934,7 +930,7 @@ bool Server::checkDecrypt(ServerUser *u, const char *encrypt, char *plain, unsig } void Server::sendMessage(ServerUser *u, const char *data, int len, QByteArray &cache, bool force) { - if ((QAtomicIntLoad(u->aiUdpFlag) == 1 || force) && (u->sUdpSocket != INVALID_SOCKET)) { + if ((u->aiUdpFlag.load() == 1 || force) && (u->sUdpSocket != INVALID_SOCKET)) { #if defined(__LP64__) STACKVAR(char, ebuffer, len+4+16); char *buffer = reinterpret_cast(((reinterpret_cast(ebuffer) + 8) & ~7) + 4); @@ -1299,10 +1295,8 @@ void Server::newClient() { // In Qt 5.4, QSsl::SecureProtocols is equivalent // to "TLSv1.0 or later", which we require. sock->setProtocol(QSsl::SecureProtocols); -#elif QT_VERSION >= 0x050000 - sock->setProtocol(QSsl::TlsV1_0); #else - sock->setProtocol(QSsl::TlsV1); + sock->setProtocol(QSsl::TlsV1_0); #endif sock->startServerEncryption(); } @@ -1327,14 +1321,9 @@ void Server::encrypted() { QList certs = uSource->peerCertificateChain(); if (!certs.isEmpty()) { const QSslCertificate &cert = certs.last(); -#if QT_VERSION >= 0x050000 uSource->qslEmail = cert.subjectAlternativeNames().values(QSsl::EmailEntry); -#else - uSource->qslEmail = cert.alternateSubjectNames().values(QSsl::EmailEntry); -#endif uSource->qsHash = cert.digest(QCryptographicHash::Sha1).toHex(); if (! uSource->qslEmail.isEmpty() && uSource->bVerified) { -#if QT_VERSION >= 0x050000 QString subject; QString issuer; @@ -1347,10 +1336,7 @@ void Server::encrypted() { if (! issuerList.isEmpty()) { issuer = issuerList.first(); } -#else - QString subject = cert.subjectInfo(QSslCertificate::CommonName); - QString issuer = certs.first().issuerInfo(QSslCertificate::CommonName); -#endif + log(uSource, QString::fromUtf8("Strong certificate for %1 <%2> (signed by %3)").arg(subject).arg(uSource->qslEmail.join(", ")).arg(issuer)); } @@ -1424,11 +1410,8 @@ void Server::sslError(const QList &errors) { // See // https://bugreports.qt.io/browse/QTBUG-53906 // https://github.com/mumble-voip/mumble/issues/2334 -#if QT_VERSION >= 0x050000 + u->disconnectSocket(); -#else - u->disconnectSocket(true); -#endif } } diff --git a/src/murmur/Server.h b/src/murmur/Server.h index 79dd87b07..03e0b719b 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -65,11 +65,7 @@ class SslServer : public QTcpServer { Q_DISABLE_COPY(SslServer) protected: QList qlSockets; -#if QT_VERSION >= 0x050000 void incomingConnection(qintptr) Q_DECL_OVERRIDE; -#else - void incomingConnection(int) Q_DECL_OVERRIDE; -#endif public: QSslSocket *nextPendingSSLConnection(); SslServer(QObject *parent = NULL); diff --git a/src/murmur/Tray.h b/src/murmur/Tray.h index 5ab77981b..c0d330571 100644 --- a/src/murmur/Tray.h +++ b/src/murmur/Tray.h @@ -8,12 +8,7 @@ #include #include - -#if QT_VERSION >= 0x050000 -# include -#else -# include -#endif +#include class LogEmitter; class QAction; diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp index 5572ea67c..ea6a99031 100644 --- a/src/murmur/main.cpp +++ b/src/murmur/main.cpp @@ -151,16 +151,10 @@ static void murmurMessageOutputQString(QtMsgType type, const QString &msg) { } } -#if QT_VERSION >= 0x050000 static void murmurMessageOutputWithContext(QtMsgType type, const QMessageLogContext &ctx, const QString &msg) { Q_UNUSED(ctx); murmurMessageOutputQString(type, msg); } -#else -static void murmurMessageOutput(QtMsgType type, const char *msg) { - murmurMessageOutputQString(type, QString::fromUtf8(msg)); -} -#endif #ifdef USE_ICE void IceParse(int &argc, char *argv[]); @@ -220,9 +214,6 @@ int main(int argc, char **argv) { MumbleSSL::initialize(); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); -#if QT_VERSION < 0x050000 - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); -#endif #ifdef Q_OS_WIN // By default, windbus expects the path to dbus-daemon to be in PATH, and the path @@ -252,11 +243,8 @@ int main(int argc, char **argv) { #endif qsrand(QDateTime::currentDateTime().toTime_t()); -#if QT_VERSION >= 0x050000 + qInstallMessageHandler(murmurMessageOutputWithContext); -#else - qInstallMsgHandler(murmurMessageOutput); -#endif #ifdef Q_OS_WIN Tray tray(NULL, &le); @@ -618,11 +606,7 @@ int main(int argc, char **argv) { delete meta; -#if QT_VERSION >= 0x050000 qInstallMessageHandler(NULL); -#else - qInstallMsgHandler(NULL); -#endif #ifdef Q_OS_UNIX if (! Meta::mp.qsPid.isEmpty()) { diff --git a/src/murmur/murmur_pch.h b/src/murmur/murmur_pch.h index eb2405e94..c11c46269 100644 --- a/src/murmur/murmur_pch.h +++ b/src/murmur/murmur_pch.h @@ -32,19 +32,14 @@ # include #endif -#include "QAtomicIntCompat.h" - #ifdef Q_OS_WIN # include -# if QT_VERSION >= 0x050000 -# include "Qt4Compat.h" -# include -# endif # include # include # include # include + extern "C" { void __cpuid(int a[4], int b); }; diff --git a/src/tests/TestSSLLocks/TestSSLLocks.cpp b/src/tests/TestSSLLocks/TestSSLLocks.cpp index 7b9cc41a2..289138ea4 100644 --- a/src/tests/TestSSLLocks/TestSSLLocks.cpp +++ b/src/tests/TestSSLLocks/TestSSLLocks.cpp @@ -7,7 +7,6 @@ #include #include "SSL.h" -#include "QAtomicIntCompat.h" #include @@ -30,7 +29,7 @@ public: void run() { unsigned char buf[64]; - while (QAtomicIntLoad(*m_running) == 1) { + while (m_running->load() == 1) { for (int i = 0; i < 1024; i++) { if (m_seed) { RAND_seed(buf, sizeof(buf)); diff --git a/src/tests/TestServerResolver/TestServerResolver.cpp b/src/tests/TestServerResolver/TestServerResolver.cpp index e8c984509..ddafcdb11 100644 --- a/src/tests/TestServerResolver/TestServerResolver.cpp +++ b/src/tests/TestServerResolver/TestServerResolver.cpp @@ -13,13 +13,7 @@ void signalSpyWait(QSignalSpy &spy) { // We increase the timeout from 5s to 8s because travis builds could fail otherwise (slow network response). const int signalTimeoutS = 8; -#if QT_VERSION >= 0x050000 spy.wait(signalTimeoutS * 1000); -#else - // Equivalent to QSignalSpy::wait() in Qt 5, except we do not return early on a spied on signal result. - QTestEventLoop loop; - loop.enterLoop(signalTimeoutS); -#endif } class TestServerResolver : public QObject { diff --git a/src/tests/TestServerResolver/TestServerResolver.pro b/src/tests/TestServerResolver/TestServerResolver.pro index eab330173..e7d89aaf2 100644 --- a/src/tests/TestServerResolver/TestServerResolver.pro +++ b/src/tests/TestServerResolver/TestServerResolver.pro @@ -9,17 +9,7 @@ include(../../../qmake/qt.pri) QT *= network TARGET = TestServerResolver -SOURCES *= TestServerResolver.cpp HostAddress.cpp ServerResolver_qt5.cpp ServerResolverRecord.cpp +SOURCES *= TestServerResolver.cpp HostAddress.cpp ServerResolver.cpp ServerResolverRecord.cpp HEADERS *= HostAddress.h ServerResolver.h ServerResolverRecord.h -isEqual(QT_MAJOR_VERSION, 4) { - CONFIG *= no-srv -} - -CONFIG(no-srv) { - DEFINES += USE_NO_SRV - SOURCES -= ServerResolver_qt5.cpp - SOURCES *= ServerResolver_nosrv.cpp -} - win32:LIBS *= -lws2_32
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2
    %1%2