From: Manuel Nickschas Date: Tue, 17 Jul 2018 22:42:45 +0000 (+0200) Subject: qt4-b-gone: Remove all code supporting Qt < 5.5 and KDE4 X-Git-Tag: test-travis-01~186 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ab7ef4d24f62b5848b628482b7762ebfc0b53e1a qt4-b-gone: Remove all code supporting Qt < 5.5 and KDE4 Remove compatibility code for Qt versions we no longer support. --- diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 322f58ad..a29505f9 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -20,8 +20,6 @@ #include "clientauthhandler.h" -// TODO: support system application proxy (new in Qt 4.6) - #include #ifdef HAVE_SSL @@ -35,10 +33,6 @@ #include "logmessage.h" #include "peerfactory.h" -#if QT_VERSION < 0x050000 -# include "../../3rdparty/sha512/sha512.h" -#endif - using namespace Protocol; ClientAuthHandler::ClientAuthHandler(CoreAccount account, QObject *parent) @@ -505,11 +499,7 @@ void ClientAuthHandler::onSslErrors() break; case ClientAuthHandler::DigestVersion::Sha2_512: -#if QT_VERSION >= 0x050000 calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Sha512); -#else - calculatedDigest = sha2_512(socket->peerCertificate().toDer()); -#endif break; default: @@ -527,11 +517,7 @@ void ClientAuthHandler::onSslErrors() } if (permanently) { -#if QT_VERSION >= 0x050000 s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); -#else - s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); -#endif s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } else { @@ -540,28 +526,11 @@ void ClientAuthHandler::onSslErrors() } } else if (knownDigestVersion != ClientAuthHandler::DigestVersion::Latest) { -#if QT_VERSION >= 0x050000 s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); -#else - s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); -#endif s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } socket->ignoreSslErrors(); } -#if QT_VERSION < 0x050000 -QByteArray ClientAuthHandler::sha2_512(const QByteArray &input) { - unsigned char output[64]; - sha512((unsigned char*) input.constData(), input.size(), output, false); - // QByteArray::fromRawData() cannot be used here because that constructor - // does not copy "output" and the data is clobbered when the variable goes - // out of scope. - QByteArray result; - result.append((char*) output, 64); - return result; -} -#endif - #endif /* HAVE_SSL */ diff --git a/src/client/clientauthhandler.h b/src/client/clientauthhandler.h index 888f935d..a43d9c8a 100644 --- a/src/client/clientauthhandler.h +++ b/src/client/clientauthhandler.h @@ -90,10 +90,6 @@ private: void checkAndEnableSsl(bool coreSupportsSsl); void startRegistration(); -#if QT_VERSION < 0x050000 - QByteArray sha2_512(const QByteArray &input); -#endif - private slots: void onSocketConnected(); void onSocketStateChanged(QAbstractSocket::SocketState state); diff --git a/src/client/clientidentity.cpp b/src/client/clientidentity.cpp index 3507a10b..08a24b7f 100644 --- a/src/client/clientidentity.cpp +++ b/src/client/clientidentity.cpp @@ -111,10 +111,8 @@ void CertIdentity::markClean() void ClientCertManager::setSslKey(const QByteArray &encoded) { QSslKey key(encoded, QSsl::Rsa); -#if QT_VERSION >= 0x050500 if (key.isNull() && Client::isCoreFeatureEnabled(Quassel::Feature::EcdsaCertfpKeys)) key = QSslKey(encoded, QSsl::Ec); -#endif if (key.isNull()) key = QSslKey(encoded, QSsl::Dsa); _certIdentity->setSslKey(key); @@ -126,5 +124,4 @@ void ClientCertManager::setSslCert(const QByteArray &encoded) _certIdentity->setSslCert(QSslCertificate(encoded)); } - #endif // HAVE_SSL diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 0907deea..5daec856 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -22,9 +22,6 @@ #include #include -#if QT_VERSION < 0x050000 -#include // for Qt::escape() -#endif #include "buffermodel.h" #include "buffersettings.h" @@ -86,11 +83,7 @@ QString NetworkItem::escapeHTML(const QString &string, bool useNonbreakingSpaces { // QString.replace() doesn't guarantee the source string will remain constant. // Use a local variable to avoid compiler errors. -#if QT_VERSION < 0x050000 - QString formattedString = Qt::escape(string); -#else QString formattedString = string.toHtmlEscaped(); -#endif return (useNonbreakingSpaces ? formattedString.replace(" ", " ") : formattedString); } diff --git a/src/common/basichandler.cpp b/src/common/basichandler.cpp index fe7531d1..6ad78289 100644 --- a/src/common/basichandler.cpp +++ b/src/common/basichandler.cpp @@ -51,11 +51,7 @@ const QHash &BasicHandler::handlerHash() { if (!_initDone) { for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) { -#if QT_VERSION >= 0x050000 QString methodSignature = metaObject()->method(i).methodSignature(); -#else - QString methodSignature = metaObject()->method(i).signature(); -#endif if (methodSignature.startsWith("defaultHandler")) { _defaultHandler = i; continue; diff --git a/src/common/eventmanager.cpp b/src/common/eventmanager.cpp index 79bed3f9..f43f6edb 100644 --- a/src/common/eventmanager.cpp +++ b/src/common/eventmanager.cpp @@ -148,12 +148,7 @@ int EventManager::findEventType(const QString &methodSignature_, const QString & void EventManager::registerObject(QObject *object, Priority priority, const QString &methodPrefix, const QString &filterPrefix) { for (int i = object->metaObject()->methodOffset(); i < object->metaObject()->methodCount(); i++) { -#if QT_VERSION >= 0x050000 QString methodSignature = object->metaObject()->method(i).methodSignature(); -#else - QString methodSignature = object->metaObject()->method(i).signature(); -#endif - int eventType = findEventType(methodSignature, methodPrefix); if (eventType > 0) { Handler handler(object, i, priority); diff --git a/src/common/expressionmatch.cpp b/src/common/expressionmatch.cpp index bbcd1dac..ae5661e1 100644 --- a/src/common/expressionmatch.cpp +++ b/src/common/expressionmatch.cpp @@ -25,12 +25,6 @@ #include #include -#if QT_VERSION >= 0x050000 -#include -#else -#include -#endif - #include "logmessage.h" ExpressionMatch::ExpressionMatch(const QString &expression, MatchMode mode, bool caseSensitive) @@ -66,15 +60,7 @@ bool ExpressionMatch::match(const QString &string, bool matchEmpty) const // If specified, first check inverted rules if (_matchInvertRegExActive && _matchInvertRegEx.isValid()) { // Check inverted match rule - - // See _matchRegEx section below for explanations of QRegExp vs. QRegularExpression - if ( -#if QT_VERSION >= 0x050000 - _matchInvertRegEx.match(string).hasMatch() -#else - _matchInvertRegEx.indexIn(string) != -1 -#endif - ) { + if (_matchInvertRegEx.match(string).hasMatch()) { // Inverted rule matched, the rest of the rule cannot match return false; } @@ -82,17 +68,9 @@ bool ExpressionMatch::match(const QString &string, bool matchEmpty) const if (_matchRegExActive && _matchRegEx.isValid()) { // Check regular match rule - #if QT_VERSION >= 0x050000 - // QRegularExpression does partial matching by default (exact matching requires anchoring - // expressions to be added) - // See https://doc.qt.io/qt-5/qregularexpression.html#porting-from-qregexp-exactmatch return _matchRegEx.match(string).hasMatch(); - #else - // QRegExp partial matching is done via indexIn - // See https://doc.qt.io/qt-5/qregexp.html#indexIn - return (_matchRegEx.indexIn(string) != -1); - #endif - } else { + } + else { // If no valid regular rules exist, due to the isValid() check there must be valid inverted // rules that did not match. Count this as properly matching (implicit wildcard). return true; @@ -422,24 +400,13 @@ void ExpressionMatch::cacheRegEx() } -#if QT_VERSION >= 0x050000 QRegularExpression ExpressionMatch::regExFactory(const QString ®ExString, bool caseSensitive) -#else -QRegExp ExpressionMatch::regExFactory(const QString ®ExString, bool caseSensitive) -#endif { // Construct the regular expression object, setting case sensitivity as appropriate -#if QT_VERSION >= 0x050000 - QRegularExpression newRegEx = - QRegularExpression(regExString, caseSensitive ? - QRegularExpression::PatternOption::NoPatternOption - : QRegularExpression::PatternOption::CaseInsensitiveOption ); -#else - QRegExp newRegEx = QRegExp(regExString, caseSensitive ? - Qt::CaseSensitivity::CaseSensitive - : Qt::CaseSensitivity::CaseInsensitive); -#endif + QRegularExpression newRegEx = QRegularExpression(regExString, caseSensitive ? + QRegularExpression::PatternOption::NoPatternOption + : QRegularExpression::PatternOption::CaseInsensitiveOption); // Check if rule is valid if (!newRegEx.isValid()) { @@ -449,8 +416,8 @@ QRegExp ExpressionMatch::regExFactory(const QString ®ExString, bool caseSensi qDebug() << "Internal regular expression component" << regExString << "is invalid and will be ignored"; } - // Qt 5.4 (QT_VERSION >= 0x050400) offers explicit control over when QRegularExpression objects - // get optimized. By default, patterns are only optimized after some number of uses as defined + // Qt offers explicit control over when QRegularExpression objects get optimized. + // By default, patterns are only optimized after some number of uses as defined // within Qt internals. // // In the context of ExpressionMatch, some regular expressions might go unused, e.g. a highlight @@ -465,10 +432,7 @@ QRegExp ExpressionMatch::regExFactory(const QString ®ExString, bool caseSensi // // else { // // Optimize regex now - // #if QT_VERSION >= 0x050400 // newRegEx.optimize(); - // #endif - // // } // // NOTE: This should only be called if the expression is valid! Apply within an "else" of the @@ -483,11 +447,7 @@ QRegExp ExpressionMatch::regExFactory(const QString ®ExString, bool caseSensi QString ExpressionMatch::regExEscape(const QString &phrase) { // Escape the given phrase of any special regular expression characters -#if QT_VERSION >= 0x050000 return QRegularExpression::escape(phrase); -#else - return QRegExp::escape(phrase); -#endif } diff --git a/src/common/expressionmatch.h b/src/common/expressionmatch.h index 0f5acfcf..27127786 100644 --- a/src/common/expressionmatch.h +++ b/src/common/expressionmatch.h @@ -20,15 +20,10 @@ #pragma once +#include #include #include -#if QT_VERSION >= 0x050000 -#include -#else -#include -#endif - /** * Expression matcher with multiple modes of operation and automatic caching for performance */ @@ -37,11 +32,7 @@ class ExpressionMatch public: /// Expression matching mode -#if QT_VERSION >= 0x050000 enum class MatchMode { -#else - enum MatchMode { -#endif MatchPhrase, ///< Match phrase as specified, no special handling MatchMultiPhrase, ///< Match phrase as specified, split on \n only MatchWildcard, ///< Match wildcards, "!" at start inverts, "\" escapes @@ -189,13 +180,9 @@ private: * * @param regExString Regular expression string * @param caseSensitive If true, match case-sensitively, otherwise ignore case when matching - * @return Configured QRegExp class on Qt 4, QRegularExpression on Qt 5 + * @return Configured QRegularExpression */ -#if QT_VERSION >= 0x050000 static QRegularExpression regExFactory(const QString ®ExString, bool caseSensitive); -#else - static QRegExp regExFactory(const QString ®ExString, bool caseSensitive); -#endif /** * Escapes any regular expression characters in a string so they have no special meaning @@ -244,18 +231,10 @@ private: bool _sourceExpressionEmpty = false; ///< Cached expression match string is empty /// Underlying regular expression matching instance for normal (noninverted) rules -#if QT_VERSION >= 0x050000 QRegularExpression _matchRegEx = {}; -#else - QRegExp _matchRegEx = {}; -#endif bool _matchRegExActive = false; ///< If true, use normal expression in matching /// Underlying regular expression matching instance for inverted rules -#if QT_VERSION >= 0x050000 QRegularExpression _matchInvertRegEx = {}; -#else - QRegExp _matchInvertRegEx = {}; -#endif bool _matchInvertRegExActive = false; ///< If true, use invert expression in matching }; diff --git a/src/common/logger.cpp b/src/common/logger.cpp index ed8d8023..a72c68f3 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -53,11 +53,7 @@ Logger::Logger(QObject *parent) connect(this, SIGNAL(messageLogged(Logger::LogEntry)), this, SLOT(onMessageLogged(Logger::LogEntry))); -#if QT_VERSION < 0x050000 - qInstallMsgHandler(Logger::messageHandler); -#else qInstallMessageHandler(Logger::messageHandler); -#endif } @@ -130,11 +126,7 @@ bool Logger::setup(bool keepMessages) } -#if QT_VERSION < 0x050000 -void Logger::messageHandler(QtMsgType type, const char *message) -#else void Logger::messageHandler(QtMsgType type, const QMessageLogContext &, const QString &message) -#endif { Quassel::instance()->logger()->handleMessage(type, message); } @@ -146,11 +138,9 @@ void Logger::handleMessage(QtMsgType type, const QString &msg) case QtDebugMsg: handleMessage(LogLevel::Debug, msg); break; -#if QT_VERSION >= 0x050500 case QtInfoMsg: handleMessage(LogLevel::Info, msg); break; -#endif case QtWarningMsg: handleMessage(LogLevel::Warning, msg); break; diff --git a/src/common/logger.h b/src/common/logger.h index 8c1f2f00..7752a74a 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -72,11 +72,7 @@ public: */ std::vector messages() const; -#if QT_VERSION < 0x050000 - static void messageHandler(QtMsgType type, const char *message); -#else static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message); -#endif /** * Takes the given message with the given log level, formats it and emits the @a messageLogged() signal. diff --git a/src/common/main.cpp b/src/common/main.cpp index 234891c7..598425f6 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -42,26 +42,14 @@ #error "Something is wrong - you need to #define a build mode!" #endif -// We don't want quasselcore to depend on KDE -#if defined HAVE_KDE4 && defined BUILD_CORE -# undef HAVE_KDE4 -#endif // We don't want quasselcore to depend on KDE #if defined HAVE_KF5 && defined BUILD_CORE # undef HAVE_KF5 #endif -#ifdef HAVE_KDE4 -# include -# include "kcmdlinewrapper.h" -#elif defined HAVE_KF5 +#if defined HAVE_KF5 # include # include -# include "qt5cliparser.h" -#elif defined HAVE_QT5 -# include "qt5cliparser.h" -#else -# include "cliparser.h" #endif #if !defined(BUILD_CORE) && defined(STATIC) @@ -70,6 +58,7 @@ Q_IMPORT_PLUGIN(qjpeg) Q_IMPORT_PLUGIN(qgif) #endif +#include "qt5cliparser.h" #include "quassel.h" #include "types.h" @@ -82,30 +71,18 @@ int main(int argc, char **argv) // Instantiate early, so log messages are handled Quassel quassel; -#if QT_VERSION < 0x050000 - // All our source files are in UTF-8, and Qt5 even requires that - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); -#endif - Quassel::setupBuildInfo(); QCoreApplication::setApplicationName(Quassel::buildInfo().applicationName); QCoreApplication::setApplicationVersion(Quassel::buildInfo().plainVersionString); QCoreApplication::setOrganizationName(Quassel::buildInfo().organizationName); QCoreApplication::setOrganizationDomain(Quassel::buildInfo().organizationDomain); - // on OSX with Qt4, raster seems to fix performance issues -#if QT_VERSION < 0x050000 && defined Q_OS_MAC && !defined BUILD_CORE - QApplication::setGraphicsSystem("raster"); -#endif -//Setup the High-DPI settings + //Setup the High-DPI settings # if QT_VERSION >= 0x050600 && defined(Q_OS_WIN) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //Added in Qt 5.6 #endif -# if QT_VERSION >= 0x050400 - //Added in the early Qt5 versions (5.0?)- use 5.4 as the cutoff since lots of high-DPI work was added then QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -# endif + // We need to explicitly initialize the required resources when linking statically #ifndef BUILD_QTUI Q_INIT_RESOURCE(sql); @@ -134,24 +111,7 @@ int main(int argc, char **argv) # endif #endif - std::shared_ptr cliParser; - -#ifdef HAVE_KDE4 - // We need to init KCmdLineArgs first - KAboutData aboutData("quassel", "kdelibs4", ki18n("Quassel IRC"), Quassel::buildInfo().plainVersionString.toUtf8(), - ki18n("A modern, distributed IRC client")); - aboutData.addLicense(KAboutData::License_GPL_V2); - aboutData.addLicense(KAboutData::License_GPL_V3); - aboutData.setBugAddress("https://bugs.quassel-irc.org/projects/quassel-irc/issues/new"); - aboutData.setOrganizationDomain(Quassel::buildInfo().organizationDomain.toUtf8()); - KCmdLineArgs::init(argc, argv, &aboutData); - - cliParser = std::make_shared(); -#elif defined HAVE_QT5 - cliParser = std::make_shared(); -#else - cliParser = std::make_shared(); -#endif + std::shared_ptr cliParser = std::make_shared(); Quassel::setCliParser(cliParser); // Initialize CLI arguments @@ -211,14 +171,6 @@ int main(int argc, char **argv) cliParser->addSwitch("enable-experimental-dcc", 0, "Enable highly experimental and unfinished support for CTCP DCC (DANGEROUS)"); #endif -#ifdef HAVE_KDE4 - // the KDE version needs this extra call to parse argc/argv before app is instantiated - if (!cliParser->init()) { - cliParser->usage(); - return EXIT_FAILURE; - } -#endif - #if defined BUILD_CORE CoreApplication app(argc, argv); #elif defined BUILD_QTUI @@ -227,13 +179,10 @@ int main(int argc, char **argv) MonolithicApplication app(argc, argv); #endif -#ifndef HAVE_KDE4 - // the non-KDE version parses after app has been instantiated if (!cliParser->init(app.arguments())) { cliParser->usage(); return EXIT_FAILURE; } -#endif // Migrate settings from KDE4 to KF5 if appropriate #ifdef HAVE_KF5 diff --git a/src/common/nickhighlightmatcher.h b/src/common/nickhighlightmatcher.h index efc3d8e5..e6757b7d 100644 --- a/src/common/nickhighlightmatcher.h +++ b/src/common/nickhighlightmatcher.h @@ -34,11 +34,7 @@ class NickHighlightMatcher { public: /// Nickname highlighting mode -#if QT_VERSION >= 0x050000 enum class HighlightNickType { -#else - enum HighlightNickType { -#endif NoNick = 0x00, ///< Don't match any nickname CurrentNick = 0x01, ///< Match the current nickname AllNicks = 0x02 ///< Match all configured nicknames in the chosen identity diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index ea1dc3f3..3598fa39 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -559,7 +559,7 @@ void Quassel::loadTranslation(const QLocale &locale) quasselTranslator->setObjectName("QuasselTr"); qApp->installTranslator(quasselTranslator); -#if QT_VERSION >= 0x040800 && !defined Q_OS_MAC +#ifndef Q_OS_MAC bool success = qtTranslator->load(locale, QString("qt_"), translationDirPath()); if (!success) qtTranslator->load(locale, QString("qt_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); diff --git a/src/common/quassel.h b/src/common/quassel.h index 77f7b870..b658677d 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -115,11 +115,7 @@ public: * * This list should be cleaned up after every protocol break, as we can assume them to be present then. */ - #if QT_VERSION >= 0x050000 enum class Feature : uint32_t { - #else - enum Feature { - #endif SynchronizedMarkerLine, SaslAuthentication, SaslExternal, @@ -138,9 +134,7 @@ public: LongTime, ///< Serialize time as 64-bit values RichMessages, ///< Real Name and Avatar URL in backlog BacklogFilterType, ///< BacklogManager supports filtering backlog by MessageType -#if QT_VERSION >= 0x050500 EcdsaCertfpKeys, ///< ECDSA keys for CertFP in identities -#endif LongMessageId, ///< 64-bit IDs for messages SyncedCoreInfo, ///< CoreInfo dynamically updated using signals }; diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index 5e5f59d4..19b9af83 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -96,11 +96,7 @@ void SignalProxy::SignalRelay::attachSignal(QObject *sender, int signalId, const } else { fn = SIGNAL(fakeMethodSignature()); -#if QT_VERSION >= 0x050000 fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).methodSignature()); -#else - fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature()); -#endif } _slots[slotId] = Signal(sender, signalId, fn); @@ -145,11 +141,7 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void ** const QList &argTypes = eMeta->argTypes(signal.signalId); for (int i = 0; i < argTypes.size(); i++) { if (argTypes[i] == 0) { -#if QT_VERSION >= 0x050000 qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(signal.signalId).methodSignature().constData()); -#else - qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(signal.signalId).signature()); -#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return _id; } @@ -669,11 +661,7 @@ bool SignalProxy::invokeSlot(QObject *receiver, int methodId, const QVariantList // check for argument compatibility and build params array for (int i = 0; i < numArgs; i++) { if (!params[i].isValid()) { -#if QT_VERSION >= 0x050000 qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).methodSignature().constData()); -#else - qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).signature()); -#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return false; } @@ -896,11 +884,7 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo if (_meta->method(i).methodType() != QMetaMethod::Slot) continue; -#if QT_VERSION >= 0x050000 if (_meta->method(i).methodSignature().contains('*')) -#else - if (QByteArray(_meta->method(i).signature()).contains('*')) -#endif continue; // skip methods with ptr params QByteArray method = methodName(_meta->method(i)); @@ -929,11 +913,7 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo } if (checkConflicts) { qWarning() << "class" << meta->className() << "contains overloaded methods which is currently not supported!"; -#if QT_VERSION >= 0x050000 qWarning() << " - " << _meta->method(i).methodSignature() << "conflicts with" << _meta->method(_methodIds[method]).methodSignature(); -#else - qWarning() << " - " << _meta->method(i).signature() << "conflicts with" << _meta->method(_methodIds[method]).signature(); -#endif } continue; } @@ -973,11 +953,7 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() if (QMetaType::Void == (QMetaType::Type)returnType(i)) continue; -#if QT_VERSION >= 0x050000 signature = requestSlot.methodSignature(); -#else - signature = QByteArray(requestSlot.signature()); -#endif if (!signature.startsWith("request")) continue; @@ -1011,22 +987,14 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() QByteArray SignalProxy::ExtendedMetaObject::methodName(const QMetaMethod &method) { -#if QT_VERSION >= 0x050000 QByteArray sig(method.methodSignature()); -#else - QByteArray sig(method.signature()); -#endif return sig.left(sig.indexOf("(")); } QString SignalProxy::ExtendedMetaObject::methodBaseName(const QMetaMethod &method) { -#if QT_VERSION >= 0x050000 QString methodname = QString(method.methodSignature()).section("(", 0, 0); -#else - QString methodname = QString(method.signature()).section("(", 0, 0); -#endif // determine where we have to chop: int upperCharPos; @@ -1064,11 +1032,7 @@ SignalProxy::ExtendedMetaObject::MethodDescriptor::MethodDescriptor(const QMetaM _argTypes = argTypes; // determine minArgCount -#if QT_VERSION >= 0x050000 QString signature(method.methodSignature()); -#else - QString signature(method.signature()); -#endif _minArgCount = method.parameterTypes().count() - signature.count("="); _receiverMode = (_methodName.startsWith("request")) diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index f24882c6..f3ea4c52 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -98,12 +98,10 @@ public: } //A better version, but only implemented on Qt5 if Initializer Lists exist -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #ifdef Q_COMPILER_INITIALIZER_LISTS void restrictTargetPeers(std::initializer_list peers, std::function closure) { restrictTargetPeers(QSet(peers), std::move(closure)); } -#endif #endif /**}@*/ diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index a2d092eb..ba05014f 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -114,11 +114,7 @@ QVariantMap SyncableObject::toVariantMap() QVariant::Type variantType = QVariant::nameToType(method.typeName()); if (variantType == QVariant::Invalid && !QByteArray(method.typeName()).isEmpty()) { -#if QT_VERSION >= 0x050000 qWarning() << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.methodSignature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName()); -#else - qWarning() << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.signature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName()); -#endif continue; } diff --git a/src/core/coreidentity.cpp b/src/core/coreidentity.cpp index b7cd6d09..840edbdd 100644 --- a/src/core/coreidentity.cpp +++ b/src/core/coreidentity.cpp @@ -77,10 +77,8 @@ void CoreIdentity::synchronize(SignalProxy *proxy) void CoreIdentity::setSslKey(const QByteArray &encoded) { QSslKey key(encoded, QSsl::Rsa); -#if QT_VERSION >= 0x050500 if (key.isNull()) key = QSslKey(encoded, QSsl::Ec); -#endif if (key.isNull()) key = QSslKey(encoded, QSsl::Dsa); setSslKey(key); diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index 29efd4bd..d060ada2 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -30,13 +30,6 @@ # include "cipher.h" #endif -#if QT_VERSION < 0x050000 -// QChar::LineFeed is Qt 5 -static const QChar QCharLF = QChar('\n'); -#else -static const QChar QCharLF = QChar::LineFeed; -#endif - CoreUserInputHandler::CoreUserInputHandler(CoreNetwork *parent) : CoreBasicHandler(parent) { @@ -457,7 +450,7 @@ void CoreUserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString // Split apart messages at line feeds. The IRC protocol uses those to separate commands, so // they need to be split into multiple messages. - QStringList messages = msg.split(QCharLF); + QStringList messages = msg.split(QChar::LineFeed); foreach (auto message, messages) { // Handle each separated message independently @@ -532,7 +525,7 @@ void CoreUserInputHandler::handleNotice(const BufferInfo &bufferInfo, const QStr QList params; // Split apart messages at line feeds. The IRC protocol uses those to separate commands, so // they need to be split into multiple messages. - QStringList messages = msg.section(' ', 1).split(QCharLF); + QStringList messages = msg.section(' ', 1).split(QChar::LineFeed); foreach (auto message, messages) { // Handle each separated message independently @@ -606,7 +599,7 @@ void CoreUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QStri QString target = msg.section(' ', 0, 0); // Split apart messages at line feeds. The IRC protocol uses those to separate commands, so // they need to be split into multiple messages. - QStringList messages = msg.section(' ', 1).split(QCharLF); + QStringList messages = msg.section(' ', 1).split(QChar::LineFeed); foreach (auto message, messages) { // Handle each separated message independently @@ -657,7 +650,7 @@ void CoreUserInputHandler::handleSay(const BufferInfo &bufferInfo, const QString // Split apart messages at line feeds. The IRC protocol uses those to separate commands, so // they need to be split into multiple messages. - QStringList messages = msg.split(QCharLF, QString::SkipEmptyParts); + QStringList messages = msg.split(QChar::LineFeed, QString::SkipEmptyParts); foreach (auto message, messages) { // Handle each separated message independently diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index 183bbe18..a1e090b7 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -71,11 +71,8 @@ QTcpSocket *SslServer::nextPendingConnection() return _pendingConnections.takeFirst(); } -#if QT_VERSION >= 0x050000 + void SslServer::incomingConnection(qintptr socketDescriptor) -#else -void SslServer::incomingConnection(int socketDescriptor) -#endif { QSslSocket *serverSocket = new QSslSocket(this); if (serverSocket->setSocketDescriptor(socketDescriptor)) { @@ -196,20 +193,16 @@ bool SslServer::setCertificate(const QString &path, const QString &keyPath) // We allow the core to offer SSL anyway, so no "return false" here. Client will warn about the cert being invalid. const QDateTime now = QDateTime::currentDateTime(); - if (now < untestedCert.effectiveDate()) + if (now < untestedCert.effectiveDate()) { quWarning() << "SslServer: Certificate won't be valid before" << untestedCert.effectiveDate().toString(); - - else if (now > untestedCert.expiryDate()) + } + else if (now > untestedCert.expiryDate()) { quWarning() << "SslServer: Certificate expired on" << untestedCert.expiryDate().toString(); - - else { // Qt4's isValid() checks for time range and blacklist; avoid a double warning, hence the else block -#if QT_VERSION < 0x050000 - if (!untestedCert.isValid()) -#else - if (untestedCert.isBlacklisted()) -#endif - quWarning() << "SslServer: Certificate blacklisted"; } + else if (untestedCert.isBlacklisted()) { + quWarning() << "SslServer: Certificate blacklisted"; + } + if (untestedKey.isNull()) { quWarning() << "SslServer:" << qPrintable(keyPath) << "contains no key data"; return false; @@ -230,7 +223,6 @@ QSslKey SslServer::loadKey(QFile *keyFile) { QSslKey key; key = QSslKey(keyFile, QSsl::Rsa); -#if QT_VERSION >= 0x050500 if (key.isNull()) { if (!keyFile->reset()) { quWarning() << "SslServer: IO error reading key file"; @@ -238,7 +230,6 @@ QSslKey SslServer::loadKey(QFile *keyFile) } key = QSslKey(keyFile, QSsl::Ec); } -#endif return key; } diff --git a/src/core/sslserver.h b/src/core/sslserver.h index 609ec77a..518db2e4 100644 --- a/src/core/sslserver.h +++ b/src/core/sslserver.h @@ -53,11 +53,7 @@ public: bool reloadCerts(); protected: -#if QT_VERSION >= 0x050000 void incomingConnection(qintptr socketDescriptor) override; -#else - void incomingConnection(int socketDescriptor) override; -#endif bool setCertificate(const QString &path, const QString &keyPath); diff --git a/src/core/storage.cpp b/src/core/storage.cpp index d6c0ba52..92892563 100644 --- a/src/core/storage.cpp +++ b/src/core/storage.cpp @@ -20,12 +20,9 @@ #include "storage.h" -#include #include -#if QT_VERSION < 0x050000 -# include "../../3rdparty/sha512/sha512.h" -#endif +#include Storage::Storage(QObject *parent) : QObject(parent) @@ -40,7 +37,7 @@ QString Storage::hashPassword(const QString &password) bool Storage::checkHashedPassword(const UserId user, const QString &password, const QString &hashedPassword, const Storage::HashVersion version) { bool passwordCorrect = false; - + switch (version) { case Storage::HashVersion::Sha1: passwordCorrect = checkHashedPasswordSha1(password, hashedPassword); @@ -53,11 +50,11 @@ bool Storage::checkHashedPassword(const UserId user, const QString &password, co default: qWarning() << "Password hash version" << QString(version) << "is not supported, please reset password"; } - + if (passwordCorrect && version < Storage::HashVersion::Latest) { updateUser(user, password); } - + return passwordCorrect; } @@ -104,12 +101,5 @@ bool Storage::checkHashedPasswordSha2_512(const QString &password, const QString QString Storage::sha2_512(const QString &input) { -#if QT_VERSION >= 0x050000 return QString(QCryptographicHash::hash(input.toUtf8(), QCryptographicHash::Sha512).toHex()); -#else - QByteArray inputBytes = input.toUtf8(); - unsigned char output[64]; - sha512((unsigned char*) inputBytes.constData(), inputBytes.size(), output, false); - return QString(QByteArray::fromRawData((char*) output, 64).toHex()); -#endif } diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 92ad3725..02f5faca 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -31,12 +31,6 @@ #include #include -#ifdef HAVE_KDE4 -# include -#else -# include -#endif - #ifdef HAVE_WEBENGINE # include #elif defined HAVE_WEBKIT diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 704b3bea..23703113 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -109,11 +109,7 @@ bool ChatView::event(QEvent *event) } } -#if QT_VERSION >= 0x050000 - if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) { -#else - if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) { -#endif + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type() == QTouchDevice::TouchScreen) { // Enable scrolling by draging, disable selecting/clicking content setDragMode(QGraphicsView::ScrollHandDrag); setInteractive(false); @@ -122,11 +118,7 @@ bool ChatView::event(QEvent *event) if (verticalScrollBar()->isVisible()) return true; } -#if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { -#else - if (event->type() == QEvent::TouchEnd) { -#endif // End scroll and reset settings to default setDragMode(QGraphicsView::NoDrag); setInteractive(true); @@ -149,11 +141,7 @@ bool ChatView::event(QEvent *event) } // Applying the movement happens automatically by the drag-mode } -#if QT_VERSION >= 0x050000 - if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) || event->type() == QEvent::TouchUpdate) { -#else - if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) || event->type() == QEvent::TouchUpdate) { -#endif + if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type() == QTouchDevice::TouchScreen) || event->type() == QEvent::TouchUpdate) { if (!verticalScrollBar()->isVisible()) { scene()->requestBacklog(); return true; diff --git a/src/qtui/chatviewsearchcontroller.h b/src/qtui/chatviewsearchcontroller.h index d2a9dd8e..b85d3551 100644 --- a/src/qtui/chatviewsearchcontroller.h +++ b/src/qtui/chatviewsearchcontroller.h @@ -90,14 +90,10 @@ private: class SearchHighlightItem : public QObject, public QGraphicsItem { Q_OBJECT - -// Apparently, there are broken Qt 4.8.2 mocs around that will fail without this (otherwise useless) #if... looking at you, Wheezy! -#if QT_VERSION >= 0x040600 Q_INTERFACES(QGraphicsItem) -#endif -public : - SearchHighlightItem(QRectF wordRect, QGraphicsItem *parent = 0); +public: + SearchHighlightItem(QRectF wordRect, QGraphicsItem *parent = 0); virtual inline QRectF boundingRect() const { return _boundingRect; } void updateGeometry(qreal width, qreal height); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 8225fe47..ebb23b83 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -318,11 +318,7 @@ AuthenticationSelectionPage::AuthenticationSelectionPage(const QVariantList &aut setSizePolicy({QSizePolicy::Fixed, QSizePolicy::Fixed}); QSizePolicy sp{QSizePolicy::MinimumExpanding, QSizePolicy::Fixed}; -#if QT_VERSION >= 0x050200 sp.setRetainSizeWhenHidden(true); -#else - ui.authSettingsStack->setVisible(true); // ugly hack that will show an empty box, but we'll deprecate Qt4 soon anyway -#endif ui.descriptionStack->setSizePolicy(sp); ui.authSettingsStack->setSizePolicy(sp); @@ -347,11 +343,7 @@ QString AuthenticationSelectionPage::displayName() const QString AuthenticationSelectionPage::authenticator() const { -#if QT_VERSION >= 0x050200 return ui.backendList->currentData().toString(); -#else - return ui.backendList->itemData(ui.backendList->currentIndex()).toString(); -#endif } @@ -424,11 +416,7 @@ StorageSelectionPage::StorageSelectionPage(const QVariantList &backendInfos, QWi setSizePolicy({QSizePolicy::Fixed, QSizePolicy::Fixed}); QSizePolicy sp{QSizePolicy::MinimumExpanding, QSizePolicy::Fixed}; -#if QT_VERSION >= 0x050200 sp.setRetainSizeWhenHidden(true); -#else - ui.storageSettingsStack->setVisible(true); // ugly hack that will show an empty box, but we'll deprecate Qt4 soon anyway -#endif ui.descriptionStack->setSizePolicy(sp); ui.storageSettingsStack->setSizePolicy(sp); @@ -453,11 +441,7 @@ QString StorageSelectionPage::displayName() const QString StorageSelectionPage::backend() const { -#if QT_VERSION >= 0x050200 return ui.backendList->currentData().toString(); -#else - return ui.backendList->itemData(ui.backendList->currentIndex()).toString(); -#endif } diff --git a/src/qtui/knotificationbackend.cpp b/src/qtui/knotificationbackend.cpp index e7ba2d4c..9ca881ef 100644 --- a/src/qtui/knotificationbackend.cpp +++ b/src/qtui/knotificationbackend.cpp @@ -23,13 +23,8 @@ #include #include -#ifdef HAVE_KDE4 -# include -# include -#else -# include -# include -#endif +#include +#include #include "client.h" #include "icon.h" @@ -61,11 +56,7 @@ void KNotificationBackend::notify(const Notification &n) type = "PrivMsgFocused"; break; } -#if QT_VERSION < 0x050000 - QString message = QString("<%1> %2").arg(n.sender, Qt::escape(n.message)); -#else QString message = QString("<%1> %2").arg(n.sender, n.message.toHtmlEscaped()); -#endif KNotification *notification = KNotification::event(type, message, icon::get("dialog-information").pixmap(48), QtUi::mainWindow(), KNotification::RaiseWidgetOnActivation |KNotification::CloseWhenWidgetActivated diff --git a/src/qtui/legacysystemtray.cpp b/src/qtui/legacysystemtray.cpp index 40cd2ed8..87ff3dfe 100644 --- a/src/qtui/legacysystemtray.cpp +++ b/src/qtui/legacysystemtray.cpp @@ -28,15 +28,9 @@ LegacySystemTray::LegacySystemTray(QWidget *parent) : SystemTray(parent) + , _trayIcon{new QSystemTrayIcon(associatedWidget())} { -#ifndef HAVE_KDE4 - _trayIcon = new QSystemTrayIcon(associatedWidget()); -#else - _trayIcon = new KSystemTrayIcon(associatedWidget()); - // We don't want to trigger a minimize if a highlight is pending, so we brutally remove the internal connection for that - disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - _trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason))); -#endif + #ifndef Q_OS_MAC connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onActivated(QSystemTrayIcon::ActivationReason))); diff --git a/src/qtui/legacysystemtray.h b/src/qtui/legacysystemtray.h index e2bc3386..8ef478eb 100644 --- a/src/qtui/legacysystemtray.h +++ b/src/qtui/legacysystemtray.h @@ -23,12 +23,7 @@ #ifndef QT_NO_SYSTEMTRAYICON #include - -#ifdef HAVE_KDE4 -# include -#else -# include -#endif +#include #include "systemtray.h" @@ -58,11 +53,7 @@ private slots: private: uint _lastMessageId {0}; -#ifdef HAVE_KDE4 - KSystemTrayIcon *_trayIcon; -#else QSystemTrayIcon *_trayIcon; -#endif }; #endif /* QT_NO_SYSTEMTRAYICON */ diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 77e693a6..f2c13886 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -28,15 +28,6 @@ #include #include -#ifdef HAVE_KDE4 -# include -# include -# include -# include -# include -# include -#endif - #ifdef HAVE_KF5 # include # include diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 505bb614..9b422504 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -22,9 +22,7 @@ #include -#ifdef HAVE_KDE4 -# include -#elif defined HAVE_KF5 +#ifdef HAVE_KF5 # include #else # include diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index a6c48c35..9bd81577 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -347,7 +347,6 @@ void QtUi::refreshIconTheme() return; } -#if QT_VERSION >= 0x050000 // At this point, we have a system theme that we don't want to override, but that may not contain all // required icons. // We create a dummy theme that inherits first from the system theme, then from the supported fallback. @@ -397,10 +396,4 @@ void QtUi::refreshIconTheme() } indexFile.close(); QIcon::setThemeName("quassel-icon-proxy"); -#else - // Qt4 doesn't support QTemporaryDir. Since it's deprecated and slated to be removed soon anyway, we don't bother - // writing a replacement and simply don't support not overriding the system theme. - QIcon::setThemeName(fallbackTheme); - emit iconThemeRefreshed(); -#endif } diff --git a/src/qtui/qtui.h b/src/qtui/qtui.h index af9ddff3..a6551a86 100644 --- a/src/qtui/qtui.h +++ b/src/qtui/qtui.h @@ -27,10 +27,7 @@ #include #include #include - -#if QT_VERSION >= 0x050000 -# include -#endif +#include #include "abstractnotificationbackend.h" #include "graphicalui.h" @@ -136,9 +133,7 @@ private: QString _systemIconTheme; -#if QT_VERSION >= 0x050000 std::unique_ptr _dummyThemeDir; -#endif bool _useSystemTray; }; diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index fc04f59b..74be5b49 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef HAVE_KDE4 -# include -#endif - #include "chatviewsettings.h" #include "cliparser.h" #include "logmessage.h" @@ -37,59 +33,15 @@ #include "types.h" QtUiApplication::QtUiApplication(int &argc, char **argv) -#ifdef HAVE_KDE4 - : KApplication() // KApplication is deprecated in KF5 -#else : QApplication(argc, argv) -#endif { -#ifdef HAVE_KDE4 - Q_UNUSED(argc); Q_UNUSED(argv); - - // Setup KDE's data dirs - // Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here... - QStringList dataDirs = KGlobal::dirs()->findDirs("data", ""); - - // Just in case, also check our install prefix - dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/"; - - // Normalize and append our application name - for (int i = 0; i < dataDirs.count(); i++) - dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/"; - - // Add resource path and just in case. - // Workdir should have precedence - dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/"); - dataDirs.append(":/data/"); - - // Append trailing '/' and check for existence - auto iter = dataDirs.begin(); - while (iter != dataDirs.end()) { - if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/')) - iter->append(QDir::separator()); - if (!QFile::exists(*iter)) - iter = dataDirs.erase(iter); - else - ++iter; - } - - dataDirs.removeDuplicates(); - Quassel::setDataDirPaths(dataDirs); - -#else /* HAVE_KDE4 */ - Quassel::setDataDirPaths(Quassel::findDataDirPaths()); - -#endif /* HAVE_KDE4 */ - Quassel::setRunMode(Quassel::ClientOnly); -#if QT_VERSION >= 0x050000 connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection); connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection); -#endif -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) +#if QT_VERSION >= 0x050600 QGuiApplication::setFallbackSessionManagementEnabled(false); #endif } diff --git a/src/qtui/qtuiapplication.h b/src/qtui/qtuiapplication.h index a5e68e1b..8d8608e7 100644 --- a/src/qtui/qtuiapplication.h +++ b/src/qtui/qtuiapplication.h @@ -22,12 +22,7 @@ #include -#ifdef HAVE_KDE4 -# include -#else -# include -#endif - +#include #include #include "client.h" @@ -37,14 +32,8 @@ class QtUi; -#ifdef HAVE_KDE4 -class QtUiApplication : public KApplication -{ -#else class QtUiApplication : public QApplication { -#endif - Q_OBJECT public: @@ -55,13 +44,8 @@ public: void resumeSessionIfPossible(); inline bool isAboutToQuit() const { return _aboutToQuit; } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - void commitData(QSessionManager &manager) override; - void saveState(QSessionManager &manager) override; -#else void commitData(QSessionManager &manager); void saveState(QSessionManager &manager); -#endif protected: virtual Quassel::QuitHandler quitHandler(); diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 1a25533f..f5360c34 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -40,10 +40,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) #ifdef QT_NO_SYSTEMTRAYICON ui.useSystemTrayIcon->hide(); #endif -#if QT_VERSION < 0x050000 - // We don't support overriding the system icon theme with Qt4 - ui.overrideSystemIconTheme->hide(); -#endif // If no system icon theme is given, showing the override option makes no sense. // Also don't mention a "fallback". diff --git a/src/qtui/settingspages/corehighlightsettingspage.cpp b/src/qtui/settingspages/corehighlightsettingspage.cpp index 3de8d766..9315f3f8 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.cpp +++ b/src/qtui/settingspages/corehighlightsettingspage.cpp @@ -136,21 +136,12 @@ void CoreHighlightSettingsPage::setupRuleTable(QTableWidget *table) const table->horizontalHeaderItem(CoreHighlightSettingsPage::SenderColumn), table->horizontalHeaderItem(CoreHighlightSettingsPage::ChanColumn)); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents); - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::NameColumn, QHeaderView::Stretch); - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents); - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents); - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::SenderColumn, QHeaderView::ResizeToContents); - table->horizontalHeader()->setResizeMode(CoreHighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents); -#else table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents); table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::NameColumn, QHeaderView::Stretch); table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents); table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents); table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::SenderColumn, QHeaderView::ResizeToContents); table->horizontalHeader()->setSectionResizeMode(CoreHighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents); -#endif } diff --git a/src/qtui/settingspages/highlightsettingspage.cpp b/src/qtui/settingspages/highlightsettingspage.cpp index db5982e9..59ffac33 100644 --- a/src/qtui/settingspages/highlightsettingspage.cpp +++ b/src/qtui/settingspages/highlightsettingspage.cpp @@ -79,19 +79,11 @@ HighlightSettingsPage::HighlightSettingsPage(QWidget *parent) ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setWhatsThis( ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->toolTip()); -#if QT_VERSION < 0x050000 - ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::NameColumn, QHeaderView::Stretch); - ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents); - ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents); - ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents); - ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents); -#else ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::NameColumn, QHeaderView::Stretch); ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents); ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents); ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents); ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents); -#endif // Information icon ui.localHighlightsIcon->setPixmap(icon::get("dialog-information").pixmap(16)); diff --git a/src/qtui/settingspages/identityeditwidget.cpp b/src/qtui/settingspages/identityeditwidget.cpp index 684dc616..3a2534b6 100644 --- a/src/qtui/settingspages/identityeditwidget.cpp +++ b/src/qtui/settingspages/identityeditwidget.cpp @@ -23,15 +23,10 @@ #include #include #include +#include #include #include -#include - -#if QT_VERSION < 0x050000 -# include -#else -# include -#endif +#include #include "client.h" #include "icon.h" @@ -115,11 +110,7 @@ IdentityEditWidget::IdentityEditWidget(QWidget *parent) addRow("AP", tr("AM/PM"), true); addRow("dd", tr("day"), true); addRow("MM", tr("month"), true); -#if QT_VERSION > 0x050000 - // Alas, this was only added in Qt 5. We don't know what version the core has, just hope - // for the best (Qt 4 will soon be dropped). addRow("t", tr("current timezone"), true); -#endif formatTooltip << ""; formatTooltip << "

" << tr("Example: Away since %%hh:mm%% on %%dd.MM%%.") << "

"; formatTooltip << "

" << tr("%%%% without anything inside represents %%. Other format " @@ -370,12 +361,7 @@ void IdentityEditWidget::on_clearOrLoadKeyButton_clicked() QSslKey key; if (ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty()) - key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), -#if QT_VERSION < 0x050000 - QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); -#else - QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); -#endif + key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); showKeyState(key); emit widgetHasChanged(); @@ -392,16 +378,8 @@ QSslKey IdentityEditWidget::keyByFilename(const QString &filename) keyFile.close(); for (int i = 0; i < 2; i++) { -#if QT_VERSION >= 0x050500 // On Qt5.5+, support QSsl::KeyAlgorithm::Rsa (1), QSsl::KeyAlgorithm::Dsa (2), and QSsl::KeyAlgorithm::Ec (3) for (int j = 1; j < 4; j++) { -#elif QT_VERSION >= 0x050000 - // On Qt5.0-Qt5.4, support QSsl::KeyAlgorithm::Rsa (1) and QSsl::KeyAlgorithm::Dsa (2) (Ec wasn't added until 5.5) - for (int j = 1; j < 3; j++) { -#else - // On Qt4, support QSsl::KeyAlgorithm::Rsa (0) and QSsl::KeyAlgorithm::Dsa (1) (Qt4 uses different indices for the values) - for (int j = 0; j < 2; j++) { -#endif key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i); if (!key.isNull()) goto returnKey; @@ -409,12 +387,10 @@ QSslKey IdentityEditWidget::keyByFilename(const QString &filename) } QMessageBox::information(this, tr("Failed to read key"), tr("Failed to read the key file. It is either incompatible or invalid. Note that the key file must not have a passphrase.")); returnKey: -#if QT_VERSION >= 0x050500 if(!key.isNull() && key.algorithm() == QSsl::KeyAlgorithm::Ec && !Client::isCoreFeatureEnabled(Quassel::Feature::EcdsaCertfpKeys)) { QMessageBox::information(this, tr("Core does not support ECDSA keys"), tr("You loaded an ECDSA key, but the core does not support ECDSA keys. Please contact the core administrator.")); key.clear(); } -#endif return key; } @@ -430,11 +406,9 @@ void IdentityEditWidget::showKeyState(const QSslKey &key) case QSsl::Rsa: ui.keyTypeLabel->setText(tr("RSA")); break; -#if QT_VERSION >= 0x050500 case QSsl::Ec: ui.keyTypeLabel->setText(tr("ECDSA")); break; -#endif case QSsl::Dsa: ui.keyTypeLabel->setText(tr("DSA")); break; @@ -453,12 +427,7 @@ void IdentityEditWidget::on_clearOrLoadCertButton_clicked() QSslCertificate cert; if (ui.certOrgLabel->property("sslCert").toByteArray().isEmpty()) - cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), -#if QT_VERSION < 0x050000 - QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); -#else - QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); -#endif + cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); showCertState(cert); emit widgetHasChanged(); } @@ -489,13 +458,8 @@ void IdentityEditWidget::showCertState(const QSslCertificate &cert) ui.clearOrLoadCertButton->setText(tr("Load")); } else { -#if QT_VERSION < 0x050000 - ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); - ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); -#else ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization).join(", ")); ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName).join(", ")); -#endif ui.clearOrLoadCertButton->setText(tr("Clear")); } ui.certOrgLabel->setProperty("sslCert", cert.toPem()); diff --git a/src/qtui/sslinfodlg.cpp b/src/qtui/sslinfodlg.cpp index 584303e6..a549d8fc 100644 --- a/src/qtui/sslinfodlg.cpp +++ b/src/qtui/sslinfodlg.cpp @@ -80,32 +80,18 @@ void SslInfoDlg::setCurrentCert(int index) ui.validity->setText(tr("%1 to %2").arg(cert.effectiveDate().date().toString(Qt::ISODate), cert.expiryDate().date().toString(Qt::ISODate))); ui.md5Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Md5))); ui.sha1Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha1))); -#if QT_VERSION < 0x050000 - // Qt 4 doesn't include SHA-2 hashes, so hide the row - ui.sha256Label->hide(); - ui.sha256Digest->hide(); -#else ui.sha256Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha256))); -#endif } // in Qt5, subjectInfo returns a QStringList(); turn this into a comma-separated string instead QString SslInfoDlg::subjectInfo(const QSslCertificate &cert, QSslCertificate::SubjectInfo subjectInfo) const { -#if QT_VERSION < 0x050000 - return cert.subjectInfo(subjectInfo); -#else return cert.subjectInfo(subjectInfo).join(", "); -#endif } // same here QString SslInfoDlg::issuerInfo(const QSslCertificate &cert, QSslCertificate::SubjectInfo subjectInfo) const { -#if QT_VERSION < 0x050000 - return cert.issuerInfo(subjectInfo); -#else return cert.issuerInfo(subjectInfo).join(", "); -#endif } diff --git a/src/qtui/statusnotifieritem.cpp b/src/qtui/statusnotifieritem.cpp index 59a129ea..f3b362e9 100644 --- a/src/qtui/statusnotifieritem.cpp +++ b/src/qtui/statusnotifieritem.cpp @@ -72,9 +72,7 @@ protected: StatusNotifierItem::StatusNotifierItem(QWidget *parent) : StatusNotifierItemParent(parent) -#if QT_VERSION >= 0x050000 , _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}} -#endif { static bool registered = []() -> bool { qDBusRegisterMetaType(); @@ -93,15 +91,12 @@ StatusNotifierItem::StatusNotifierItem(QWidget *parent) trayMenu()->installEventFilter(this); // Create a temporary directory that holds copies of the tray icons. That way, visualizers can find our icons. - // For Qt4 the relevant icons are installed in hicolor already, so nothing to be done. -#if QT_VERSION >= 0x050000 if (_iconThemeDir.isValid()) { _iconThemePath = _iconThemeDir.path(); } else { qWarning() << "Could not create temporary directory for themed tray icons!"; } -#endif connect(this, SIGNAL(iconsChanged()), this, SLOT(refreshIcons())); refreshIcons(); @@ -195,7 +190,6 @@ void StatusNotifierItem::onDBusError(const QDBusError &error) void StatusNotifierItem::refreshIcons() { -#if QT_VERSION >= 0x050000 if (!_iconThemePath.isEmpty()) { QDir baseDir{_iconThemePath + "/hicolor"}; baseDir.removeRecursively(); @@ -223,7 +217,7 @@ void StatusNotifierItem::refreshIcons() } } } -#endif + if (_statusNotifierItemDBus) { emit _statusNotifierItemDBus->NewIcon(); emit _statusNotifierItemDBus->NewAttentionIcon(); @@ -321,18 +315,9 @@ void StatusNotifierItem::activated(const QPoint &pos) bool StatusNotifierItem::eventFilter(QObject *watched, QEvent *event) { if (mode() == StatusNotifier) { - //FIXME: ugly ugly workaround to weird QMenu's focus problems -#ifdef HAVE_KDE4 - if (watched == trayMenu() && - (event->type() == QEvent::WindowDeactivate || (event->type() == QEvent::MouseButtonRelease && static_cast(event)->button() == Qt::LeftButton))) { - // put at the back of event queue to let the action activate anyways - QTimer::singleShot(0, trayMenu(), SLOT(hide())); - } -#else if (watched == trayMenu() && event->type() == QEvent::HoverLeave) { trayMenu()->hide(); } -#endif } return StatusNotifierItemParent::eventFilter(watched, event); } @@ -342,12 +327,9 @@ void StatusNotifierItem::showMessage(const QString &title, const QString &messag { QString message = message_; if (_notificationsClient->isValid()) { - if (_notificationsClientSupportsMarkup) -#if QT_VERSION < 0x050000 - message = Qt::escape(message); -#else + if (_notificationsClientSupportsMarkup) { message = message.toHtmlEscaped(); -#endif + } QStringList actions; if (_notificationsClientSupportsActions) diff --git a/src/qtui/statusnotifieritem.h b/src/qtui/statusnotifieritem.h index 8e40be37..5a103b61 100644 --- a/src/qtui/statusnotifieritem.h +++ b/src/qtui/statusnotifieritem.h @@ -28,10 +28,7 @@ #include #include #include - -#if QT_VERSION >= 0x050000 -# include -#endif +#include #include "notificationsclient.h" #include "systemtray.h" @@ -101,9 +98,7 @@ private: QString _iconThemePath; QString _menuObjectPath; -#if QT_VERSION >= 0x050000 QTemporaryDir _iconThemeDir; -#endif friend class StatusNotifierItemDBus; }; diff --git a/src/qtui/statusnotifieritemdbus.cpp b/src/qtui/statusnotifieritemdbus.cpp index ee21928f..e13af94a 100644 --- a/src/qtui/statusnotifieritemdbus.cpp +++ b/src/qtui/statusnotifieritemdbus.cpp @@ -24,17 +24,11 @@ #include "statusnotifieritemdbus.h" #include "statusnotifieritem.h" +#include #include -#include #include -#include #include -#include - -#ifdef HAVE_KDE4 -# include -# include -#endif +#include #include "statusnotifierwatcher.h" #include "statusnotifieritemadaptor.h" @@ -45,7 +39,6 @@ __inline int toInt(WId wid) return (int)((__int64)wid); } - #else __inline int toInt(WId wid) { @@ -320,15 +313,7 @@ void StatusNotifierItemDBus::ContextMenu(int x, int y) //TODO: nicer placement, possible? if (!m_statusNotifierItem->trayMenu()->isVisible()) { -#ifdef HAVE_KDE4 - m_statusNotifierItem->trayMenu()->setWindowFlags(Qt::Window|Qt::FramelessWindowHint); -#endif m_statusNotifierItem->trayMenu()->popup(QPoint(x, y)); -#ifdef HAVE_KDE4 - KWindowSystem::setState(m_statusNotifierItem->trayMenu()->winId(), NET::SkipTaskbar|NET::SkipPager|NET::KeepAbove); - KWindowSystem::setType(m_statusNotifierItem->trayMenu()->winId(), NET::PopupMenu); - KWindowSystem::forceActiveWindow(m_statusNotifierItem->trayMenu()->winId()); -#endif } else { m_statusNotifierItem->trayMenu()->hide(); diff --git a/src/qtui/systemtray.cpp b/src/qtui/systemtray.cpp index 7e38a6a0..d4e17661 100644 --- a/src/qtui/systemtray.cpp +++ b/src/qtui/systemtray.cpp @@ -23,12 +23,6 @@ #include #include -#ifdef HAVE_KDE4 -# include -# include -# include -#endif - #include "action.h" #include "actioncollection.h" #include "client.h" @@ -48,19 +42,9 @@ SystemTray::SystemTray(QWidget *parent) ActionCollection *coll = QtUi::actionCollection("General"); _minimizeRestoreAction = new Action(tr("&Minimize"), this, this, SLOT(minimizeRestore())); -#ifdef HAVE_KDE4 - KMenu *kmenu; - _trayMenu = kmenu = new KMenu(); - kmenu->addTitle(icon::get(iconName(State::Active)), "Quassel IRC"); -#else _trayMenu = new QMenu(associatedWidget()); -#endif - _trayMenu->setTitle("Quassel IRC"); - -#ifndef HAVE_KDE4 _trayMenu->setAttribute(Qt::WA_Hover); -#endif _trayMenu->addAction(coll->action("ConnectCore")); _trayMenu->addAction(coll->action("DisconnectCore")); @@ -121,16 +105,6 @@ void SystemTray::setMode(Mode mode) { if (mode != _mode) { _mode = mode; -#ifdef HAVE_KDE4 - if (_trayMenu) { - if (mode == Mode::Legacy) { - _trayMenu->setWindowFlags(Qt::Popup); - } - else { - _trayMenu->setWindowFlags(Qt::Window); - } - } -#endif emit modeChanged(mode); } } diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 9e6435da..c0831933 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -114,19 +114,11 @@ void TopicWidget::setTopic(const QModelIndex &index) switch (Client::networkModel()->bufferType(id)) { case BufferInfo::StatusBuffer: if (network) { -#if QT_VERSION < 0x050000 - newtopic = QString("%1 (%2) | %3 | %4") - .arg(Qt::escape(network->networkName())) - .arg(Qt::escape(network->currentServer())) - .arg(tr("Users: %1").arg(network->ircUsers().count())) - .arg(tr("Lag: %1 msecs").arg(network->latency())); -#else newtopic = QString("%1 (%2) | %3 | %4") .arg(network->networkName().toHtmlEscaped()) .arg(network->currentServer().toHtmlEscaped()) .arg(tr("Users: %1").arg(network->ircUsers().count())) .arg(tr("Lag: %1 msecs").arg(network->latency())); -#endif } else { newtopic = index0.data(Qt::DisplayRole).toString(); @@ -280,9 +272,7 @@ QString TopicWidget::sanitizeTopic(const QString& topic) // some unicode characters with a new line, which then triggers // a stack overflow later QString result(topic); -#if QT_VERSION >= 0x050000 result.replace(QChar::CarriageReturn, " "); -#endif result.replace(QChar::ParagraphSeparator, " "); result.replace(QChar::LineSeparator, " "); diff --git a/src/uisupport/action.cpp b/src/uisupport/action.cpp index 1807631a..55427392 100644 --- a/src/uisupport/action.cpp +++ b/src/uisupport/action.cpp @@ -25,22 +25,14 @@ #include Action::Action(QObject *parent) -#ifdef HAVE_KDE4 - : KAction(parent) -#else : QWidgetAction(parent) -#endif { init(); } Action::Action(const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut) -#ifdef HAVE_KDE4 - : KAction(parent) -#else : QWidgetAction(parent) -#endif { init(); setText(text); @@ -51,11 +43,7 @@ Action::Action(const QString &text, QObject *parent, const QObject *receiver, co Action::Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut) -#ifdef HAVE_KDE4 - : KAction(parent) -#else : QWidgetAction(parent) -#endif { init(); setIcon(icon); @@ -66,9 +54,6 @@ Action::Action(const QIcon &icon, const QString &text, QObject *parent, const QO } -#ifdef HAVE_KDE4 -void Action::init() {} -#else void Action::init() { connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered())); @@ -99,12 +84,8 @@ QKeySequence Action::shortcut(ShortcutTypes type) const { Q_ASSERT(type); if (type == DefaultShortcut) { -#if QT_VERSION < 0x050000 - return property("defaultShortcut").value(); -#else auto sequence = property("defaultShortcuts").value>(); return sequence.isEmpty() ? QKeySequence() : sequence.first(); -#endif } return shortcuts().isEmpty() ? QKeySequence() : shortcuts().first(); @@ -122,15 +103,8 @@ void Action::setShortcut(const QKeySequence &key, ShortcutTypes type) Q_ASSERT(type); if (type & DefaultShortcut) { -#if QT_VERSION < 0x050000 - setProperty("defaultShortcut", key); -#else setProperty("defaultShortcuts", QVariant::fromValue(QList() << key)); -#endif } if (type & ActiveShortcut) QAction::setShortcut(key); } - - -#endif /* HAVE_KDE4 */ diff --git a/src/uisupport/action.h b/src/uisupport/action.h index fb0a7e18..62bc8a37 100644 --- a/src/uisupport/action.h +++ b/src/uisupport/action.h @@ -20,10 +20,7 @@ * Parts of this API have been shamelessly stolen from KDE's kaction.h * ***************************************************************************/ -#ifndef ACTION_H_ -#define ACTION_H_ - -#ifndef HAVE_KDE4 +#pragma once #include #include @@ -70,24 +67,3 @@ private slots: Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes) - -#else /* HAVE_KDE4 */ -#include - -class Action : public KAction -{ - Q_OBJECT - -public: - explicit Action(QObject *parent); - Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); - Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); - -private: - void init(); -}; - - -#endif - -#endif diff --git a/src/uisupport/actioncollection.cpp b/src/uisupport/actioncollection.cpp index 3d5fcf8e..89280532 100644 --- a/src/uisupport/actioncollection.cpp +++ b/src/uisupport/actioncollection.cpp @@ -203,31 +203,19 @@ void ActionCollection::actionDestroyed(QObject *obj) unlistAction(action); } -#if QT_VERSION >= 0x050000 void ActionCollection::connectNotify(const QMetaMethod &signal) -#else -void ActionCollection::connectNotify(const char *signal) -#endif { if (_connectHovered && _connectTriggered) return; -#if QT_VERSION >= 0x050000 if (QMetaMethod::fromSignal(&ActionCollection::actionHovered) == signal) { -#else - if (QMetaObject::normalizedSignature(SIGNAL(actionHovered(QAction *))) == signal) { -#endif if (!_connectHovered) { _connectHovered = true; foreach(QAction* action, actions()) connect(action, SIGNAL(hovered()), SLOT(slotActionHovered())); } } -#if QT_VERSION >= 0x050000 else if (QMetaMethod::fromSignal(&ActionCollection::actionTriggered) == signal) { -#else - else if (QMetaObject::normalizedSignature(SIGNAL(actionTriggered(QAction *))) == signal) { -#endif if (!_connectTriggered) { _connectTriggered = true; foreach(QAction* action, actions()) diff --git a/src/uisupport/actioncollection.h b/src/uisupport/actioncollection.h index f7f5ff81..5de038ff 100644 --- a/src/uisupport/actioncollection.h +++ b/src/uisupport/actioncollection.h @@ -95,11 +95,7 @@ signals: void actionTriggered(QAction *action); protected slots: -#if QT_VERSION >= 0x050000 virtual void connectNotify(const QMetaMethod &signal); -#else - virtual void connectNotify(const char *signal); -#endif virtual void slotActionTriggered(); private slots: @@ -123,11 +119,7 @@ int ActionCollection::count() const { return actions().count(); } bool ActionCollection::isEmpty() const { return actions().count(); } #else /* HAVE_KDE */ -# ifdef HAVE_KDE4 -# include -# else -# include -# endif +# include class ActionCollection : public KActionCollection { diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 9bf7a524..969107cd 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -75,9 +75,7 @@ void BufferView::init() setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // breaks with Qt 4.8 - if (QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10! - setAnimated(true); + setAnimated(true); // FIXME This is to workaround bug #663 setUniformRowHeights(true); @@ -394,15 +392,9 @@ void BufferView::setExpandedState(const QModelIndex &networkIdx) storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state } -#if QT_VERSION < 0x050000 -void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - TreeViewTouch::dataChanged(topLeft, bottomRight); -#else void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { TreeViewTouch::dataChanged(topLeft, bottomRight, roles); -#endif // determine how many items have been changed and if any of them is a networkitem // which just swichted from active to inactive or vice versa @@ -716,11 +708,7 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c if (!value.isValid()) return QStyledItemDelegate::editorEvent(event, model, option, index); -#if QT_VERSION < 0x050000 - QStyleOptionViewItemV4 viewOpt(option); -#else QStyleOptionViewItem viewOpt(option); -#endif initStyleOption(&viewOpt, index); QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget); diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index 2a32eb2c..47a519f5 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -85,11 +85,7 @@ protected: virtual void focusInEvent(QFocusEvent *event) { QAbstractScrollArea::focusInEvent(event); } virtual void contextMenuEvent(QContextMenuEvent *event); -#if QT_VERSION < 0x050000 - virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); -#else virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); -#endif private slots: void joinChannel(const QModelIndex &index); diff --git a/src/uisupport/colorbutton.cpp b/src/uisupport/colorbutton.cpp index 8dad5684..22e03836 100644 --- a/src/uisupport/colorbutton.cpp +++ b/src/uisupport/colorbutton.cpp @@ -20,15 +20,11 @@ #include "colorbutton.h" +#include #include #include #include -#ifdef HAVE_KDE4 -# include -#else -# include -#endif ColorButton::ColorButton(QWidget *parent) : QToolButton(parent) { @@ -56,13 +52,7 @@ QColor ColorButton::color() const void ColorButton::chooseColor() { -#ifdef HAVE_KDE4 - QColor c = color(); - KColorDialog::getColor(c, this); -#else QColor c = QColorDialog::getColor(color(), this); -#endif - if (c.isValid()) { setColor(c); } diff --git a/src/uisupport/graphicalui.cpp b/src/uisupport/graphicalui.cpp index 3f65505a..ffd4e3df 100644 --- a/src/uisupport/graphicalui.cpp +++ b/src/uisupport/graphicalui.cpp @@ -31,17 +31,12 @@ #ifdef Q_WS_X11 # include #endif -#ifdef HAVE_KDE4 -# include -# include -#endif QWidget *GraphicalUi::_mainWidget = 0; QHash GraphicalUi::_actionCollections; ContextMenuActionProvider *GraphicalUi::_contextMenuActionProvider = 0; ToolBarActionProvider *GraphicalUi::_toolBarActionProvider = 0; UiStyle *GraphicalUi::_uiStyle = 0; -bool GraphicalUi::_onAllDesktops = false; GraphicalUi::GraphicalUi(QObject *parent) : AbstractUi(parent), Singleton(this) @@ -169,65 +164,6 @@ bool GraphicalUi::checkMainWidgetVisibility(bool perform) return true; } -#elif defined(HAVE_KDE4) && defined(Q_WS_X11) - KWindowInfo info1 = KWindowSystem::windowInfo(mainWidget()->winId(), NET::XAWMState | NET::WMState | NET::WMDesktop); - // mapped = visible (but possibly obscured) - bool mapped = (info1.mappingState() == NET::Visible) && !info1.isMinimized(); - - // - not mapped -> show, raise, focus - // - mapped - // - obscured -> raise, focus - // - not obscured -> hide - //info1.mappingState() != NET::Visible -> window on another desktop? - if (!mapped) { - if (perform) - minimizeRestore(true); - return true; - } - else { - QListIterator it(KWindowSystem::stackingOrder()); - it.toBack(); - while (it.hasPrevious()) { - WId id = it.previous(); - if (id == mainWidget()->winId()) - break; - - KWindowInfo info2 = KWindowSystem::windowInfo(id, NET::WMDesktop | NET::WMGeometry | NET::XAWMState | NET::WMState | NET::WMWindowType); - - if (info2.mappingState() != NET::Visible) - continue; // not visible on current desktop -> ignore - - if (!info2.geometry().intersects(mainWidget()->geometry())) - continue; // not obscuring the window -> ignore - - if (!info1.hasState(NET::KeepAbove) && info2.hasState(NET::KeepAbove)) - continue; // obscured by window kept above -> ignore - - NET::WindowType type = info2.windowType(NET::NormalMask | NET::DesktopMask - | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask - | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask); - - if (type == NET::Dock || type == NET::TopMenu) - continue; // obscured by dock or topmenu -> ignore - - if (perform) { - KWindowSystem::raiseWindow(mainWidget()->winId()); - KWindowSystem::activateWindow(mainWidget()->winId()); - } - return true; - } - - //not on current desktop? - if (!info1.isOnCurrentDesktop()) { - if (perform) - KWindowSystem::activateWindow(mainWidget()->winId()); - return true; - } - - if (perform) - minimizeRestore(false); // hide - return false; - } #else if (!mainWidget()->isVisible() || mainWidget()->isMinimized() || !mainWidget()->isActiveWindow()) { @@ -264,29 +200,6 @@ void GraphicalUi::minimizeRestore(bool show) void GraphicalUi::activateMainWidget() { -#ifdef HAVE_KDE4 -# ifdef Q_WS_X11 - KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents); - if (_onAllDesktops) { - KWindowSystem::setOnAllDesktops(mainWidget()->winId(), true); - } - else { - KWindowSystem::setCurrentDesktop(info.desktop()); - } - - mainWidget()->move(info.frameGeometry().topLeft()); // avoid placement policies - mainWidget()->show(); - mainWidget()->raise(); - KWindowSystem::raiseWindow(mainWidget()->winId()); - KWindowSystem::activateWindow(mainWidget()->winId()); -# else - mainWidget()->show(); - KWindowSystem::raiseWindow(mainWidget()->winId()); - KWindowSystem::forceActiveWindow(mainWidget()->winId()); -# endif - -#else /* HAVE_KDE4 */ - #ifdef Q_WS_X11 // Bypass focus stealing prevention QX11Info::setAppUserTime(QX11Info::appTime()); @@ -306,18 +219,11 @@ void GraphicalUi::activateMainWidget() mainWidget()->raise(); mainWidget()->activateWindow(); #endif - -#endif /* HAVE_KDE4 */ } void GraphicalUi::hideMainWidget() { -#if defined(HAVE_KDE4) && defined(Q_WS_X11) - KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents); - _onAllDesktops = info.onAllDesktops(); -#endif - if (instance()->isHidingMainWidgetAllowed()) #ifdef Q_OS_MAC ShowHideProcess(&instance()->_procNum, false); diff --git a/src/uisupport/graphicalui.h b/src/uisupport/graphicalui.h index 3797d084..3b945440 100644 --- a/src/uisupport/graphicalui.h +++ b/src/uisupport/graphicalui.h @@ -115,7 +115,6 @@ private: static ContextMenuActionProvider *_contextMenuActionProvider; static ToolBarActionProvider *_toolBarActionProvider; static UiStyle *_uiStyle; - static bool _onAllDesktops; #ifdef Q_OS_WIN DWORD _dwTickCount; diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index 133a2433..2c9d5947 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -87,7 +87,6 @@ MultiLineEdit::~MultiLineEdit() { } - #if defined HAVE_SONNET && !defined HAVE_KDE Sonnet::Highlighter *MultiLineEdit::highlighter() const { @@ -206,11 +205,8 @@ void MultiLineEdit::updateSizeHint() // use the style to determine a decent size int h = qMin(qMax((int)document()->size().height() + scrollBarHeight, minPixelHeight), maxPixelHeight) + 2 * frameWidth(); -#if QT_VERSION < 0x050000 - QStyleOptionFrameV2 opt; -#else + QStyleOptionFrame opt; -#endif opt.initFrom(this); opt.rect = QRect(0, 0, 100, h); opt.lineWidth = lineWidth(); @@ -745,11 +741,7 @@ void MultiLineEdit::on_textChanged() QString msg = tr("Do you really want to paste %n line(s)?", "", lines.count()); msg += "

"; for (int i = 0; i < 4; i++) { -#if QT_VERSION < 0x050000 - msg += Qt::escape(lines[i].left(40)); -#else msg += lines[i].left(40).toHtmlEscaped(); -#endif if (lines[i].count() > 40) msg += "..."; msg += "
"; diff --git a/src/uisupport/multilineedit.h b/src/uisupport/multilineedit.h index bd59bbc3..b4badfb4 100644 --- a/src/uisupport/multilineedit.h +++ b/src/uisupport/multilineedit.h @@ -24,10 +24,7 @@ #include #include -#ifdef HAVE_KDE4 -# include -# define MultiLineEditParent KTextEdit -#elif defined HAVE_KF5 +#if defined HAVE_KF5 # include # define MultiLineEditParent KTextEdit #else diff --git a/src/uisupport/nickview.cpp b/src/uisupport/nickview.cpp index eb5dd11a..2bd783b1 100644 --- a/src/uisupport/nickview.cpp +++ b/src/uisupport/nickview.cpp @@ -47,8 +47,6 @@ NickView::NickView(QWidget *parent) setContextMenuPolicy(Qt::CustomContextMenu); setSelectionMode(QAbstractItemView::ExtendedSelection); -// // breaks with Qt 4.8 -// if(QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10! setAnimated(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); diff --git a/src/uisupport/styledlabel.cpp b/src/uisupport/styledlabel.cpp index d3d7982f..6e2361b0 100644 --- a/src/uisupport/styledlabel.cpp +++ b/src/uisupport/styledlabel.cpp @@ -156,11 +156,7 @@ void StyledLabel::setText(const QString &text) void StyledLabel::updateToolTip() { if (frameRect().width() - 2*frameWidth() < _layout.minimumWidth()) -#if QT_VERSION < 0x050000 - setToolTip(QString("%1").arg(Qt::escape(_layout.text()))); // only rich text gets wordwrapped! -#else setToolTip(QString("%1").arg(_layout.text().toHtmlEscaped())); // only rich text gets wordwrapped! -#endif else setToolTip(QString()); } @@ -216,11 +212,7 @@ int StyledLabel::posToCursor(const QPointF &pos) void StyledLabel::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() == Qt::NoButton) { -#if QT_VERSION < 0x050000 - Clickable click = _clickables.atCursorPos(posToCursor(event->posF())); -#else Clickable click = _clickables.atCursorPos(posToCursor(event->localPos())); -#endif if (click.isValid()) setHoverMode(click.start(), click.length()); else @@ -247,11 +239,7 @@ void StyledLabel::leaveEvent(QEvent *) void StyledLabel::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { -#if QT_VERSION < 0x050000 - Clickable click = _clickables.atCursorPos(posToCursor(event->posF())); -#else Clickable click = _clickables.atCursorPos(posToCursor(event->localPos())); -#endif if (click.isValid()) emit clickableActivated(click); } diff --git a/src/uisupport/treeviewtouch.cpp b/src/uisupport/treeviewtouch.cpp index 067ac13b..74799b3f 100644 --- a/src/uisupport/treeviewtouch.cpp +++ b/src/uisupport/treeviewtouch.cpp @@ -33,11 +33,7 @@ TreeViewTouch::TreeViewTouch(QWidget *parent) bool TreeViewTouch::event(QEvent *event) { -#if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) { -#else - if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) { -#endif // Register that we may be scrolling, set the scroll mode to scroll-per-pixel // and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel _touchScrollInProgress = true; @@ -62,11 +58,7 @@ bool TreeViewTouch::event(QEvent *event) { return true; } -#if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { -#else - if (event->type() == QEvent::TouchEnd) { -#endif // End scroll and reset variables _touchScrollInProgress = false; _firstTouchUpdateHappened = false; diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 038dc8ab..f7edcbc8 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -1150,25 +1150,18 @@ quint8 UiStyle::StyledMessage::senderHash() const /***********************************************************************************/ -#if QT_VERSION < 0x050000 -uint qHash(UiStyle::ItemFormatType key) -{ - return qHash(static_cast(key)); -} - -#else - uint qHash(UiStyle::ItemFormatType key, uint seed) { return qHash(static_cast(key), seed); } -#endif + UiStyle::FormatType operator|(UiStyle::FormatType lhs, UiStyle::FormatType rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } + UiStyle::FormatType& operator|=(UiStyle::FormatType& lhs, UiStyle::FormatType rhs) { lhs = static_cast(static_cast(lhs) | static_cast(rhs)); diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index acf6597b..661e0257 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -166,11 +166,7 @@ public: }; /// Display of sender prefix modes -#if QT_VERSION >= 0x050000 enum class SenderPrefixMode { -#else - enum SenderPrefixMode { -#endif NoModes = 0, ///< Hide sender modes HighestMode = 1, ///< Show the highest active sender mode AllModes = 2 ///< Show all active sender modes @@ -393,11 +389,7 @@ private: mutable quint8 _senderHash; }; -#if QT_VERSION < 0x050000 -uint qHash(UiStyle::ItemFormatType key); -#else uint qHash(UiStyle::ItemFormatType key, uint seed); -#endif // ---- Operators for dealing with enums ----------------------------------------------------------