From 2bcb04a0dbe8d1e2e5ad5afbdb666942f74d2b9c Mon Sep 17 00:00:00 2001 From: kate Date: Wed, 12 Jan 2022 21:24:36 +0800 Subject: [PATCH] fix(desktop_menu): update size request --- src/controls/RoundedRect.qml | 4 +++- src/controls/Window.qml | 2 +- src/desktop/menupopupwindow.cpp | 13 +++++++++++++ src/desktop/menupopupwindow.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/controls/RoundedRect.qml b/src/controls/RoundedRect.qml index f900ba5..0641eb1 100644 --- a/src/controls/RoundedRect.qml +++ b/src/controls/RoundedRect.qml @@ -53,8 +53,10 @@ Item { anchors.fill: parent color: "transparent" 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) visible: control.borderEnabled antialiasing: true } -} \ No newline at end of file +} diff --git a/src/controls/Window.qml b/src/controls/Window.qml index e8d7c8d..79bd5d4 100644 --- a/src/controls/Window.qml +++ b/src/controls/Window.qml @@ -71,7 +71,7 @@ Window { FishUI.WindowShadow { view: control radius: _background.radius - strength: control.active ? 1.5 : 0.5 + strength: control.active ? 1.5 : 0.9 } // Left bottom edge diff --git a/src/desktop/menupopupwindow.cpp b/src/desktop/menupopupwindow.cpp index 9bc88f3..2239f8f 100644 --- a/src/desktop/menupopupwindow.cpp +++ b/src/desktop/menupopupwindow.cpp @@ -97,6 +97,9 @@ void MenuPopupWindow::setPopupContentItem(QQuickItem *contentItem) contentItem->setParentItem(this->contentItem()); m_contentItem = contentItem; + + connect(contentItem, &QQuickItem::implicitWidthChanged, this, &MenuPopupWindow::updateGeometry); + connect(contentItem, &QQuickItem::implicitHeightChanged, this, &MenuPopupWindow::updateGeometry); } void MenuPopupWindow::dismissPopup() @@ -106,6 +109,16 @@ void MenuPopupWindow::dismissPopup() 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) { m_mouseMoved = true; diff --git a/src/desktop/menupopupwindow.h b/src/desktop/menupopupwindow.h index abf46c1..191fc1d 100644 --- a/src/desktop/menupopupwindow.h +++ b/src/desktop/menupopupwindow.h @@ -43,6 +43,7 @@ public: public slots: Q_INVOKABLE void show(); Q_INVOKABLE void dismissPopup(); + Q_INVOKABLE void updateGeometry(); signals: void popupDismissed();