fix(desktop_menu): update size request

pull/31/head
kate 5 years ago
parent 11697565e1
commit 2bcb04a0db

@ -53,8 +53,10 @@ Item {
anchors.fill: parent anchors.fill: parent
color: "transparent" color: "transparent"
radius: _background.radius radius: _background.radius
border.width: 1 / FishUI.Theme.devicePixelRatio
border.pixelAligned: FishUI.Theme.devicePixelRatio > 1 ? false : true
border.color: FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.1) : Qt.rgba(0, 0, 0, 0.1) border.color: FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.1) : Qt.rgba(0, 0, 0, 0.1)
visible: control.borderEnabled visible: control.borderEnabled
antialiasing: true antialiasing: true
} }
} }

@ -71,7 +71,7 @@ Window {
FishUI.WindowShadow { FishUI.WindowShadow {
view: control view: control
radius: _background.radius radius: _background.radius
strength: control.active ? 1.5 : 0.5 strength: control.active ? 1.5 : 0.9
} }
// Left bottom edge // Left bottom edge

@ -97,6 +97,9 @@ void MenuPopupWindow::setPopupContentItem(QQuickItem *contentItem)
contentItem->setParentItem(this->contentItem()); contentItem->setParentItem(this->contentItem());
m_contentItem = contentItem; m_contentItem = contentItem;
connect(contentItem, &QQuickItem::implicitWidthChanged, this, &MenuPopupWindow::updateGeometry);
connect(contentItem, &QQuickItem::implicitHeightChanged, this, &MenuPopupWindow::updateGeometry);
} }
void MenuPopupWindow::dismissPopup() void MenuPopupWindow::dismissPopup()
@ -106,6 +109,16 @@ void MenuPopupWindow::dismissPopup()
hide(); hide();
} }
void MenuPopupWindow::updateGeometry()
{
int w = m_contentItem->implicitWidth();
int h = m_contentItem->implicitHeight() + 16;
int posx = geometry().x();
int posy = geometry().y();
setGeometry(posx, posy, w, h);
}
void MenuPopupWindow::mouseMoveEvent(QMouseEvent *e) void MenuPopupWindow::mouseMoveEvent(QMouseEvent *e)
{ {
m_mouseMoved = true; m_mouseMoved = true;

@ -43,6 +43,7 @@ public:
public slots: public slots:
Q_INVOKABLE void show(); Q_INVOKABLE void show();
Q_INVOKABLE void dismissPopup(); Q_INVOKABLE void dismissPopup();
Q_INVOKABLE void updateGeometry();
signals: signals:
void popupDismissed(); void popupDismissed();

Loading…
Cancel
Save