fix: xdg folders rename
This commit is contained in:
parent
3a062c3792
commit
5c450d527a
4 changed files with 27 additions and 3 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "filepropertiesdialog.h"
|
#include "filepropertiesdialog.h"
|
||||||
#include "../desktopiconprovider.h"
|
#include "../desktopiconprovider.h"
|
||||||
|
#include "../helper/fm.h"
|
||||||
|
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
@ -97,7 +98,7 @@ void FilePropertiesDialog::accept(const QString &text)
|
||||||
if (fileName() != newFileName) {
|
if (fileName() != newFileName) {
|
||||||
QUrl newUrl;
|
QUrl newUrl;
|
||||||
|
|
||||||
if (!location().isEmpty()) {
|
if (!location().isEmpty() && !Fm::isFixedFolder(m_items.first().url())) {
|
||||||
newUrl = location();
|
newUrl = location();
|
||||||
newUrl.setPath(concatPaths(newUrl.path(), newFileName));
|
newUrl.setPath(concatPaths(newUrl.path(), newFileName));
|
||||||
newUrl.setScheme(item.url().scheme());
|
newUrl.setScheme(item.url().scheme());
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <KIO/EmptyTrashJob>
|
#include <KIO/EmptyTrashJob>
|
||||||
|
|
||||||
Fm::Fm(QObject *parent) : QObject(parent)
|
Fm::Fm(QObject *parent) : QObject(parent)
|
||||||
|
@ -36,3 +39,16 @@ void Fm::emptyTrash()
|
||||||
KIO::Job *job = KIO::emptyTrash();
|
KIO::Job *job = KIO::emptyTrash();
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Fm::isFixedFolder(const QUrl &folderUrl)
|
||||||
|
{
|
||||||
|
const QString folder = folderUrl.toLocalFile();
|
||||||
|
|
||||||
|
return folder == QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::DesktopLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first() ||
|
||||||
|
folder == QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first();
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QString rootPath();
|
Q_INVOKABLE QString rootPath();
|
||||||
Q_INVOKABLE static void emptyTrash();
|
Q_INVOKABLE static void emptyTrash();
|
||||||
|
static bool isFixedFolder(const QUrl &folderUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FM_H
|
#endif // FM_H
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "../helper/datehelper.h"
|
#include "../helper/datehelper.h"
|
||||||
#include "../helper/filelauncher.h"
|
#include "../helper/filelauncher.h"
|
||||||
|
#include "../helper/fm.h"
|
||||||
|
|
||||||
#include "../cio/cfilesizejob.h"
|
#include "../cio/cfilesizejob.h"
|
||||||
|
|
||||||
|
@ -86,7 +87,6 @@ static bool isDropBetweenSharedViews(const QList<QUrl> &urls, const QUrl &folder
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FolderModel::FolderModel(QObject *parent)
|
FolderModel::FolderModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
, m_dirWatch(nullptr)
|
, m_dirWatch(nullptr)
|
||||||
|
@ -1231,6 +1231,12 @@ void FolderModel::drop(QQuickItem *target, QObject *dropEvent, int row)
|
||||||
if (!isDropBetweenSharedViews(mimeData->urls(), dropTargetFolderUrl)) {
|
if (!isDropBetweenSharedViews(mimeData->urls(), dropTargetFolderUrl)) {
|
||||||
KIO::Job *job = KIO::move(mimeData->urls(), dropTargetUrl, KIO::HideProgressInfo);
|
KIO::Job *job = KIO::move(mimeData->urls(), dropTargetUrl, KIO::HideProgressInfo);
|
||||||
job->start();
|
job->start();
|
||||||
|
|
||||||
|
// Add select
|
||||||
|
for (QUrl url : mimeData->urls()) {
|
||||||
|
m_needSelectUrls.append(QUrl::fromLocalFile(QString("%1/%2").arg(rootItem().url().toLocalFile())
|
||||||
|
.arg(url.fileName())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,7 +1926,7 @@ void FolderModel::updateActions()
|
||||||
|
|
||||||
if (QAction *rename = m_actionCollection.action(QStringLiteral("rename"))) {
|
if (QAction *rename = m_actionCollection.action(QStringLiteral("rename"))) {
|
||||||
rename->setEnabled(itemProperties.supportsMoving());
|
rename->setEnabled(itemProperties.supportsMoving());
|
||||||
rename->setVisible(!isTrash);
|
rename->setVisible(!isTrash && !Fm::isFixedFolder(items.first().url()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QAction *trash = m_actionCollection.action("trash")) {
|
if (QAction *trash = m_actionCollection.action("trash")) {
|
||||||
|
|
Loading…
Reference in a new issue