mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add hover tooltip
Change-Id: I34a0b315032bbd5d4308f43be934494eb78dd6dd
This commit is contained in:
parent
4bfaa78d66
commit
0c7f8f6677
Notes:
Deepin Code Review
2016-09-01 06:50:13 +00:00
Verified+1: Anonymous Coward #1000004 Verified+1: <zhaofangfang@linuxdeepin.com> Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Thu, 01 Sep 2016 06:50:13 +0000 Reviewed-on: https://cr.deepin.io/15677 Project: dde/dde-dock Branch: refs/heads/master
@ -6,7 +6,7 @@
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
DiskControlItem::DiskControlItem(const DiskInfo &info, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
: QFrame(parent),
|
||||
|
||||
m_unknowIcon(":/icons/resources/unknown.svg"),
|
||||
|
||||
@ -62,9 +62,13 @@ DiskControlItem::DiskControlItem(const DiskInfo &info, QWidget *parent)
|
||||
centeralLayout->addWidget(m_diskIcon);
|
||||
centeralLayout->addLayout(progressLayout);
|
||||
centeralLayout->setSpacing(0);
|
||||
centeralLayout->setMargin(0);
|
||||
centeralLayout->setContentsMargins(0, 0, 5, 0);
|
||||
|
||||
setLayout(centeralLayout);
|
||||
setObjectName("DiskItem");
|
||||
setStyleSheet("QFrame #DiskItem:hover {"
|
||||
"background-color:rgba(255, 255, 255, .1);"
|
||||
"}");
|
||||
|
||||
connect(m_unmountButton, &DImageButton::clicked, [this] {emit requestUnmount(m_info.m_id);});
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <QProgressBar>
|
||||
#include <QIcon>
|
||||
|
||||
class DiskControlItem : public QWidget
|
||||
class DiskControlItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "diskcontrolwidget.h"
|
||||
#include "diskcontrolitem.h"
|
||||
|
||||
#define MAX_HEIGHT 300
|
||||
#define WIDTH 300
|
||||
|
||||
DiskControlWidget::DiskControlWidget(QWidget *parent)
|
||||
@ -56,7 +55,7 @@ void DiskControlWidget::diskListChanged()
|
||||
emit diskCountChanged(mountedCount);
|
||||
|
||||
const int contentHeight = mountedCount * 70;
|
||||
const int maxHeight = std::min(contentHeight, MAX_HEIGHT);
|
||||
const int maxHeight = std::min(contentHeight, 70 * 6);
|
||||
|
||||
m_centeralWidget->setFixedHeight(contentHeight);
|
||||
setFixedHeight(maxHeight);
|
||||
|
@ -5,10 +5,15 @@ DiskMountPlugin::DiskMountPlugin(QObject *parent)
|
||||
|
||||
m_pluginAdded(false),
|
||||
|
||||
m_tipsLabel(new QLabel),
|
||||
m_diskPluginItem(new DiskPluginItem),
|
||||
m_diskControlApplet(nullptr)
|
||||
{
|
||||
m_diskPluginItem->setVisible(false);
|
||||
m_tipsLabel->setVisible(false);
|
||||
m_tipsLabel->setText(tr("Disk"));
|
||||
m_tipsLabel->setStyleSheet("color:white;"
|
||||
"padding:5px 10px;");
|
||||
}
|
||||
|
||||
const QString DiskMountPlugin::pluginName() const
|
||||
@ -31,6 +36,13 @@ QWidget *DiskMountPlugin::itemWidget(const QString &itemKey)
|
||||
return m_diskPluginItem;
|
||||
}
|
||||
|
||||
QWidget *DiskMountPlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return m_tipsLabel;
|
||||
}
|
||||
|
||||
QWidget *DiskMountPlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef DISKMOUNTPLUGIN_H
|
||||
#define DISKMOUNTPLUGIN_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "diskcontrolwidget.h"
|
||||
#include "diskpluginitem.h"
|
||||
@ -18,6 +20,7 @@ public:
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
|
||||
private:
|
||||
@ -31,6 +34,7 @@ private slots:
|
||||
private:
|
||||
bool m_pluginAdded;
|
||||
|
||||
QLabel *m_tipsLabel;
|
||||
DiskPluginItem *m_diskPluginItem;
|
||||
DiskControlWidget *m_diskControlApplet;
|
||||
};
|
||||
|
@ -40,18 +40,15 @@ QWidget *ShutdownPlugin::itemWidget(const QString &itemKey)
|
||||
|
||||
QWidget *ShutdownPlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
const Dock::DisplayMode mode = displayMode();
|
||||
|
||||
if (mode == Dock::Efficient && itemKey == SHUTDOWN_KEY)
|
||||
return nullptr;
|
||||
|
||||
const BatteryPercentageMap data = m_powerInter->batteryPercentage();
|
||||
|
||||
if (data.isEmpty())
|
||||
return nullptr;
|
||||
if (itemKey == SHUTDOWN_KEY || data.isEmpty())
|
||||
{
|
||||
m_tipsLabel->setText(tr("Shut down"));
|
||||
return m_tipsLabel;
|
||||
}
|
||||
|
||||
m_tipsLabel->setText(QString("%1%").arg(data.value("Display"), 1, 'f', 1));
|
||||
|
||||
return m_tipsLabel;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user