mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add snapshot widget
Change-Id: I170cca94efd60b1d18f33773626f6af92d51f1f5
This commit is contained in:
parent
8022e96d40
commit
0f1e3db89f
Notes:
Deepin Code Review
2017-05-22 15:19:08 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Mon, 22 May 2017 15:19:02 +0800 Reviewed-on: https://cr.deepin.io/23316 Project: dde/dde-dock Branch: refs/heads/master
@ -40,7 +40,8 @@ SOURCES += main.cpp \
|
||||
dbus/dbusdockadaptors.cpp \
|
||||
item/components/previewcontainer.cpp \
|
||||
item/components/previewwidget.cpp \
|
||||
item/components/_previewcontainer.cpp
|
||||
item/components/_previewcontainer.cpp \
|
||||
item/components/appsnapshot.cpp
|
||||
|
||||
HEADERS += \
|
||||
window/mainwindow.h \
|
||||
@ -71,7 +72,8 @@ HEADERS += \
|
||||
dbus/dbusdockadaptors.h \
|
||||
item/components/previewcontainer.h \
|
||||
item/components/previewwidget.h \
|
||||
item/components/_previewcontainer.h
|
||||
item/components/_previewcontainer.h \
|
||||
item/components/appsnapshot.h
|
||||
|
||||
dbus_service.files += com.deepin.dde.Dock.service
|
||||
dbus_service.path = /usr/share/dbus-1/services
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "_previewcontainer.h"
|
||||
|
||||
#define FIXED_WIDTH 200
|
||||
#define FIXED_HEIGHT 130
|
||||
|
||||
_PreviewContainer::_PreviewContainer(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
||||
@ -14,7 +17,25 @@ _PreviewContainer::_PreviewContainer(QWidget *parent)
|
||||
|
||||
void _PreviewContainer::setWindowInfos(const WindowDict &infos)
|
||||
{
|
||||
qDebug() << infos;
|
||||
// check removed window
|
||||
for (auto it(m_snapshots.begin()); it != m_snapshots.end();)
|
||||
{
|
||||
if (!infos.contains(it.key()))
|
||||
{
|
||||
it.value()->deleteLater();
|
||||
it = m_snapshots.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it(infos.cbegin()); it != infos.cend(); ++it)
|
||||
{
|
||||
if (!m_snapshots.contains(it.key()))
|
||||
appendSnapWidget(it.key());
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void _PreviewContainer::updateLayoutDirection(const Dock::Position dockPos)
|
||||
@ -23,4 +44,30 @@ void _PreviewContainer::updateLayoutDirection(const Dock::Position dockPos)
|
||||
m_windowListLayout->setDirection(QBoxLayout::LeftToRight);
|
||||
else
|
||||
m_windowListLayout->setDirection(QBoxLayout::TopToBottom);
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void _PreviewContainer::adjustSize()
|
||||
{
|
||||
const bool horizontal = m_windowListLayout->direction() == QBoxLayout::LeftToRight;
|
||||
const int count = m_snapshots.size();
|
||||
|
||||
if (horizontal)
|
||||
{
|
||||
setFixedHeight(FIXED_HEIGHT);
|
||||
setFixedWidth(FIXED_WIDTH * count);
|
||||
} else {
|
||||
setFixedWidth(FIXED_WIDTH);
|
||||
setFixedHeight(FIXED_HEIGHT * count);
|
||||
}
|
||||
}
|
||||
|
||||
void _PreviewContainer::appendSnapWidget(const WId wid)
|
||||
{
|
||||
AppSnapshot *snap = new AppSnapshot;
|
||||
|
||||
m_windowListLayout->addWidget(snap);
|
||||
|
||||
m_snapshots.insert(wid, snap);
|
||||
}
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
#include <QTimer>
|
||||
|
||||
#include "dbus/dbusdockentry.h"
|
||||
#include "constants.h"
|
||||
#include "appsnapshot.h"
|
||||
|
||||
#include <DWindowManagerHelper>
|
||||
|
||||
@ -31,12 +33,15 @@ public slots:
|
||||
void updateLayoutDirection(const Dock::Position dockPos);
|
||||
|
||||
private:
|
||||
QMap<WId, QWidget *> m_windows;
|
||||
void adjustSize();
|
||||
void appendSnapWidget(const WId wid);
|
||||
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
private:
|
||||
QMap<WId, AppSnapshot *> m_snapshots;
|
||||
|
||||
QBoxLayout *m_windowListLayout;
|
||||
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
};
|
||||
|
||||
#endif // _PREVIEWCONTAINER_H
|
||||
|
7
frame/item/components/appsnapshot.cpp
Normal file
7
frame/item/components/appsnapshot.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "appsnapshot.h"
|
||||
|
||||
AppSnapshot::AppSnapshot(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
||||
}
|
14
frame/item/components/appsnapshot.h
Normal file
14
frame/item/components/appsnapshot.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef APPSNAPSHOT_H
|
||||
#define APPSNAPSHOT_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class AppSnapshot : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AppSnapshot(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
#endif // APPSNAPSHOT_H
|
Loading…
x
Reference in New Issue
Block a user