changeset 36:2743011a6042

*: mass update formatted all source files, converted ALL instances of setStyleSheet() to palettes and fonts (stylesheets suck), and I changed the clang-format file because it wasn't working on my laptop for some reason.
author Paper <mrpapersonic@gmail.com>
date Thu, 21 Sep 2023 15:17:47 -0400
parents 329b7921a6be
children 9ae9365dd4ea
files .clang-format include/core/array.h include/core/config.h include/core/filesystem.h include/core/strings.h include/core/time.h include/services/anilist.h include/services/services.h src/core/anime.cpp src/core/date.cpp src/core/filesystem.cpp src/gui/dialog/information.cpp src/gui/dialog/settings.cpp src/gui/dialog/settings/application.cpp src/gui/sidebar.cpp src/gui/ui_utils.cpp src/gui/window.cpp src/services/anilist.cpp
diffstat 18 files changed, 98 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/.clang-format	Thu Sep 21 11:43:24 2023 -0400
+++ b/.clang-format	Thu Sep 21 15:17:47 2023 -0400
@@ -17,10 +17,7 @@
 AlignAfterOpenBracket: Align
 AlignArrayOfStructures: Left
 AlignEscapedNewlines: DontAlign
-AlignConsecutiveMacros:
-  Enabled: true
-  AcrossEmptyLines: true
-  AcrossComments: false
+AlignConsecutiveMacros: true
 
 AllowShortIfStatementsOnASingleLine: false
 AllowShortBlocksOnASingleLine: Empty
--- a/include/core/array.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/core/array.h	Thu Sep 21 15:17:47 2023 -0400
@@ -2,8 +2,7 @@
 #define __core__array_h
 
 #ifndef ARRAYSIZE
-#define ARRAYSIZE(x) \
-    (sizeof(x) / sizeof(x[0]))
+#	define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
 #endif
 
 #endif // __core__array_h
\ No newline at end of file
--- a/include/core/config.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/core/config.h	Thu Sep 21 15:17:47 2023 -0400
@@ -33,7 +33,7 @@
 		} anilist;
 };
 
-#define CONFIG_DIR		"minori"
-#define CONFIG_NAME		"config.json"
+#define CONFIG_DIR      "minori"
+#define CONFIG_NAME     "config.json"
 #define MAX_LINE_LENGTH 256
 #endif // __core__config_h
--- a/include/core/filesystem.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/core/filesystem.h	Thu Sep 21 15:17:47 2023 -0400
@@ -9,6 +9,6 @@
 std::string GetParentDirectory(std::string path);
 std::string GetConfigPath();
 
-}
+} // namespace Filesystem
 
 #endif // __core__filesystem_h
--- a/include/core/strings.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/core/strings.h	Thu Sep 21 15:17:47 2023 -0400
@@ -21,5 +21,5 @@
 std::string ToUpper(const std::string& string);
 std::string ToLower(const std::string& string);
 
-};	// namespace StringUtils
+};     // namespace Strings
 #endif // __core__strings_h
\ No newline at end of file
--- a/include/core/time.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/core/time.h	Thu Sep 21 15:17:47 2023 -0400
@@ -19,5 +19,5 @@
 
 int64_t GetSystemTime();
 
-};	   // namespace Time
+};     // namespace Time
 #endif // __core__time_h
\ No newline at end of file
--- a/include/services/anilist.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/services/anilist.h	Thu Sep 21 15:17:47 2023 -0400
@@ -15,6 +15,6 @@
 /* Write queries (mutations) */
 int UpdateAnimeEntry(int id);
 
-};     // namespace Services::AniList
+}; // namespace Services::AniList
 
 #endif // __services__anilist_h
--- a/include/services/services.h	Thu Sep 21 11:43:24 2023 -0400
+++ b/include/services/services.h	Thu Sep 21 15:17:47 2023 -0400
@@ -6,6 +6,6 @@
 void Synchronize();
 void Authorize();
 
-};
+}; // namespace Services
 
 #endif // __services__services_h
\ No newline at end of file
--- a/src/core/anime.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/core/anime.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -148,8 +148,8 @@
 std::vector<std::string> Anime::GetTitleSynonyms() const {
 	std::vector<std::string> result;
 #define IN_VECTOR(v, k) (std::count(v.begin(), v.end(), k))
-#define ADD_TO_SYNONYMS(v, k)                                                                                          \
-	if (!k.empty() && !IN_VECTOR(v, k) && k != GetUserPreferredTitle())                                                \
+#define ADD_TO_SYNONYMS(v, k) \
+	if (!k.empty() && !IN_VECTOR(v, k) && k != GetUserPreferredTitle()) \
 	v.push_back(k)
 	ADD_TO_SYNONYMS(result, info_.title.english);
 	ADD_TO_SYNONYMS(result, info_.title.romaji);
--- a/src/core/date.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/core/date.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -6,25 +6,25 @@
 
 /* An implementation of AniList's "fuzzy date" */
 
-#define MIN(A, B)                                                                                                      \
-	({                                                                                                                 \
-		__typeof__(A) __a = (A);                                                                                       \
-		__typeof__(B) __b = (B);                                                                                       \
-		__a < __b ? __a : __b;                                                                                         \
+#define MIN(A, B) \
+	({ \
+		__typeof__(A) __a = (A); \
+		__typeof__(B) __b = (B); \
+		__a < __b ? __a : __b; \
 	})
-#define MAX(A, B)                                                                                                      \
-	({                                                                                                                 \
-		__typeof__(A) __a = (A);                                                                                       \
-		__typeof__(B) __b = (B);                                                                                       \
-		__a < __b ? __b : __a;                                                                                         \
+#define MAX(A, B) \
+	({ \
+		__typeof__(A) __a = (A); \
+		__typeof__(B) __b = (B); \
+		__a < __b ? __b : __a; \
 	})
 
-#define CLAMP(x, low, high)                                                                                            \
-	({                                                                                                                 \
-		__typeof__(x) __x = (x);                                                                                       \
-		__typeof__(low) __low = (low);                                                                                 \
-		__typeof__(high) __high = (high);                                                                              \
-		__x > __high ? __high : (__x < __low ? __low : __x);                                                           \
+#define CLAMP(x, low, high) \
+	({ \
+		__typeof__(x) __x = (x); \
+		__typeof__(low) __low = (low); \
+		__typeof__(high) __high = (high); \
+		__x > __high ? __high : (__x < __low ? __low : __x); \
 	})
 
 Date::Date() {
--- a/src/core/filesystem.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/core/filesystem.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -16,8 +16,8 @@
 #	include <sys/stat.h>
 #endif
 
+#include "core/filesystem.h"
 #include "core/config.h"
-#include "core/filesystem.h"
 #include <limits.h>
 
 namespace Filesystem {
--- a/src/gui/dialog/information.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/dialog/information.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -17,8 +17,12 @@
 	setFixedSize(842, 613);
 	setWindowTitle(tr("Anime Information"));
 	setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
-	setObjectName("infodiag");
-	setStyleSheet(UiUtils::IsInDarkMode() ? "" : "QDialog#infodiag{background-color: white;}");
+
+	{
+		QPalette pal;
+		pal.setColor(QPalette::Window, Qt::white);
+		setPalette(pal);
+	}
 
 	QWidget* widget = new QWidget(this);
 
@@ -28,7 +32,13 @@
 
 	/* main widget */
 	QWidget* main_widget = new QWidget(widget);
-	main_widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
+
+	{
+		QPalette pal;
+		pal.setColor(QPalette::Window, Qt::white);
+		main_widget->setPalette(pal);
+	}
+
 	main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
 	/* anime title header text */
@@ -41,7 +51,18 @@
 	anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
 	anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 	anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-	anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;");
+
+	{
+		QFont font(anime_title->font());
+		font.setPointSize(12);
+		anime_title->setFont(font);
+	}
+
+	{
+		QPalette pal;
+		pal.setColor(QPalette::Window, QColor(255, 255, 255, 0));
+		pal.setColor(QPalette::WindowText, Qt::blue);
+	}
 
 	/* tabbed widget */
 	QTabWidget* tabbed_widget = new QTabWidget(main_widget);
--- a/src/gui/dialog/settings.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/dialog/settings.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -17,8 +17,17 @@
 	page_title->setWordWrap(false);
 	page_title->setFrameShape(QFrame::Panel);
 	page_title->setFrameShadow(QFrame::Sunken);
-	page_title->setStyleSheet(
-	    "QLabel { font-size: 10pt; font-weight: bold; background-color: #ABABAB; color: white; }");
+
+	QFont font(page_title->font());
+	font.setPointSize(10);
+	font.setWeight(QFont::Bold);
+	page_title->setFont(font);
+
+	QPalette pal;
+	pal.setColor(QPalette::WindowText, QColor(0xAB, 0xAB, 0xAB));
+	pal.setColor(QPalette::Window, Qt::white);
+	page_title->setPalette(pal);
+
 	page_title->setFixedHeight(23);
 	page_title->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
 	page_title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -68,7 +77,15 @@
 	// sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png"));
 	sidebar->setIconSize(QSize(24, 24));
 	sidebar->setFrameShape(QFrame::Box);
-	sidebar->setStyleSheet("QListWidget { background-color: white; font-size: 12px; }");
+
+	QFont font(sidebar->font());
+	font.setPointSize(9);
+	sidebar->setFont(font);
+
+	QPalette pal;
+	pal.setColor(QPalette::Window, Qt::white);
+	sidebar->setPalette(pal);
+
 	sidebar->setFixedWidth(158);
 	sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
 
--- a/src/gui/dialog/settings/application.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/dialog/settings/application.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -67,7 +67,7 @@
 	hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
 	hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
 	hl_above_anime_box->setEnabled(hl_anime_box->checkState() != Qt::Unchecked);
-	hl_above_anime_box->setStyleSheet("margin-left: 10px;");
+	hl_above_anime_box->setContentsMargins(10, 0, 0, 0);
 
 	/* Appearance */
 	QVBoxLayout* appearance_layout = new QVBoxLayout;
--- a/src/gui/sidebar.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/sidebar.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -14,7 +14,9 @@
 	setSelectionBehavior(QAbstractItemView::SelectItems);
 	setMouseTracking(true);
 	viewport()->setAutoFillBackground(false);
-	setStyleSheet("font-size: 12px");
+	QFont font;
+	font.setPointSize(9);
+	setFont(font);
 	connect(this, &QListWidget::currentRowChanged, this,
 	        [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); });
 }
@@ -37,12 +39,16 @@
 
 QListWidgetItem* SideBar::AddSeparator() {
 	QListWidgetItem* item = new QListWidgetItem(this);
-	setStyleSheet("QListWidget::item:disabled {background: transparent;}");
 	QFrame* line = new QFrame(this);
 	line->setFrameShape(QFrame::HLine);
 	line->setFrameShadow(QFrame::Sunken);
 	line->setMouseTracking(true);
 	line->setEnabled(false);
+
+	QPalette pal;
+	pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
+	line->setPalette(pal);
+
 	setItemWidget(item, line);
 	item->setFlags(Qt::NoItemFlags);
 	return item;
@@ -61,8 +67,7 @@
 	return !(index.isValid() && index.flags() & Qt::ItemIsEnabled);
 }
 
-QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index,
-                                                              const QEvent*) const {
+QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index, const QEvent*) const {
 	if (IndexIsSeparator(index))
 		return QItemSelectionModel::NoUpdate;
 	return QItemSelectionModel::ClearAndSelect;
--- a/src/gui/ui_utils.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/ui_utils.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -98,8 +98,7 @@
 	return paragraph;
 }
 
-LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data,
-                                             QWidget* parent)
+LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent)
     : QWidget(parent) {
 	setLayout(new QVBoxLayout);
 
@@ -149,8 +148,7 @@
 	return paragraph;
 }
 
-SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent)
-    : QWidget(parent) {
+SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent) : QWidget(parent) {
 	setLayout(new QVBoxLayout);
 
 	header = new Header(title, this);
@@ -193,7 +191,11 @@
 	setFrameShape(QFrame::NoFrame);
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-	setStyleSheet("background: transparent;");
+
+	QPalette pal;
+	pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
+	setPalette(pal);
+
 	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 }
 
--- a/src/gui/window.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/gui/window.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -47,7 +47,7 @@
 	sidebar->AddItem("Seasons", SideBar::CreateIcon(":/icons/16x16/calendar.png"));
 	sidebar->AddItem("Torrents", SideBar::CreateIcon(":/icons/16x16/feed.png"));
 	sidebar->setFixedWidth(128);
-	sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+	sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
 
 	QStackedWidget* stack = new QStackedWidget(main_widget);
 	stack->addWidget(new NowPlayingWidget(main_widget));
--- a/src/services/anilist.cpp	Thu Sep 21 11:43:24 2023 -0400
+++ b/src/services/anilist.cpp	Thu Sep 21 15:17:47 2023 -0400
@@ -14,7 +14,6 @@
 #include <chrono>
 #include <curl/curl.h>
 #include <exception>
-#include <format>
 #define CLIENT_ID "13706"
 
 using nlohmann::literals::operator"" _json_pointer;
@@ -24,17 +23,13 @@
 class Account {
 	public:
 		std::string Username() const { return session.config.anilist.username; }
-		void SetUsername(std::string const& username) {
-			session.config.anilist.username = username;
-		}
+		void SetUsername(std::string const& username) { session.config.anilist.username = username; }
 
 		int UserId() const { return session.config.anilist.user_id; }
 		void SetUserId(const int id) { session.config.anilist.user_id = id; }
 
 		std::string AuthToken() const { return session.config.anilist.auth_token; }
-		void SetAuthToken(std::string const& auth_token) {
-			session.config.anilist.auth_token = auth_token;
-		}
+		void SetAuthToken(std::string const& auth_token) { session.config.anilist.auth_token = auth_token; }
 
 		bool Authenticated() const { return !AuthToken().empty(); }
 };
@@ -68,8 +63,7 @@
 		curl_easy_cleanup(curl);
 		if (res != CURLE_OK) {
 			QMessageBox box(QMessageBox::Icon::Critical, "",
-			                QString("curl_easy_perform(curl) failed!: ") +
-			                    QString(curl_easy_strerror(res)));
+			                QString("curl_easy_perform(curl) failed!: ") + QString(curl_easy_strerror(res)));
 			box.exec();
 			return "";
 		}
@@ -317,13 +311,12 @@
 
 int AuthorizeUser() {
 	/* Prompt for PIN */
-	QDesktopServices::openUrl(QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID
-	                               "&response_type=token"));
+	QDesktopServices::openUrl(
+	    QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID "&response_type=token"));
 	bool ok;
 	QString token = QInputDialog::getText(
-	    0, "Credentials needed!",
-	    "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, "",
-	    &ok);
+	    0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal,
+	    "", &ok);
 	if (ok && !token.isEmpty())
 		account.SetAuthToken(token.toStdString());
 	else // fail