新增文件夹应用列表界面,qml环境增加打开菜单和应用接口
This commit is contained in:
parent
8f40eb3af1
commit
80d92c01c4
|
@ -32,11 +32,13 @@ AppControls2.StyleBackground {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
AppPageHeader {
|
AppPageHeader {
|
||||||
|
id: appPageHeader
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 40
|
||||||
}
|
}
|
||||||
|
|
||||||
AppPageContent {
|
AppPageContent {
|
||||||
|
appPageHeader: appPageHeader
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,15 @@ import QtQuick.Controls 2.5
|
||||||
import AppControls2 1.0 as AppControls2
|
import AppControls2 1.0 as AppControls2
|
||||||
import org.ukui.menu.core 1.0
|
import org.ukui.menu.core 1.0
|
||||||
|
|
||||||
|
SwipeView {
|
||||||
|
id: root
|
||||||
|
interactive: false
|
||||||
|
required property AppPageHeader appPageHeader
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
id: appListBase
|
||||||
AppList {
|
AppList {
|
||||||
id: appList
|
id: appList
|
||||||
clip: true
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: 4
|
anchors.leftMargin: 4
|
||||||
onLabelItemClicked: {
|
onLabelItemClicked: {
|
||||||
|
@ -43,3 +48,82 @@ Item {
|
||||||
onLabelSelected: appList.labelSelection(labelId)
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,8 +26,21 @@ import org.ukui.menu.utils 1.0
|
||||||
Item {
|
Item {
|
||||||
id: appPageHeaderRoot
|
id: appPageHeaderRoot
|
||||||
property string title: ""
|
property string title: ""
|
||||||
|
property Component content: null
|
||||||
clip: true
|
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"
|
state: "normal"
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
|
@ -93,7 +106,7 @@ Item {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
searchInputBar.clear();
|
searchInputBar.clear();
|
||||||
appPageHeaderRoot.state = "normal";
|
root.state = "normal";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +144,7 @@ Item {
|
||||||
buttonIcon: model.icon
|
buttonIcon: model.icon
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
appPageHeaderRoot.state = "search";
|
root.state = "search";
|
||||||
searchInputBar.providerId = model.id;
|
searchInputBar.providerId = model.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,3 +161,5 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "menu-manager.h"
|
#include "menu-manager.h"
|
||||||
#include "app-manager.h"
|
#include "app-manager.h"
|
||||||
|
#include "app-data-manager.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
@ -178,6 +179,14 @@ void MenuManager::registerMenuProvider(MenuProvider *provider)
|
||||||
m_providers.append(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)
|
void MenuManager::showMenu(const DataEntity &entity, const QPoint &point)
|
||||||
{
|
{
|
||||||
showMenu(MenuProvider::DataType, QVariant::fromValue(entity), point);
|
showMenu(MenuProvider::DataType, QVariant::fromValue(entity), point);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
static MenuManager *instance();
|
static MenuManager *instance();
|
||||||
~MenuManager() override;
|
~MenuManager() override;
|
||||||
void registerMenuProvider(MenuProvider *provider);
|
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 DataEntity &entity, const QPoint &point = QPoint());
|
||||||
void showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point = QPoint());
|
void showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point = QPoint());
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "app-page-header-utils.h"
|
#include "app-page-header-utils.h"
|
||||||
#include "power-button.h"
|
#include "power-button.h"
|
||||||
#include "items/theme-icon.h"
|
#include "items/theme-icon.h"
|
||||||
|
#include "app-manager.h"
|
||||||
|
#include "menu-manager.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
@ -83,6 +85,8 @@ void UkuiMenuApplication::initQmlEngine()
|
||||||
context->setContextProperty("modelManager", ModelManager::instance());
|
context->setContextProperty("modelManager", ModelManager::instance());
|
||||||
context->setContextProperty("extensionManager", MenuExtension::instance());
|
context->setContextProperty("extensionManager", MenuExtension::instance());
|
||||||
context->setContextProperty("appPageHeaderUtils", new AppPageHeaderUtils(this));
|
context->setContextProperty("appPageHeaderUtils", new AppPageHeaderUtils(this));
|
||||||
|
context->setContextProperty("menuManager", MenuManager::instance());
|
||||||
|
context->setContextProperty("appManager", AppManager::instance());
|
||||||
|
|
||||||
// MenuMainWindow
|
// MenuMainWindow
|
||||||
// const QUrl url(QStringLiteral("qrc:/qml/MenuMainWindow.qml"));
|
// const QUrl url(QStringLiteral("qrc:/qml/MenuMainWindow.qml"));
|
||||||
|
|
|
@ -32,8 +32,8 @@ public:
|
||||||
AppManager(const AppManager &obj) = delete;
|
AppManager(const AppManager &obj) = delete;
|
||||||
AppManager &operator = (const AppManager &obj) = delete;
|
AppManager &operator = (const AppManager &obj) = delete;
|
||||||
|
|
||||||
bool launchApp(const QString &desktopFilePath);
|
Q_INVOKABLE bool launchApp(const QString &desktopFilePath);
|
||||||
bool launchBinaryApp(const QString &app, const QString &args = QString());
|
Q_INVOKABLE bool launchBinaryApp(const QString &app, const QString &args = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AppManager(QObject *parent = nullptr);
|
explicit AppManager(QObject *parent = nullptr);
|
||||||
|
|
Loading…
Reference in New Issue