2016-07-19 09:46:08 +08:00
|
|
|
#include "diskmountplugin.h"
|
|
|
|
|
|
|
|
DiskMountPlugin::DiskMountPlugin(QObject *parent)
|
2016-07-19 10:30:02 +08:00
|
|
|
: QObject(parent),
|
2016-07-19 09:46:08 +08:00
|
|
|
|
2016-07-19 11:21:29 +08:00
|
|
|
m_pluginAdded(false),
|
|
|
|
|
2016-08-30 15:46:08 +08:00
|
|
|
m_tipsLabel(new QLabel),
|
2016-07-19 11:21:29 +08:00
|
|
|
m_diskPluginItem(new DiskPluginItem),
|
|
|
|
m_diskControlApplet(nullptr)
|
2016-07-19 10:30:02 +08:00
|
|
|
{
|
2016-07-19 11:21:29 +08:00
|
|
|
m_diskPluginItem->setVisible(false);
|
2016-08-30 15:46:08 +08:00
|
|
|
m_tipsLabel->setVisible(false);
|
|
|
|
m_tipsLabel->setText(tr("Disk"));
|
|
|
|
m_tipsLabel->setStyleSheet("color:white;"
|
|
|
|
"padding:5px 10px;");
|
2016-07-19 09:46:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString DiskMountPlugin::pluginName() const
|
|
|
|
{
|
|
|
|
return "disk-mount";
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskMountPlugin::init(PluginProxyInterface *proxyInter)
|
|
|
|
{
|
|
|
|
m_proxyInter = proxyInter;
|
2016-07-19 11:21:29 +08:00
|
|
|
|
|
|
|
initCompoments();
|
2016-08-02 14:41:42 +08:00
|
|
|
m_diskPluginItem->setDockDisplayMode(displayMode());
|
2016-07-19 09:46:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *DiskMountPlugin::itemWidget(const QString &itemKey)
|
|
|
|
{
|
|
|
|
Q_UNUSED(itemKey);
|
|
|
|
|
2016-07-19 11:21:29 +08:00
|
|
|
return m_diskPluginItem;
|
|
|
|
}
|
|
|
|
|
2016-08-30 15:46:08 +08:00
|
|
|
QWidget *DiskMountPlugin::itemTipsWidget(const QString &itemKey)
|
|
|
|
{
|
|
|
|
Q_UNUSED(itemKey);
|
|
|
|
|
|
|
|
return m_tipsLabel;
|
|
|
|
}
|
|
|
|
|
2016-07-19 11:21:29 +08:00
|
|
|
QWidget *DiskMountPlugin::itemPopupApplet(const QString &itemKey)
|
|
|
|
{
|
|
|
|
Q_UNUSED(itemKey);
|
|
|
|
|
|
|
|
return m_diskControlApplet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskMountPlugin::initCompoments()
|
|
|
|
{
|
|
|
|
m_diskControlApplet = new DiskControlWidget;
|
2016-07-28 10:59:21 +08:00
|
|
|
m_diskControlApplet->setObjectName("dist-mount");
|
2016-07-19 11:21:29 +08:00
|
|
|
m_diskControlApplet->setVisible(false);
|
|
|
|
|
|
|
|
connect(m_diskControlApplet, &DiskControlWidget::diskCountChanged, this, &DiskMountPlugin::diskCountChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskMountPlugin::displayModeChanged(const Dock::DisplayMode mode)
|
|
|
|
{
|
|
|
|
m_diskPluginItem->setDockDisplayMode(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskMountPlugin::diskCountChanged(const int count)
|
|
|
|
{
|
|
|
|
if (m_pluginAdded == bool(count))
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_pluginAdded = bool(count);
|
|
|
|
|
|
|
|
if (m_pluginAdded)
|
|
|
|
m_proxyInter->itemAdded(this, QString());
|
|
|
|
else
|
|
|
|
m_proxyInter->itemRemoved(this, QString());
|
2016-07-19 09:46:08 +08:00
|
|
|
}
|