mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add trash plugin
Change-Id: Ife73a4c9fade75fe9ee135803824121fa54fe518
This commit is contained in:
parent
7c0a0534fd
commit
dac174d756
@ -4,4 +4,5 @@ SUBDIRS = \
|
||||
shutdown \
|
||||
system-tray \
|
||||
disk-mount \
|
||||
network
|
||||
network \
|
||||
trash
|
||||
|
2
plugins/trash/trash.json
Normal file
2
plugins/trash/trash.json
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
24
plugins/trash/trash.pro
Normal file
24
plugins/trash/trash.pro
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
include(../../interfaces/interfaces.pri)
|
||||
|
||||
QT += widgets svg
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG +=
|
||||
|
||||
TARGET = $$qtLibraryTarget(trash)
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
DISTFILES += trash.json
|
||||
|
||||
HEADERS += \
|
||||
trashplugin.h \
|
||||
trashwidget.h
|
||||
|
||||
SOURCES += \
|
||||
trashplugin.cpp \
|
||||
trashwidget.cpp
|
||||
|
||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||
INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
34
plugins/trash/trashplugin.cpp
Normal file
34
plugins/trash/trashplugin.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "trashplugin.h"
|
||||
|
||||
TrashPlugin::TrashPlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_trashWidget(new TrashWidget)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const QString TrashPlugin::pluginName() const
|
||||
{
|
||||
return "trash";
|
||||
}
|
||||
|
||||
void TrashPlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
m_proxyInter->itemAdded(this, QString());
|
||||
}
|
||||
|
||||
QWidget *TrashPlugin::itemWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return m_trashWidget;
|
||||
}
|
||||
|
||||
const QString TrashPlugin::itemCommand(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return "gvfs-open trash://";
|
||||
}
|
26
plugins/trash/trashplugin.h
Normal file
26
plugins/trash/trashplugin.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef TRASHPLUGIN_H
|
||||
#define TRASHPLUGIN_H
|
||||
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "trashwidget.h"
|
||||
|
||||
class TrashPlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginsItemInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "trash.json")
|
||||
|
||||
public:
|
||||
explicit TrashPlugin(QObject *parent = 0);
|
||||
|
||||
const QString pluginName() const;
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
|
||||
private:
|
||||
TrashWidget *m_trashWidget;
|
||||
};
|
||||
|
||||
#endif // TRASHPLUGIN_H
|
22
plugins/trash/trashwidget.cpp
Normal file
22
plugins/trash/trashwidget.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "trashwidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
|
||||
TrashWidget::TrashWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QIcon::setThemeName("deepin");
|
||||
}
|
||||
|
||||
void TrashWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
|
||||
const int size = std::min(width(), height()) * 0.8;
|
||||
QIcon icon = QIcon::fromTheme("user-trash");
|
||||
QPixmap pixmap = icon.pixmap(size, size);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(rect().center() - pixmap.rect().center(), pixmap);
|
||||
}
|
17
plugins/trash/trashwidget.h
Normal file
17
plugins/trash/trashwidget.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef TRASHWIDGET_H
|
||||
#define TRASHWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class TrashWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrashWidget(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
};
|
||||
|
||||
#endif // TRASHWIDGET_H
|
Loading…
x
Reference in New Issue
Block a user