filebrowser-qt: unify various folder views#190
Merged
radioactiveman merged 1 commit intomasterfrom Oct 22, 2025
Merged
Conversation
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. |
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());
}
|
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
3d70905 to
e595409
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File browser functionality is currently divided into 3 different views:
I think we can unify these and keep the best features of all 3: