Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
225:56ea2bdc6724 | 226:f784b5b1914c |
---|---|
166 | 166 |
167 { | 167 { |
168 folder_menu = menu->addMenu(tr("&Library folders")); | 168 folder_menu = menu->addMenu(tr("&Library folders")); |
169 | 169 |
170 /* add in all of our existing folders... */ | 170 /* add in all of our existing folders... */ |
171 for (std::size_t i = 0; i < session.config.library.paths.size(); i++) { | 171 std::size_t i = 0; |
172 const QString folder = Strings::ToQString(session.config.library.paths[i]); | 172 for (const auto& path : session.config.library.paths) { |
173 const QString folder = Strings::ToQString(path); | |
173 QAction* action = folder_menu->addAction(folder, [folder]{ | 174 QAction* action = folder_menu->addAction(folder, [folder]{ |
174 QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); | 175 QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); |
175 }); | 176 }); |
176 if (i < 9) | 177 if (i < 9) |
177 action->setShortcut(QKeySequence(Qt::ALT | (Qt::Key_1 + i))); | 178 action->setShortcut(QKeySequence(Qt::ALT | (Qt::Key_1 + i++))); |
178 else if (i == 9) | 179 else if (i == 9) |
179 action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0)); | 180 action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0)); |
180 } | 181 } |
181 | 182 |
182 folder_menu->addSeparator(); | 183 folder_menu->addSeparator(); |
183 | 184 |
184 { | 185 { |
185 folder_menu->addAction(tr("&Add new folder..."), [this]{ | 186 folder_menu->addAction(tr("&Add new folder..."), [this]{ |
186 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), | 187 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), |
187 "/home", | 188 QDir::homePath(), |
188 QFileDialog::ShowDirsOnly | 189 QFileDialog::ShowDirsOnly |
189 | QFileDialog::DontResolveSymlinks); | 190 | QFileDialog::DontResolveSymlinks); |
190 if (dir.isEmpty()) | 191 if (dir.isEmpty()) |
191 return; | 192 return; |
192 session.config.library.paths.push_back(Strings::ToUtf8String(dir)); | 193 session.config.library.paths.insert(Strings::ToUtf8String(dir)); |
193 /* we have to recreate the menu bar to add the new folder */ | 194 /* we have to recreate the menu bar to add the new folder */ |
194 CreateBars(); | 195 CreateBars(); |
195 }); | 196 }); |
196 } | 197 } |
197 } | 198 } |