Fix several warnings when building against Qt 6

This commit is contained in:
Martchus 2021-11-04 00:16:27 +01:00
parent 5b9b69625b
commit e81166cd79
4 changed files with 20 additions and 12 deletions

View File

@ -1110,7 +1110,7 @@ RelevantDir Application::findDirectory(const QString &dirIdentifier)
// check whether the specified identifier is a known Syncthing directory or a relative path to an item in a // check whether the specified identifier is a known Syncthing directory or a relative path to an item in a
// known Syncthing directory // known Syncthing directory
int firstSlash = dirIdentifier.indexOf(QChar('/')); auto firstSlash = dirIdentifier.indexOf(QChar('/'));
relevantDir.dirObj = m_connection.findDirInfo(firstSlash >= 0 ? dirIdentifier.mid(0, firstSlash) : dirIdentifier, dummy); relevantDir.dirObj = m_connection.findDirInfo(firstSlash >= 0 ? dirIdentifier.mid(0, firstSlash) : dirIdentifier, dummy);
if (relevantDir) { if (relevantDir) {
if (firstSlash >= 0) { if (firstSlash >= 0) {

View File

@ -27,16 +27,17 @@ QByteArray makeSyncthingIcon(const StatusIconColorSet &colors, StatusEmblem stat
// serialize colors // serialize colors
auto gradientStartColor = colors.backgroundStart.name(QColor::HexRgb); auto gradientStartColor = colors.backgroundStart.name(QColor::HexRgb);
auto gradientEndColor = colors.backgroundEnd.name(QColor::HexRgb); auto gradientEndColor = colors.backgroundEnd.name(QColor::HexRgb);
if (colors.backgroundStart.alphaF() < 1.0) { constexpr auto opaque = static_cast<decltype(colors.backgroundStart.alphaF())>(1.0);
gradientStartColor += QStringLiteral(";stop-opacity:") + QString::number(colors.backgroundStart.alphaF()); if (colors.backgroundStart.alphaF() < opaque) {
gradientStartColor += QStringLiteral(";stop-opacity:") + QString::number(static_cast<double>(colors.backgroundStart.alphaF()));
} }
if (colors.backgroundEnd.alphaF() < 1.0) { if (colors.backgroundEnd.alphaF() < opaque) {
gradientEndColor += QStringLiteral(";stop-opacity:") + QString::number(colors.backgroundEnd.alphaF()); gradientEndColor += QStringLiteral(";stop-opacity:") + QString::number(static_cast<double>(colors.backgroundEnd.alphaF()));
} }
auto fillColor = colors.foreground.name(QColor::HexRgb); auto fillColor = colors.foreground.name(QColor::HexRgb);
auto strokeColor = fillColor; auto strokeColor = fillColor;
if (colors.foreground.alphaF() < 1.0) { if (colors.foreground.alphaF() < opaque) {
const auto alpha = QString::number(colors.foreground.alphaF()); const auto alpha = QString::number(static_cast<double>(colors.foreground.alphaF()));
fillColor += QStringLiteral(";fill-opacity:") + alpha; fillColor += QStringLiteral(";fill-opacity:") + alpha;
strokeColor += QStringLiteral(";stroke-opacity:") + alpha; strokeColor += QStringLiteral(";stroke-opacity:") + alpha;
} }
@ -304,7 +305,14 @@ IconManager::IconManager()
, m_trayIcons(m_statusIcons) , m_trayIcons(m_statusIcons)
, m_commonForkAwesomeIcons(m_forkAwesomeRenderer, QGuiApplication::palette().color(QPalette::Normal, QPalette::Text), QSize(64, 64)) , m_commonForkAwesomeIcons(m_forkAwesomeRenderer, QGuiApplication::palette().color(QPalette::Normal, QPalette::Text), QSize(64, 64))
{ {
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
QObject::connect(qGuiApp, &QGuiApplication::paletteChanged, this, &IconManager::handlePaletteChanged); QObject::connect(qGuiApp, &QGuiApplication::paletteChanged, this, &IconManager::handlePaletteChanged);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
} }
void IconManager::handlePaletteChanged(const QPalette &pal) void IconManager::handlePaletteChanged(const QPalette &pal)

View File

@ -797,7 +797,7 @@ void TrayWidget::handleNewNotification(DateTime when, const QString &msg)
void TrayWidget::handleConnectionSelected(QAction *connectionAction) void TrayWidget::handleConnectionSelected(QAction *connectionAction)
{ {
int index = m_connectionsMenu->actions().indexOf(connectionAction); auto index = m_connectionsMenu->actions().indexOf(connectionAction);
if (index >= 0) { if (index >= 0) {
m_selectedConnection m_selectedConnection
= (index == 0) ? &Settings::values().connection.primary : &Settings::values().connection.secondary[static_cast<size_t>(index - 1)]; = (index == 0) ? &Settings::values().connection.primary : &Settings::values().connection.secondary[static_cast<size_t>(index - 1)];

View File

@ -139,10 +139,10 @@ void StatusInfo::updateConnectedDevices(const SyncthingConnection &connection)
m_additionalDeviceInfo m_additionalDeviceInfo
= QCoreApplication::translate("QtGui::StatusInfo", "Connected to %1 devices", nullptr, deviceCount).arg(deviceCount); = QCoreApplication::translate("QtGui::StatusInfo", "Connected to %1 devices", nullptr, deviceCount).arg(deviceCount);
} else if (deviceNames.size() < deviceCount) { } else if (deviceNames.size() < deviceCount) {
m_additionalDeviceInfo m_additionalDeviceInfo = QCoreApplication::translate(
= QCoreApplication::translate("QtGui::StatusInfo", "Connected to %1 and %2 other devices", nullptr, deviceCount - deviceNames.size()) "QtGui::StatusInfo", "Connected to %1 and %2 other devices", nullptr, deviceCount - static_cast<int>(deviceNames.size()))
.arg(deviceNames.join(QStringLiteral(", "))) .arg(deviceNames.join(QStringLiteral(", ")))
.arg(deviceCount - deviceNames.size()); .arg(deviceCount - deviceNames.size());
} else if (deviceNames.size() == 2) { } else if (deviceNames.size() == 2) {
m_additionalDeviceInfo = QCoreApplication::translate("QtGui::StatusInfo", "Connected to %1 and %2", nullptr, deviceCount) m_additionalDeviceInfo = QCoreApplication::translate("QtGui::StatusInfo", "Connected to %1 and %2", nullptr, deviceCount)
.arg(deviceNames[0], deviceNames[1]); .arg(deviceNames[0], deviceNames[1]);