diff src/gui/window.cc @ 226:f784b5b1914c

settings: add library page
author Paper <mrpapersonic@gmail.com>
date Mon, 08 Jan 2024 21:23:00 -0500
parents 84e0a3c4737a
children d030b30526d5
line wrap: on
line diff
--- a/src/gui/window.cc	Mon Jan 08 17:07:01 2024 -0500
+++ b/src/gui/window.cc	Mon Jan 08 21:23:00 2024 -0500
@@ -168,13 +168,14 @@
 			folder_menu = menu->addMenu(tr("&Library folders"));
 
 			/* add in all of our existing folders... */
-			for (std::size_t i = 0; i < session.config.library.paths.size(); i++) {
-				const QString folder = Strings::ToQString(session.config.library.paths[i]);
+			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));
 				});
 				if (i < 9)
-					action->setShortcut(QKeySequence(Qt::ALT | (Qt::Key_1 + i)));
+					action->setShortcut(QKeySequence(Qt::ALT | (Qt::Key_1 + i++)));
 				else if (i == 9)
 					action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0));
 			}
@@ -184,12 +185,12 @@
 			{
 				folder_menu->addAction(tr("&Add new folder..."), [this]{
 					const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
-																		  "/home",
+																		  QDir::homePath(),
 																		  QFileDialog::ShowDirsOnly
 																		  | QFileDialog::DontResolveSymlinks);
 					if (dir.isEmpty())
 						return;
-					session.config.library.paths.push_back(Strings::ToUtf8String(dir));
+					session.config.library.paths.insert(Strings::ToUtf8String(dir));
 					/* we have to recreate the menu bar to add the new folder */
 					CreateBars();
 				});