add trash plugin

Change-Id: Ife73a4c9fade75fe9ee135803824121fa54fe518
This commit is contained in:
石博文 2016-08-01 10:58:10 +08:00 committed by Hualet Wang
parent 7c0a0534fd
commit dac174d756
7 changed files with 127 additions and 1 deletions

View File

@ -4,4 +4,5 @@ SUBDIRS = \
shutdown \
system-tray \
disk-mount \
network
network \
trash

2
plugins/trash/trash.json Normal file
View File

@ -0,0 +1,2 @@
{
}

24
plugins/trash/trash.pro Normal file
View 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 += \

View 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://";
}

View 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

View 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);
}

View 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