optimize ui details

Change-Id: I9ad3312423a757f44ea8cc04afceb86d522a172d
This commit is contained in:
石博文 2016-08-09 14:51:03 +08:00
parent 8754639364
commit ea04ee5226
Notes: Deepin Code Review 2016-08-09 06:57:38 +00:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Tue, 09 Aug 2016 06:57:38 +0000
Reviewed-on: https://cr.deepin.io/15030
Project: dde/dde-dock
Branch: refs/heads/master
17 changed files with 53 additions and 25 deletions

View File

@ -117,10 +117,12 @@ void AppItem::paintEvent(QPaintEvent *e)
{ {
case Top: case Top:
case Bottom: case Bottom:
backgroundRect = itemRect.marginsRemoved(QMargins(2, 1, 2, 1)); // backgroundRect = itemRect;//.marginsRemoved(QMargins(2, 0, 2, 0));
// backgroundRect = itemRect.marginsRemoved(QMargins(0, 1, 0, 1));
case Left: case Left:
case Right: case Right:
backgroundRect = itemRect.marginsRemoved(QMargins(1, 2, 1, 2)); backgroundRect = itemRect.marginsRemoved(QMargins(1, 1, 1, 1));
// backgroundRect = itemRect.marginsRemoved(QMargins(1, 0, 1, 0));
} }
} }

View File

@ -28,6 +28,9 @@ MainPanel::MainPanel(QWidget *parent)
"border:" xstr(PANEL_BORDER) "px solid rgba(162, 162, 162, .2);" "border:" xstr(PANEL_BORDER) "px solid rgba(162, 162, 162, .2);"
"background-color:rgba(10, 10, 10, .6);" "background-color:rgba(10, 10, 10, .6);"
"}" "}"
"QWidget #MainPanel[displayMode='1'] {"
"border:none;"
"}"
// Top // Top
"QWidget #MainPanel[displayMode='0'][position='0'] {" "QWidget #MainPanel[displayMode='0'][position='0'] {"
"border-bottom-left-radius:5px;" "border-bottom-left-radius:5px;"

View File

@ -19,29 +19,32 @@ DiskControlItem::DiskControlItem(const DiskInfo &info, QWidget *parent)
QIcon::setThemeName("deepin"); QIcon::setThemeName("deepin");
m_diskName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_diskName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_diskName->setStyleSheet("color:white;"); m_diskName->setStyleSheet("color:white;"
"font-size:12px;");
m_diskCapacity->setStyleSheet("color:white;"); m_diskCapacity->setStyleSheet("color:rgba(255, 255, 255, .6);"
"font-size:10px;");
m_capacityValueBar->setTextVisible(false); m_capacityValueBar->setTextVisible(false);
m_capacityValueBar->setFixedHeight(3); m_capacityValueBar->setFixedHeight(2);
m_capacityValueBar->setStyleSheet("QProgressBar {" m_capacityValueBar->setStyleSheet("QProgressBar {"
"border:none;" "border:none;"
"background-color:rgba(255, 255, 255, .3);" "background-color:rgba(255, 255, 255, .1);"
"}" "}"
"QProgressBar::chunk {" "QProgressBar::chunk {"
"background-color:white;" "background-color:rgba(255, 255, 255, .8);"
"}"); "}");
m_unmountButton->setNormalPic(":/icons/resources/unmount-normal.png"); m_unmountButton->setNormalPic(":/icons/resources/unmount-normal.png");
m_unmountButton->setHoverPic(":/icons/resources/unmount-hover.png"); m_unmountButton->setHoverPic(":/icons/resources/unmount-hover.png");
m_unmountButton->setPressPic(":/icons/resources/unmount-press.png"); m_unmountButton->setPressPic(":/icons/resources/unmount-press.png");
m_unmountButton->setStyleSheet("margin-top:12px;");
QVBoxLayout *infoLayout = new QVBoxLayout; QVBoxLayout *infoLayout = new QVBoxLayout;
infoLayout->addWidget(m_diskName); infoLayout->addWidget(m_diskName);
infoLayout->addWidget(m_diskCapacity); infoLayout->addWidget(m_diskCapacity);
infoLayout->setSpacing(0); infoLayout->setSpacing(0);
infoLayout->setContentsMargins(3, 4, 0, 8); infoLayout->setContentsMargins(3, 6, 0, 8);
QHBoxLayout *unmountLayout = new QHBoxLayout; QHBoxLayout *unmountLayout = new QHBoxLayout;
unmountLayout->addLayout(infoLayout); unmountLayout->addLayout(infoLayout);
@ -72,7 +75,7 @@ void DiskControlItem::updateInfo(const DiskInfo &info)
{ {
m_info = info; m_info = info;
m_diskIcon->setPixmap(QIcon::fromTheme(info.m_icon, m_unknowIcon).pixmap(32, 32)); m_diskIcon->setPixmap(QIcon::fromTheme(info.m_icon, m_unknowIcon).pixmap(48, 48));
if (!info.m_name.isEmpty()) if (!info.m_name.isEmpty())
m_diskName->setText(info.m_name); m_diskName->setText(info.m_name);
else else

View File

@ -34,7 +34,7 @@ void DiskPluginItem::resizeEvent(QResizeEvent *e)
QSize DiskPluginItem::sizeHint() const QSize DiskPluginItem::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void DiskPluginItem::updateIcon() void DiskPluginItem::updateIcon()

View File

@ -23,6 +23,7 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent)
m_seperator = new HorizontalSeperator; m_seperator = new HorizontalSeperator;
m_seperator->setFixedHeight(1); m_seperator->setFixedHeight(1);
m_seperator->setColor(0.1);
QVBoxLayout *centeralLayout = new QVBoxLayout; QVBoxLayout *centeralLayout = new QVBoxLayout;
centeralLayout->addStretch(); centeralLayout->addStretch();

View File

@ -3,15 +3,21 @@
#include <QPainter> #include <QPainter>
HorizontalSeperator::HorizontalSeperator(QWidget *parent) HorizontalSeperator::HorizontalSeperator(QWidget *parent)
: QWidget(parent) : QWidget(parent),
m_color(255, 255, 255, 255 * 0.1)
{ {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
} }
void HorizontalSeperator::setColor(const QColor color)
{
m_color = color;
}
void HorizontalSeperator::paintEvent(QPaintEvent *e) void HorizontalSeperator::paintEvent(QPaintEvent *e)
{ {
QWidget::paintEvent(e); QWidget::paintEvent(e);
QPainter painter(this); QPainter painter(this);
painter.fillRect(rect(), QColor(255, 255, 255, 255 * 0.1)); painter.fillRect(rect(), m_color);
} }

View File

@ -10,8 +10,13 @@ class HorizontalSeperator : public QWidget
public: public:
explicit HorizontalSeperator(QWidget *parent = 0); explicit HorizontalSeperator(QWidget *parent = 0);
void setColor(const QColor color);
protected: protected:
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
private:
QColor m_color;
}; };
#endif // HORIZONTALSEPERATOR_H #endif // HORIZONTALSEPERATOR_H

View File

@ -11,7 +11,7 @@ DeviceItem::DeviceItem(const QUuid &deviceUuid)
QSize DeviceItem::sizeHint() const QSize DeviceItem::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
const QUuid DeviceItem::uuid() const const QUuid DeviceItem::uuid() const

View File

@ -32,7 +32,7 @@ void WirelessItem::paintEvent(QPaintEvent *e)
const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>(); const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
const int iconSize = std::min(width(), height()) * 0.8; const int iconSize = displayMode == Dock::Fashion ? std::min(width(), height()) * 0.8 : 16;
const QPixmap pixmap = iconPix(displayMode, iconSize); const QPixmap pixmap = iconPix(displayMode, iconSize);
QPainter painter(this); QPainter painter(this);

View File

@ -15,7 +15,7 @@ PluginWidget::PluginWidget(QWidget *parent)
QSize PluginWidget::sizeHint() const QSize PluginWidget::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void PluginWidget::paintEvent(QPaintEvent *e) void PluginWidget::paintEvent(QPaintEvent *e)
@ -29,7 +29,7 @@ void PluginWidget::paintEvent(QPaintEvent *e)
if (displayMode == Dock::Efficient) if (displayMode == Dock::Efficient)
{ {
pixmap = loadSvg(":/icons/resources/icons/normal.svg", QSize(18, 18)); pixmap = loadSvg(":/icons/resources/icons/normal.svg", QSize(16, 16));
break; break;
} }

View File

@ -13,7 +13,7 @@ PowerStatusWidget::PowerStatusWidget(QWidget *parent)
QSize PowerStatusWidget::sizeHint() const QSize PowerStatusWidget::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void PowerStatusWidget::paintEvent(QPaintEvent *e) void PowerStatusWidget::paintEvent(QPaintEvent *e)

View File

@ -14,5 +14,5 @@ void HorizontalSeparator::paintEvent(QPaintEvent *e)
QWidget::paintEvent(e); QWidget::paintEvent(e);
QPainter painter(this); QPainter painter(this);
painter.fillRect(rect(), QColor(255, 255, 255, 255 * 0.5)); painter.fillRect(rect(), QColor(255, 255, 255, 255 * 0.1));
} }

View File

@ -18,6 +18,7 @@ SinkInputWidget::SinkInputWidget(const QString &inputPath, QWidget *parent)
QHBoxLayout *centeralLayout = new QHBoxLayout; QHBoxLayout *centeralLayout = new QHBoxLayout;
centeralLayout->addWidget(m_volumeIcon); centeralLayout->addWidget(m_volumeIcon);
centeralLayout->addSpacing(10);
centeralLayout->addWidget(m_volumeSlider); centeralLayout->addWidget(m_volumeSlider);
centeralLayout->setSpacing(2); centeralLayout->setSpacing(2);
centeralLayout->setMargin(0); centeralLayout->setMargin(0);

View File

@ -30,6 +30,7 @@ SoundApplet::SoundApplet(QWidget *parent)
QHBoxLayout *deviceLineLayout = new QHBoxLayout; QHBoxLayout *deviceLineLayout = new QHBoxLayout;
deviceLineLayout->addWidget(deviceLabel); deviceLineLayout->addWidget(deviceLabel);
// deviceLineLayout->addSpacing(12);
deviceLineLayout->addWidget(new HorizontalSeparator); deviceLineLayout->addWidget(new HorizontalSeparator);
deviceLineLayout->setMargin(0); deviceLineLayout->setMargin(0);
deviceLineLayout->setSpacing(10); deviceLineLayout->setSpacing(10);
@ -37,6 +38,7 @@ SoundApplet::SoundApplet(QWidget *parent)
QHBoxLayout *volumeCtrlLayout = new QHBoxLayout; QHBoxLayout *volumeCtrlLayout = new QHBoxLayout;
volumeCtrlLayout->addSpacing(2); volumeCtrlLayout->addSpacing(2);
volumeCtrlLayout->addWidget(m_volumeBtn); volumeCtrlLayout->addWidget(m_volumeBtn);
volumeCtrlLayout->addSpacing(10);
volumeCtrlLayout->addWidget(m_volumeSlider); volumeCtrlLayout->addWidget(m_volumeSlider);
volumeCtrlLayout->setSpacing(0); volumeCtrlLayout->setSpacing(0);
volumeCtrlLayout->setMargin(0); volumeCtrlLayout->setMargin(0);
@ -59,8 +61,11 @@ SoundApplet::SoundApplet(QWidget *parent)
m_centeralLayout = new QVBoxLayout; m_centeralLayout = new QVBoxLayout;
m_centeralLayout->addLayout(deviceLineLayout); m_centeralLayout->addLayout(deviceLineLayout);
m_centeralLayout->addSpacing(8);
m_centeralLayout->addLayout(volumeCtrlLayout); m_centeralLayout->addLayout(volumeCtrlLayout);
m_centeralLayout->addSpacing(10);
m_centeralLayout->addWidget(m_applicationTitle); m_centeralLayout->addWidget(m_applicationTitle);
m_centeralLayout->addSpacing(8);
m_centeralWidget->setLayout(m_centeralLayout); m_centeralWidget->setLayout(m_centeralLayout);
m_centeralWidget->setFixedWidth(WIDTH); m_centeralWidget->setFixedWidth(WIDTH);
@ -124,7 +129,7 @@ void SoundApplet::volumeSliderValueChanged()
void SoundApplet::sinkInputsChanged() void SoundApplet::sinkInputsChanged()
{ {
QVBoxLayout *appLayout = m_centeralLayout; QVBoxLayout *appLayout = m_centeralLayout;
while (QLayoutItem *item = appLayout->takeAt(3)) while (QLayoutItem *item = appLayout->takeAt(6))
{ {
delete item->widget(); delete item->widget();
delete item; delete item;

View File

@ -24,7 +24,7 @@ QWidget *SoundItem::popupApplet()
QSize SoundItem::sizeHint() const QSize SoundItem::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void SoundItem::resizeEvent(QResizeEvent *e) void SoundItem::resizeEvent(QResizeEvent *e)
@ -75,7 +75,7 @@ void SoundItem::refershIcon()
iconString = QString("audio-volume-%1-symbolic").arg(volumeString); iconString = QString("audio-volume-%1-symbolic").arg(volumeString);
} }
const int iconSize = std::min(width(), height()) * 0.8; const int iconSize = displayMode == Dock::Fashion ? std::min(width(), height()) * 0.8 : 16;
const QIcon icon = QIcon::fromTheme(iconString); const QIcon icon = QIcon::fromTheme(iconString);
m_iconPixmap = icon.pixmap(iconSize, iconSize); m_iconPixmap = icon.pixmap(iconSize, iconSize);

View File

@ -44,7 +44,7 @@ const QImage TrayWidget::trayImage() const
QSize TrayWidget::sizeHint() const QSize TrayWidget::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void TrayWidget::paintEvent(QPaintEvent *e) void TrayWidget::paintEvent(QPaintEvent *e)

View File

@ -29,7 +29,7 @@ QWidget *TrashWidget::popupApplet()
QSize TrashWidget::sizeHint() const QSize TrashWidget::sizeHint() const
{ {
return QSize(20, 20); return QSize(26, 26);
} }
void TrashWidget::dragEnterEvent(QDragEnterEvent *e) void TrashWidget::dragEnterEvent(QDragEnterEvent *e)
@ -64,13 +64,15 @@ void TrashWidget::resizeEvent(QResizeEvent *e)
void TrashWidget::updateIcon() void TrashWidget::updateIcon()
{ {
const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
QString iconString = "user-trash"; QString iconString = "user-trash";
if (!m_popupApplet->empty()) if (!m_popupApplet->empty())
iconString.append("-full"); iconString.append("-full");
if (qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>() == Dock::Efficient) if (displayMode == Dock::Efficient)
iconString.append("-symbolic"); iconString.append("-symbolic");
const int size = std::min(width(), height()) * 0.8; const int size = displayMode == Dock::Fashion ? std::min(width(), height()) * 0.8 : 16;
QIcon icon = QIcon::fromTheme(iconString); QIcon icon = QIcon::fromTheme(iconString);
m_icon = icon.pixmap(size, size); m_icon = icon.pixmap(size, size);