optimize dock panel color and size

Change-Id: I387ab618ebe02137cdfb32cfa0455ac665b6afdb
This commit is contained in:
石博文 2016-07-11 17:17:32 +08:00 committed by Hualet Wang
parent 60b0600284
commit fb29c69923
4 changed files with 64 additions and 16 deletions

View File

@ -55,7 +55,10 @@ int AppItem::itemBaseWidth()
int AppItem::itemBaseHeight()
{
return IconBaseSize * 1.5;
if (DockDisplayMode == Efficient)
return IconBaseSize * 1.2;
else
return IconBaseSize * 1.5;
}
void AppItem::paintEvent(QPaintEvent *e)
@ -72,14 +75,27 @@ void AppItem::paintEvent(QPaintEvent *e)
const QRect itemRect = rect();
// draw background
const QRect backgroundRect = itemRect.marginsRemoved(QMargins(1, 2, 1, 2));
QRect backgroundRect = itemRect;
if (DockDisplayMode == Efficient)
{
switch (DockPosition)
{
case Top:
case Bottom:
backgroundRect = itemRect.marginsRemoved(QMargins(2, 1, 2, 1));
case Left:
case Right:
backgroundRect = itemRect.marginsRemoved(QMargins(1, 2, 1, 2));
}
}
if (DockDisplayMode == Efficient)
{
if (m_active)
{
painter.fillRect(backgroundRect, QColor(70, 100, 200, 120));
painter.fillRect(backgroundRect, QColor(44, 167, 248, 255 * 0.3));
const int activeLineWidth = 3;
const int activeLineWidth = itemRect.height() > 50 ? 4 : 2;
QRect activeRect = backgroundRect;
switch (DockPosition)
{
@ -89,10 +105,10 @@ void AppItem::paintEvent(QPaintEvent *e)
case Right: activeRect.setLeft(activeRect.right() - activeLineWidth); break;
}
painter.fillRect(activeRect, QColor(47, 168, 247));
painter.fillRect(activeRect, QColor(44, 167, 248, 255));
}
else if (!m_titles.isEmpty())
painter.fillRect(backgroundRect, QColor(255, 255, 255, 50));
painter.fillRect(backgroundRect, QColor(255, 255, 255, 255 * 0.2));
// else
// painter.fillRect(backgroundRect, Qt::gray);
}
@ -100,28 +116,32 @@ void AppItem::paintEvent(QPaintEvent *e)
{
if (!m_titles.isEmpty())
{
const int activeLineWidth = 1;
const int activeLineWidth = 2;
const int activeLineLength = 20;
QRect activeRect = itemRect;
switch (DockPosition)
{
case Top:
activeRect.setBottom(activeRect.top() + activeLineWidth);
activeRect.moveBottom(activeRect.bottom() + 1);
activeRect.setWidth(activeLineLength);
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
break;
case Bottom:
activeRect.setTop(activeRect.bottom() - activeLineWidth);
activeRect.moveTop(activeRect.top() - 1);
activeRect.setWidth(activeLineLength);
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
break;
case Left:
activeRect.setRight(activeRect.left() + activeLineWidth);
activeRect.moveRight(activeRect.right() + 1);
activeRect.setHeight(activeLineLength);
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
break;
case Right:
activeRect.setLeft(activeRect.right() - activeLineWidth);
activeRect.moveLeft(activeRect.left() - 1);
activeRect.setHeight(activeLineLength);
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
break;
@ -252,8 +272,14 @@ void AppItem::updateIcon()
const QString icon = m_itemEntry->icon();
const int iconSize = qMin(width(), height());
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
if (DockDisplayMode == Efficient)
{
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7);
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9);
} else {
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
}
}
void AppItem::activeChanged()

View File

@ -32,8 +32,14 @@ void LauncherItem::resizeEvent(QResizeEvent *e)
DockItem::resizeEvent(e);
const int iconSize = qMin(width(), height());
m_smallIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.6);
m_largeIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.8);
if (DockDisplayMode == Efficient)
{
m_smallIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.7);
m_largeIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.9);
} else {
m_smallIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.6);
m_largeIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.8);
}
}
void LauncherItem::mousePressEvent(QMouseEvent *e)

View File

@ -21,8 +21,8 @@ MainPanel::MainPanel(QWidget *parent)
setAcceptDrops(true);
setObjectName("MainPanel");
setStyleSheet("QWidget #MainPanel {"
"border:none;"
"background-color:rgba(0, 0, 0, .65);"
"border:1px solid rgba(162, 162, 162, .2);"
"background-color:rgba(10, 10, 10, .6);"
"}"
// Top
"QWidget #MainPanel[displayMode='0'][position='0'] {"
@ -36,13 +36,29 @@ MainPanel::MainPanel(QWidget *parent)
"}"
// Bottom
"QWidget #MainPanel[displayMode='0'][position='2'] {"
"border-top-left-radius:5px;"
"border-top-right-radius:5px;"
"border-top-left-radius:6px;"
"border-top-right-radius:6px;"
"}"
// Left
"QWidget #MainPanel[displayMode='0'][position='3'] {"
"border-top-right-radius:5px;"
"border-bottom-right-radius:5px;"
"}"
"QWidget #MainPanel[position='0'] {"
"padding:0 6px;"
"border-top:none;"
"}"
"QWidget #MainPanel[position='1'] {"
"padding:6px 0;"
"border-right:none;"
"}"
"QWidget #MainPanel[position='2'] {"
"padding:0 6px;"
"border-bottom:none;"
"}"
"QWidget #MainPanel[position='3'] {"
"padding:6px 0;"
"border-left:none;"
"}");
connect(m_itemController, &DockItemController::itemInserted, this, &MainPanel::itemInserted);

View File

@ -6,7 +6,7 @@
#define ICON_SIZE_LARGE 48
#define ICON_SIZE_MEDIUM 36
#define ICON_SIZE_SMALL 24
#define ICON_SIZE_SMALL 30
DockSettings::DockSettings(QWidget *parent)
: QObject(parent),