Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ElTh0r0 committed Jan 18, 2024
1 parent 5b912d4 commit 9c1b208
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,11 @@ void Settings::saveBoardStyle(const QString &sStyleFile) {
void Settings::saveColor(QColor &color, QSettings *pSet, const int nRow,
const QString &sKey) {
QColor cTmp = color;
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(m_pUi->tableBoardStyle->item(nRow, 0)->text());
#else
color = QColor::fromString(m_pUi->tableBoardStyle->item(nRow, 0)->text());
#endif
if (cTmp != color) this->changedSettings();
pSet->setValue(sKey, color.name());
}
Expand Down Expand Up @@ -563,10 +567,18 @@ void Settings::accept() {
qWarning() << "User chose invalid stone color:"
<< m_listColorEdit[i]->text();
if (i < m_DefaultPlayerColors.size()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(m_DefaultPlayerColors[i]);
#else
color = QColor::fromString(m_DefaultPlayerColors[i]);
#endif
} else {
qWarning() << "Fallback player color missing!";
qWarning() << "Fallback player color missing!";
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(m_DefaultPlayerColors[0]);
#else
color = QColor::fromString(m_DefaultPlayerColors[0]);
#endif
}
}
tmpMap[QStringLiteral("Color")] = color.name();
Expand Down Expand Up @@ -823,10 +835,18 @@ auto Settings::readColor(QSettings *pSet, const QString &sKey,
QString sValue = pSet->value(sKey, sFallback).toString();
QColor color(sFallback);

#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(sValue);
#else
color = QColor::fromString(sValue);
#endif
if (!color.isValid()) {
color.setNamedColor(sFallback);
qWarning() << "Found invalid color for key" << sKey;
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(sFallback);
#else
color = QColor::fromString(sFallback);
#endif
}
return color;
}
Expand Down
2 changes: 1 addition & 1 deletion stackandconquer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DEFINES += QT_NO_FOREACH

CONFIG(debug, debug|release) {
CONFIG += warn_on
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060500
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060600
}

SOURCES += main.cpp\
Expand Down

0 comments on commit 9c1b208

Please sign in to comment.