diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 6d7140f..5a30284 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -1,3 +1,27 @@ +/*************************************************************************** + * Copyright (C) 2006 David Faure * + * Copyright (C) 2008 Fredrik Höglund * + * Copyright (C) 2008 Rafael Fernández López * + * Copyright (C) 2011 Marco Martin * + * Copyright (C) 2014 by Eike Hein * + * Copyright (C) 2021 Reven Martin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + #include "foldermodel.h" #include "dirlister.h" diff --git a/model/foldermodel.h b/model/foldermodel.h index 405dc8e..9de7766 100644 --- a/model/foldermodel.h +++ b/model/foldermodel.h @@ -1,3 +1,27 @@ +/*************************************************************************** + * Copyright (C) 2006 David Faure * + * Copyright (C) 2008 Fredrik Höglund * + * Copyright (C) 2008 Rafael Fernández López * + * Copyright (C) 2011 Marco Martin * + * Copyright (C) 2014 by Eike Hein * + * Copyright (C) 2021 Reven Martin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + #ifndef FOLDERMODEL_H #define FOLDERMODEL_H diff --git a/model/pathbarmodel.cpp b/model/pathbarmodel.cpp index 7bb1878..7797167 100644 --- a/model/pathbarmodel.cpp +++ b/model/pathbarmodel.cpp @@ -41,7 +41,12 @@ void PathBarModel::setUrl(const QString &url) if (m_url != url) { beginResetModel(); - m_url = url; + QUrl _url = QUrl::fromUserInput(url); + if (_url.isValid() && !_url.toLocalFile().isEmpty()) { + m_url = _url.toLocalFile(); + } else { + m_url = url; + } qDeleteAll(m_pathList); m_pathList.clear(); @@ -53,7 +58,8 @@ void PathBarModel::setUrl(const QString &url) m_pathList.append(item); } else { QDir dir(m_url); - while (true) { + + do { if (dir.isRoot()) { PathBarItem *item = new PathBarItem; item->name = "/"; @@ -66,8 +72,7 @@ void PathBarModel::setUrl(const QString &url) item->name = dir.dirName(); item->url = QUrl::fromLocalFile(dir.absolutePath()); m_pathList.append(item); - dir.cdUp(); - } + } while (dir.cdUp()); } std::reverse(m_pathList.begin(), m_pathList.end()); diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index 65cd741..4ccc368 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -155,35 +155,43 @@ GridView { } } Keys.onUpPressed: { - var newIndex = positioner.nearestItem(currentIndex, - effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.UpArrow)) - if (newIndex !== -1) { - currentIndex = newIndex - updateSelection(event.modifiers) + if (!editor || !editor.targetItem) { + var newIndex = positioner.nearestItem(currentIndex, + effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.UpArrow)) + if (newIndex !== -1) { + currentIndex = newIndex + updateSelection(event.modifiers) + } } } Keys.onDownPressed: { - var newIndex = positioner.nearestItem(currentIndex, - effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.DownArrow)) - if (newIndex !== -1) { - currentIndex = newIndex - updateSelection(event.modifiers) + if (!editor || !editor.targetItem) { + var newIndex = positioner.nearestItem(currentIndex, + effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.DownArrow)) + if (newIndex !== -1) { + currentIndex = newIndex + updateSelection(event.modifiers) + } } } Keys.onLeftPressed: { - var newIndex = positioner.nearestItem(currentIndex, - effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.LeftArrow)) - if (newIndex !== -1) { - currentIndex = newIndex; - updateSelection(event.modifiers) + if (!editor || !editor.targetItem) { + var newIndex = positioner.nearestItem(currentIndex, + effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.LeftArrow)) + if (newIndex !== -1) { + currentIndex = newIndex; + updateSelection(event.modifiers) + } } } Keys.onRightPressed: { - var newIndex = positioner.nearestItem(currentIndex, - effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.RightArrow)) - if (newIndex !== -1) { - currentIndex = newIndex; - updateSelection(event.modifiers) + if (!editor || !editor.targetItem) { + var newIndex = positioner.nearestItem(currentIndex, + effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.RightArrow)) + if (newIndex !== -1) { + currentIndex = newIndex; + updateSelection(event.modifiers) + } } } diff --git a/qml/PathBar.qml b/qml/PathBar.qml index e74420a..f571302 100644 --- a/qml/PathBar.qml +++ b/qml/PathBar.qml @@ -79,7 +79,7 @@ Item { selectByMouse: true inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase - text: control.url + text: _pathBarModel.url color: FishUI.Theme.darkMode ? "white" : "black" background: Rectangle { @@ -116,7 +116,7 @@ Item { } function openEditor() { - _pathEditor.text = control.url + _pathEditor.text = _pathBarModel.url _pathEditor.visible = true _pathEditor.forceActiveFocus() _pathEditor.selectAll()