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 "foldermodel.h"
|
||||||
#include "dirlister.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
|
#ifndef FOLDERMODEL_H
|
||||||
#define FOLDERMODEL_H
|
#define FOLDERMODEL_H
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,12 @@ void PathBarModel::setUrl(const QString &url)
|
||||||
if (m_url != url) {
|
if (m_url != url) {
|
||||||
beginResetModel();
|
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);
|
qDeleteAll(m_pathList);
|
||||||
m_pathList.clear();
|
m_pathList.clear();
|
||||||
|
@ -53,7 +58,8 @@ void PathBarModel::setUrl(const QString &url)
|
||||||
m_pathList.append(item);
|
m_pathList.append(item);
|
||||||
} else {
|
} else {
|
||||||
QDir dir(m_url);
|
QDir dir(m_url);
|
||||||
while (true) {
|
|
||||||
|
do {
|
||||||
if (dir.isRoot()) {
|
if (dir.isRoot()) {
|
||||||
PathBarItem *item = new PathBarItem;
|
PathBarItem *item = new PathBarItem;
|
||||||
item->name = "/";
|
item->name = "/";
|
||||||
|
@ -66,8 +72,7 @@ void PathBarModel::setUrl(const QString &url)
|
||||||
item->name = dir.dirName();
|
item->name = dir.dirName();
|
||||||
item->url = QUrl::fromLocalFile(dir.absolutePath());
|
item->url = QUrl::fromLocalFile(dir.absolutePath());
|
||||||
m_pathList.append(item);
|
m_pathList.append(item);
|
||||||
dir.cdUp();
|
} while (dir.cdUp());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::reverse(m_pathList.begin(), m_pathList.end());
|
std::reverse(m_pathList.begin(), m_pathList.end());
|
||||||
|
|
|
@ -155,35 +155,43 @@ GridView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onUpPressed: {
|
Keys.onUpPressed: {
|
||||||
var newIndex = positioner.nearestItem(currentIndex,
|
if (!editor || !editor.targetItem) {
|
||||||
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.UpArrow))
|
var newIndex = positioner.nearestItem(currentIndex,
|
||||||
if (newIndex !== -1) {
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.UpArrow))
|
||||||
currentIndex = newIndex
|
if (newIndex !== -1) {
|
||||||
updateSelection(event.modifiers)
|
currentIndex = newIndex
|
||||||
|
updateSelection(event.modifiers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onDownPressed: {
|
Keys.onDownPressed: {
|
||||||
var newIndex = positioner.nearestItem(currentIndex,
|
if (!editor || !editor.targetItem) {
|
||||||
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.DownArrow))
|
var newIndex = positioner.nearestItem(currentIndex,
|
||||||
if (newIndex !== -1) {
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.DownArrow))
|
||||||
currentIndex = newIndex
|
if (newIndex !== -1) {
|
||||||
updateSelection(event.modifiers)
|
currentIndex = newIndex
|
||||||
|
updateSelection(event.modifiers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onLeftPressed: {
|
Keys.onLeftPressed: {
|
||||||
var newIndex = positioner.nearestItem(currentIndex,
|
if (!editor || !editor.targetItem) {
|
||||||
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.LeftArrow))
|
var newIndex = positioner.nearestItem(currentIndex,
|
||||||
if (newIndex !== -1) {
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.LeftArrow))
|
||||||
currentIndex = newIndex;
|
if (newIndex !== -1) {
|
||||||
updateSelection(event.modifiers)
|
currentIndex = newIndex;
|
||||||
|
updateSelection(event.modifiers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onRightPressed: {
|
Keys.onRightPressed: {
|
||||||
var newIndex = positioner.nearestItem(currentIndex,
|
if (!editor || !editor.targetItem) {
|
||||||
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.RightArrow))
|
var newIndex = positioner.nearestItem(currentIndex,
|
||||||
if (newIndex !== -1) {
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.RightArrow))
|
||||||
currentIndex = newIndex;
|
if (newIndex !== -1) {
|
||||||
updateSelection(event.modifiers)
|
currentIndex = newIndex;
|
||||||
|
updateSelection(event.modifiers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ Item {
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
|
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
|
||||||
|
|
||||||
text: control.url
|
text: _pathBarModel.url
|
||||||
color: FishUI.Theme.darkMode ? "white" : "black"
|
color: FishUI.Theme.darkMode ? "white" : "black"
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -116,7 +116,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEditor() {
|
function openEditor() {
|
||||||
_pathEditor.text = control.url
|
_pathEditor.text = _pathBarModel.url
|
||||||
_pathEditor.visible = true
|
_pathEditor.visible = true
|
||||||
_pathEditor.forceActiveFocus()
|
_pathEditor.forceActiveFocus()
|
||||||
_pathEditor.selectAll()
|
_pathEditor.selectAll()
|
||||||
|
|
Loading…
Reference in a new issue