Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs #2478

Merged
merged 7 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/scripts/dfm-dlnfs-automount
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ if [ "$dlnfs_enable" == "true" ]; then

# do dlnfs mount for $abs_path.
gdbus call -y \
-d com.deepin.filemanager.daemon \
-o /com/deepin/filemanager/daemon/MountControl \
-m com.deepin.filemanager.daemon.MountControl.Mount \
-d org.deepin.Filemanager.MountControl \
-o /org/deepin/Filemanager/MountControl \
-m org.deepin.Filemanager.MountControl.Mount \
"${abs_path}" \
"{'fsType': <'dlnfs'>}" \
-t 1
Expand Down
11 changes: 3 additions & 8 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Depends:
libqt6sql6-sqlite,
qt6-translations-l10n,
libimageeditor6 | hello
Conflicts: dde-workspace (<< 2.90.5), dde-file-manager-oem, dde-desktop-plugins
Conflicts: dde-workspace (<< 2.90.5), dde-file-manager-oem
Replaces: dde-file-manager-oem, dde-file-manager (<< 6.0.1), dde-desktop-plugins
Recommends: qt5dxcb-plugin, deepin-screensaver, dcc-wallpapersetting-plugin
Description: deepin desktop-environment - desktop module
Expand Down Expand Up @@ -109,11 +109,6 @@ Replaces: dde-file-manager-oem, dde-desktop (<< 6.0.1),
dde-file-manager-plugins,
dde-file-manager-daemon-plugins,
dde-file-manager-common-plugins
Conflicts: dde-file-manager-preview,
dde-file-manager-preview-plugins,
dde-file-manager-plugins,
dde-file-manager-daemon-plugins,
dde-file-manager-common-plugins
Recommends: dde-qt5integration, avfs, samba, deepin-anything-server
Description: File manager front end
File manager front-end of Deepin OS
Expand All @@ -126,12 +121,12 @@ Depends:
libpoppler-cpp0v5 (>= 0.48.0),
gvfs-backends (>=1.27.3),
cryptsetup,
libdfm-extension (=${binary:Version})
libdfm-extension (=${binary:Version}),
dlnfs | hello
Multi-Arch: same
Description: DDE File Manager core librarys
This package contains the shared libraries.
Replaces: dfmplugin-disk-encrypt
Conflicts: dfmplugin-disk-encrypt

Package: dde-disk-mount-plugin
Architecture: any
Expand Down
6 changes: 3 additions & 3 deletions src/dfm-base/utils/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ bool FileUtils::isSameFile(const QUrl &url1, const QUrl &url2, const Global::Cre
return isSameFile(path1, path2);
}

bool FileUtils::isSameFile(const QString &path1, const QString &path2)
bool FileUtils::isSameFile(const QString &path1, const QString &path2)
{
struct stat stat1;
struct stat stat2;
Expand All @@ -372,7 +372,7 @@ bool FileUtils::isSameFile(const QString &path1, const QString &path2)
if (0 == ret1 && 0 == ret2) {
// 通过inode判断是否是同一个文件
return (stat1.st_ino == stat2.st_ino
&& stat1.st_dev == stat2.st_dev); //! 需要判断设备号
&& stat1.st_dev == stat2.st_dev); //! 需要判断设备号
}

return false;
Expand Down Expand Up @@ -1333,7 +1333,7 @@ bool FileUtils::fileCanTrash(const QUrl &url)
// 获取当前配置
bool alltotrash = DConfigManager::instance()->value(kDefaultCfgPath, kFileAllTrash).toBool();
if (!alltotrash)
return info ? info->extendAttributes(ExtInfoType::kFileLocalDevice).toBool() : isLocalDevice(url);
return info ? info->canAttributes(CanableInfoType::kCanTrash) : false;
if (!url.isValid())
return false;

Expand Down
41 changes: 39 additions & 2 deletions src/dfm-base/utils/systempathutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool SystemPathUtil::checkContainsSystemPathByFileInfo(const QList<QUrl> &urlLis

bool SystemPathUtil::checkContainsSystemPathByFileUrl(const QList<QUrl> &urlList)
{
return std::any_of(urlList.begin(), urlList.end(),[this](const QUrl &url){
return std::any_of(urlList.begin(), urlList.end(), [this](const QUrl &url) {
return isSystemPath(url.path());
});
}
Expand All @@ -169,7 +169,7 @@ QString SystemPathUtil::findSystemPathKey(const QString &path) const

if (targetPath.endsWith(sysPath))
return FileUtils::isSameFile(targetPath, sysPath);

return false;
});

Expand Down Expand Up @@ -202,3 +202,40 @@ void SystemPathUtil::loadSystemPaths()
mkPath(path);
}
}

QList<QUrl> SystemPathUtil::canonicalUrlList(const QList<QUrl> &urls)
{
QList<QUrl> processedUrls;
processedUrls.reserve(urls.size());

for (const QUrl &url : urls) {
if (!url.isLocalFile()) {
processedUrls << url;
continue;
}

auto info = InfoFactory::create<FileInfo>(url);
if (!info) {
processedUrls << url;
continue;
}

// 如果是符号链接文件
if (info->isAttributes(OptInfoType::kIsSymLink)) {
// 获取链接文件所在目录的真实路径
QString parentPath = QFileInfo(url.path()).dir().canonicalPath();
// 获取链接文件的名称
QString fileName = QFileInfo(url.path()).fileName();
// 组合出正确的路径
QString realLinkPath = parentPath + "/" + fileName;
processedUrls << QUrl::fromLocalFile(realLinkPath);
continue;
}

// 非符号链接使用canonicalFilePath
const QString canonicalPath = QFileInfo(url.path()).canonicalFilePath();
processedUrls << (canonicalPath.isEmpty() ? url : QUrl::fromLocalFile(canonicalPath));
}

return processedUrls;
}
3 changes: 3 additions & 0 deletions src/dfm-base/utils/systempathutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class SystemPathUtil final : public QObject
bool isSystemPath(QString path) const;
bool checkContainsSystemPath(const QList<QUrl> &urlList);

// 将URL列表转换为规范路径,保持符号链接的原始路径
static QList<QUrl> canonicalUrlList(const QList<QUrl> &urls);

private:
explicit SystemPathUtil(QObject *parent = nullptr);
~SystemPathUtil();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,27 @@ JobHandlePointer TrashFileEventReceiver::doMoveToTrash(const quint64 windowId, c
return nullptr;
}

const QUrl &sourceFirst = sources.first();
// gio can only handle canonical file paths
QList<QUrl> processedSources = SystemPathUtil::canonicalUrlList(sources);
const QUrl &sourceFirst = processedSources.first();
JobHandlePointer handle = nullptr;
bool nullDirDelete = false;
if (sources.count() == 1) {
if (processedSources.count() == 1) {
auto info = InfoFactory::create<FileInfo>(sourceFirst);
nullDirDelete = info && info->isAttributes(OptInfoType::kIsDir)
&& !info->isAttributes(OptInfoType::kIsSymLink)
&& !info->isAttributes(OptInfoType::kIsWritable);
}
const auto &sourceInfo = InfoFactory::create<FileInfo>(sourceFirst);
bool canTrash = false;
auto filesource = FileUtils::bindUrlTransform(sourceFirst);
if (sourceInfo)
canTrash = sourceInfo->isAttributes(OptInfoType::kIsSymLink)
&& filesource.path().startsWith(StandardPaths::location(StandardPaths::StandardLocation::kHomePath));
if (nullDirDelete || !FileUtils::fileCanTrash(sourceFirst) ||
(!dfmio::DFMUtils::supportTrash(sourceFirst) && !canTrash)) {
if (DialogManagerInstance->showDeleteFilesDialog(sources, true) != QDialog::Accepted)

if (nullDirDelete || !FileUtils::fileCanTrash(sourceFirst)) {
if (DialogManagerInstance->showDeleteFilesDialog(processedSources, true) != QDialog::Accepted)
return nullptr;
handle = copyMoveJob->deletes(sources, flags, isInit);
handle = copyMoveJob->deletes(processedSources, flags, isInit);
if (!isInit)
return handle;
} else {
// check url permission
QList<QUrl> urlsCanTrash = sources;
QList<QUrl> urlsCanTrash = processedSources;
if (!flags.testFlag(AbstractJobHandler::JobFlag::kRevocation) && Application::instance()->genericAttribute(Application::kShowDeleteConfirmDialog).toBool()) {
if (DialogManagerInstance->showNormalDeleteConfirmDialog(urlsCanTrash) != QDialog::Accepted)
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QVBoxLayout>
#include <QFrame>
#include <QScreen>
#include <QTimer>

DWIDGET_USE_NAMESPACE
DFMBASE_USE_NAMESPACE
Expand Down Expand Up @@ -68,16 +69,23 @@ void FilePropertyDialog::initInfoUI()
scrollArea->viewport()->setPalette(palette);
scrollArea->setFrameShape(QFrame::Shape::NoFrame);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

QFrame *mainWidget = new QFrame(this);
mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
mainWidget->setMaximumWidth(kDialogWidth);

QVBoxLayout *scrollWidgetLayout = new QVBoxLayout;
scrollWidgetLayout->setContentsMargins(10, 0, 10, 10);
scrollWidgetLayout->setSpacing(kArrowExpandSpacing);
mainWidget->setLayout(scrollWidgetLayout);

scrollArea->setWidget(mainWidget);

scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
scrollArea->setMaximumWidth(kDialogWidth);

QVBoxLayout *vlayout1 = new QVBoxLayout;
vlayout1->addWidget(scrollArea);
vlayout1->setContentsMargins(0, 0, 0, 0);
Expand Down Expand Up @@ -123,7 +131,6 @@ void FilePropertyDialog::createPermissionManagerWidget(const QUrl &url)
QVBoxLayout *vlayout = qobject_cast<QVBoxLayout *>(scrollArea->widget()->layout());
if (vlayout) {
insertExtendedControl(vlayout->count(), permissionManagerWidget);
vlayout->addStretch();
}
}

Expand Down Expand Up @@ -232,16 +239,23 @@ void FilePropertyDialog::processHeight(int height)
Q_UNUSED(height)

QRect rect = geometry();
if (WindowUtils::isWayLand()) {
int logicHeight = contentHeight() + kArrowExpandSpacing;
int screenHeight = WindowUtils::cursorScreen()->availableSize().height();
int realHeight = logicHeight > screenHeight ? screenHeight : logicHeight;
rect.setHeight(realHeight);
} else {
rect.setHeight(contentHeight() + kArrowExpandSpacing);
}
int screenHeight = WindowUtils::cursorScreen()->availableSize().height();
screenHeight -= 100;

int contentH = contentHeight() + kArrowExpandSpacing;
int maxHeight = qMin(contentH, screenHeight);
rect.setHeight(maxHeight);
setGeometry(rect);

if (scrollArea) {
QWidget *content = scrollArea->widget();
if (content) {
content->setMinimumHeight(0);
content->adjustSize();
content->updateGeometry();
}
scrollArea->updateGeometry();
}
}

void FilePropertyDialog::insertExtendedControl(int index, QWidget *widget)
Expand Down Expand Up @@ -300,6 +314,22 @@ void FilePropertyDialog::resizeEvent(QResizeEvent *event)
void FilePropertyDialog::showEvent(QShowEvent *event)
{
DDialog::showEvent(event);

QVBoxLayout *vlayout = qobject_cast<QVBoxLayout *>(scrollArea->widget()->layout());
if (vlayout) {
if (vlayout->count() > 0) {
QLayoutItem *item = vlayout->itemAt(vlayout->count() - 1);
if (item && item->spacerItem()) {
vlayout->removeItem(item);
delete item;
}
}
vlayout->addStretch();
}

QTimer::singleShot(0, this, [this]() {
processHeight(contentHeight());
});
}

void FilePropertyDialog::closeEvent(QCloseEvent *event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,11 @@ bool AppendCompressHelper::dragDropCompress(const QUrl &toUrl, const QList<QUrl>

bool AppendCompressHelper::appendCompress(const QString &toFilePath, const QStringList &fromFilePaths)
{
QStringList arguments;
QString cmd = "deepin-compressor";
#ifdef COMPILE_ON_V2X
cmd = "ll-cli";
arguments << "run";
arguments << "org.deepin.compressor";
arguments << "--exec";
arguments << "deepin-compressor";
#endif
arguments << toFilePath;
QStringList arguments { toFilePath };
arguments << fromFilePaths;
arguments << "dragdropadd";
return QProcess::startDetached(cmd, arguments);

return QProcess::startDetached("deepin-compressor", arguments);
}

bool AppendCompressHelper::canAppendCompress(const QList<QUrl> &fromUrls, const QUrl &toUrl)
Expand Down
Loading