mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -07:00
qt 5.15 compatibility (#4027)
This commit is contained in:
parent
0f0e0193c1
commit
7fa1936d0f
27 changed files with 101 additions and 39 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -517,4 +517,4 @@ void DeckListModel::printDeckList(QPrinter *printer)
|
|||
}
|
||||
|
||||
doc.print(printer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ private slots:
|
|||
void actBrowse();
|
||||
|
||||
private:
|
||||
QImage image;
|
||||
QLabel *textLabel, *imageLabel;
|
||||
QPushButton *browseButton;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "replay_timeline_widget.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPalette>
|
||||
#include <QTimer>
|
||||
#include <cmath>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1120,7 +1120,7 @@ void MainWindow::actCheckCardUpdates()
|
|||
return;
|
||||
}
|
||||
|
||||
cardUpdateProcess->start("\"" + updaterCmd + "\"");
|
||||
cardUpdateProcess->start("\"" + updaterCmd + "\"", QStringList());
|
||||
}
|
||||
|
||||
void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue