From fbfa5e0f4183f23f7603f23760eee049cb6e45e8 Mon Sep 17 00:00:00 2001 From: kornes <28986062+kornes@users.noreply.github.com> Date: Thu, 10 Nov 2022 19:11:40 +0000 Subject: [PATCH] Disable use of Qt APIs deprecated in 5.15.0 and earlier versions (#4133) --- CHANGELOG.md | 1 + src/CMakeLists.txt | 1 + src/singletons/NativeMessaging.cpp | 7 +++---- src/singletons/Updates.cpp | 6 +++--- src/singletons/helper/LoggingChannel.cpp | 4 ++-- src/util/IncognitoBrowser.cpp | 3 ++- src/widgets/AttachedWindow.cpp | 2 +- src/widgets/BaseWindow.cpp | 7 ++++--- src/widgets/StreamView.cpp | 2 +- src/widgets/Window.cpp | 2 +- src/widgets/dialogs/EmotePopup.cpp | 6 +++--- src/widgets/dialogs/NotificationPopup.cpp | 3 +-- src/widgets/dialogs/ReplyThreadPopup.cpp | 3 ++- src/widgets/dialogs/SettingsDialog.cpp | 4 +--- src/widgets/helper/EditableModelView.cpp | 2 +- src/widgets/helper/EffectLabel.cpp | 4 ++-- src/widgets/helper/SearchPopup.cpp | 4 ++-- src/widgets/splits/Split.cpp | 2 +- src/widgets/splits/SplitHeader.cpp | 2 +- src/widgets/splits/SplitInput.cpp | 5 ++--- src/widgets/splits/SplitOverlay.cpp | 2 +- 21 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 404fa86d8..e948a12b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ - Dev: Got rid of BaseTheme (#4132) - Dev: Removed official support for QMake. (#3839, #3883) - Dev: Rewrote LimitedQueue (#3798) +- Dev: Set cmake `QT_DISABLE_DEPRECATED_BEFORE` to disable deprecated APIs up to Qt 5.15.0 (#4133) - Dev: Overhauled highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801, #3835) - Dev: Use Game Name returned by Get Streams instead of querying it from the Get Games API. (#3662) - Dev: Batched checking live status for all channels after startup. (#3757, #3762, #3767) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c24e7d35b..f2a75e773 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ set(LIBRARY_PROJECT "${PROJECT_NAME}-lib") set(EXECUTABLE_PROJECT "${PROJECT_NAME}") +add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00) set(SOURCE_FILES Application.cpp diff --git a/src/singletons/NativeMessaging.cpp b/src/singletons/NativeMessaging.cpp index f4dff7c0b..2f50c8272 100644 --- a/src/singletons/NativeMessaging.cpp +++ b/src/singletons/NativeMessaging.cpp @@ -19,7 +19,7 @@ namespace ipc = boost::interprocess; #ifdef Q_OS_WIN -# include +# include # include # include "singletons/WindowManager.hpp" @@ -98,9 +98,8 @@ void registerNmManifest(Paths &paths, const QString &manifestFilename, file.flush(); #ifdef Q_OS_WIN - // clang-format off - QProcess::execute("REG ADD \"" + registryKeyName + "\" /ve /t REG_SZ /d \"" + manifestPath + "\" /f"); -// clang-format on + QSettings registry(registryKeyName, QSettings::NativeFormat); + registry.setValue("Default", manifestPath); #endif } diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index cf32b30ff..ab50e55e4 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -179,10 +179,10 @@ void Updates::installUpdates() }) .onSuccess([this](auto result) -> Outcome { QByteArray object = result.getData(); - auto filename = + auto filePath = combinePath(getPaths()->miscDirectory, "Update.exe"); - QFile file(filename); + QFile file(filePath); file.open(QIODevice::Truncate | QIODevice::WriteOnly); if (file.write(object) == -1) @@ -203,7 +203,7 @@ void Updates::installUpdates() file.flush(); file.close(); - if (QProcess::startDetached(filename)) + if (QProcess::startDetached(filePath, {})) { QApplication::exit(0); } diff --git a/src/singletons/helper/LoggingChannel.cpp b/src/singletons/helper/LoggingChannel.cpp index 54dac7f78..13f40c06e 100644 --- a/src/singletons/helper/LoggingChannel.cpp +++ b/src/singletons/helper/LoggingChannel.cpp @@ -109,7 +109,7 @@ void LoggingChannel::addMessage(MessagePtr message) QString LoggingChannel::generateOpeningString(const QDateTime &now) const { - QString ret = QLatin1Literal("# Start logging at "); + QString ret("# Start logging at "); ret.append(now.toString("yyyy-MM-dd HH:mm:ss ")); ret.append(now.timeZoneAbbreviation()); @@ -120,7 +120,7 @@ QString LoggingChannel::generateOpeningString(const QDateTime &now) const QString LoggingChannel::generateClosingString(const QDateTime &now) const { - QString ret = QLatin1Literal("# Stop logging at "); + QString ret("# Stop logging at "); ret.append(now.toString("yyyy-MM-dd HH:mm:ss")); ret.append(now.timeZoneAbbreviation()); diff --git a/src/util/IncognitoBrowser.cpp b/src/util/IncognitoBrowser.cpp index 24e79a7e7..d4bf14fe1 100644 --- a/src/util/IncognitoBrowser.cpp +++ b/src/util/IncognitoBrowser.cpp @@ -90,7 +90,8 @@ bool openLinkIncognito(const QString &link) #ifdef Q_OS_WIN auto command = getCommand(link); - return QProcess::startDetached(command); + // TODO: split command into program path and incognito argument + return QProcess::startDetached(command, {}); #else return false; #endif diff --git a/src/widgets/AttachedWindow.cpp b/src/widgets/AttachedWindow.cpp index 9ac753345..ecae39ec4 100644 --- a/src/widgets/AttachedWindow.cpp +++ b/src/widgets/AttachedWindow.cpp @@ -48,7 +48,7 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset) , yOffset_(_yOffset) { QLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); this->setLayout(layout); auto *split = new Split(this); diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 0cbd80f0b..06fa9c07d 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -144,7 +144,7 @@ void BaseWindow::init() { QHBoxLayout *buttonLayout = this->ui_.titlebarBox = new QHBoxLayout(); - buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(0, 0, 0, 0); layout->addLayout(buttonLayout); // title @@ -343,14 +343,15 @@ bool BaseWindow::event(QEvent *event) void BaseWindow::wheelEvent(QWheelEvent *event) { - if (event->orientation() != Qt::Vertical) + // ignore horizontal mouse wheels + if (event->angleDelta().x() != 0) { return; } if (event->modifiers() & Qt::ControlModifier) { - if (event->delta() > 0) + if (event->angleDelta().y() > 0) { getSettings()->setClampedUiScale( getSettings()->getClampedUiScale() + 0.1); diff --git a/src/widgets/StreamView.cpp b/src/widgets/StreamView.cpp index a47450b44..8840e8838 100644 --- a/src/widgets/StreamView.cpp +++ b/src/widgets/StreamView.cpp @@ -29,7 +29,7 @@ StreamView::StreamView(ChannelPtr channel, const QUrl &url) chat->setChannel(std::move(channel)); this->layout()->setSpacing(0); - this->layout()->setMargin(0); + this->layout()->setContentsMargins(0, 0, 0, 0); } } // namespace chatterino diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index f976b0c53..610a5d2ea 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -153,7 +153,7 @@ void Window::addLayout() this->getLayoutContainer()->setLayout(layout); // set margin - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); this->notebook_->setAllowUserTabManagement(true); this->notebook_->setShowAddButton(true); diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 456b8c005..9645f8da1 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -167,11 +167,11 @@ EmotePopup::EmotePopup(QWidget *parent) QRegularExpression searchRegex("\\S*"); searchRegex.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); QHBoxLayout *layout2 = new QHBoxLayout(this); - layout2->setMargin(8); + layout2->setContentsMargins(8, 8, 8, 8); layout2->setSpacing(8); this->search_ = new QLineEdit(); @@ -214,7 +214,7 @@ EmotePopup::EmotePopup(QWidget *parent) this->notebook_ = new Notebook(this); layout->addWidget(this->notebook_); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); this->subEmotesView_ = makeView("Subs"); this->channelEmotesView_ = makeView("Channel"); diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index 11e1b63a9..0e73969c5 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -32,8 +32,7 @@ void NotificationPopup::updatePosition() { Location location = BottomRight; - QDesktopWidget *desktop = QApplication::desktop(); - const QRect rect = desktop->availableGeometry(); + const QRect rect = QGuiApplication::primaryScreen()->availableGeometry(); switch (location) { diff --git a/src/widgets/dialogs/ReplyThreadPopup.cpp b/src/widgets/dialogs/ReplyThreadPopup.cpp index 6fc387dfa..2e3cf25bd 100644 --- a/src/widgets/dialogs/ReplyThreadPopup.cpp +++ b/src/widgets/dialogs/ReplyThreadPopup.cpp @@ -90,7 +90,8 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, QWidget *parent, layout->setSpacing(0); // provide draggable margin if frameless - layout->setMargin(closeAutomatically ? 15 : 1); + auto marginPx = closeAutomatically ? 15 : 1; + layout->setContentsMargins(marginPx, marginPx, marginPx, marginPx); layout->addWidget(this->ui_.threadView, 1); layout->addWidget(this->ui_.replyInput); } diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index d6969cbfc..d2af987e0 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -123,7 +123,7 @@ void SettingsDialog::initUi() .assign(&this->ui_.pageStack) .withoutMargin(); - this->ui_.pageStack->setMargin(0); + this->ui_.pageStack->setContentsMargins(0, 0, 0, 0); outerBox->addSpacing(12); @@ -193,9 +193,7 @@ void SettingsDialog::filterElements(const QString &text) void SettingsDialog::addTabs() { - this->ui_.tabContainer->setMargin(0); this->ui_.tabContainer->setSpacing(0); - this->ui_.tabContainer->setContentsMargins(0, 20, 0, 20); // Constructors are wrapped in std::function to remove some strain from first time loading. diff --git a/src/widgets/helper/EditableModelView.cpp b/src/widgets/helper/EditableModelView.cpp index a002d8209..f331cdd17 100644 --- a/src/widgets/helper/EditableModelView.cpp +++ b/src/widgets/helper/EditableModelView.cpp @@ -29,7 +29,7 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable) // create layout QVBoxLayout *vbox = new QVBoxLayout(this); - vbox->setMargin(0); + vbox->setContentsMargins(0, 0, 0, 0); // create button layout QHBoxLayout *buttons = new QHBoxLayout(this); diff --git a/src/widgets/helper/EffectLabel.cpp b/src/widgets/helper/EffectLabel.cpp index 1f2960d77..3e156ae5b 100644 --- a/src/widgets/helper/EffectLabel.cpp +++ b/src/widgets/helper/EffectLabel.cpp @@ -13,7 +13,7 @@ EffectLabel::EffectLabel(BaseWidget *parent, int spacing) this->label_.setAlignment(Qt::AlignCenter); - this->hbox_.setMargin(0); + this->hbox_.setContentsMargins(0, 0, 0, 0); this->hbox_.addSpacing(spacing); this->hbox_.addWidget(&this->label_); this->hbox_.addSpacing(spacing); @@ -29,7 +29,7 @@ EffectLabel2::EffectLabel2(BaseWidget *parent, int padding) // this->label_.setAlignment(Qt::AlignCenter); this->label_.setCentered(true); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); // hbox.addSpacing(spacing); hbox->addWidget(&this->label_); // hbox.addSpacing(spacing); diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index 8c4f24719..5c42d9209 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -248,13 +248,13 @@ void SearchPopup::initLayout() // VBOX { auto *layout1 = new QVBoxLayout(this); - layout1->setMargin(0); + layout1->setContentsMargins(0, 0, 0, 0); layout1->setSpacing(0); // HBOX { auto *layout2 = new QHBoxLayout(this); - layout2->setMargin(8); + layout2->setContentsMargins(8, 8, 8, 8); layout2->setSpacing(8); // SEARCH INPUT diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 889561914..282590e96 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -96,7 +96,7 @@ Split::Split(QWidget *parent) this->setFocusProxy(this->input_->ui_.textEdit); this->vbox_->setSpacing(0); - this->vbox_->setMargin(1); + this->vbox_->setContentsMargins(1, 1, 1, 1); this->vbox_->addWidget(this->header_); this->vbox_->addWidget(this->view_, 1); diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index fe95aca5a..b782e72a0 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -330,7 +330,7 @@ void SplitHeader::initializeLayout() }, this->managedConnections_); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); this->setLayout(layout); diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index ccedbb86b..3acec66de 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -209,9 +209,8 @@ void SplitInput::themeChangedEvent() #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) this->ui_.textEdit->setPalette(placeholderPalette); #endif - - this->ui_.vbox->setMargin( - int((this->theme->isLightTheme() ? 4 : 2) * this->scale())); + auto marginPx = (this->theme->isLightTheme() ? 4 : 2) * this->scale(); + this->ui_.vbox->setContentsMargins(marginPx, marginPx, marginPx, marginPx); this->ui_.emoteButton->getLabel().setStyleSheet("color: #000"); diff --git a/src/widgets/splits/SplitOverlay.cpp b/src/widgets/splits/SplitOverlay.cpp index 30cd743d2..ca2a1c632 100644 --- a/src/widgets/splits/SplitOverlay.cpp +++ b/src/widgets/splits/SplitOverlay.cpp @@ -22,7 +22,7 @@ SplitOverlay::SplitOverlay(Split *parent) { QGridLayout *layout = new QGridLayout(this); this->layout_ = layout; - layout->setMargin(1); + layout->setContentsMargins(1, 1, 1, 1); layout->setSpacing(1); layout->setRowStretch(1, 1);