Skip to content

Commit

Permalink
Disable use of Qt APIs deprecated in 5.15.0 and earlier versions (#4133)
Browse files Browse the repository at this point in the history
  • Loading branch information
kornes committed Nov 10, 2022
1 parent 3303cdc commit fbfa5e0
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/singletons/NativeMessaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace ipc = boost::interprocess;

#ifdef Q_OS_WIN
# include <QProcess>
# include <QSettings>

# include <Windows.h>
# include "singletons/WindowManager.hpp"
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions src/singletons/Updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -203,7 +203,7 @@ void Updates::installUpdates()
file.flush();
file.close();

if (QProcess::startDetached(filename))
if (QProcess::startDetached(filePath, {}))
{
QApplication::exit(0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/singletons/helper/LoggingChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/util/IncognitoBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/AttachedWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/widgets/BaseWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/StreamView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/widgets/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/dialogs/EmotePopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/dialogs/NotificationPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/dialogs/ReplyThreadPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions src/widgets/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/helper/EditableModelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/helper/EffectLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/helper/SearchPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/splits/Split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/splits/SplitHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void SplitHeader::initializeLayout()
},
this->managedConnections_);

layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setLayout(layout);

Expand Down
5 changes: 2 additions & 3 deletions src/widgets/splits/SplitInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/splits/SplitOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fbfa5e0

Please sign in to comment.