mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Merge "add trash tips"
This commit is contained in:
commit
6fd0caa02d
@ -31,6 +31,11 @@ bool PopupControlWidget::empty() const
|
||||
return m_empty;
|
||||
}
|
||||
|
||||
int PopupControlWidget::trashItems() const
|
||||
{
|
||||
return m_trashItemsCount;
|
||||
}
|
||||
|
||||
QSize PopupControlWidget::sizeHint() const
|
||||
{
|
||||
return QSize(width(), m_empty ? 30 : 60);
|
||||
@ -105,13 +110,12 @@ void PopupControlWidget::trashStatusChanged()
|
||||
// m_fsWatcher->addPath(TrashDir + "/info");
|
||||
|
||||
// check empty
|
||||
bool empty;
|
||||
if (/*(!info || QDir(TrashDir + "/info").entryList().count() == 2) &&*/
|
||||
(!files || QDir(TrashDir + "/files").entryList().count() == 2))
|
||||
empty = true;
|
||||
if (!files)
|
||||
m_trashItemsCount = 0;
|
||||
else
|
||||
empty = false;
|
||||
m_trashItemsCount = QDir(TrashDir + "/files").entryList().count() - 2;
|
||||
|
||||
const bool empty = m_trashItemsCount == 0;
|
||||
if (m_empty == empty)
|
||||
return;
|
||||
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
explicit PopupControlWidget(QWidget *parent = 0);
|
||||
|
||||
bool empty() const;
|
||||
int trashItems() const;
|
||||
QSize sizeHint() const;
|
||||
static const QString trashDir();
|
||||
|
||||
@ -32,6 +33,7 @@ private slots:
|
||||
|
||||
private:
|
||||
bool m_empty;
|
||||
int m_trashItemsCount;
|
||||
|
||||
// Dtk::Widget::DLinkButton *m_openBtn;
|
||||
// Dtk::Widget::DLinkButton *m_clearBtn;
|
||||
|
@ -2,8 +2,12 @@
|
||||
|
||||
TrashPlugin::TrashPlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_trashWidget(new TrashWidget)
|
||||
m_trashWidget(new TrashWidget),
|
||||
m_tipsLabel(new QLabel)
|
||||
{
|
||||
m_tipsLabel->setStyleSheet("color:white;"
|
||||
"padding:5px 10px;");
|
||||
|
||||
connect(m_trashWidget, &TrashWidget::requestContextMenu, this, &TrashPlugin::showContextMenu);
|
||||
}
|
||||
|
||||
@ -26,6 +30,19 @@ QWidget *TrashPlugin::itemWidget(const QString &itemKey)
|
||||
return m_trashWidget;
|
||||
}
|
||||
|
||||
QWidget *TrashPlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
const int count = m_trashWidget->trashItemCount();
|
||||
if (count < 2)
|
||||
m_tipsLabel->setText(tr("Trash-%1 file").arg(count));
|
||||
else
|
||||
m_tipsLabel->setText(tr("Trash-%1 files").arg(count));
|
||||
|
||||
return m_tipsLabel;
|
||||
}
|
||||
|
||||
QWidget *TrashPlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "trashwidget.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class TrashPlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -17,6 +19,7 @@ public:
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
const QString itemContextMenu(const QString &itemKey);
|
||||
@ -30,6 +33,7 @@ private:
|
||||
|
||||
private:
|
||||
TrashWidget *m_trashWidget;
|
||||
QLabel *m_tipsLabel;
|
||||
};
|
||||
|
||||
#endif // TRASHPLUGIN_H
|
||||
|
@ -63,6 +63,11 @@ const QString TrashWidget::contextMenu() const
|
||||
return QJsonDocument::fromVariant(menu).toJson();
|
||||
}
|
||||
|
||||
int TrashWidget::trashItemCount() const
|
||||
{
|
||||
return m_popupApplet->trashItems();
|
||||
}
|
||||
|
||||
void TrashWidget::invokeMenuItem(const QString &menuId, const bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
|
||||
QSize sizeHint() const;
|
||||
const QString contextMenu() const;
|
||||
int trashItemCount() const;
|
||||
void invokeMenuItem(const QString &menuId, const bool checked);
|
||||
|
||||
signals:
|
||||
|
Loading…
x
Reference in New Issue
Block a user