diff src/gui/dialog/settings/services.cpp @ 68:2417121d894e

*: normalize usage of layouts before, I used them two ways, once was by setting the layout later by using setLayout(QWidget), and the other was just using the constructor. I find the constructor to be easier to read, so I chose that one.
author Paper <mrpapersonic@gmail.com>
date Mon, 02 Oct 2023 21:33:25 -0400
parents 26721c28bf22
children 5ccb99bfa605
line wrap: on
line diff
--- a/src/gui/dialog/settings/services.cpp	Mon Oct 02 07:06:44 2023 -0400
+++ b/src/gui/dialog/settings/services.cpp	Mon Oct 02 21:33:25 2023 -0400
@@ -7,6 +7,10 @@
 #include <QGroupBox>
 #include <QPushButton>
 #include <QSizePolicy>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QLineEdit>
 
 QWidget* SettingsPageServices::CreateMainPage() {
 	QWidget* result = new QWidget(this);
@@ -26,17 +30,16 @@
 	QLabel* sync_note_label =
 	    new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box);
 
-	QVBoxLayout* sync_layout = new QVBoxLayout;
+	QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box);
 	sync_layout->addWidget(sync_combo_box_label);
 	sync_layout->addWidget(sync_combo_box);
 	sync_layout->addWidget(sync_note_label);
-	sync_group_box->setLayout(sync_layout);
 
-	QVBoxLayout* full_layout = new QVBoxLayout;
+	QVBoxLayout* full_layout = new QVBoxLayout(result);
 	full_layout->addWidget(sync_group_box);
 	full_layout->setSpacing(10);
 	full_layout->addStretch();
-	result->setLayout(full_layout);
+
 	return result;
 }
 
@@ -60,27 +63,24 @@
 	connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); });
 	auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize..."));
 
-	QHBoxLayout* auth_layout = new QHBoxLayout;
+	QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget);
 	auth_layout->addWidget(username_entry);
 	auth_layout->addWidget(auth_button);
-	auth_widget->setLayout(auth_layout);
 
 	QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box);
 	note_label->setTextFormat(Qt::RichText);
 	note_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
 	note_label->setOpenExternalLinks(true);
 
-	QVBoxLayout* layout = new QVBoxLayout;
+	QVBoxLayout* layout = new QVBoxLayout(group_box);
 	layout->addWidget(username_entry_label);
 	layout->addWidget(auth_widget);
 	layout->addWidget(note_label);
-	group_box->setLayout(layout);
 
-	QVBoxLayout* full_layout = new QVBoxLayout;
+	QVBoxLayout* full_layout = new QVBoxLayout(result);
 	full_layout->addWidget(group_box);
 	full_layout->setSpacing(10);
 	full_layout->addStretch();
-	result->setLayout(full_layout);
 	return result;
 }