fix some deprecations, more compatibility
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a882738735
commit
28fedfdd0b
5 changed files with 49 additions and 14 deletions
|
@ -77,7 +77,11 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
|
||||||
ui->txtJSON->setFont(jsonFont);
|
ui->txtJSON->setFont(jsonFont);
|
||||||
#endif
|
#endif
|
||||||
QFontMetrics fontMetrics(ui->txtJSON->font());
|
QFontMetrics fontMetrics(ui->txtJSON->font());
|
||||||
|
#if QT_VERSION >= 0x050B00
|
||||||
|
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
|
||||||
|
#else
|
||||||
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
|
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
|
||||||
|
#endif
|
||||||
|
|
||||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
|
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
|
||||||
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
|
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
|
||||||
|
|
|
@ -135,12 +135,15 @@ void PictureDialog::setupPictureDialog()
|
||||||
smpic = nullptr;
|
smpic = nullptr;
|
||||||
crewStr = "";
|
crewStr = "";
|
||||||
|
|
||||||
|
// Get Snapmatic Resolution
|
||||||
|
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
|
||||||
|
|
||||||
// Avatar area
|
// Avatar area
|
||||||
qreal screenRatio = AppEnv::screenRatio();
|
qreal screenRatio = AppEnv::screenRatio();
|
||||||
qreal screenRatioPR = AppEnv::screenRatioPR();
|
qreal screenRatioPR = AppEnv::screenRatioPR();
|
||||||
if (screenRatio != 1 || screenRatioPR != 1)
|
if (screenRatio != 1 || screenRatioPR != 1)
|
||||||
{
|
{
|
||||||
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(536 * screenRatio * screenRatioPR, Qt::FastTransformation);
|
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::FastTransformation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -151,7 +154,7 @@ void PictureDialog::setupPictureDialog()
|
||||||
avatarSize = 470;
|
avatarSize = 470;
|
||||||
|
|
||||||
// DPI calculation (picture)
|
// DPI calculation (picture)
|
||||||
ui->labPicture->setFixedSize(960 * screenRatio, 536 * screenRatio);
|
ui->labPicture->setFixedSize(snapmaticResolution.width() * screenRatio, snapmaticResolution.height() * screenRatio);
|
||||||
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
|
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
|
||||||
ui->labPicture->setScaledContents(true);
|
ui->labPicture->setScaledContents(true);
|
||||||
|
|
||||||
|
@ -198,8 +201,8 @@ void PictureDialog::setupPictureDialog()
|
||||||
ui->jsonLayout->setContentsMargins(4 * screenRatio, 10 * screenRatio, 4 * screenRatio, 4 * screenRatio);
|
ui->jsonLayout->setContentsMargins(4 * screenRatio, 10 * screenRatio, 4 * screenRatio, 4 * screenRatio);
|
||||||
|
|
||||||
// Pre-adapt window for DPI
|
// Pre-adapt window for DPI
|
||||||
setFixedWidth(960 * screenRatio);
|
setFixedWidth(snapmaticResolution.width() * screenRatio);
|
||||||
setFixedHeight(536 * screenRatio);
|
setFixedHeight(snapmaticResolution.height() * screenRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
PictureDialog::~PictureDialog()
|
PictureDialog::~PictureDialog()
|
||||||
|
@ -389,7 +392,11 @@ void PictureDialog::resizeEvent(QResizeEvent *event)
|
||||||
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
|
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
|
||||||
{
|
{
|
||||||
Q_UNUSED(newLabelSize)
|
Q_UNUSED(newLabelSize)
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
int newDialogHeight = SnapmaticPicture::getSnapmaticResolution().height();
|
||||||
|
#else
|
||||||
int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
|
int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
|
||||||
|
#endif
|
||||||
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
|
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
|
||||||
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
|
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
|
||||||
setMaximumSize(width(), newDialogHeight);
|
setMaximumSize(width(), newDialogHeight);
|
||||||
|
@ -715,10 +722,11 @@ void PictureDialog::renderPicture()
|
||||||
{
|
{
|
||||||
if (overlayEnabled)
|
if (overlayEnabled)
|
||||||
{
|
{
|
||||||
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
|
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
|
||||||
|
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
|
||||||
shownImagePixmap.fill(Qt::transparent);
|
shownImagePixmap.fill(Qt::transparent);
|
||||||
QPainter shownImagePainter(&shownImagePixmap);
|
QPainter shownImagePainter(&shownImagePixmap);
|
||||||
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage);
|
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage);
|
||||||
shownImagePainter.end();
|
shownImagePainter.end();
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
|
@ -728,10 +736,11 @@ void PictureDialog::renderPicture()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
|
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
|
||||||
|
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
|
||||||
shownImagePixmap.fill(Qt::transparent);
|
shownImagePixmap.fill(Qt::transparent);
|
||||||
QPainter shownImagePainter(&shownImagePixmap);
|
QPainter shownImagePainter(&shownImagePixmap);
|
||||||
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
shownImagePainter.end();
|
shownImagePainter.end();
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
|
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
|
||||||
|
@ -742,15 +751,16 @@ void PictureDialog::renderPicture()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Generating Avatar Preview
|
// Generating Avatar Preview
|
||||||
QPixmap avatarPixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
|
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
|
||||||
|
QPixmap avatarPixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
|
||||||
QPainter snapPainter(&avatarPixmap);
|
QPainter snapPainter(&avatarPixmap);
|
||||||
QFont snapPainterFont;
|
QFont snapPainterFont;
|
||||||
snapPainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
|
snapPainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
|
||||||
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
snapPainter.drawImage(0, 0, avatarAreaPicture);
|
snapPainter.drawImage(0, 0, avatarAreaPicture);
|
||||||
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
|
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
|
||||||
snapPainter.setFont(snapPainterFont);
|
snapPainter.setFont(snapPainterFont);
|
||||||
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
|
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
|
||||||
snapPainter.end();
|
snapPainter.end();
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
avatarPixmap.setDevicePixelRatio(screenRatioPR);
|
avatarPixmap.setDevicePixelRatio(screenRatioPR);
|
||||||
|
|
|
@ -264,7 +264,11 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
|
||||||
QStringList widgetsKeyList = widgets.values();
|
QStringList widgetsKeyList = widgets.values();
|
||||||
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#else
|
||||||
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
||||||
#endif
|
#endif
|
||||||
|
@ -284,7 +288,11 @@ void ProfileInterface::insertSavegameIPI(QWidget *widget)
|
||||||
QString widgetKey = widgets[proWidget];
|
QString widgetKey = widgets[proWidget];
|
||||||
QStringList widgetsKeyList = widgets.values();
|
QStringList widgetsKeyList = widgets.values();
|
||||||
QStringList savegameKeyList = widgetsKeyList.filter("SGD", Qt::CaseSensitive);
|
QStringList savegameKeyList = widgetsKeyList.filter("SGD", Qt::CaseSensitive);
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
std::sort(savegameKeyList.begin(), savegameKeyList.end());
|
||||||
|
#else
|
||||||
qSort(savegameKeyList.begin(), savegameKeyList.end());
|
qSort(savegameKeyList.begin(), savegameKeyList.end());
|
||||||
|
#endif
|
||||||
int sgdIndex = savegameKeyList.indexOf(QRegExp(widgetKey));
|
int sgdIndex = savegameKeyList.indexOf(QRegExp(widgetKey));
|
||||||
ui->vlSavegame->insertWidget(sgdIndex, proWidget);
|
ui->vlSavegame->insertWidget(sgdIndex, proWidget);
|
||||||
|
|
||||||
|
@ -303,7 +311,11 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
|
||||||
QStringList widgetsKeyList = widgets.values();
|
QStringList widgetsKeyList = widgets.values();
|
||||||
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#else
|
||||||
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
||||||
#endif
|
#endif
|
||||||
|
@ -338,7 +350,11 @@ void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
|
||||||
QStringList widgetsKeyList = widgets.values();
|
QStringList widgetsKeyList = widgets.values();
|
||||||
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
|
||||||
#if QT_VERSION >= 0x050600
|
#if QT_VERSION >= 0x050600
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#else
|
||||||
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
|
||||||
#endif
|
#endif
|
||||||
|
@ -369,7 +385,12 @@ void ProfileInterface::sortingProfileInterface()
|
||||||
ui->vlSnapmatic->setEnabled(false);
|
ui->vlSnapmatic->setEnabled(false);
|
||||||
|
|
||||||
QStringList widgetsKeyList = widgets.values();
|
QStringList widgetsKeyList = widgets.values();
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
std::sort(widgetsKeyList.begin(), widgetsKeyList.end());
|
||||||
|
#else
|
||||||
qSort(widgetsKeyList.begin(), widgetsKeyList.end());
|
qSort(widgetsKeyList.begin(), widgetsKeyList.end());
|
||||||
|
#endif
|
||||||
|
|
||||||
for (QString widgetKey : widgetsKeyList)
|
for (QString widgetKey : widgetsKeyList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -433,8 +433,8 @@ QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHe
|
||||||
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
|
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
|
||||||
{
|
{
|
||||||
QByteArray jsonUsefulBytes = jsonBytes;
|
QByteArray jsonUsefulBytes = jsonBytes;
|
||||||
jsonUsefulBytes.replace('\x00', QString());
|
jsonUsefulBytes.replace('\x00', "");
|
||||||
jsonUsefulBytes.replace('\x0c', QString());
|
jsonUsefulBytes.replace('\x0c', "");
|
||||||
return QString::fromUtf8(jsonUsefulBytes.trimmed());
|
return QString::fromUtf8(jsonUsefulBytes.trimmed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
|
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
|
||||||
|
|
||||||
// PREDEFINED PROPERTIES
|
// PREDEFINED PROPERTIES
|
||||||
QSize getSnapmaticResolution();
|
static QSize getSnapmaticResolution();
|
||||||
|
|
||||||
// SNAPMATIC DEFAULTS
|
// SNAPMATIC DEFAULTS
|
||||||
bool isSnapmaticDefaultsEnforced();
|
bool isSnapmaticDefaultsEnforced();
|
||||||
|
|
Loading…
Reference in a new issue