2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
2022-09-06 11:36:55 +08:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2017-09-18 14:33:44 +08:00
|
|
|
|
2016-08-01 10:58:10 +08:00
|
|
|
#ifndef TRASHWIDGET_H
|
|
|
|
#define TRASHWIDGET_H
|
|
|
|
|
2016-08-01 15:20:44 +08:00
|
|
|
#include "popupcontrolwidget.h"
|
|
|
|
|
2022-09-16 20:12:52 +00:00
|
|
|
#include "org_freedesktop_filemanager.h"
|
|
|
|
|
2016-08-01 10:58:10 +08:00
|
|
|
#include <QWidget>
|
2016-08-08 16:28:37 +08:00
|
|
|
#include <QPixmap>
|
2016-12-12 10:58:48 +08:00
|
|
|
#include <QAction>
|
2019-10-22 14:53:30 +08:00
|
|
|
#include <QIcon>
|
2016-08-08 19:19:11 +08:00
|
|
|
|
2021-08-20 10:19:10 +08:00
|
|
|
using DBusFileManager1 = org::freedesktop::FileManager1;
|
|
|
|
|
2016-08-01 10:58:10 +08:00
|
|
|
class TrashWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TrashWidget(QWidget *parent = 0);
|
|
|
|
|
2016-08-01 15:20:44 +08:00
|
|
|
QWidget *popupApplet();
|
|
|
|
|
2016-09-19 15:06:25 +08:00
|
|
|
const QString contextMenu() const;
|
2016-09-20 14:42:22 +08:00
|
|
|
int trashItemCount() const;
|
2016-09-19 15:06:25 +08:00
|
|
|
void invokeMenuItem(const QString &menuId, const bool checked);
|
2017-03-20 10:36:18 +08:00
|
|
|
void updateIcon();
|
2019-09-06 15:28:22 +08:00
|
|
|
void updateIconAndRefresh();
|
2021-09-03 13:31:32 +08:00
|
|
|
bool getDragging() const;
|
|
|
|
void setDragging(bool state);
|
2016-08-08 16:28:37 +08:00
|
|
|
|
2016-08-08 19:19:11 +08:00
|
|
|
signals:
|
2016-09-19 14:11:18 +08:00
|
|
|
void requestContextMenu() const;
|
2016-08-08 19:19:11 +08:00
|
|
|
|
2016-08-01 10:58:10 +08:00
|
|
|
protected:
|
2020-06-13 19:19:30 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
2021-09-03 13:31:32 +08:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
2020-06-13 19:19:30 +08:00
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2016-08-08 19:19:11 +08:00
|
|
|
|
2016-08-08 16:28:37 +08:00
|
|
|
private slots:
|
2016-08-11 16:03:45 +08:00
|
|
|
void removeApp(const QString &appKey);
|
2016-08-08 16:53:18 +08:00
|
|
|
void moveToTrash(const QUrl &url);
|
2016-08-01 15:20:44 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
PopupControlWidget *m_popupApplet;
|
2021-08-20 10:19:10 +08:00
|
|
|
DBusFileManager1 *m_fileManagerInter;
|
2016-08-08 16:28:37 +08:00
|
|
|
|
2021-09-03 13:31:32 +08:00
|
|
|
bool m_dragging; // item是否被拖入回收站
|
|
|
|
|
2016-08-08 16:28:37 +08:00
|
|
|
QPixmap m_icon;
|
2019-10-22 14:53:30 +08:00
|
|
|
QIcon m_defaulticon;
|
2016-08-01 10:58:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TRASHWIDGET_H
|