diff --git a/qml/main.qml b/qml/main.qml index 66ed06a..205d50a 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -128,6 +128,31 @@ Item { } } } + + DockItem { + id: trashItem + implicitWidth: isHorizontal ? root.height : root.width + implicitHeight: isHorizontal ? root.height : root.width + popupText: qsTr("Trash") + enableActivateDot: false + iconName: trash.count === 0 ? "user-trash-empty" : "user-trash-full" + onClicked: trash.openTrash() + onRightClicked: trashMenu.popup() + + FishUI.DesktopMenu { + id: trashMenu + + MenuItem { + text: qsTr("Open") + onTriggered: trash.openTrash() + } + + MenuItem { + text: qsTr("Empty Trash") + onTriggered: trash.emptyTrash() + } + } + } } Connections { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 23f58f8..2efc9ed 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -38,6 +38,7 @@ MainWindow::MainWindow(QQuickView *parent) , m_settings(DockSettings::self()) , m_appModel(new ApplicationModel) , m_fakeWindow(nullptr) + , m_trashManager(new TrashManager) { setDefaultAlphaBuffer(false); setColor(Qt::transparent); @@ -50,6 +51,7 @@ MainWindow::MainWindow(QQuickView *parent) engine()->rootContext()->setContextProperty("process", new ProcessProvider); engine()->rootContext()->setContextProperty("Settings", m_settings); engine()->rootContext()->setContextProperty("mainWindow", this); + engine()->rootContext()->setContextProperty("trash", m_trashManager); setSource(QUrl(QStringLiteral("qrc:/qml/main.qml"))); setResizeMode(QQuickView::SizeRootObjectToView); @@ -90,7 +92,8 @@ QRect MainWindow::windowRect() const int maxLength = isHorizontal ? screenGeometry.width() - m_settings->edgeMargins() : availableGeometry.height() - m_settings->edgeMargins();; - int appCount = m_appModel->rowCount(); + // Add trash item. + int appCount = m_appModel->rowCount() + 1; int iconSize = m_settings->iconSize(); iconSize += iconSize * 0.1; int length = appCount * iconSize; diff --git a/src/mainwindow.h b/src/mainwindow.h index 89021b9..a3af6db 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -26,6 +26,7 @@ #include "docksettings.h" #include "applicationmodel.h" #include "fakewindow.h" +#include "trashmanager.h" class MainWindow : public QQuickView { @@ -58,6 +59,7 @@ private: DockSettings *m_settings; ApplicationModel *m_appModel; FakeWindow *m_fakeWindow; + TrashManager *m_trashManager; }; #endif // MAINWINDOW_H diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 636a687..99c3aec 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -32,9 +32,27 @@ ApplicationModel - + Launcher 应用启动器 + + main + + + Trash + 回收站 + + + + Open + 打开 + + + + Empty Trash + 清空回收站 + +