diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index d052262..55ea42c 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -1296,8 +1296,14 @@ void FolderModel::openDeleteDialog() view->show(); } -void FolderModel::openInNewWindow() +void FolderModel::openInNewWindow(const QString &url) { + if (!url.isEmpty()) { + QProcess::startDetached("cutefish-filemanager", QStringList() << url); + return; + } + + // url 为空则打开已选择的 items. if (!m_selectionModel->hasSelection()) return; @@ -1642,7 +1648,7 @@ void FolderModel::createActions() }); QAction *openInNewWindow = new QAction(tr("Open in new window"), this); - QObject::connect(openInNewWindow, &QAction::triggered, this, &FolderModel::openInNewWindow); + QObject::connect(openInNewWindow, &QAction::triggered, this, [=] { this->openInNewWindow(); }); m_actionCollection.addAction(QStringLiteral("open"), open); m_actionCollection.addAction(QStringLiteral("openWith"), openWith); diff --git a/model/foldermodel.h b/model/foldermodel.h index 8b0f4f2..7877075 100644 --- a/model/foldermodel.h +++ b/model/foldermodel.h @@ -207,7 +207,7 @@ public: Q_INVOKABLE void openInTerminal(); Q_INVOKABLE void openChangeWallpaperDialog(); Q_INVOKABLE void openDeleteDialog(); - Q_INVOKABLE void openInNewWindow(); + Q_INVOKABLE void openInNewWindow(const QString &url = QString()); Q_INVOKABLE void updateSelectedItemsSize(); Q_INVOKABLE void keyboardSearch(const QString &text); diff --git a/qml/SideBar.qml b/qml/SideBar.qml index d47419b..4d566ba 100644 --- a/qml/SideBar.qml +++ b/qml/SideBar.qml @@ -29,6 +29,7 @@ ListView { id: sideBar signal clicked(string path) + signal openInNewWindow(string path) FishUI.WheelHandler { target: sideBar @@ -91,13 +92,40 @@ ListView { id: _mouseArea anchors.fill: parent hoverEnabled: true - acceptedButtons: Qt.LeftButton + acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { - if (model.isDevice && model.setupNeeded) - placesModel.requestSetup(index) + if (mouse.button === Qt.LeftButton) { + if (model.isDevice && model.setupNeeded) + placesModel.requestSetup(index) - // sideBar.currentIndex = index - sideBar.clicked(model.path ? model.path : model.url) + // sideBar.currentIndex = index + sideBar.clicked(model.path ? model.path : model.url) + } else if (mouse.button === Qt.RightButton) { + _menu.popup() + } + } + } + + FishUI.DesktopMenu { + id: _menu + + MenuItem { + text: qsTr("Open") + + onTriggered: { + if (model.isDevice && model.setupNeeded) + placesModel.requestSetup(index) + + sideBar.clicked(model.path ? model.path : model.url) + } + } + + MenuItem { + text: qsTr("Open in new window") + + onTriggered: { + sideBar.openInNewWindow(model.path ? model.path : model.url) + } } } diff --git a/qml/main.qml b/qml/main.qml index 5d32252..37e2a77 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -112,6 +112,7 @@ FishUI.Window { Layout.fillHeight: true width: 180 + FishUI.Units.largeSpacing onClicked: _folderPage.openUrl(path) + onOpenInNewWindow: _folderPage.model.openInNewWindow(path) } FolderPage { diff --git a/translations/en_US.ts b/translations/en_US.ts index 0d21481..9f29909 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -96,17 +96,17 @@ File Manager - + Do you want to permanently delete all files from the Trash? Do you want to permanently delete all files from the Trash? - + Cancel Cancel - + Empty Trash Empty Trash @@ -127,112 +127,112 @@ FolderModel - + %1 item %1 item - + %1 items %1 items - + The file or folder %1 does not exist. The file or folder %1 does not exist. - + Select All Select All - + File Manager File Manager - + Open Open - + Open with Open with - + Cut Cut - + Copy Copy - + Paste Paste - + New Folder New Folder - + Move To Trash Move To Trash - + Empty Trash Empty Trash - + Delete Delete - + Rename Rename - + Open in Terminal Open in Terminal - + Set as Wallpaper Set as Wallpaper - + Properties Properties - + Change background Change background - + Restore Restore - + Show hidden files Show hidden files - + Open in new window @@ -245,13 +245,13 @@ Empty folder - + Open Open - + Properties Properties @@ -316,22 +316,22 @@ - + %1 item %1 item - + %1 items %1 items - + %1 selected %1 selected - + Empty Trash Empty Trash @@ -339,22 +339,22 @@ OpenWithDialog - + No applications No applications - + Set as default Set as default - + Cancel Cancel - + Open Open @@ -494,6 +494,19 @@ OK + + SideBar + + + Open + Open + + + + Open in new window + + + main diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 986549c..2912b6e 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -96,17 +96,17 @@ 文件管理器 - + Do you want to permanently delete all files from the Trash? 是否要从回收站中永久删除所有文件? - + Cancel 取消 - + Empty Trash 清空回收站 @@ -127,112 +127,112 @@ FolderModel - + %1 item %1 项 - + %1 items %1 项 - + The file or folder %1 does not exist. 文件或文件夹 %1 不存在 - + Select All 全选 - + File Manager 文件管理器 - + Open 打开 - + Open with 打开方式 - + Cut 剪切 - + Copy 复制 - + Paste 粘贴 - + New Folder 新建文件夹 - + Move To Trash 移动到回收站 - + Empty Trash 清空回收站 - + Delete 删除 - + Rename 重命名 - + Open in Terminal 在终端中打开 - + Set as Wallpaper 设置为壁纸 - + Properties 属性 - + Change background 更改桌面背景 - + Restore 恢复 - + Show hidden files 显示隐藏文件 - + Open in new window 在新窗口中打开 @@ -245,13 +245,13 @@ 空文件夹 - + Open 打开 - + Properties 属性 @@ -316,22 +316,22 @@ 专为 CutefishOS 打造的文件管理器 - + %1 item %1 项 - + %1 items %1 项 - + %1 selected 选中了 %1 项 - + Empty Trash 清空回收站 @@ -339,22 +339,22 @@ OpenWithDialog - + No applications 没有应用程序 - + Set as default 设置为默认 - + Cancel 取消 - + Open 打开 @@ -502,6 +502,19 @@ %1 项 + + SideBar + + + Open + 打开 + + + + Open in new window + 在新窗口中打开 + + main