From afdb9ddce9d7f27fe85e6fa9273afc12ab88c511 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 28 Apr 2023 17:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=B6=E8=97=8F=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E6=8B=96=E6=8B=BD=E5=AE=9A=E4=BD=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E6=B7=BB=E5=8A=A0=E6=89=93=E5=BC=80?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=BC=80=E5=A7=8B=E8=8F=9C=E5=8D=95=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/extensions/FavoriteExtension.qml | 25 +++++++++++++++++-------- src/ukui-menu-application.cpp | 8 ++++++++ src/ukui-menu-application.h | 3 ++- src/utils/app-manager.cpp | 1 + src/utils/app-manager.h | 4 ++++ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/qml/extensions/FavoriteExtension.qml b/qml/extensions/FavoriteExtension.qml index cf6564f..4680ac8 100644 --- a/qml/extensions/FavoriteExtension.qml +++ b/qml/extensions/FavoriteExtension.qml @@ -71,7 +71,9 @@ UkuiMenuExtension { id: delegateRoot property int visualIndex: DelegateModel.itemsIndex width: favoriteView.cellWidth; height: favoriteView.cellHeight - onEntered: visualModel.items.move(drag.source.visualIndex, icon.visualIndex) + onEntered: { + visualModel.items.move(drag.source.visualIndex, icon.visualIndex) + } Binding { target: icon; property: "visualIndex"; value: visualIndex } @@ -112,11 +114,6 @@ UkuiMenuExtension { pressAndHoldInterval: 300 acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed: { - if (mouse.button === Qt.RightButton) { - console.log("RightButtononPressed:",mouse.x,mouse.y); - } - } onClicked: { if (mouse.button === Qt.RightButton) { visualModel.model.openMenu(index) @@ -161,8 +158,20 @@ UkuiMenuExtension { } ParallelAnimation { id: iconResetAnimation - NumberAnimation { target: icon; property: "x"; to: delegateRoot.x; easing.type: Easing.OutQuad; duration: 300 } - NumberAnimation { target: icon; property: "y"; to: delegateRoot.y; easing.type: Easing.OutQuad; duration: 300 } + NumberAnimation { + target: icon + property: "x" + to: delegateRoot.x + easing.type: Easing.OutQuad + duration: 300 + } + NumberAnimation { + target: icon + property: "y" + to: delegateRoot.y - favoriteView.contentY + easing.type: Easing.OutQuad + duration: 300 + } onFinished: { icon.parent = delegateRoot; diff --git a/src/ukui-menu-application.cpp b/src/ukui-menu-application.cpp index d8f6d89..e1009a0 100644 --- a/src/ukui-menu-application.cpp +++ b/src/ukui-menu-application.cpp @@ -103,6 +103,8 @@ void UkuiMenuApplication::initQmlEngine() // }, Qt::QueuedConnection); // // m_applicationEngine->load(url); + + connect(AppManager::instance(), &AppManager::request, this, &UkuiMenuApplication::execCommand); } void UkuiMenuApplication::loadMenuUI() @@ -148,6 +150,12 @@ void UkuiMenuApplication::execCommand(Command command) QCoreApplication::quit(); break; } + case Hide: { + if (m_mainWindow) { + m_mainWindow->setVisible(false); + } + break; + } default: break; } diff --git a/src/ukui-menu-application.h b/src/ukui-menu-application.h index da1d71e..2b419f0 100644 --- a/src/ukui-menu-application.h +++ b/src/ukui-menu-application.h @@ -37,7 +37,8 @@ public: enum Command { Active = 0, Show, - Quit + Quit, + Hide }; explicit UkuiMenuApplication(MenuMessageProcessor *processor); ~UkuiMenuApplication() override; diff --git a/src/utils/app-manager.cpp b/src/utils/app-manager.cpp index 147fd60..72502fc 100644 --- a/src/utils/app-manager.cpp +++ b/src/utils/app-manager.cpp @@ -49,6 +49,7 @@ AppManager::AppManager(QObject *parent) : QObject(parent) bool AppManager::launchApp(const QString &desktopFilePath) { + Q_EMIT request(UkuiMenuApplication::Hide); if (launchAppWithDBus(desktopFilePath)) { return true; } diff --git a/src/utils/app-manager.h b/src/utils/app-manager.h index aa39852..7a26d85 100644 --- a/src/utils/app-manager.h +++ b/src/utils/app-manager.h @@ -19,6 +19,7 @@ #ifndef UKUI_MENU_APP_MANAGER_H #define UKUI_MENU_APP_MANAGER_H #include +#include "ukui-menu-application.h" class QDBusInterface; @@ -43,6 +44,9 @@ private: private: QDBusInterface *m_appManagerDbusInterface = nullptr; + +Q_SIGNALS: + void request(UkuiMenuApplication::Command command); }; } // UkuiMenu