bugfix: show desktop menu when click the empty area on fashion-mode

Change-Id: I966b1500b63313961f4e46333ec3ef2f152a09ee
This commit is contained in:
杨万青 2015-09-22 10:06:25 +08:00
parent 86bb370595
commit ad377421a6
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: Tue, 22 Sep 2015 16:36:01 +0800
Reviewed-on: https://cr.deepin.io/7241
Project: dde/dde-dock
Branch: refs/heads/master
4 changed files with 38 additions and 22 deletions

View File

@ -9,11 +9,12 @@ MainWidget::MainWidget(QWidget *parent)
QRect rec = QApplication::desktop()->screenGeometry();
this->setFixedSize(rec.width(),m_dmd->getDockHeight());
this->move(0, rec.height() - this->height());
this->move((rec.width() - width()) / 2, rec.height() - this->height());
mainPanel = new Panel(this);
connect(mainPanel,&Panel::startShow,this,&MainWidget::showDock);
connect(mainPanel,&Panel::panelHasHidden,this,&MainWidget::hideDock);
m_mainPanel = new Panel(this);
connect(m_mainPanel,&Panel::startShow,this,&MainWidget::showDock);
connect(m_mainPanel,&Panel::panelHasHidden,this,&MainWidget::hideDock);
connect(m_mainPanel, &Panel::sizeChanged, this, &MainWidget::onPanelSizeChanged);
this->setWindowFlags(Qt::Window);
this->setAttribute(Qt::WA_TranslucentBackground);
@ -37,7 +38,7 @@ void MainWidget::changeDockMode(Dock::DockMode, Dock::DockMode)
QRect rec = QApplication::desktop()->screenGeometry();
this->setFixedSize(rec.width(),m_dmd->getDockHeight());
this->move(0, rec.height() - this->height());
this->move((rec.width() - width()) / 2, rec.height() - this->height());
updateXcbStructPartial();
}
@ -70,22 +71,22 @@ void MainWidget::enterEvent(QEvent *event)
{
if (height() == 1){
showDock();
mainPanel->setContainMouse(true);
mainPanel->startShow();
m_mainPanel->setContainMouse(true);
m_mainPanel->startShow();
}
}
void MainWidget::leaveEvent(QEvent *)
{
mainPanel->setContainMouse(false);
m_mainPanel->setContainMouse(false);
}
void MainWidget::showDock()
{
hasHidden = false;
QRect rec = QApplication::desktop()->screenGeometry();
this->setFixedSize(rec.width(),m_dmd->getDockHeight());
this->move(0, rec.height() - this->height());
this->setFixedSize(m_mainPanel->width(), m_dmd->getDockHeight());
this->move((rec.width() - width()) / 2, rec.height() - this->height());
updateXcbStructPartial();
}
@ -94,11 +95,18 @@ void MainWidget::hideDock()
hasHidden = true;
QRect rec = QApplication::desktop()->screenGeometry();
//set height with 0 mean window is hidden,Windows manager will handle it's showing animation
this->setFixedSize(rec.width(),1);
this->move(0, rec.height() - 1);//1 pixel for grab mouse enter event to show panel
this->setFixedSize(m_mainPanel->width(), 1);
this->move((rec.width() - width()) / 2, rec.height() - 1);//1 pixel for grab mouse enter event to show panel
updateXcbStructPartial();
}
void MainWidget::onPanelSizeChanged()
{
this->setFixedSize(m_mainPanel->size());
QRect rec = QApplication::desktop()->screenGeometry();
this->move((rec.width() - width()) / 2, y());
}
MainWidget::~MainWidget()
{

View File

@ -33,12 +33,14 @@ protected:
private:
void showDock();
void hideDock();
void onPanelSizeChanged();
void changeDockMode(Dock::DockMode, Dock::DockMode);
void updateXcbStructPartial();
void initHideStateManager();
void initDockSetting();
private:
Panel *mainPanel = NULL;
Panel *m_mainPanel = NULL;
bool hasHidden = false;
DockModeData * m_dmd = DockModeData::instance();
DBusHideStateManager *m_dhsm = NULL;

View File

@ -94,7 +94,7 @@ void Panel::initWidthAnimation()
m_pluginLayout->move(width() - m_pluginLayout->width() - FASHION_PANEL_RPADDING, 1);
updateRightReflection();
this->move((m_parentWidget->width() - width()) / 2,0);
emit sizeChanged();
});
}
@ -229,14 +229,16 @@ void Panel::onLayoutContentsWidthChanged()
}
else
{
QRect rec = QApplication::desktop()->screenGeometry();
m_pluginLayout->resize(m_pluginLayout->getContentsWidth(),m_dockModeData->getItemHeight());
m_pluginLayout->move(m_parentWidget->width() - m_pluginLayout->width(),1);
m_pluginLayout->move(rec.width() - m_pluginLayout->width(),1);
m_appLayout->move(0,1);
m_appLayout->resize(m_parentWidget->width() - m_pluginLayout->width() ,m_dockModeData->getItemHeight());
m_appLayout->resize(rec.width() - m_pluginLayout->width() ,m_dockModeData->getItemHeight());
this->setFixedSize(m_appLayout->width() + m_pluginLayout->width(),m_dockModeData->getDockHeight());
this->move((m_parentWidget->width() - m_appLayout->width() - m_pluginLayout->width()) / 2,0);
emit sizeChanged();
}
}
@ -324,18 +326,21 @@ void Panel::reanchorsLayout(Dock::DockMode mode)
m_appLayout->move(FASHION_PANEL_LPADDING,1);
m_pluginLayout->move(m_appLayout->x() + m_appLayout->width() - m_dockModeData->getAppItemSpacing(),1);
this->move((m_parentWidget->width() - width()) / 2,0);
emit sizeChanged();
}
else
{
QRect rec = QApplication::desktop()->screenGeometry();
m_pluginLayout->resize(m_pluginLayout->getContentsWidth(), m_dockModeData->getItemHeight());
m_pluginLayout->move(m_parentWidget->width() - m_pluginLayout->width(),1);
m_pluginLayout->move(rec.width() - m_pluginLayout->width(),1);
m_appLayout->move(0,1);
m_appLayout->resize(m_parentWidget->width() - m_pluginLayout->width() ,m_dockModeData->getItemHeight());
m_appLayout->resize(rec.width() - m_pluginLayout->width() ,m_dockModeData->getItemHeight());
this->setFixedSize(m_appLayout->width() + m_pluginLayout->width(), m_dockModeData->getDockHeight());
this->move((m_parentWidget->width() - m_appLayout->width() - m_pluginLayout->width()) / 2,0);
emit sizeChanged();
}
}

View File

@ -30,12 +30,14 @@ public:
void setContainMouse(bool value); //for smart-hide and keep-hide
bool isFashionMode(); //for qss setting background
void showPanelMenu();
signals:
void startShow();
void startHide();
void panelHasShown();
void panelHasHidden();
void sizeChanged();
protected:
void mousePressEvent(QMouseEvent *event);
@ -70,7 +72,6 @@ private:
void showPluginLayoutMask();
void hidePluginLayoutMask();
void reloadStyleSheet();
void showPanelMenu();
void setY(int value); //for hide and show animation
private: