Remove compatibility code for Qt versions we no longer support.
#include "clientauthhandler.h"
-// TODO: support system application proxy (new in Qt 4.6)
-
#include <QtEndian>
#ifdef HAVE_SSL
#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)
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:
}
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 {
}
}
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 */
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);
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);
_certIdentity->setSslCert(QSslCertificate(encoded));
}
-
#endif // HAVE_SSL
#include <QAbstractItemView>
#include <QMimeData>
-#if QT_VERSION < 0x050000
-#include <QTextDocument> // for Qt::escape()
-#endif
#include "buffermodel.h"
#include "buffersettings.h"
{
// 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);
}
{
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;
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);
#include <QString>
#include <QStringList>
-#if QT_VERSION >= 0x050000
-#include <QRegularExpression>
-#else
-#include <QRegExp>
-#endif
-
#include "logmessage.h"
ExpressionMatch::ExpressionMatch(const QString &expression, MatchMode mode, bool caseSensitive)
// 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;
}
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;
}
-#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()) {
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
//
// 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
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
}
#pragma once
+#include <QRegularExpression>
#include <QString>
#include <QStringList>
-#if QT_VERSION >= 0x050000
-#include <QRegularExpression>
-#else
-#include <QRegExp>
-#endif
-
/**
* Expression matcher with multiple modes of operation and automatic caching for performance
*/
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
*
* @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
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
};
connect(this, SIGNAL(messageLogged(Logger::LogEntry)), this, SLOT(onMessageLogged(Logger::LogEntry)));
-#if QT_VERSION < 0x050000
- qInstallMsgHandler(Logger::messageHandler);
-#else
qInstallMessageHandler(Logger::messageHandler);
-#endif
}
}
-#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);
}
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;
*/
std::vector<Logger::LogEntry> 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.
#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 <KAboutData>
-# include "kcmdlinewrapper.h"
-#elif defined HAVE_KF5
+#if defined HAVE_KF5
# include <KCoreAddons/KAboutData>
# include <KCoreAddons/Kdelibs4ConfigMigrator>
-# include "qt5cliparser.h"
-#elif defined HAVE_QT5
-# include "qt5cliparser.h"
-#else
-# include "cliparser.h"
#endif
#if !defined(BUILD_CORE) && defined(STATIC)
Q_IMPORT_PLUGIN(qgif)
#endif
+#include "qt5cliparser.h"
#include "quassel.h"
#include "types.h"
// 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);
# endif
#endif
- std::shared_ptr<AbstractCliParser> 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<KCmdLineWrapper>();
-#elif defined HAVE_QT5
- cliParser = std::make_shared<Qt5CliParser>();
-#else
- cliParser = std::make_shared<CliParser>();
-#endif
+ std::shared_ptr<AbstractCliParser> cliParser = std::make_shared<Qt5CliParser>();
Quassel::setCliParser(cliParser);
// Initialize CLI arguments
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
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
{
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
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));
*
* 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,
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
};
}
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);
const QList<int> &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;
}
// 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;
}
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));
}
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;
}
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;
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;
_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"))
}
//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<Peer*> peers, std::function<void()> closure) {
restrictTargetPeers(QSet<Peer*>(peers), std::move(closure));
}
-#endif
#endif
/**}@*/
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;
}
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);
# 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)
{
// 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
QList<QByteArray> 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
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
// 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
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)) {
// 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;
{
QSslKey key;
key = QSslKey(keyFile, QSsl::Rsa);
-#if QT_VERSION >= 0x050500
if (key.isNull()) {
if (!keyFile->reset()) {
quWarning() << "SslServer: IO error reading key file";
}
key = QSslKey(keyFile, QSsl::Ec);
}
-#endif
return key;
}
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);
#include "storage.h"
-#include <QCryptographicHash>
#include <random>
-#if QT_VERSION < 0x050000
-# include "../../3rdparty/sha512/sha512.h"
-#endif
+#include <QCryptographicHash>
Storage::Storage(QObject *parent)
: QObject(parent)
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);
default:
qWarning() << "Password hash version" << QString(version) << "is not supported, please reset password";
}
-
+
if (passwordCorrect && version < Storage::HashVersion::Latest) {
updateUser(user, password);
}
-
+
return passwordCorrect;
}
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
}
#include <QPersistentModelIndex>
#include <QUrl>
-#ifdef HAVE_KDE4
-# include <KMenuBar>
-#else
-# include <QMenuBar>
-#endif
-
#ifdef HAVE_WEBENGINE
# include <QWebEngineView>
#elif defined HAVE_WEBKIT
}
}
-#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);
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);
}
// 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;
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);
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);
QString AuthenticationSelectionPage::authenticator() const
{
-#if QT_VERSION >= 0x050200
return ui.backendList->currentData().toString();
-#else
- return ui.backendList->itemData(ui.backendList->currentIndex()).toString();
-#endif
}
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);
QString StorageSelectionPage::backend() const
{
-#if QT_VERSION >= 0x050200
return ui.backendList->currentData().toString();
-#else
- return ui.backendList->itemData(ui.backendList->currentIndex()).toString();
-#endif
}
#include <QTextDocument>
#include <QVBoxLayout>
-#ifdef HAVE_KDE4
-# include <KNotification>
-# include <KNotifyConfigWidget>
-#else
-# include <KNotifications/KNotification>
-# include <KNotifyConfig/KNotifyConfigWidget>
-#endif
+#include <KNotifications/KNotification>
+#include <KNotifyConfig/KNotifyConfigWidget>
#include "client.h"
#include "icon.h"
type = "PrivMsgFocused"; break;
}
-#if QT_VERSION < 0x050000
- QString message = QString("<b><%1></b> %2").arg(n.sender, Qt::escape(n.message));
-#else
QString message = QString("<b><%1></b> %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
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)));
#ifndef QT_NO_SYSTEMTRAYICON
#include <QString>
-
-#ifdef HAVE_KDE4
-# include <KSystemTrayIcon>
-#else
-# include <QSystemTrayIcon>
-#endif
+#include <QSystemTrayIcon>
#include "systemtray.h"
private:
uint _lastMessageId {0};
-#ifdef HAVE_KDE4
- KSystemTrayIcon *_trayIcon;
-#else
QSystemTrayIcon *_trayIcon;
-#endif
};
#endif /* QT_NO_SYSTEMTRAYICON */
#include <QToolBar>
#include <QInputDialog>
-#ifdef HAVE_KDE4
-# include <KHelpMenu>
-# include <KMenuBar>
-# include <KShortcutsDialog>
-# include <KStatusBar>
-# include <KToggleFullScreenAction>
-# include <KToolBar>
-#endif
-
#ifdef HAVE_KF5
# include <KConfigWidgets/KStandardAction>
# include <KXmlGui/KHelpMenu>
#include <QUuid>
-#ifdef HAVE_KDE4
-# include <KMainWindow>
-#elif defined HAVE_KF5
+#ifdef HAVE_KF5
# include <KXmlGui/KMainWindow>
#else
# include <QMainWindow>
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.
}
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
}
#include <QList>
#include <QObject>
#include <QString>
-
-#if QT_VERSION >= 0x050000
-# include <QTemporaryDir>
-#endif
+#include <QTemporaryDir>
#include "abstractnotificationbackend.h"
#include "graphicalui.h"
QString _systemIconTheme;
-#if QT_VERSION >= 0x050000
std::unique_ptr<QTemporaryDir> _dummyThemeDir;
-#endif
bool _useSystemTray;
};
#include <QFile>
#include <QStringList>
-#ifdef HAVE_KDE4
-# include <KStandardDirs>
-#endif
-
#include "chatviewsettings.h"
#include "cliparser.h"
#include "logmessage.h"
#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
}
#include <memory>
-#ifdef HAVE_KDE4
-# include <KApplication>
-#else
-# include <QApplication>
-#endif
-
+#include <QApplication>
#include <QSessionManager>
#include "client.h"
class QtUi;
-#ifdef HAVE_KDE4
-class QtUiApplication : public KApplication
-{
-#else
class QtUiApplication : public QApplication
{
-#endif
-
Q_OBJECT
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();
#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".
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
}
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));
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QFileDialog>
+#include <QMessageBox>
#include <QMimeData>
#include <QUrl>
-#include <QMessageBox>
-
-#if QT_VERSION < 0x050000
-# include <QDesktopServices>
-#else
-# include <QStandardPaths>
-#endif
+#include <QStandardPaths>
#include "client.h"
#include "icon.h"
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 << "</table>";
formatTooltip << "<p>" << tr("Example: Away since %%hh:mm%% on %%dd.MM%%.") << "</p>";
formatTooltip << "<p>" << tr("%%%% without anything inside represents %%. Other format "
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();
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;
}
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;
}
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;
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();
}
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());
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
}
StatusNotifierItem::StatusNotifierItem(QWidget *parent)
: StatusNotifierItemParent(parent)
-#if QT_VERSION >= 0x050000
, _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}}
-#endif
{
static bool registered = []() -> bool {
qDBusRegisterMetaType<DBusImageStruct>();
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();
void StatusNotifierItem::refreshIcons()
{
-#if QT_VERSION >= 0x050000
if (!_iconThemePath.isEmpty()) {
QDir baseDir{_iconThemePath + "/hicolor"};
baseDir.removeRecursively();
}
}
}
-#endif
+
if (_statusNotifierItemDBus) {
emit _statusNotifierItemDBus->NewIcon();
emit _statusNotifierItemDBus->NewAttentionIcon();
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<QMouseEvent *>(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);
}
{
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)
#include <QDBusError>
#include <QHash>
#include <QString>
-
-#if QT_VERSION >= 0x050000
-# include <QTemporaryDir>
-#endif
+#include <QTemporaryDir>
#include "notificationsclient.h"
#include "systemtray.h"
QString _iconThemePath;
QString _menuObjectPath;
-#if QT_VERSION >= 0x050000
QTemporaryDir _iconThemeDir;
-#endif
friend class StatusNotifierItemDBus;
};
#include "statusnotifieritemdbus.h"
#include "statusnotifieritem.h"
+#include <QApplication>
#include <QDBusConnection>
-#include <QPixmap>
#include <QImage>
-#include <QApplication>
#include <QMenu>
-#include <QMovie>
-
-#ifdef HAVE_KDE4
-# include <KWindowInfo>
-# include <KWindowSystem>
-#endif
+#include <QPixmap>
#include "statusnotifierwatcher.h"
#include "statusnotifieritemadaptor.h"
return (int)((__int64)wid);
}
-
#else
__inline int toInt(WId wid)
{
//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();
#include <QApplication>
#include <QMenu>
-#ifdef HAVE_KDE4
-# include <KMenu>
-# include <KWindowInfo>
-# include <KWindowSystem>
-#endif
-
#include "action.h"
#include "actioncollection.h"
#include "client.h"
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"));
{
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);
}
}
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();
// 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, " ");
#include <QApplication>
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);
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);
}
-#ifdef HAVE_KDE4
-void Action::init() {}
-#else
void Action::init()
{
connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered()));
{
Q_ASSERT(type);
if (type == DefaultShortcut) {
-#if QT_VERSION < 0x050000
- return property("defaultShortcut").value<QKeySequence>();
-#else
auto sequence = property("defaultShortcuts").value<QList<QKeySequence>>();
return sequence.isEmpty() ? QKeySequence() : sequence.first();
-#endif
}
return shortcuts().isEmpty() ? QKeySequence() : shortcuts().first();
Q_ASSERT(type);
if (type & DefaultShortcut) {
-#if QT_VERSION < 0x050000
- setProperty("defaultShortcut", key);
-#else
setProperty("defaultShortcuts", QVariant::fromValue(QList<QKeySequence>() << key));
-#endif
}
if (type & ActiveShortcut)
QAction::setShortcut(key);
}
-
-
-#endif /* HAVE_KDE4 */
* 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 <QShortcut>
#include <QWidgetAction>
Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes)
-
-#else /* HAVE_KDE4 */
-#include <KAction>
-
-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
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())
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:
bool ActionCollection::isEmpty() const { return actions().count(); }
#else /* HAVE_KDE */
-# ifdef HAVE_KDE4
-# include <KActionCollection>
-# else
-# include <KXmlGui/KActionCollection>
-# endif
+# include <KXmlGui/KActionCollection>
class ActionCollection : public KActionCollection
{
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);
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<int> &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
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);
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<int> &roles);
-#endif
private slots:
void joinChannel(const QModelIndex &index);
#include "colorbutton.h"
+#include <QColorDialog>
#include <QPainter>
#include <QStyle>
#include <QStyleOptionFrame>
-#ifdef HAVE_KDE4
-# include <KColorDialog>
-#else
-# include <QColorDialog>
-#endif
ColorButton::ColorButton(QWidget *parent) : QToolButton(parent)
{
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);
}
#ifdef Q_WS_X11
# include <QX11Info>
#endif
-#ifdef HAVE_KDE4
-# include <KWindowInfo>
-# include <KWindowSystem>
-#endif
QWidget *GraphicalUi::_mainWidget = 0;
QHash<QString, ActionCollection *> 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<GraphicalUi>(this)
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<WId> 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()) {
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());
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);
static ContextMenuActionProvider *_contextMenuActionProvider;
static ToolBarActionProvider *_toolBarActionProvider;
static UiStyle *_uiStyle;
- static bool _onAllDesktops;
#ifdef Q_OS_WIN
DWORD _dwTickCount;
{
}
-
#if defined HAVE_SONNET && !defined HAVE_KDE
Sonnet::Highlighter *MultiLineEdit::highlighter() const
{
// 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();
QString msg = tr("Do you really want to paste %n line(s)?", "", lines.count());
msg += "<p>";
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 += "<br />";
#include <QKeyEvent>
#include <QHash>
-#ifdef HAVE_KDE4
-# include <KDE/KTextEdit>
-# define MultiLineEditParent KTextEdit
-#elif defined HAVE_KF5
+#if defined HAVE_KF5
# include <KTextWidgets/KTextEdit>
# define MultiLineEditParent KTextEdit
#else
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 &)));
void StyledLabel::updateToolTip()
{
if (frameRect().width() - 2*frameWidth() < _layout.minimumWidth())
-#if QT_VERSION < 0x050000
- setToolTip(QString("<qt>%1</qt>").arg(Qt::escape(_layout.text()))); // only rich text gets wordwrapped!
-#else
setToolTip(QString("<qt>%1</qt>").arg(_layout.text().toHtmlEscaped())); // only rich text gets wordwrapped!
-#endif
else
setToolTip(QString());
}
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
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);
}
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;
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;
/***********************************************************************************/
-#if QT_VERSION < 0x050000
-uint qHash(UiStyle::ItemFormatType key)
-{
- return qHash(static_cast<quint32>(key));
-}
-
-#else
-
uint qHash(UiStyle::ItemFormatType key, uint seed)
{
return qHash(static_cast<quint32>(key), seed);
}
-#endif
+
UiStyle::FormatType operator|(UiStyle::FormatType lhs, UiStyle::FormatType rhs)
{
return static_cast<UiStyle::FormatType>(static_cast<quint32>(lhs) | static_cast<quint32>(rhs));
}
+
UiStyle::FormatType& operator|=(UiStyle::FormatType& lhs, UiStyle::FormatType rhs)
{
lhs = static_cast<UiStyle::FormatType>(static_cast<quint32>(lhs) | static_cast<quint32>(rhs));
};
/// 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
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 ----------------------------------------------------------