From aa56197885c849053787839c3e4d749eebfa8ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8D=9A=E6=96=87?= Date: Wed, 15 Jun 2016 11:20:05 +0800 Subject: [PATCH] optimize icon size Change-Id: I9baecb3881cf8267246e41c853138514bda1b61b --- item/appitem.cpp | 20 ++++++++++++++------ item/appitem.h | 5 +++-- panel/mainpanel.cpp | 2 +- window/mainwindow.cpp | 5 ++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/item/appitem.cpp b/item/appitem.cpp index c9488c3a6..99b6092fa 100644 --- a/item/appitem.cpp +++ b/item/appitem.cpp @@ -24,11 +24,11 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent) m_id = m_itemEntry->id(); - connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::titlesChanged); + connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::updateTitle); connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, static_cast(&AppItem::update)); - titlesChanged(); - iconChanged(); + updateTitle(); + updateIcon(); } const QString AppItem::appId() const @@ -98,6 +98,13 @@ void AppItem::mouseMoveEvent(QMouseEvent *e) startDrag(); } +void AppItem::resizeEvent(QResizeEvent *e) +{ + DockItem::resizeEvent(e); + + updateIcon(); +} + void AppItem::startDrag() { m_draging = true; @@ -130,16 +137,17 @@ void AppItem::initClientManager() // }); } -void AppItem::titlesChanged() +void AppItem::updateTitle() { m_titles = m_itemEntry->titles(); update(); } -void AppItem::iconChanged() +void AppItem::updateIcon() { const QString icon = m_itemEntry->icon(); + const int iconSize = qMin(width(), height()) * 0.8; - m_icon = ThemeAppIcon::getIcon(icon, 48); + m_icon = ThemeAppIcon::getIcon(icon, iconSize); } diff --git a/item/appitem.h b/item/appitem.h index 1c8f929fa..514f88787 100644 --- a/item/appitem.h +++ b/item/appitem.h @@ -19,13 +19,14 @@ private: void mouseReleaseEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e); + void resizeEvent(QResizeEvent *e); void startDrag(); void initClientManager(); private slots: - void titlesChanged(); - void iconChanged(); + void updateTitle(); + void updateIcon(); private: DBusDockEntry *m_itemEntry; diff --git a/panel/mainpanel.cpp b/panel/mainpanel.cpp index 50e7992c5..c5aecf01c 100644 --- a/panel/mainpanel.cpp +++ b/panel/mainpanel.cpp @@ -10,7 +10,7 @@ MainPanel::MainPanel(QWidget *parent) m_itemController(DockItemController::instance(this)) { m_itemLayout->setSpacing(0); - m_itemLayout->setContentsMargins(5, 5, 5, 5); + m_itemLayout->setContentsMargins(0, 0, 0, 0); setAcceptDrops(true); setObjectName("MainPanel"); diff --git a/window/mainwindow.cpp b/window/mainwindow.cpp index 11dd831eb..ff217c3d7 100644 --- a/window/mainwindow.cpp +++ b/window/mainwindow.cpp @@ -70,7 +70,7 @@ void MainWindow::updatePosition() setFixedWidth(screenRect.width()); setFixedHeight(60); - move(0, screenRect.bottom() - 60); + move(0, screenRect.height() - 60); setStrutPartial(); } @@ -82,6 +82,9 @@ void MainWindow::clearStrutPartial() void MainWindow::setStrutPartial() { + // first, clear old strut partial + clearStrutPartial(); + const DockSettings::DockSide side = m_settings->side(); const int maxScreenHeight = m_displayInter->screenHeight();