optimize icon size

Change-Id: I9baecb3881cf8267246e41c853138514bda1b61b
This commit is contained in:
石博文 2016-06-15 11:20:05 +08:00 committed by Hualet Wang
parent e5b63e9dcb
commit aa56197885
4 changed files with 22 additions and 10 deletions

View File

@ -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<void (AppItem::*)()>(&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);
}

View File

@ -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;

View File

@ -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");

View File

@ -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();