mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
test: 测试插件适配新的任务栏插件接口
在homemonitor插件中新增插件新的接口,匹配新的任务栏插件 Log: Influence: 无 Task: https://pms.uniontech.com/task-view-110309.html Change-Id: Idd9907d55b839939d52121934bd5c28ea349392c
This commit is contained in:
parent
1172b54b9f
commit
73ad24a682
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"api": "1.1.1"
|
"api": "2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "homemonitorplugin.h"
|
#include "homemonitorplugin.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
HomeMonitorPlugin::HomeMonitorPlugin(QObject *parent)
|
HomeMonitorPlugin::HomeMonitorPlugin(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@ -133,3 +135,42 @@ void HomeMonitorPlugin::invokedMenuItem(const QString &itemKey, const QString &m
|
|||||||
QProcess::startDetached("gparted");
|
QProcess::startDetached("gparted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QIcon *HomeMonitorPlugin::icon()
|
||||||
|
{
|
||||||
|
static QIcon pixMapIcon;
|
||||||
|
QPixmap pixmap;
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.begin(&pixmap);
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(10);
|
||||||
|
painter.setFont(font);
|
||||||
|
painter.drawText(QPoint(0, 0), m_pluginWidget->textContent());
|
||||||
|
painter.end();
|
||||||
|
pixMapIcon.detach();
|
||||||
|
pixMapIcon.addPixmap(pixmap);
|
||||||
|
return &pixMapIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginsItemInterface::PluginStatus HomeMonitorPlugin::status() const
|
||||||
|
{
|
||||||
|
return PluginStatus::Active;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HomeMonitorPlugin::isPrimary() const
|
||||||
|
{
|
||||||
|
// 如果当前插件是在快捷设置区域最上方显示的大图标且可以展开查看详情的,则返回true
|
||||||
|
// 否则,返回false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString HomeMonitorPlugin::description() const
|
||||||
|
{
|
||||||
|
// 当isPrimary()返回值为true的时候,这个值用于返回在大图标下面的状态信息,
|
||||||
|
// 例如,如果当前图标是网络图标,下面则显示连接的网络信息,或者如果是其他的图标,下面显示连接的
|
||||||
|
// 状态等(开启或者关闭)
|
||||||
|
if (status() == PluginStatus::Active)
|
||||||
|
return tr("Enabled");
|
||||||
|
|
||||||
|
return tr("Disabled");
|
||||||
|
}
|
||||||
|
@ -31,6 +31,11 @@ public:
|
|||||||
const QString itemContextMenu(const QString &itemKey) override;
|
const QString itemContextMenu(const QString &itemKey) override;
|
||||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
||||||
|
|
||||||
|
const QIcon *icon() override;
|
||||||
|
PluginStatus status() const override;
|
||||||
|
bool isPrimary() const override;
|
||||||
|
QString description() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InformationWidget *m_pluginWidget;
|
InformationWidget *m_pluginWidget;
|
||||||
QLabel *m_tipsWidget;
|
QLabel *m_tipsWidget;
|
||||||
|
@ -33,7 +33,7 @@ InformationWidget::InformationWidget(QWidget *parent)
|
|||||||
refreshInfo();
|
refreshInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InformationWidget::refreshInfo()
|
const QString InformationWidget::textContent() const
|
||||||
{
|
{
|
||||||
// 获取分区总容量
|
// 获取分区总容量
|
||||||
const double total = m_storageInfo->bytesTotal();
|
const double total = m_storageInfo->bytesTotal();
|
||||||
@ -41,7 +41,11 @@ void InformationWidget::refreshInfo()
|
|||||||
const double available = m_storageInfo->bytesAvailable();
|
const double available = m_storageInfo->bytesAvailable();
|
||||||
// 得到可用百分比
|
// 得到可用百分比
|
||||||
const int percent = qRound(available / total * 100);
|
const int percent = qRound(available / total * 100);
|
||||||
|
return QString("Home:\n%1\%").arg(percent);
|
||||||
// 更新内容
|
}
|
||||||
m_infoLabel->setText(QString("Home:\n%1\%").arg(percent));
|
|
||||||
|
void InformationWidget::refreshInfo()
|
||||||
|
{
|
||||||
|
// 更新内容
|
||||||
|
m_infoLabel->setText(textContent());
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ public:
|
|||||||
explicit InformationWidget(QWidget *parent = nullptr);
|
explicit InformationWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
inline QStorageInfo * storageInfo() { return m_storageInfo; }
|
inline QStorageInfo * storageInfo() { return m_storageInfo; }
|
||||||
|
const QString textContent() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// 用于更新数据的槽函数
|
// 用于更新数据的槽函数
|
||||||
|
@ -51,6 +51,10 @@ PluginsItemInterface 中定义的接口除了displayMode 和 position(历史
|
|||||||
|refreshIcon | 当插件控件的图标需要更新时此接口被调用|
|
|refreshIcon | 当插件控件的图标需要更新时此接口被调用|
|
||||||
|displayMode | 用于插件主动获取 dde-dock 当前的显示模式|
|
|displayMode | 用于插件主动获取 dde-dock 当前的显示模式|
|
||||||
|position | 用于插件主动获取 dde-dock 当前的位置|
|
|position | 用于插件主动获取 dde-dock 当前的位置|
|
||||||
|
|icon | 用于返回当前插件在快捷设置面板上的图标,正常状态下显示的图标即可 |
|
||||||
|
|status | 用于返回当前快捷设置插件的状态,激活状态还是禁用状态 |
|
||||||
|
|isPrimary | 用于标记当前快捷设置的插件是否为主插件(图标占两个图标位置) |
|
||||||
|
|description | 用于返回插件的描述(快捷设置面板中isPrimary为true的时候有用) |
|
||||||
|
|
||||||
### PluginProxyInterface
|
### PluginProxyInterface
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user