mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
update app preview size
Change-Id: I330f7b86c9aaf77b64d4d326a9e653d22da03045
This commit is contained in:
parent
79f1630578
commit
b3a35bc81e
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Mon, 21 Sep 2015 15:19:47 +0800 Reviewed-on: https://cr.deepin.io/7221 Project: dde/dde-dock Branch: refs/heads/master
@ -60,14 +60,22 @@ QPushButton#PreviewCloseButton:pressed {
|
||||
border-image: url(:/images/resources/dark/images/close_press.png);
|
||||
}
|
||||
|
||||
QFrame#WindowPreview[isHover="true"] {
|
||||
QFrame#WindowPreview {
|
||||
border-radius: 3px;
|
||||
border-width: 3px;
|
||||
border-style: solid;
|
||||
border-color: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
QFrame#WindowPreview[isHover="true"] {
|
||||
border-color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
QLabel#AppPreviewFrameTitle {
|
||||
border-top-left-radius: 0px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-right-radius: 0px;
|
||||
border-bottom-right-radius: 3px;
|
||||
font-size: 10px;
|
||||
color: #FFFFFF;
|
||||
background-color: rgba(0,0,0,0.7);
|
||||
|
@ -16,9 +16,9 @@ enum HideMode {
|
||||
};
|
||||
|
||||
//////////////// App ////////////////////////////////
|
||||
const int APP_PREVIEW_WIDTH = 160;
|
||||
const int APP_PREVIEW_HEIGHT = 100;
|
||||
const int APP_PREVIEW_MARGIN = 6 ; //20 - 28 / 2
|
||||
const int APP_PREVIEW_WIDTH = 200;
|
||||
const int APP_PREVIEW_HEIGHT = 124;
|
||||
const int APP_PREVIEW_MARGIN = 20 ;
|
||||
const int APP_PREVIEW_CLOSEBUTTON_SIZE = 26;
|
||||
|
||||
const int APP_ITEM_FASHION_HEIGHT = 70;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "apppreviews.h"
|
||||
|
||||
AppPreviewFrame::AppPreviewFrame(const QString &title, int xid, QWidget *parent) :
|
||||
QWidget(parent),xidValue(xid)
|
||||
QFrame(parent),xidValue(xid)
|
||||
{
|
||||
addPreview(xid);
|
||||
setTitle(title);
|
||||
@ -18,8 +18,8 @@ void AppPreviewFrame::addPreview(int xid)
|
||||
m_preview = new WindowPreview(xid, this);
|
||||
m_preview->resize(Dock::APP_PREVIEW_WIDTH,Dock::APP_PREVIEW_HEIGHT);
|
||||
|
||||
resize(m_preview->width() + BUTTON_SIZE, m_preview->height() + BUTTON_SIZE);
|
||||
m_preview->move(BUTTON_SIZE / 2, BUTTON_SIZE / 2);
|
||||
setFixedSize(m_preview->width() + BUTTON_SIZE / 2, m_preview->height() + BUTTON_SIZE);
|
||||
m_preview->move(0, BUTTON_SIZE / 2);
|
||||
}
|
||||
|
||||
void AppPreviewFrame::setTitle(const QString &t)
|
||||
@ -29,8 +29,8 @@ void AppPreviewFrame::setTitle(const QString &t)
|
||||
QFontMetrics fm(titleLabel->font());
|
||||
titleLabel->setText(fm.elidedText(t,Qt::ElideRight,width()));
|
||||
titleLabel->setAlignment(Qt::AlignCenter);
|
||||
titleLabel->resize(width() - BUTTON_SIZE - PREVIEW_BORDER_WIDTH * 2, TITLE_HEIGHT);
|
||||
titleLabel->move(BUTTON_SIZE / 2 + PREVIEW_BORDER_WIDTH, height() - titleLabel->height() - BUTTON_SIZE / 2 - PREVIEW_BORDER_WIDTH);
|
||||
titleLabel->resize(width() - BUTTON_SIZE / 2, TITLE_HEIGHT);
|
||||
titleLabel->move(0, height() - titleLabel->height() - BUTTON_SIZE / 2);
|
||||
}
|
||||
|
||||
void AppPreviewFrame::mousePressEvent(QMouseEvent *)
|
||||
@ -56,7 +56,7 @@ void AppPreviewFrame::addCloseButton()
|
||||
{
|
||||
m_cb = new QPushButton(this);
|
||||
m_cb->setObjectName("PreviewCloseButton");
|
||||
m_cb->resize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
m_cb->setFixedSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
m_cb->move(width() - m_cb->width(), 0);
|
||||
m_cb->hide();
|
||||
|
||||
@ -76,7 +76,9 @@ void AppPreviewFrame::hideCloseButton()
|
||||
AppPreviews::AppPreviews(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_mainLayout = new QHBoxLayout(this);
|
||||
m_mainLayout->setMargin(0);
|
||||
m_mainLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
m_mainLayout->setContentsMargins(20 - PREVIEW_PADDING, 0, 0, 0);
|
||||
m_mainLayout->setSpacing(Dock::APP_PREVIEW_MARGIN - BUTTON_SIZE / 2);
|
||||
setLayout(m_mainLayout);
|
||||
resize(Dock::APP_PREVIEW_WIDTH,Dock::APP_PREVIEW_HEIGHT);
|
||||
}
|
||||
@ -85,8 +87,6 @@ void AppPreviews::addItem(const QString &title, int xid)
|
||||
{
|
||||
if (m_xidList.indexOf(xid) != -1)
|
||||
return;
|
||||
m_mainLayout->setMargin(Dock::APP_PREVIEW_MARGIN);
|
||||
m_mainLayout->setSpacing(0);
|
||||
m_xidList.append(xid);
|
||||
|
||||
AppPreviewFrame *f = new AppPreviewFrame(title, xid);
|
||||
@ -95,8 +95,7 @@ void AppPreviews::addItem(const QString &title, int xid)
|
||||
|
||||
m_mainLayout->addWidget(f);
|
||||
|
||||
int contentWidth = m_mainLayout->count() * (f->width() + Dock::APP_PREVIEW_MARGIN) + Dock::APP_PREVIEW_MARGIN;
|
||||
resize(contentWidth,f->height() + Dock::APP_PREVIEW_MARGIN*2);
|
||||
resize(getContentSize());
|
||||
}
|
||||
|
||||
void AppPreviews::leaveEvent(QEvent *)
|
||||
@ -117,10 +116,7 @@ void AppPreviews::removePreview(int xid)
|
||||
return;
|
||||
}
|
||||
|
||||
int contentWidth = m_mainLayout->count()
|
||||
* (Dock::APP_PREVIEW_WIDTH + Dock::APP_PREVIEW_MARGIN + Dock::APP_PREVIEW_CLOSEBUTTON_SIZE)
|
||||
+ Dock::APP_PREVIEW_MARGIN + Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
resize(contentWidth,Dock::APP_PREVIEW_HEIGHT + Dock::APP_PREVIEW_CLOSEBUTTON_SIZE + Dock::APP_PREVIEW_MARGIN*2);
|
||||
resize(getContentSize());
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
@ -140,6 +136,16 @@ void AppPreviews::clearUpPreview()
|
||||
m_xidList.clear();
|
||||
}
|
||||
|
||||
QSize AppPreviews::getContentSize()
|
||||
{
|
||||
|
||||
int contentWidth = m_mainLayout->count() * (Dock::APP_PREVIEW_WIDTH + Dock::APP_PREVIEW_MARGIN)
|
||||
+ Dock::APP_PREVIEW_MARGIN - PREVIEW_PADDING * 2;
|
||||
int contentHeight = Dock::APP_PREVIEW_HEIGHT + Dock::APP_PREVIEW_MARGIN*2 - PREVIEW_PADDING * 2;
|
||||
|
||||
return QSize(contentWidth, contentHeight);
|
||||
}
|
||||
|
||||
AppPreviews::~AppPreviews()
|
||||
{
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "dbus/dbusclientmanager.h"
|
||||
#include "interfaces/dockconstants.h"
|
||||
|
||||
class AppPreviewFrame : public QWidget
|
||||
class AppPreviewFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -65,12 +65,15 @@ public slots:
|
||||
void removePreview(int xid);
|
||||
void activatePreview(int xid);
|
||||
void clearUpPreview();
|
||||
QSize getContentSize();
|
||||
|
||||
private:
|
||||
DBusClientManager *m_clientManager = new DBusClientManager(this);
|
||||
QHBoxLayout *m_mainLayout = NULL;
|
||||
QList<int> m_xidList;
|
||||
bool m_isClosing = false;
|
||||
const int PREVIEW_PADDING = 5;
|
||||
const int BUTTON_SIZE = Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
};
|
||||
|
||||
#endif // APPPREVIEWS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user