Fix pressing backspace
This commit is contained in:
parent
58357bbb37
commit
c7d09c918f
5 changed files with 87 additions and 26 deletions
|
@ -1,3 +1,27 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 David Faure <faure@kde.org> *
|
||||
* Copyright (C) 2008 Fredrik Höglund <fredrik@kde.org> *
|
||||
* Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org> *
|
||||
* Copyright (C) 2011 Marco Martin <mart@kde.org> *
|
||||
* Copyright (C) 2014 by Eike Hein <hein@kde.org> *
|
||||
* Copyright (C) 2021 Reven Martin <revenmartin@gmail.com> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 David Faure <faure@kde.org> *
|
||||
* Copyright (C) 2008 Fredrik Höglund <fredrik@kde.org> *
|
||||
* Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org> *
|
||||
* Copyright (C) 2011 Marco Martin <mart@kde.org> *
|
||||
* Copyright (C) 2014 by Eike Hein <hein@kde.org> *
|
||||
* Copyright (C) 2021 Reven Martin <revenmartin@gmail.com> *
|
||||
* *
|
||||
* 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
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue