add margins

Change-Id: I9ab40b1059e5950923375fc554653c9bb8eef40b
This commit is contained in:
石博文 2017-05-22 17:41:36 +08:00
parent e0b2be7cb7
commit fd82c588c1
Notes: Deepin Code Review 2017-05-22 17:47:29 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Mon, 22 May 2017 17:47:27 +0800
Reviewed-on: https://cr.deepin.io/23329
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 11 additions and 6 deletions

View File

@ -3,17 +3,19 @@
#define FIXED_WIDTH 200
#define FIXED_HEIGHT 130
#define SPACING 5
#define MARGIN 5
_PreviewContainer::_PreviewContainer(QWidget *parent)
: QWidget(parent),
m_wmHelper(DWindowManagerHelper::instance())
{
m_windowListLayout = new QVBoxLayout;
m_windowListLayout = new QBoxLayout(QBoxLayout::LeftToRight);
m_windowListLayout->setSpacing(SPACING);
m_windowListLayout->setMargin(0);
m_windowListLayout->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN);
setLayout(m_windowListLayout);
setFixedSize(FIXED_WIDTH, FIXED_HEIGHT);
}
void _PreviewContainer::setWindowInfos(const WindowDict &infos)
@ -23,6 +25,7 @@ void _PreviewContainer::setWindowInfos(const WindowDict &infos)
{
if (!infos.contains(it.key()))
{
m_windowListLayout->removeWidget(it.value());
it.value()->deleteLater();
it = m_snapshots.erase(it);
} else {
@ -59,11 +62,11 @@ void _PreviewContainer::adjustSize()
if (horizontal)
{
setFixedHeight(FIXED_HEIGHT);
setFixedWidth(FIXED_WIDTH * count + SPACING * (count - 1));
setFixedHeight(FIXED_HEIGHT + MARGIN * 2);
setFixedWidth(FIXED_WIDTH * count + MARGIN * 2 + SPACING * (count - 1));
} else {
setFixedWidth(FIXED_WIDTH);
setFixedHeight(FIXED_HEIGHT * count + SPACING * (count - 1));
setFixedWidth(FIXED_WIDTH + MARGIN * 2);
setFixedHeight(FIXED_HEIGHT * count + MARGIN * 2 + SPACING * (count - 1));
}
}

View File

@ -19,6 +19,8 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
m_fetchSnapshotTimer->setInterval(10);
connect(m_fetchSnapshotTimer, &QTimer::timeout, this, &AppSnapshot::fetchSnapshot, Qt::QueuedConnection);
QTimer::singleShot(1, this, &AppSnapshot::fetchSnapshot);
}
void AppSnapshot::fetchSnapshot()