From 6ac633366e14679d5819dd91ea800467a07430c9 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 25 Jun 2019 13:49:53 +0200 Subject: [PATCH] Don't use functions obsoleted in Qt 5.13.0 --- fileitemactionplugin/syncthinginfoaction.cpp | 2 +- plasmoid/lib/syncthingapplet.cpp | 2 +- tray/gui/downloaditemdelegate.cpp | 2 +- tray/gui/traymenu.cpp | 2 +- tray/gui/traywidget.cpp | 7 +++---- widgets/misc/direrrorsdialog.cpp | 4 ++-- widgets/misc/internalerrorsdialog.cpp | 4 ++-- widgets/misc/otherdialogs.cpp | 2 +- widgets/misc/syncthingkiller.cpp | 20 ++++++++++++++++++-- 9 files changed, 30 insertions(+), 15 deletions(-) diff --git a/fileitemactionplugin/syncthinginfoaction.cpp b/fileitemactionplugin/syncthinginfoaction.cpp index b2a1eac..5c10c24 100644 --- a/fileitemactionplugin/syncthinginfoaction.cpp +++ b/fileitemactionplugin/syncthinginfoaction.cpp @@ -10,7 +10,7 @@ SyncthingInfoWidget::SyncthingInfoWidget(const SyncthingInfoAction *action, QWid , m_iconLabel(new QLabel(parent)) { auto *const layout = new QHBoxLayout(parent); - layout->setMargin(4); + layout->setContentsMargins(4, 4, 4, 4); layout->setSpacing(5); m_iconLabel->setFixedWidth(16); m_iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index 13b03b0..5d66b6c 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -244,7 +244,7 @@ void SyncthingApplet::updateStatusIconAndTooltip() QIcon SyncthingApplet::loadFontAwesomeIcon(const QString &name, bool solid) const { - return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, QGuiApplication::palette().color(QPalette::Foreground), solid), QSize(32, 32), 8); + return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, QGuiApplication::palette().color(QPalette::WindowText), solid), QSize(32, 32), 8); } QString SyncthingApplet::formatFileSize(quint64 fileSizeInByte) const diff --git a/tray/gui/downloaditemdelegate.cpp b/tray/gui/downloaditemdelegate.cpp index 929f772..778ba3b 100644 --- a/tray/gui/downloaditemdelegate.cpp +++ b/tray/gui/downloaditemdelegate.cpp @@ -68,7 +68,7 @@ void DownloadItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & progressBarOption.textAlignment = Qt::AlignCenter; progressBarOption.textVisible = true; if (option.state & QStyle::State_Selected) { - progressBarOption.palette.setBrush(QPalette::Foreground, option.palette.brush(QPalette::HighlightedText)); + progressBarOption.palette.setBrush(QPalette::WindowText, option.palette.brush(QPalette::HighlightedText)); } progressBarOption.progress = model->data(index, SyncthingDownloadModel::ItemPercentage).toInt(); progressBarOption.minimum = 0; diff --git a/tray/gui/traymenu.cpp b/tray/gui/traymenu.cpp index 49e392d..af512c0 100644 --- a/tray/gui/traymenu.cpp +++ b/tray/gui/traymenu.cpp @@ -20,7 +20,7 @@ TrayMenu::TrayMenu(TrayIcon *trayIcon, QWidget *parent) , m_trayIcon(trayIcon) { auto *const menuLayout = new QHBoxLayout; - menuLayout->setMargin(0); + menuLayout->setContentsMargins(0, 0, 0, 0); menuLayout->setSpacing(0); menuLayout->addWidget(m_trayWidget = new TrayWidget(this)); setLayout(menuLayout); diff --git a/tray/gui/traywidget.cpp b/tray/gui/traywidget.cpp index 45527ce..032fd58 100644 --- a/tray/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -87,8 +87,7 @@ TrayWidget::TrayWidget(TrayMenu *parent) m_cornerFrame = new QFrame(this); auto *cornerFrameLayout = new QHBoxLayout(m_cornerFrame); cornerFrameLayout->setSpacing(0); - cornerFrameLayout->setMargin(0); - //cornerFrameLayout->addStretch(); + cornerFrameLayout->setContentsMargins(0, 0, 0, 0); m_cornerFrame->setLayout(cornerFrameLayout); auto *viewIdButton = new QPushButton(m_cornerFrame); viewIdButton->setToolTip(tr("View own device ID")); @@ -506,8 +505,8 @@ void TrayWidget::updateTraffic() static const auto trafficIcons = [this]() { const auto size = QSize(16, 13); const auto &palette = m_ui->trafficFormWidget->palette(); // FIXME: make this aware of palette changes - const auto colorBackground = palette.color(QPalette::Background); - const auto colorActive = palette.color(QPalette::Foreground); + const auto colorBackground = palette.color(QPalette::Window); + const auto colorActive = palette.color(QPalette::WindowText); const auto colorInactive = QColor((colorActive.red() + colorBackground.red()) / 2, (colorActive.green() + colorBackground.green()) / 2, (colorActive.blue() + colorBackground.blue()) / 2); const auto renderIcon diff --git a/widgets/misc/direrrorsdialog.cpp b/widgets/misc/direrrorsdialog.cpp index 7f6a08c..3b0dcdc 100644 --- a/widgets/misc/direrrorsdialog.cpp +++ b/widgets/misc/direrrorsdialog.cpp @@ -31,7 +31,7 @@ DirectoryErrorsDialog::DirectoryErrorsDialog(const Data::SyncthingConnection &co { // add layout to show status and additional buttons auto *const buttonLayout = new QHBoxLayout; - buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(0, 0, 0, 0); layout()->addLayout(buttonLayout); // add label for overall status @@ -45,7 +45,7 @@ DirectoryErrorsDialog::DirectoryErrorsDialog(const Data::SyncthingConnection &co m_rmNonEmptyDirsButton = new QPushButton(this); m_rmNonEmptyDirsButton->setText(tr("Remove non-empty directories")); m_rmNonEmptyDirsButton->setIcon(QIcon::fromTheme(QStringLiteral("remove"))); - buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(0, 0, 0, 0); buttonLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); buttonLayout->addWidget(m_rmNonEmptyDirsButton); diff --git a/widgets/misc/internalerrorsdialog.cpp b/widgets/misc/internalerrorsdialog.cpp index abaef92..32d2526 100644 --- a/widgets/misc/internalerrorsdialog.cpp +++ b/widgets/misc/internalerrorsdialog.cpp @@ -33,7 +33,7 @@ InternalErrorsDialog::InternalErrorsDialog() // add layout to show status and additional buttons auto *const buttonLayout = new QHBoxLayout; - buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(0, 0, 0, 0); // add label for overall status QFont boldFont(m_statusLabel->font()); @@ -52,7 +52,7 @@ InternalErrorsDialog::InternalErrorsDialog() auto *const clearButton = new QPushButton(this); clearButton->setText(tr("Clear errors")); clearButton->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear"))); - buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(0, 0, 0, 0); buttonLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); buttonLayout->addWidget(clearButton); connect(clearButton, &QPushButton::clicked, &InternalErrorsDialog::clearErrors); diff --git a/widgets/misc/otherdialogs.cpp b/widgets/misc/otherdialogs.cpp index 9a42296..9148411 100644 --- a/widgets/misc/otherdialogs.cpp +++ b/widgets/misc/otherdialogs.cpp @@ -27,7 +27,7 @@ QDialog *ownDeviceIdDialog(Data::SyncthingConnection &connection) dlg->setWindowTitle(QCoreApplication::translate("QtGui::OtherDialogs", "Own device ID") + QStringLiteral(" - " APP_NAME)); dlg->setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg"))); dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setBackgroundRole(QPalette::Background); + dlg->setBackgroundRole(QPalette::Window); auto *layout = new QVBoxLayout(dlg); layout->setAlignment(Qt::AlignCenter); auto *pixmapLabel = new QLabel(dlg); diff --git a/widgets/misc/syncthingkiller.cpp b/widgets/misc/syncthingkiller.cpp index 2f1df4c..30c1701 100644 --- a/widgets/misc/syncthingkiller.cpp +++ b/widgets/misc/syncthingkiller.cpp @@ -29,7 +29,15 @@ void SyncthingKiller::waitForFinished() continue; } if (!waitForSignalsOrFail(noop, 0, signalInfo(this, &SyncthingKiller::ignored), - signalInfo(process, static_cast(&SyncthingProcess::finished)))) { + signalInfo(process, +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) || QT_DEPRECATED_SINCE(5, 13) + static_cast( +#endif + &SyncthingProcess::finished +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) || QT_DEPRECATED_SINCE(5, 13) + ) +#endif + ))) { return; } } @@ -50,7 +58,15 @@ void SyncthingKiller::confirmKill() const msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->addButton(tr("Keep running"), QMessageBox::RejectRole); msgBox->addButton(tr("Kill process"), QMessageBox::AcceptRole); - connect(process, static_cast(&SyncthingProcess::finished), msgBox, &QMessageBox::close); + connect(process, +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) || QT_DEPRECATED_SINCE(5, 13) + static_cast( +#endif + &SyncthingProcess::finished +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) || QT_DEPRECATED_SINCE(5, 13) + ) +#endif + , msgBox, &QMessageBox::close); connect(msgBox, &QMessageBox::accepted, process, &SyncthingProcess::killSyncthing); // FIXME: can not really ignore, just keep the process running //connect(msgBox, &QMessageBox::rejected, this, &SyncthingKiller::ignored);