Add trash item
This commit is contained in:
parent
b8c163aa87
commit
04e5a7ea22
4 changed files with 50 additions and 2 deletions
25
qml/main.qml
25
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 {
|
Connections {
|
||||||
|
|
|
@ -38,6 +38,7 @@ MainWindow::MainWindow(QQuickView *parent)
|
||||||
, m_settings(DockSettings::self())
|
, m_settings(DockSettings::self())
|
||||||
, m_appModel(new ApplicationModel)
|
, m_appModel(new ApplicationModel)
|
||||||
, m_fakeWindow(nullptr)
|
, m_fakeWindow(nullptr)
|
||||||
|
, m_trashManager(new TrashManager)
|
||||||
{
|
{
|
||||||
setDefaultAlphaBuffer(false);
|
setDefaultAlphaBuffer(false);
|
||||||
setColor(Qt::transparent);
|
setColor(Qt::transparent);
|
||||||
|
@ -50,6 +51,7 @@ MainWindow::MainWindow(QQuickView *parent)
|
||||||
engine()->rootContext()->setContextProperty("process", new ProcessProvider);
|
engine()->rootContext()->setContextProperty("process", new ProcessProvider);
|
||||||
engine()->rootContext()->setContextProperty("Settings", m_settings);
|
engine()->rootContext()->setContextProperty("Settings", m_settings);
|
||||||
engine()->rootContext()->setContextProperty("mainWindow", this);
|
engine()->rootContext()->setContextProperty("mainWindow", this);
|
||||||
|
engine()->rootContext()->setContextProperty("trash", m_trashManager);
|
||||||
|
|
||||||
setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
|
@ -90,7 +92,8 @@ QRect MainWindow::windowRect() const
|
||||||
int maxLength = isHorizontal ? screenGeometry.width() - m_settings->edgeMargins()
|
int maxLength = isHorizontal ? screenGeometry.width() - m_settings->edgeMargins()
|
||||||
: availableGeometry.height() - 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();
|
int iconSize = m_settings->iconSize();
|
||||||
iconSize += iconSize * 0.1;
|
iconSize += iconSize * 0.1;
|
||||||
int length = appCount * iconSize;
|
int length = appCount * iconSize;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "docksettings.h"
|
#include "docksettings.h"
|
||||||
#include "applicationmodel.h"
|
#include "applicationmodel.h"
|
||||||
#include "fakewindow.h"
|
#include "fakewindow.h"
|
||||||
|
#include "trashmanager.h"
|
||||||
|
|
||||||
class MainWindow : public QQuickView
|
class MainWindow : public QQuickView
|
||||||
{
|
{
|
||||||
|
@ -58,6 +59,7 @@ private:
|
||||||
DockSettings *m_settings;
|
DockSettings *m_settings;
|
||||||
ApplicationModel *m_appModel;
|
ApplicationModel *m_appModel;
|
||||||
FakeWindow *m_fakeWindow;
|
FakeWindow *m_fakeWindow;
|
||||||
|
TrashManager *m_trashManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -32,9 +32,27 @@
|
||||||
<context>
|
<context>
|
||||||
<name>ApplicationModel</name>
|
<name>ApplicationModel</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/applicationmodel.cpp" line="282"/>
|
<location filename="../src/applicationmodel.cpp" line="285"/>
|
||||||
<source>Launcher</source>
|
<source>Launcher</source>
|
||||||
<translation>应用启动器</translation>
|
<translation>应用启动器</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>main</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/main.qml" line="136"/>
|
||||||
|
<source>Trash</source>
|
||||||
|
<translation>回收站</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/main.qml" line="146"/>
|
||||||
|
<source>Open</source>
|
||||||
|
<translation>打开</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/main.qml" line="151"/>
|
||||||
|
<source>Empty Trash</source>
|
||||||
|
<translation>清空回收站</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
Loading…
Add table
Reference in a new issue