新增文件夹应用列表界面,qml环境增加打开菜单和应用接口
This commit is contained in:
parent
8f40eb3af1
commit
80d92c01c4
|
@ -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
|
||||
}
|
||||
|
|
|
@ -22,24 +22,108 @@ import QtQuick.Controls 2.5
|
|||
import AppControls2 1.0 as AppControls2
|
||||
import org.ukui.menu.core 1.0
|
||||
|
||||
Item {
|
||||
AppList {
|
||||
id: appList
|
||||
clip: true
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
onLabelItemClicked: {
|
||||
appList.visible = false;
|
||||
selectionPage.viewShowStart();
|
||||
SwipeView {
|
||||
id: root
|
||||
interactive: false
|
||||
required property AppPageHeader appPageHeader
|
||||
|
||||
Item {
|
||||
id: appListBase
|
||||
AppList {
|
||||
id: appList
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
onLabelItemClicked: {
|
||||
appList.visible = false;
|
||||
selectionPage.viewShowStart();
|
||||
}
|
||||
}
|
||||
|
||||
SelectionPage {
|
||||
id: selectionPage
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: 54
|
||||
visible: !appList.visible
|
||||
onViewHideFinished: appList.visible = true
|
||||
onLabelSelected: appList.labelSelection(labelId)
|
||||
}
|
||||
}
|
||||
|
||||
SelectionPage {
|
||||
id: selectionPage
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: 54
|
||||
visible: !appList.visible
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,124 +26,139 @@ import org.ukui.menu.utils 1.0
|
|||
Item {
|
||||
id: appPageHeaderRoot
|
||||
property string title: ""
|
||||
property Component content: null
|
||||
clip: true
|
||||
|
||||
state: "normal"
|
||||
states: [
|
||||
State {
|
||||
name: "normal"
|
||||
PropertyChanges { target: searchBar; scale: 0.9; y: -pluginSelectionBar.height }
|
||||
PropertyChanges { target: pluginSelectionBar; scale: 1.0; y: 0 }
|
||||
StateChangeScript { script: pluginSelectMenu.model.reactivateProvider() }
|
||||
},
|
||||
State {
|
||||
name: "search"
|
||||
PropertyChanges { target: searchBar; scale: 1.0; y: 0 }
|
||||
PropertyChanges { target: pluginSelectionBar; scale: 0.9; y: pluginSelectionBar.height }
|
||||
}
|
||||
]
|
||||
|
||||
transitions:[
|
||||
Transition {
|
||||
to: "normal"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||
ScriptAction { script: searchBar.visible = false }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "search"
|
||||
SequentialAnimation {
|
||||
ScriptAction { script: searchBar.visible = true }
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Item {
|
||||
id: searchBar
|
||||
width: parent.width; height: 30
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 15
|
||||
anchors.rightMargin: 15
|
||||
spacing: 10
|
||||
|
||||
SearchInputBar {
|
||||
id: searchInputBar
|
||||
property string providerId: ""
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
radius: 16
|
||||
onTextChanged: {
|
||||
if (text === "") {
|
||||
pluginSelectMenu.model.reactivateProvider();
|
||||
} else {
|
||||
appPageHeaderUtils.activateProvider(providerId);
|
||||
appPageHeaderUtils.startSearch(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppControls2.RoundButton {
|
||||
Layout.preferredWidth: parent.height; Layout.preferredHeight: parent.height
|
||||
buttonIcon: "image://appicon/edit-clear-symbolic"
|
||||
|
||||
onClicked: {
|
||||
searchInputBar.clear();
|
||||
appPageHeaderRoot.state = "normal";
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
property string title: appPageHeaderRoot.title
|
||||
sourceComponent: {
|
||||
return appPageHeaderRoot.content === null ? defaultComponent : appPageHeaderRoot.content
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: pluginSelectionBar
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 16
|
||||
spacing: 12
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
text: appPageHeaderRoot.title
|
||||
font.bold: true
|
||||
}
|
||||
Component {
|
||||
id: defaultComponent
|
||||
Item {
|
||||
id: root
|
||||
state: "normal"
|
||||
states: [
|
||||
State {
|
||||
name: "normal"
|
||||
PropertyChanges { target: searchBar; scale: 0.9; y: -pluginSelectionBar.height }
|
||||
PropertyChanges { target: pluginSelectionBar; scale: 1.0; y: 0 }
|
||||
StateChangeScript { script: pluginSelectMenu.model.reactivateProvider() }
|
||||
},
|
||||
State {
|
||||
name: "search"
|
||||
PropertyChanges { target: searchBar; scale: 1.0; y: 0 }
|
||||
PropertyChanges { target: pluginSelectionBar; scale: 0.9; y: pluginSelectionBar.height }
|
||||
}
|
||||
]
|
||||
|
||||
ListView {
|
||||
Layout.preferredWidth: childrenRect.width
|
||||
Layout.preferredHeight: 32
|
||||
Layout.maximumWidth: 68
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
transitions:[
|
||||
Transition {
|
||||
to: "normal"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||
ScriptAction { script: searchBar.visible = false }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "search"
|
||||
SequentialAnimation {
|
||||
ScriptAction { script: searchBar.visible = true }
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
clip: true
|
||||
spacing: 4
|
||||
orientation: ListView.Horizontal
|
||||
Item {
|
||||
id: searchBar
|
||||
width: parent.width; height: 30
|
||||
|
||||
model: appPageHeaderUtils.model(PluginGroup.Button)
|
||||
delegate: AppControls2.RoundButton {
|
||||
width: height; height: ListView.view ? ListView.view.height : 0
|
||||
buttonIcon: model.icon
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 15
|
||||
anchors.rightMargin: 15
|
||||
spacing: 10
|
||||
|
||||
onClicked: {
|
||||
appPageHeaderRoot.state = "search";
|
||||
searchInputBar.providerId = model.id;
|
||||
SearchInputBar {
|
||||
id: searchInputBar
|
||||
property string providerId: ""
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
radius: 16
|
||||
onTextChanged: {
|
||||
if (text === "") {
|
||||
pluginSelectMenu.model.reactivateProvider();
|
||||
} else {
|
||||
appPageHeaderUtils.activateProvider(providerId);
|
||||
appPageHeaderUtils.startSearch(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppControls2.RoundButton {
|
||||
Layout.preferredWidth: parent.height; Layout.preferredHeight: parent.height
|
||||
buttonIcon: "image://appicon/edit-clear-symbolic"
|
||||
|
||||
onClicked: {
|
||||
searchInputBar.clear();
|
||||
root.state = "normal";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PluginSelectMenu {
|
||||
id: pluginSelectMenu
|
||||
Layout.preferredWidth: childrenRect.width
|
||||
Layout.preferredHeight: 32
|
||||
Layout.maximumHeight: 32
|
||||
Layout.rightMargin: 8
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Item {
|
||||
id: pluginSelectionBar
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 16
|
||||
spacing: 12
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
text: appPageHeaderRoot.title
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
ListView {
|
||||
Layout.preferredWidth: childrenRect.width
|
||||
Layout.preferredHeight: 32
|
||||
Layout.maximumWidth: 68
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
clip: true
|
||||
spacing: 4
|
||||
orientation: ListView.Horizontal
|
||||
|
||||
model: appPageHeaderUtils.model(PluginGroup.Button)
|
||||
delegate: AppControls2.RoundButton {
|
||||
width: height; height: ListView.view ? ListView.view.height : 0
|
||||
buttonIcon: model.icon
|
||||
|
||||
onClicked: {
|
||||
root.state = "search";
|
||||
searchInputBar.providerId = model.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PluginSelectMenu {
|
||||
id: pluginSelectMenu
|
||||
Layout.preferredWidth: childrenRect.width
|
||||
Layout.preferredHeight: 32
|
||||
Layout.maximumHeight: 32
|
||||
Layout.rightMargin: 8
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue