|
14 | 14 | #include <QResource> |
15 | 15 | #include <QUiLoader> |
16 | 16 | #include <QVBoxLayout> |
| 17 | +#include <qtreeview.h> |
17 | 18 |
|
18 | 19 | AOOptionsDialog::AOOptionsDialog(AOApplication *p_ao_app, QWidget *parent) |
19 | 20 | : QDialog(parent) |
@@ -445,20 +446,39 @@ void AOOptionsDialog::setupUI() |
445 | 446 |
|
446 | 447 | FROM_UI(QPushButton, mount_add); |
447 | 448 | connect(ui_mount_add, &QPushButton::clicked, this, [this] { |
448 | | - QString path = QFileDialog::getExistingDirectory(this, tr("Select a base folder"), get_app_path(), QFileDialog::ShowDirsOnly); |
449 | | - if (path.isEmpty()) |
| 449 | + // QString path = QFileDialog::getExistingDirectory(this, tr("Select one or more base folders"), get_app_path(), QFileDialog::ShowDirsOnly); |
| 450 | + |
| 451 | + QFileDialog* _fileddialogue = new QFileDialog(this); |
| 452 | + _fileddialogue->setFileMode(QFileDialog::Directory); |
| 453 | + //Switches to non-native so the tree is obtainable, otherwise it will crash on varying platforms probably. |
| 454 | + _fileddialogue->setOption(QFileDialog::DontUseNativeDialog, true); |
| 455 | + _fileddialogue->findChild<QTreeView*>("treeView")->setSelectionMode(QAbstractItemView::MultiSelection); |
| 456 | + |
| 457 | + _fileddialogue->exec(); |
| 458 | + QStringList _filepaths = _fileddialogue->selectedFiles(); |
| 459 | + // qInfo() <<"Paths are " << _filepaths; |
| 460 | + |
| 461 | + if (_filepaths.isEmpty()) |
450 | 462 | { |
451 | 463 | return; |
452 | 464 | } |
453 | | - QDir dir(get_app_path()); |
454 | | - QString relative = dir.relativeFilePath(path); |
455 | | - if (!relative.contains("../")) |
456 | | - { |
457 | | - path = relative; |
| 465 | + |
| 466 | + foreach(QString mountPath, _filepaths) { |
| 467 | + if (_filepaths.indexOf(mountPath) == 0) { |
| 468 | + continue; |
| 469 | + } |
| 470 | + QDir dir(get_app_path()); |
| 471 | + QString relative = dir.relativeFilePath(mountPath); |
| 472 | + if (!relative.contains("../")) |
| 473 | + { |
| 474 | + mountPath = relative; |
| 475 | + } |
| 476 | + QListWidgetItem *dir_item = new QListWidgetItem(mountPath); |
| 477 | + ui_mount_list->addItem(dir_item); |
| 478 | + ui_mount_list->setCurrentItem(dir_item); |
458 | 479 | } |
459 | | - QListWidgetItem *dir_item = new QListWidgetItem(path); |
460 | | - ui_mount_list->addItem(dir_item); |
461 | | - ui_mount_list->setCurrentItem(dir_item); |
| 480 | + |
| 481 | + |
462 | 482 |
|
463 | 483 | // quick hack to update buttons |
464 | 484 | Q_EMIT ui_mount_list->itemSelectionChanged(); |
|
0 commit comments