Skip to content

Commit 51b2683

Browse files
author
Martin Rotter
committed
Switch current drive when browsing folders.
1 parent a8fecb2 commit 51b2683

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/saurus/plugin-system/filesystem/filesystemsidebar.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void FilesystemSidebar::reloadDrives() {
5151
});
5252

5353
for (const QStorageInfo& strg : storages) {
54-
QString name_drive = strg.rootPath();
54+
QString name_drive = QDir::toNativeSeparators(strg.rootPath());
5555

5656
if (!strg.name().isEmpty()) {
5757
name_drive += QString(" (%1)").arg(strg.name());
@@ -63,7 +63,7 @@ void FilesystemSidebar::reloadDrives() {
6363

6464
m_cmbDrives->addItem(!strg.isReady() ?
6565
qApp->icons()->fromTheme(QSL("lock")) :
66-
qApp->icons()->fromTheme(QSL("media-flash")), name_drive, strg.rootPath());
66+
qApp->icons()->fromTheme(QSL("media-flash")), name_drive, QDir::toNativeSeparators(strg.rootPath()));
6767
}
6868
}
6969

@@ -149,11 +149,9 @@ void FilesystemSidebar::load() {
149149
connect(m_fsView, &QListView::activated, this, &FilesystemSidebar::openFileFolder);
150150
connect(m_fsView, &FilesystemView::rootIndexChanged, this, [this](const QModelIndex& idx) {
151151
saveCurrentFolder(idx);
152-
});
153-
connect(m_lvFavorites, &QListWidget::activated, this, &FilesystemSidebar::openFavoriteItem);
154-
connect(m_fsView, &FilesystemView::rootIndexChanged, this, [this]() {
155152
m_fsView->setFocus();
156153
});
154+
connect(m_lvFavorites, &QListWidget::activated, this, &FilesystemSidebar::openFavoriteItem);
157155

158156
QStringList saved_files = qApp->settings()->value(m_settingsSection, QSL("favorites"), QStringList()).toStringList();
159157

@@ -180,6 +178,13 @@ void FilesystemSidebar::load() {
180178
void FilesystemSidebar::saveCurrentFolder(const QString& path) {
181179
m_txtPath->setPlainText(path);
182180
m_txtPath->setToolTip(path);
181+
182+
int index_drive = m_cmbDrives->findData(QDir::toNativeSeparators(QStorageInfo(path).rootPath()));
183+
184+
m_cmbDrives->blockSignals(true);
185+
m_cmbDrives->setCurrentIndex(index_drive);
186+
m_cmbDrives->blockSignals(false);
187+
183188
qApp->settings()->setValue(m_settingsSection, QL1S("current_folder_") + OS_ID_LOW, path);
184189
}
185190

src/saurus/plugin-system/filesystem/filesystemview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ QString FilesystemView::normalizePath(const QString& path) const {
3131
}
3232

3333
QString FilesystemView::currentFolder() const {
34-
return m_model->filePath(rootIndex());
34+
return QDir::toNativeSeparators(m_model->filePath(rootIndex()));
3535
}
3636

3737
QString FilesystemView::selectedFileFolder() const {

0 commit comments

Comments
 (0)