Skip to content

filebrowser-qt: unify various folder views#190

Merged
radioactiveman merged 1 commit intomasterfrom
unified-filebrowser
Oct 22, 2025
Merged

filebrowser-qt: unify various folder views#190
radioactiveman merged 1 commit intomasterfrom
unified-filebrowser

Conversation

@jlindgren90
Copy link
Member

File browser functionality is currently divided into 3 different views:

  • default (folder) view
  • optional tree view mode
  • "Change Music Folder" dialog

I think we can unify these and keep the best features of all 3:

  • always show inline expander arrows as in tree view mode
  • but still changing base folder via double-click as in default mode
  • add a small toolbar (always shown) with "up" button & search entry
  • then remove the now-redundant "Change Music Folder" dialog

@jlindgren90
Copy link
Member Author

@radioactiveman please consider this. It's up to you, but I think it makes the UI significantly less awkward (no need to switch between the 3 different views) and doesn't lose any functionality.

@radioactiveman
Copy link
Member

Removing the Non-TreeView-Mode allows some more cleanups. Combined with minor style adjustments I'm fine with merging it.

diff --git a/src/filebrowser-qt/filebrowser-qt.cc b/src/filebrowser-qt/filebrowser-qt.cc
index c55ca10c4..5ec76cc73 100644
--- a/src/filebrowser-qt/filebrowser-qt.cc
+++ b/src/filebrowser-qt/filebrowser-qt.cc
@@ -138,13 +138,14 @@ FileBrowserWidget::FileBrowserWidget()
     m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
     m_filterLineEdit = new QLineEdit(this);
-    m_filterLineEdit->setContentsMargins(5, 5, 5, 5);
+    m_filterLineEdit->setContentsMargins(0, 5, 5, 5);
     m_filterLineEdit->setClearButtonEnabled(true);
 
     m_fileSystemModel = new QFileSystemModel(this);
     m_fileSystemModel->setNameFilterDisables(false);
     m_fileSystemModel->setNameFilters(supportedFileExtensions());
-    m_fileSystemModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDot | QDir::NoDotDot);
+    m_fileSystemModel->setFilter(QDir::AllDirs | QDir::Files |
+                                 QDir::NoDotAndDotDot);
 
     m_proxyModel = new FileSystemFilterProxyModel(this);
     m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
@@ -159,13 +160,8 @@ FileBrowserWidget::FileBrowserWidget()
     m_treeView->header()->setStretchLastSection(false);
     m_treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
 
-    auto upAction = new QAction(QIcon::fromTheme("go-up"), QString(), this);
-    connect(upAction, &QAction::triggered, [this]() {
-        auto dir = m_fileSystemModel->rootDirectory();
-        if (dir.cdUp())
-            setCurrentDirectory(dir.path());
-    });
-
+    auto upAction = new QAction(QIcon::fromTheme("go-up"),
+                                QString(_("Show the parent folder")), this);
     m_upButton = new QToolButton(this);
     m_upButton->setAutoRaise(true);
     m_upButton->setDefaultAction(upAction);
@@ -189,6 +185,12 @@ FileBrowserWidget::FileBrowserWidget()
                 m_proxyModel->setFilterFixedString(text);
             });
 
+    connect(upAction, &QAction::triggered, [this]() {
+        QDir dir = m_fileSystemModel->rootDirectory();
+        if (dir.cdUp())
+            setCurrentDirectory(dir.path());
+    });
+
     initMusicDirectory();
 }
 
@@ -325,10 +327,6 @@ QStringList FileBrowserWidget::selectedPaths() const
             continue;
 
         QModelIndex sourceIndex = m_proxyModel->mapToSource(index);
-        QString name = m_fileSystemModel->fileName(sourceIndex);
-        if (name == QLatin1String(".."))
-            continue;
-
         paths << m_fileSystemModel->filePath(sourceIndex);
     }
 
@@ -369,23 +367,20 @@ void FileBrowserWidget::setCurrentDirectory(const QString & path)
     if (!info.isDir() || !info.isExecutable() || !info.isReadable())
         return;
 
-    m_upButton->setEnabled(!info.isRoot());
-
     QModelIndex index = m_fileSystemModel->setRootPath(path);
     if (!index.isValid())
         return;
 
+    m_upButton->setEnabled(!info.isRoot());
     m_treeView->setRootIndex(m_proxyModel->mapFromSource(index));
 
-    QDir root = m_fileSystemModel->rootDirectory();
-    QString cleanPath = root.canonicalPath();
-    QString dirName = root.dirName();
+    QString dirName = info.baseName();
+    QString cleanPath = m_fileSystemModel->rootDirectory().canonicalPath();
 
     m_filterLineEdit->clear();
     m_filterLineEdit->setPlaceholderText(
-        dirName.isEmpty() || dirName == QLatin1String("..")
-            ? QString(_("Search"))
-            : QString(_("Search in %1")).arg(dirName));
+        dirName.isEmpty() ? QString(_("Search"))
+                          : QString(_("Search in %1")).arg(dirName));
 
     aud_set_str(CFG_ID, CFG_FILE_PATH, cleanPath.toUtf8().constData());
 }

@jlindgren90
Copy link
Member Author

Sounds good, feel free to go ahead and merge with the suggested changes, or I can, either way

File browser functionality is currently divided into 3 different views:

- default (folder) view
- optional tree view mode
- "Change Music Folder" dialog

I think we can unify these and keep the best features of all 3:

- always show inline expander arrows as in tree view mode
- but still changing base folder via double-click as in default mode
- add a small toolbar (always shown) with "up" button & search entry
- then remove the now-redundant "Change Music Folder" dialog
@radioactiveman radioactiveman merged commit cf6ff77 into master Oct 22, 2025
9 checks passed
@radioactiveman radioactiveman deleted the unified-filebrowser branch October 22, 2025 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments