qt 5.15 compatibility (#4027)

This commit is contained in:
ebbit1q 2020-06-19 16:50:09 +02:00 committed by GitHub
parent 0f0e0193c1
commit 7fa1936d0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 101 additions and 39 deletions

View file

@ -22,7 +22,7 @@ private:
CardInfoText *text;
public:
explicit CardInfoWidget(const QString &cardName, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
explicit CardInfoWidget(const QString &cardName, QWidget *parent = nullptr, Qt::WindowFlags f = {});
public slots:
void setCard(CardInfoPtr card);

View file

@ -219,7 +219,11 @@ void ChatView::appendMessage(QString message,
cursor.setCharFormat(defaultFormat);
bool mentionEnabled = settingsCache->getChatMention();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
highlightedWords = settingsCache->getHighlightWords().split(' ', Qt::SkipEmptyParts);
#else
highlightedWords = settingsCache->getHighlightWords().split(' ', QString::SkipEmptyParts);
#endif
// parse the message
while (message.size()) {

View file

@ -81,7 +81,7 @@ public:
bool optionalIsBold = false,
QString optionalFontColor = QString());
void appendMessage(QString message,
RoomMessageTypeFlags messageType = 0,
RoomMessageTypeFlags messageType = {},
QString sender = QString(),
UserLevelFlags userLevel = UserLevelFlags(),
QString UserPrivLevel = "NONE",

View file

@ -195,7 +195,7 @@ QModelIndex DeckListModel::parent(const QModelIndex &ind) const
Qt::ItemFlags DeckListModel::flags(const QModelIndex &index) const
{
if (!index.isValid()) {
return nullptr;
return Qt::NoItemFlags;
}
Qt::ItemFlags result = Qt::ItemIsEnabled;

View file

@ -10,7 +10,7 @@
#include <QPushButton>
#include <QVBoxLayout>
DlgEditAvatar::DlgEditAvatar(QWidget *parent) : QDialog(parent)
DlgEditAvatar::DlgEditAvatar(QWidget *parent) : QDialog(parent), image()
{
imageLabel = new QLabel(tr("No image chosen."));
imageLabel->setFixedSize(400, 200);
@ -55,7 +55,6 @@ void DlgEditAvatar::actBrowse()
return;
}
QImage image;
QImageReader imgReader;
imgReader.setDecideFormatFromContent(true);
imgReader.setFileName(fileName);
@ -69,13 +68,9 @@ void DlgEditAvatar::actBrowse()
QByteArray DlgEditAvatar::getImage()
{
const QPixmap *pix = imageLabel->pixmap();
if (!pix || pix->isNull())
return QByteArray();
QImage image = pix->toImage();
if (image.isNull())
if (image.isNull()) {
return QByteArray();
}
QByteArray ba;
QBuffer buffer(&ba);

View file

@ -20,6 +20,7 @@ private slots:
void actBrowse();
private:
QImage image;
QLabel *textLabel, *imageLabel;
QPushButton *browseButton;
};

View file

@ -174,11 +174,11 @@ Qt::ItemFlags FilterTreeModel::flags(const QModelIndex &index) const
Qt::ItemFlags result;
if (!index.isValid())
return 0;
return Qt::NoItemFlags;
node = indexToNode(index);
if (node == NULL)
return 0;
return Qt::NoItemFlags;
result = Qt::ItemIsEnabled;
if (node == fTree)

View file

@ -53,10 +53,17 @@ void Logger::openLogfileSession()
fileHandle.setFileName(LOGGER_FILENAME);
fileHandle.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
fileStream.setDevice(&fileHandle);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
fileStream << "Log session started at " << QDateTime::currentDateTime().toString() << Qt::endl;
fileStream << getClientVersion() << Qt::endl;
fileStream << getSystemArchitecture() << Qt::endl;
fileStream << getClientInstallInfo() << Qt::endl;
#else
fileStream << "Log session started at " << QDateTime::currentDateTime().toString() << endl;
fileStream << getClientVersion() << endl;
fileStream << getSystemArchitecture() << endl;
fileStream << getClientInstallInfo() << endl;
#endif
logToFileEnabled = true;
}
@ -66,7 +73,11 @@ void Logger::closeLogfileSession()
return;
logToFileEnabled = false;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
fileStream << "Log session closed at " << QDateTime::currentDateTime().toString() << Qt::endl;
#else
fileStream << "Log session closed at " << QDateTime::currentDateTime().toString() << endl;
#endif
fileHandle.close();
}
@ -87,8 +98,13 @@ void Logger::internalLog(QString message)
emit logEntryAdded(message);
std::cerr << message.toStdString() << std::endl; // Print to stdout
if (logToFileEnabled)
if (logToFileEnabled) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
fileStream << message << Qt::endl; // Print to fileStream
#else
fileStream << message << endl; // Print to fileStream
#endif
}
}
QString Logger::getSystemArchitecture()

View file

@ -144,7 +144,6 @@ int main(int argc, char *argv[])
QLocale::setDefault(QLocale::English);
qsrand(QDateTime::currentDateTime().toTime_t());
qDebug("main(): starting main program");
MainWindow ui;

View file

@ -558,7 +558,7 @@ void MessageLogWidget::logRollDie(Player *player, int sides, int roll)
void MessageLogWidget::logSay(Player *player, QString message)
{
appendMessage(std::move(message), nullptr, player->getName(), UserLevelFlags(player->getUserInfo()->user_level()),
appendMessage(std::move(message), {}, player->getName(), UserLevelFlags(player->getUserInfo()->user_level()),
QString::fromStdString(player->getUserInfo()->privlevel()), true);
}
@ -740,7 +740,7 @@ void MessageLogWidget::logSpectatorSay(QString spectatorName,
QString userPrivLevel,
QString message)
{
appendMessage(std::move(message), nullptr, spectatorName, spectatorUserLevel, userPrivLevel, false);
appendMessage(std::move(message), {}, spectatorName, spectatorUserLevel, userPrivLevel, false);
}
void MessageLogWidget::logStopDumpZone(Player *player, CardZone *zone)

View file

@ -203,8 +203,9 @@ QModelIndex RemoteDeckList_TreeModel::parent(const QModelIndex &ind) const
Qt::ItemFlags RemoteDeckList_TreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
if (!index.isValid()) {
return Qt::NoItemFlags;
}
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

View file

@ -199,7 +199,7 @@ QModelIndex RemoteReplayList_TreeModel::parent(const QModelIndex &ind) const
Qt::ItemFlags RemoteReplayList_TreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

View file

@ -1,6 +1,7 @@
#include "replay_timeline_widget.h"
#include <QPainter>
#include <QPainterPath>
#include <QPalette>
#include <QTimer>
#include <cmath>

View file

@ -96,7 +96,7 @@ QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int rol
Qt::ItemFlags SetsModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return Qt::NoItemFlags;
Qt::ItemFlags flags = QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
@ -195,12 +195,12 @@ void SetsModel::swapRows(int oldRow, int newRow)
void SetsModel::sort(int column, Qt::SortOrder order)
{
QMap<QString, CardSetPtr> setMap;
QMultiMap<QString, CardSetPtr> setMap;
int numRows = rowCount();
int row;
for (row = 0; row < numRows; ++row)
setMap.insertMulti(index(row, column).data(SetsModel::SortRole).toString(), sets.at(row));
setMap.insert(index(row, column).data(SetsModel::SortRole).toString(), sets.at(row));
QList<CardSetPtr> tmp = setMap.values();
sets.clear();

View file

@ -123,7 +123,7 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
const UserLevelFlags userLevel(userInfo->user_level());
const QString userPriv = QString::fromStdString(userInfo->privlevel());
chatView->appendMessage(QString::fromStdString(event.message()), 0, QString::fromStdString(event.sender_name()),
chatView->appendMessage(QString::fromStdString(event.message()), {}, QString::fromStdString(event.sender_name()),
userLevel, userPriv, true);
if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this))
soundEngine->playSound("private_message");

View file

@ -20,7 +20,7 @@ private:
QPushButton editButton, passwordButton, avatarButton;
public:
UserInfoBox(AbstractClient *_client, bool editable, QWidget *parent = nullptr, Qt::WindowFlags flags = 0);
UserInfoBox(AbstractClient *_client, bool editable, QWidget *parent = nullptr, Qt::WindowFlags flags = {});
void retranslateUi();
private slots:
void processResponse(const Response &r);

View file

@ -1120,7 +1120,7 @@ void MainWindow::actCheckCardUpdates()
return;
}
cardUpdateProcess->start("\"" + updaterCmd + "\"");
cardUpdateProcess->start("\"" + updaterCmd + "\"", QStringList());
}
void MainWindow::cardUpdateError(QProcess::ProcessError err)

View file

@ -84,15 +84,15 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
scrollBar->setSingleStep(20);
scrollBar->setPageStep(200);
connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(handleScrollBarChange(int)));
QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget;
scrollBarProxy = new ScrollableGraphicsProxyWidget;
scrollBarProxy->setWidget(scrollBar);
zoneHBox->addItem(scrollBarProxy);
vbox->addItem(zoneHBox);
zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer);
connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this,
SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *)));
connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), scrollBarProxy,
SLOT(recieveWheelEvent(QGraphicsSceneWheelEvent *)));
// numberCard is the num of cards we want to reveal from an area. Ex: scry the top 3 cards.
// If the number is < 0 then it means that we can make the area sorted and we dont care about the order.
@ -192,12 +192,6 @@ void ZoneViewWidget::resizeToZoneContents()
layout()->invalidate();
}
void ZoneViewWidget::handleWheelEvent(QGraphicsSceneWheelEvent *event)
{
QWheelEvent wheelEvent(QPoint(), event->delta(), event->buttons(), event->modifiers(), event->orientation());
scrollBar->event(&wheelEvent);
}
void ZoneViewWidget::handleScrollBarChange(int value)
{
zone->setY(-value);

View file

@ -2,6 +2,7 @@
#define ZONEVIEWWIDGET_H
#include <QCheckBox>
#include <QGraphicsProxyWidget>
#include <QGraphicsWidget>
class QLabel;
@ -18,6 +19,16 @@ class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
class QStyleOption;
class ScrollableGraphicsProxyWidget : public QGraphicsProxyWidget
{
Q_OBJECT
public slots:
void recieveWheelEvent(QGraphicsSceneWheelEvent *event)
{
wheelEvent(event);
}
};
class ZoneViewWidget : public QGraphicsWidget
{
Q_OBJECT
@ -27,6 +38,7 @@ private:
QPushButton *closeButton;
QScrollBar *scrollBar;
ScrollableGraphicsProxyWidget *scrollBarProxy;
QCheckBox sortByNameCheckBox;
QCheckBox sortByTypeCheckBox;
QCheckBox shuffleCheckBox;
@ -42,7 +54,6 @@ private slots:
void processSortByName(int value);
void processSetPileView(int value);
void resizeToZoneContents();
void handleWheelEvent(QGraphicsSceneWheelEvent *event);
void handleScrollBarChange(int value);
void zoneDeleted();
void moveEvent(QGraphicsSceneMoveEvent * /* event */);

View file

@ -216,7 +216,7 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
{"rarity", "rarity"}};
int numCards = 0;
QMap<QString, SplitCardPart> splitCards;
QMultiMap<QString, SplitCardPart> splitCards;
QString ptSeparator("/");
QVariantMap card;
QString layout, name, text, colors, colorIdentity, maintype, power, toughness;
@ -338,7 +338,7 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
// construct full card name
name = additionalNames.join(QString(" // "));
SplitCardPart split(index, text, properties, setInfo);
splitCards.insertMulti(name, split);
splitCards.insert(name, split);
} else {
// relations
relatedCards.clear();

View file

@ -110,7 +110,11 @@ void IslInterface::initServer()
socket->startServerEncryption();
if (!socket->waitForEncrypted(5000)) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
#else
QList<QSslError> sslErrors(socket->sslErrors());
#endif
if (sslErrors.isEmpty())
qDebug() << "[ISL] SSL handshake timeout, terminating connection";
else
@ -187,7 +191,11 @@ void IslInterface::initClient()
return;
}
if (!socket->waitForEncrypted(5000)) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
#else
QList<QSslError> sslErrors(socket->sslErrors());
#endif
if (sslErrors.isEmpty())
qDebug() << "[ISL] SSL handshake timeout, terminating connection";
else

View file

@ -265,7 +265,11 @@ bool Servatrice::initServer()
qDebug() << "Accept registered users only: " << getRegOnlyServerEnabled();
qDebug() << "Registration enabled: " << getRegistrationEnabled();
if (getRegistrationEnabled()) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList emailBlackListFilters = getEmailBlackList().split(",", Qt::SkipEmptyParts);
#else
QStringList emailBlackListFilters = getEmailBlackList().split(",", QString::SkipEmptyParts);
#endif
qDebug() << "Email blacklist: " << emailBlackListFilters;
qDebug() << "Require email address to register: " << getRequireEmailForRegistrationEnabled();
qDebug() << "Require email activation via token: " << getRequireEmailActivationEnabled();
@ -568,7 +572,11 @@ void Servatrice::setRequiredFeatures(const QString featureList)
FeatureSet features;
serverRequiredFeatureList.clear();
features.initalizeFeatureList(serverRequiredFeatureList);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList listReqFeatures = featureList.split(",", Qt::SkipEmptyParts);
#else
QStringList listReqFeatures = featureList.split(",", QString::SkipEmptyParts);
#endif
if (!listReqFeatures.isEmpty())
foreach (QString reqFeature, listReqFeatures)
features.enableRequiredFeature(serverRequiredFeatureList, reqFeature);

View file

@ -146,7 +146,11 @@ bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user, QString
bool allowPunctuationPrefix = settingsCache->value("users/allowpunctuationprefix", false).toBool();
QString allowedPunctuation = settingsCache->value("users/allowedpunctuation", "_").toString();
QString disallowedWordsStr = settingsCache->value("users/disallowedwords", "").toString();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList disallowedWords = disallowedWordsStr.split(",", Qt::SkipEmptyParts);
#else
QStringList disallowedWords = disallowedWordsStr.split(",", QString::SkipEmptyParts);
#endif
disallowedWords.removeDuplicates();
QString disallowedRegExpStr = settingsCache->value("users/disallowedregexp", "").toString();

View file

@ -57,7 +57,11 @@ void ServerLogger::logMessage(QString message, void *caller)
// filter out all log entries based on values in configuration file
bool shouldWeWriteLog = settingsCache->value("server/writelog", 1).toBool();
QString logFilters = settingsCache->value("server/logfilters").toString();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList listlogFilters = logFilters.split(",", Qt::SkipEmptyParts);
#else
QStringList listlogFilters = logFilters.split(",", QString::SkipEmptyParts);
#endif
bool shouldWeSkipLine = false;
if (!shouldWeWriteLog)

View file

@ -808,7 +808,11 @@ Response::ResponseCode AbstractServerSocketInterface::cmdGetWarnList(const Comma
Response_WarnList *re = new Response_WarnList;
QString officialWarnings = settingsCache->value("server/officialwarnings").toString();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList warningsList = officialWarnings.split(",", Qt::SkipEmptyParts);
#else
QStringList warningsList = officialWarnings.split(",", QString::SkipEmptyParts);
#endif
foreach (QString warning, warningsList) {
re->add_warning(warning.toStdString());
}
@ -986,7 +990,11 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
QString emailBlackList = servatrice->getEmailBlackList();
QString emailAddress = QString::fromStdString(cmd.email());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList emailBlackListFilters = emailBlackList.split(",", Qt::SkipEmptyParts);
#else
QStringList emailBlackListFilters = emailBlackList.split(",", QString::SkipEmptyParts);
#endif
// verify that users email/provider is not blacklisted
if (!emailBlackList.trimmed().isEmpty()) {

View file

@ -12,7 +12,11 @@ SettingsCache::SettingsCache(const QString &fileName, QSettings::Format format,
isPortableBuild = QFile::exists(qApp->applicationDirPath() + "/portable.dat");
QStringList disallowedRegExpStr =
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
value("users/disallowedregexp", "").toString().split(",", Qt::SkipEmptyParts);
#else
value("users/disallowedregexp", "").toString().split(",", QString::SkipEmptyParts);
#endif
disallowedRegExpStr.removeDuplicates();
for (const QString &regExpStr : disallowedRegExpStr) {
disallowedRegExp.append(QRegExp(regExpStr));

View file

@ -362,7 +362,11 @@ void QxtSmtpPrivate::authenticate()
}
else
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList auth = extensions["AUTH"].toUpper().split(' ', Qt::SkipEmptyParts);
#else
QStringList auth = extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts);
#endif
if (auth.contains("CRAM-MD5"))
{
authCramMD5();