diff src/gui/window.cc @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents fe702c8f161f
children f31305b9f60a
line wrap: on
line diff
--- a/src/gui/window.cc	Sun Feb 18 16:02:14 2024 -0500
+++ b/src/gui/window.cc	Mon Apr 01 02:43:44 2024 -0400
@@ -3,7 +3,6 @@
 #include "core/config.h"
 #include "core/session.h"
 #include "core/strings.h"
-#include "gui/theme.h"
 #include "gui/dialog/about.h"
 #include "gui/dialog/settings.h"
 #include "gui/pages/anime_list.h"
@@ -13,10 +12,11 @@
 #include "gui/pages/seasons.h"
 #include "gui/pages/statistics.h"
 #include "gui/pages/torrents.h"
+#include "gui/theme.h"
 #include "gui/widgets/sidebar.h"
+#include "library/library.h"
 #include "services/services.h"
 #include "track/media.h"
-#include "library/library.h"
 
 #include "anitomy/anitomy.h"
 
@@ -72,7 +72,7 @@
 	/* This thread will be destroyed on
 	 * close of the program OR on the destruction
 	 * of MainWindow
-	*/
+	 */
 	thread.reset(new PlayingThread(this));
 
 	connect(thread.get(), &PlayingThread::Done, this, [page](const std::vector<std::string>& files) {
@@ -82,7 +82,6 @@
 
 			const auto& elements = anitomy.elements();
 			const std::string title = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle));
-			std::cout << title << std::endl;
 
 			int id = Anime::db.GetAnimeFromTitle(title);
 			if (id <= 0)
@@ -171,22 +170,20 @@
 		}
 
 		{
-			menu->addAction(tr("&Scan available episodes"), []{
-				Library::SearchLibraryFolders();
-			});
+			menu->addAction(tr("&Scan available episodes"), [] { Library::SearchLibraryFolders(); });
 		}
 
 		menu->addSeparator();
 
-//		{
-//			QAction* action = menu->addAction(tr("Play &next episode"));
-//			action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
-//		}
-//
-//		{
-//			QAction* action = menu->addAction(tr("Play &random episode"));
-//			action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
-//		}
+		//		{
+		//			QAction* action = menu->addAction(tr("Play &next episode"));
+		//			action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
+		//		}
+		//
+		//		{
+		//			QAction* action = menu->addAction(tr("Play &random episode"));
+		//			action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
+		//		}
 
 		menu->addSeparator();
 
@@ -203,74 +200,73 @@
 			{
 				sync_action = menu->addAction(tr("Synchronize &list"));
 
-				connect(sync_action, &QAction::triggered, this, [this, sync_action]{
-					AsyncSynchronize(sync_action, stack.get());
-				});
+				connect(sync_action, &QAction::triggered, this,
+				        [this, sync_action] { AsyncSynchronize(sync_action, stack.get()); });
 
 				sync_action->setIcon(QIcon(":/icons/24x24/arrow-circle-double-135.png"));
 				sync_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
 			}
 
-//			menu->addSeparator();
-//
-//			{
-//				/* AniList */
-//				QMenu* submenu = menu->addMenu(tr("&AniList"));
-//				QAction* action = submenu->addAction(tr("Go to my &profile"));
-//				action = submenu->addAction(tr("Go to my &stats"));
-//			}
-//
-//			{
-//				/* Kitsu */
-//				QMenu* submenu = menu->addMenu(tr("&Kitsu"));
-//				QAction* action = submenu->addAction(tr("Go to my &feed"));
-//				action = submenu->addAction(tr("Go to my &library"));
-//				action = submenu->addAction(tr("Go to my &profile"));
-//			}
-//			{
-//				QMenu* submenu = menu->addMenu(tr("&MyAnimeList"));
-//				QAction* action = submenu->addAction(tr("Go to my p&anel"));
-//				action = submenu->addAction(tr("Go to my &profile"));
-//				action = submenu->addAction(tr("Go to my &history"));
-//			}
+			//			menu->addSeparator();
+			//
+			//			{
+			//				/* AniList */
+			//				QMenu* submenu = menu->addMenu(tr("&AniList"));
+			//				QAction* action = submenu->addAction(tr("Go to my &profile"));
+			//				action = submenu->addAction(tr("Go to my &stats"));
+			//			}
+			//
+			//			{
+			//				/* Kitsu */
+			//				QMenu* submenu = menu->addMenu(tr("&Kitsu"));
+			//				QAction* action = submenu->addAction(tr("Go to my &feed"));
+			//				action = submenu->addAction(tr("Go to my &library"));
+			//				action = submenu->addAction(tr("Go to my &profile"));
+			//			}
+			//			{
+			//				QMenu* submenu = menu->addMenu(tr("&MyAnimeList"));
+			//				QAction* action = submenu->addAction(tr("Go to my p&anel"));
+			//				action = submenu->addAction(tr("Go to my &profile"));
+			//				action = submenu->addAction(tr("Go to my &history"));
+			//			}
 		}
 	}
 
 	{
 		/* Tools */
 		QMenu* menu = menubar->addMenu(tr("&Tools"));
-//		{
-//			/* Export anime list */
-//			QMenu* submenu = menu->addMenu(tr("&Export anime list"));
-//
-//			{
-//				/* Markdown export */
-//				QAction* action = submenu->addAction(tr("Export as &Markdown..."));
-//			}
-//
-//			{
-//				/* XML export */
-//				QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML..."));
-//			}
-//		}
-//		menu->addSeparator();
-//
-//		{
-//			QAction* action = menu->addAction(tr("Enable anime &recognition"));
-//			action->setCheckable(true);
-//		}
-//
-//		{
-//			QAction* action = menu->addAction(tr("Enable auto &sharing"));
-//			action->setCheckable(true);
-//		}
-//
-//		{
-//			QAction* action = menu->addAction(tr("Enable &auto synchronization"));
-//			action->setCheckable(true);
-//		}
-//
-//		menu->addSeparator();
+		//		{
+		//			/* Export anime list */
+		//			QMenu* submenu = menu->addMenu(tr("&Export anime list"));
+		//
+		//			{
+		//				/* Markdown export */
+		//				QAction* action = submenu->addAction(tr("Export as &Markdown..."));
+		//			}
+		//
+		//			{
+		//				/* XML export */
+		//				QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML..."));
+		//			}
+		//		}
+		//		menu->addSeparator();
+		//
+		//		{
+		//			QAction* action = menu->addAction(tr("Enable anime &recognition"));
+		//			action->setCheckable(true);
+		//		}
+		//
+		//		{
+		//			QAction* action = menu->addAction(tr("Enable auto &sharing"));
+		//			action->setCheckable(true);
+		//		}
+		//
+		//		{
+		//			QAction* action = menu->addAction(tr("Enable &auto synchronization"));
+		//			action->setCheckable(true);
+		//		}
+		//
+		//		menu->addSeparator();
 
 		{
 			QAction* action = menu->addAction(tr("&Settings"), [this] {
@@ -294,58 +290,44 @@
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("&Now Playing")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(0);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(0); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("&Anime List")));
 				action->setCheckable(true);
 				action->setChecked(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(1);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(1); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("&History")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(2);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(2); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("&Statistics")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(3);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(3); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("S&earch")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(4);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(4); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("Se&asons")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(5);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(5); });
 			}
 
 			{
 				QAction* action = pages_group->addAction(menu->addAction(tr("&Torrents")));
 				action->setCheckable(true);
-				connect(action, &QAction::toggled, this, [this] {
-					sidebar->SetCurrentItem(6);
-				});
+				connect(action, &QAction::toggled, this, [this] { sidebar->SetCurrentItem(6); });
 			}
 
 			/* pain in my ass */
@@ -364,9 +346,9 @@
 
 		menu->addSeparator();
 
-//		{
-//			QAction* action = menu->addAction(tr("Show sidebar"));
-//		}
+		//		{
+		//			QAction* action = menu->addAction(tr("Show sidebar"));
+		//		}
 	}
 
 	{
@@ -389,7 +371,7 @@
 	}
 	/* QMainWindow will delete the old one for us,
 	 * according to the docs
-	*/
+	 */
 	setMenuBar(menubar);
 
 	/* Toolbar */
@@ -410,9 +392,7 @@
 
 		{
 			QToolButton* button = new QToolButton(toolbar);
-			{
-				button->setMenu(folder_menu);
-			}
+			{ button->setMenu(folder_menu); }
 			button->setIcon(QIcon(":/icons/24x24/folder-open.png"));
 			button->setPopupMode(QToolButton::InstantPopup);
 			toolbar->addWidget(button);
@@ -424,29 +404,18 @@
 			{
 				/* links */
 				QMenu* menu = new QMenu(button);
-				menu->addAction("Hibari", []{
-					QDesktopServices::openUrl(QUrl("https://hb.wopian.me/"));
-				});
-				menu->addAction("MALgraph", []{
-					QDesktopServices::openUrl(QUrl("https://graph.anime.plus/"));
-				});
+				menu->addAction("Hibari", [] { QDesktopServices::openUrl(QUrl("https://hb.wopian.me/")); });
+				menu->addAction("MALgraph", [] { QDesktopServices::openUrl(QUrl("https://graph.anime.plus/")); });
 				menu->addSeparator();
-				menu->addAction("AniChart", []{
-					QDesktopServices::openUrl(QUrl("https://anichart.net/airing"));
-				});
-				menu->addAction("Monthly.moe", []{
-					QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly"));
-				});
-				menu->addAction("Senpai Anime Charts", []{
-					QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar"));
-				});
+				menu->addAction("AniChart", [] { QDesktopServices::openUrl(QUrl("https://anichart.net/airing")); });
+				menu->addAction("Monthly.moe",
+				                [] { QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly")); });
+				menu->addAction("Senpai Anime Charts",
+				                [] { QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar")); });
 				menu->addSeparator();
-				menu->addAction("Anime Streaming Search Engine", []{
-					QDesktopServices::openUrl(QUrl("https://because.moe/"));
-				});
-				menu->addAction("The Fansub Database", []{
-					QDesktopServices::openUrl(QUrl("https://fansubdb.com"));
-				});
+				menu->addAction("Anime Streaming Search Engine",
+				                [] { QDesktopServices::openUrl(QUrl("https://because.moe/")); });
+				menu->addAction("The Fansub Database", [] { QDesktopServices::openUrl(QUrl("https://fansubdb.com")); });
 
 				button->setMenu(menu);
 			}
@@ -477,14 +446,13 @@
 	std::size_t i = 0;
 	for (const auto& path : session.config.library.paths) {
 		const QString folder = Strings::ToQString(path);
-		QAction* action = folder_menu->addAction(folder, [folder]{
-			QDesktopServices::openUrl(QUrl::fromLocalFile(folder));
-		});
+		QAction* action =
+		    folder_menu->addAction(folder, [folder] { QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); });
 
 		if (i < 9) {
 			/* Qt::Key_1 is equivalent to 1 in ASCII, so we can use the same
 			 * stupid `'0' + i` trick here
-			*/
+			 */
 			action->setShortcut(QKeySequence(Qt::ALT | static_cast<Qt::Modifier>(Qt::Key_1 + i)));
 		} else if (i == 9) {
 			action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0));
@@ -496,11 +464,10 @@
 	folder_menu->addSeparator();
 
 	{
-		folder_menu->addAction(tr("&Add new folder..."), [this]{
-			const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
-																  QDir::homePath(),
-																  QFileDialog::ShowDirsOnly
-																  | QFileDialog::DontResolveSymlinks);
+		folder_menu->addAction(tr("&Add new folder..."), [this] {
+			const QString dir =
+			    QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(),
+			                                      QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
 			if (dir.isEmpty())
 				return;
 			session.config.library.paths.insert(Strings::ToUtf8String(dir));
@@ -549,12 +516,9 @@
 	if (event) { /* is this really necessary */
 		switch (event->type()) {
 			// this event is send if a translator is loaded
-			case QEvent::LanguageChange:
-				RetranslateUI();
-				break;
+			case QEvent::LanguageChange: RetranslateUI(); break;
 
-			default:
-				break;
+			default: break;
 		}
 	}
 	QMainWindow::changeEvent(event);