mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add trash plugin menu
Change-Id: I409788973046d6f463c68ee97eb3558b95407bab
This commit is contained in:
parent
70253afad8
commit
14873b08af
@ -54,9 +54,20 @@ DockItem::ItemType DockItem::itemType() const
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void DockItem::updatePopupPosition()
|
||||
{
|
||||
if (!m_popupShown)
|
||||
return;
|
||||
|
||||
const QPoint p = popupMarkPoint();
|
||||
PopupWindow->show(p, PopupWindow->model());
|
||||
}
|
||||
|
||||
void DockItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
|
||||
updatePopupPosition();
|
||||
}
|
||||
|
||||
void DockItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
@ -56,6 +56,7 @@ protected:
|
||||
virtual QWidget *popupTips();
|
||||
|
||||
private:
|
||||
void updatePopupPosition();
|
||||
void showPopupWindow(QWidget * const content, const bool model = false);
|
||||
|
||||
protected:
|
||||
|
@ -71,7 +71,7 @@ void DockPopupWindow::mousePressEvent(QMouseEvent *e)
|
||||
DArrowRectangle::mousePressEvent(e);
|
||||
|
||||
// if (e->button() == Qt::LeftButton)
|
||||
// m_acceptDelayTimer->start();
|
||||
// m_acceptDelayTimer->start();
|
||||
}
|
||||
|
||||
bool DockPopupWindow::eventFilter(QObject *o, QEvent *e)
|
||||
|
34
plugins/trash/popupcontrolwidget.cpp
Normal file
34
plugins/trash/popupcontrolwidget.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "popupcontrolwidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
PopupControlWidget::PopupControlWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
||||
m_openBtn(new DLinkButton(tr("Open"), this)),
|
||||
m_clearBtn(new DLinkButton(tr("Clear"), this))
|
||||
{
|
||||
QVBoxLayout *centeralLayout = new QVBoxLayout;
|
||||
centeralLayout->addWidget(m_openBtn);
|
||||
centeralLayout->addWidget(m_clearBtn);
|
||||
|
||||
connect(m_openBtn, &DLinkButton::clicked, this, &PopupControlWidget::openTrashFloder);
|
||||
|
||||
setLayout(centeralLayout);
|
||||
setFixedWidth(80);
|
||||
setFixedHeight(60);
|
||||
}
|
||||
|
||||
void PopupControlWidget::openTrashFloder()
|
||||
{
|
||||
QProcess *proc = new QProcess;
|
||||
|
||||
connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
||||
|
||||
proc->startDetached("gvfs-open trash://");
|
||||
}
|
23
plugins/trash/popupcontrolwidget.h
Normal file
23
plugins/trash/popupcontrolwidget.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef POPUPCONTROLWIDGET_H
|
||||
#define POPUPCONTROLWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <dlinkbutton.h>
|
||||
|
||||
class PopupControlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PopupControlWidget(QWidget *parent = 0);
|
||||
|
||||
private slots:
|
||||
void openTrashFloder();
|
||||
|
||||
private:
|
||||
Dtk::Widget::DLinkButton *m_openBtn;
|
||||
Dtk::Widget::DLinkButton *m_clearBtn;
|
||||
};
|
||||
|
||||
#endif // POPUPCONTROLWIDGET_H
|
@ -4,7 +4,7 @@ include(../../interfaces/interfaces.pri)
|
||||
QT += widgets svg
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG +=
|
||||
PKGCONFIG += dtkbase dtkwidget
|
||||
|
||||
TARGET = $$qtLibraryTarget(trash)
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
@ -12,11 +12,13 @@ DISTFILES += trash.json
|
||||
|
||||
HEADERS += \
|
||||
trashplugin.h \
|
||||
trashwidget.h
|
||||
trashwidget.h \
|
||||
popupcontrolwidget.h
|
||||
|
||||
SOURCES += \
|
||||
trashplugin.cpp \
|
||||
trashwidget.cpp
|
||||
trashwidget.cpp \
|
||||
popupcontrolwidget.cpp
|
||||
|
||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||
INSTALLS += target
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
TrashPlugin::TrashPlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_trashWidget(new TrashWidget)
|
||||
m_trashWidget(new TrashWidget),
|
||||
m_popupApplet(new PopupControlWidget)
|
||||
{
|
||||
|
||||
m_popupApplet->setVisible(false);
|
||||
}
|
||||
|
||||
const QString TrashPlugin::pluginName() const
|
||||
@ -26,9 +27,17 @@ QWidget *TrashPlugin::itemWidget(const QString &itemKey)
|
||||
return m_trashWidget;
|
||||
}
|
||||
|
||||
QWidget *TrashPlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return m_popupApplet;
|
||||
}
|
||||
|
||||
const QString TrashPlugin::itemCommand(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return "gvfs-open trash://";
|
||||
return QString();
|
||||
// return "gvfs-open trash://";
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "trashwidget.h"
|
||||
#include "popupcontrolwidget.h"
|
||||
|
||||
class TrashPlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
@ -17,10 +18,12 @@ public:
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
|
||||
private:
|
||||
TrashWidget *m_trashWidget;
|
||||
PopupControlWidget *m_popupApplet;
|
||||
};
|
||||
|
||||
#endif // TRASHPLUGIN_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user