新增文件夹应用列表界面,qml环境增加打开菜单和应用接口

This commit is contained in:
hewenfei 2023-03-31 16:20:05 +08:00
parent 8f40eb3af1
commit 80d92c01c4
7 changed files with 238 additions and 123 deletions

View File

@ -32,11 +32,13 @@ AppControls2.StyleBackground {
spacing: 0
AppPageHeader {
id: appPageHeader
Layout.fillWidth: true
Layout.preferredHeight: 40
}
AppPageContent {
appPageHeader: appPageHeader
Layout.fillWidth: true
Layout.fillHeight: true
}

View File

@ -22,10 +22,15 @@ import QtQuick.Controls 2.5
import AppControls2 1.0 as AppControls2
import org.ukui.menu.core 1.0
Item {
SwipeView {
id: root
interactive: false
required property AppPageHeader appPageHeader
Item {
id: appListBase
AppList {
id: appList
clip: true
anchors.fill: parent
anchors.leftMargin: 4
onLabelItemClicked: {
@ -42,4 +47,83 @@ Item {
onViewHideFinished: appList.visible = true
onLabelSelected: appList.labelSelection(labelId)
}
}
Loader {
id: folderPageLoader
active: false
sourceComponent: Component {
AppListView {
model: modelManager.getFolderModel()
delegate: Component {
Loader {
width: ListView.view ? ListView.view.width : 0; height: 40
property string id: model.id
property string name: model.name
property string icon: model.icon
sourceComponent: AppControls2.AppItem {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
menuManager.showMenu(id);
return;
}
if (mouse.button === Qt.LeftButton) {
appManager.launchApp(id);
return;
}
}
}
}
}
}
}
function showFolderPage(folderId, folderName) {
active = true;
item.model.setFolderId(folderId);
appPageHeader.title = folderName;
appPageHeader.content = folderPageHeader;
root.currentIndex = SwipeView.index;
}
function hideFolderPage() {
root.currentIndex = appListBase.SwipeView.index;
appPageHeader.title = appList.title;
appPageHeader.content = null;
//active = false;
}
Component.onCompleted: {
appList.openFolderPageSignal.connect(showFolderPage);
}
}
Component {
id: folderPageHeader
Item {
RowLayout {
anchors.fill: parent
anchors.leftMargin: 12
Image {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: 16
Layout.maximumHeight: 16
Layout.alignment: Qt.AlignVCenter
source: "image://appicon/ukui-start-symbolic"
MouseArea {
anchors.fill: parent
onClicked: folderPageLoader.hideFolderPage();
}
}
Text {
Layout.fillWidth: true
Layout.fillHeight: true
verticalAlignment: Text.AlignVCenter
text: title
}
}
}
}
}

View File

@ -26,8 +26,21 @@ import org.ukui.menu.utils 1.0
Item {
id: appPageHeaderRoot
property string title: ""
property Component content: null
clip: true
Loader {
anchors.fill: parent
property string title: appPageHeaderRoot.title
sourceComponent: {
return appPageHeaderRoot.content === null ? defaultComponent : appPageHeaderRoot.content
}
}
Component {
id: defaultComponent
Item {
id: root
state: "normal"
states: [
State {
@ -93,7 +106,7 @@ Item {
onClicked: {
searchInputBar.clear();
appPageHeaderRoot.state = "normal";
root.state = "normal";
}
}
}
@ -131,7 +144,7 @@ Item {
buttonIcon: model.icon
onClicked: {
appPageHeaderRoot.state = "search";
root.state = "search";
searchInputBar.providerId = model.id;
}
}
@ -147,4 +160,6 @@ Item {
}
}
}
}
}
}

View File

@ -18,6 +18,7 @@
#include "menu-manager.h"
#include "app-manager.h"
#include "app-data-manager.h"
#include <QMenu>
#include <QCursor>
@ -178,6 +179,14 @@ void MenuManager::registerMenuProvider(MenuProvider *provider)
m_providers.append(provider);
}
void MenuManager::showMenu(const QString &appid, const QPoint &point)
{
DataEntity app;
if (AppDataManager::instance()->getApp(appid, app)) {
showMenu(MenuProvider::DataType, QVariant::fromValue(app), point);
}
}
void MenuManager::showMenu(const DataEntity &entity, const QPoint &point)
{
showMenu(MenuProvider::DataType, QVariant::fromValue(entity), point);

View File

@ -46,6 +46,7 @@ public:
static MenuManager *instance();
~MenuManager() override;
void registerMenuProvider(MenuProvider *provider);
Q_INVOKABLE void showMenu(const QString &appid, const QPoint &point = QPoint());
void showMenu(const DataEntity &entity, const QPoint &point = QPoint());
void showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point = QPoint());

View File

@ -28,6 +28,8 @@
#include "app-page-header-utils.h"
#include "power-button.h"
#include "items/theme-icon.h"
#include "app-manager.h"
#include "menu-manager.h"
#include <QCoreApplication>
#include <QCommandLineParser>
@ -83,6 +85,8 @@ void UkuiMenuApplication::initQmlEngine()
context->setContextProperty("modelManager", ModelManager::instance());
context->setContextProperty("extensionManager", MenuExtension::instance());
context->setContextProperty("appPageHeaderUtils", new AppPageHeaderUtils(this));
context->setContextProperty("menuManager", MenuManager::instance());
context->setContextProperty("appManager", AppManager::instance());
// MenuMainWindow
// const QUrl url(QStringLiteral("qrc:/qml/MenuMainWindow.qml"));

View File

@ -32,8 +32,8 @@ public:
AppManager(const AppManager &obj) = delete;
AppManager &operator = (const AppManager &obj) = delete;
bool launchApp(const QString &desktopFilePath);
bool launchBinaryApp(const QString &app, const QString &args = QString());
Q_INVOKABLE bool launchApp(const QString &desktopFilePath);
Q_INVOKABLE bool launchBinaryApp(const QString &app, const QString &args = QString());
private:
explicit AppManager(QObject *parent = nullptr);