Add the area displayed in the classifiaction label set
This commit is contained in:
parent
6d4fc101b2
commit
75c3d20f6c
|
@ -100,6 +100,7 @@ set(SOURCE_FILES
|
||||||
src/utils/app-page-header-utils.cpp src/utils/app-page-header-utils.h
|
src/utils/app-page-header-utils.cpp src/utils/app-page-header-utils.h
|
||||||
src/utils/power-button.cpp src/utils/power-button.h
|
src/utils/power-button.cpp src/utils/power-button.h
|
||||||
src/utils/app-manager.cpp src/utils/app-manager.h
|
src/utils/app-manager.cpp src/utils/app-manager.h
|
||||||
|
src/model/label-model.cpp src/model/label-model.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# qrc文件
|
# qrc文件
|
||||||
|
|
|
@ -4,7 +4,6 @@ import QtQuick.Controls 2.5
|
||||||
import org.ukui.menu.core 1.0
|
import org.ukui.menu.core 1.0
|
||||||
|
|
||||||
StyleBackground {
|
StyleBackground {
|
||||||
anchors.fill: parent
|
|
||||||
radius: 4
|
radius: 4
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
|
alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
|
||||||
|
|
|
@ -1,24 +1,43 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtQuick.Controls 2.5
|
||||||
|
|
||||||
|
StyleBackground {
|
||||||
|
radius: 4
|
||||||
|
useStyleTransparent: false
|
||||||
|
alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
|
||||||
|
ToolTip.text: qsTr("Open the label selection interface")
|
||||||
|
ToolTip.visible: control.containsMouse
|
||||||
|
|
||||||
Item {
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Text {
|
StyleText {
|
||||||
Layout.fillWidth: true
|
Layout.preferredHeight: parent.height
|
||||||
Layout.fillHeight: true
|
Layout.preferredWidth: contentWidth
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 12
|
||||||
|
|
||||||
horizontalAlignment: Qt.AlignLeft
|
horizontalAlignment: Qt.AlignLeft
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.bold: true
|
||||||
text: name
|
text: name
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
visible: control.containsMouse
|
||||||
Layout.preferredWidth: 32
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||||
Layout.preferredHeight: 32
|
Layout.preferredWidth: 24
|
||||||
source: icon
|
Layout.preferredHeight: 24
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
source: "image://appicon/open-menu-symbolic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: control
|
||||||
|
hoverEnabled: true
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
appList.labelItemClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,10 @@ import org.ukui.menu.core 1.0
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
property int paletteRole: Palette.Text
|
property int paletteRole: Palette.Text
|
||||||
|
property real alpha: 1.0
|
||||||
|
|
||||||
function updateColor() {
|
function updateColor() {
|
||||||
color = themePalette.paletteColor(paletteRole)
|
color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -19,4 +20,7 @@ Text {
|
||||||
onPaletteRoleChanged: {
|
onPaletteRoleChanged: {
|
||||||
updateColor()
|
updateColor()
|
||||||
}
|
}
|
||||||
|
onAlphaChanged: {
|
||||||
|
updateColor()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,10 @@ import org.ukui.menu.core 1.0
|
||||||
Item {
|
Item {
|
||||||
property string title: ""
|
property string title: ""
|
||||||
|
|
||||||
|
function labelSelection(labelId) {
|
||||||
|
appListView.positionViewAtIndex(appListView.model.currentAppIndex(labelId), ListView.Beginning)
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: appListArea
|
id: appListArea
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
@ -51,8 +55,11 @@ Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
ScrollBar.vertical: appListScrollBar
|
ScrollBar.vertical: appListScrollBar
|
||||||
model: modelManager.getAppModel()
|
|
||||||
|
|
||||||
|
highlightMoveDuration: 0
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
|
model: modelManager.getAppModel()
|
||||||
delegate: Component {
|
delegate: Component {
|
||||||
Loader {
|
Loader {
|
||||||
width: ListView.view ? ListView.view.width : 0
|
width: ListView.view ? ListView.view.width : 0
|
||||||
|
@ -80,7 +87,7 @@ Item {
|
||||||
id: appListScrollBar
|
id: appListScrollBar
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth: 14
|
Layout.preferredWidth: 14
|
||||||
visible: appListArea.containsMouse
|
visual: appListArea.containsMouse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,7 @@ AppControls2.StyleBackground {
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 40
|
||||||
}
|
}
|
||||||
|
|
||||||
AppList {
|
AppPageContent {
|
||||||
clip: true
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
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
|
||||||
|
function labelItemClicked() {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -78,8 +78,7 @@ Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
radius: 16
|
radius: 16
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
onTextChanged:
|
onTextChanged: {
|
||||||
{
|
|
||||||
if (text === "") {
|
if (text === "") {
|
||||||
sortMenu.sortMenuModel.reactivateProvider();
|
sortMenu.sortMenuModel.reactivateProvider();
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +86,6 @@ Item {
|
||||||
appPageHeaderUtils.startSearch(text);
|
appPageHeaderUtils.startSearch(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControls2.RoundButton {
|
AppControls2.RoundButton {
|
||||||
|
@ -109,6 +107,7 @@ Item {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: 16
|
anchors.leftMargin: 16
|
||||||
|
spacing: 12
|
||||||
Text {
|
Text {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Layouts 1.2
|
||||||
|
import org.ukui.menu.core 1.0
|
||||||
|
import AppControls2 1.0 as AppControls2
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
signal viewHideFinished()
|
||||||
|
signal labelSelected(string labelId)
|
||||||
|
|
||||||
|
function viewShowStart() {
|
||||||
|
viewShow.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
id: viewShow
|
||||||
|
NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.5; to: 1.0; duration: 300}
|
||||||
|
NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 0; to: 1.0; duration: 300}
|
||||||
|
}
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
id: viewHide
|
||||||
|
NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.0; to: 1.5 ;duration: 300}
|
||||||
|
NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 1.0; to: 0 ;duration: 300}
|
||||||
|
onFinished: {
|
||||||
|
viewHideFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GridView {
|
||||||
|
id: selectionArea
|
||||||
|
anchors.centerIn: parent
|
||||||
|
interactive: false
|
||||||
|
property int itemWidth: 0
|
||||||
|
property int itemHeight: 40
|
||||||
|
cellWidth: itemWidth; cellHeight: itemHeight
|
||||||
|
|
||||||
|
state: count < 20 ? "functionArea" : "AlphabetArea"
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "functionArea"
|
||||||
|
PropertyChanges { target: selectionArea; itemWidth: 80; width: itemWidth * 2; height: itemHeight * 7 }
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "AlphabetArea"
|
||||||
|
PropertyChanges { target: selectionArea; itemWidth: 40; width: itemWidth * 5; height: itemHeight * 6 }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
model: modelManager.getLabelModel()
|
||||||
|
onCountChanged: {
|
||||||
|
if (count === 0) {
|
||||||
|
viewHide.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: AppControls2.StyleBackground {
|
||||||
|
height: selectionArea.itemHeight; width: selectionArea.itemWidth
|
||||||
|
alpha: itemMouseArea.containsPress ? 0.82 : itemMouseArea.containsMouse ? 0.55 : 0.00
|
||||||
|
useStyleTransparent: false
|
||||||
|
radius: 8
|
||||||
|
|
||||||
|
AppControls2.StyleText {
|
||||||
|
anchors.fill: parent
|
||||||
|
text: model.displayName
|
||||||
|
alpha: model.isDisable ? 0.2 : 0.9
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: itemMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
visible: !model.isDisable
|
||||||
|
onClicked: {
|
||||||
|
viewHide.start();
|
||||||
|
root.labelSelected(model.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,5 +25,7 @@
|
||||||
<file>extensions/RecentFileExtension.qml</file>
|
<file>extensions/RecentFileExtension.qml</file>
|
||||||
<file>extensions/FavoriteExtension.qml</file>
|
<file>extensions/FavoriteExtension.qml</file>
|
||||||
<file>AppControls2/RoundButton.qml</file>
|
<file>AppControls2/RoundButton.qml</file>
|
||||||
|
<file>AppUI/SelectionPage.qml</file>
|
||||||
|
<file>AppUI/AppPageContent.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -78,6 +78,11 @@ void DataProviderManager::registerProvider(DataProviderPluginIFace *provider)
|
||||||
|
|
||||||
Q_EMIT dataChanged(data, mode, index);
|
Q_EMIT dataChanged(data, mode, index);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(provider, &AllAppDataProvider::labelChanged, this, [this, provider]() {
|
||||||
|
if (m_activatedPlugin != provider->id()) { return; }
|
||||||
|
Q_EMIT labelChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<DataEntity> DataProviderManager::data() const
|
QVector<DataEntity> DataProviderManager::data() const
|
||||||
|
@ -85,6 +90,11 @@ QVector<DataEntity> DataProviderManager::data() const
|
||||||
return m_providers.value(m_activatedPlugin)->data();
|
return m_providers.value(m_activatedPlugin)->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<LabelItem> DataProviderManager::labels() const
|
||||||
|
{
|
||||||
|
return m_providers.value(m_activatedPlugin)->labels();
|
||||||
|
}
|
||||||
|
|
||||||
QString DataProviderManager::activatedProvider() const
|
QString DataProviderManager::activatedProvider() const
|
||||||
{
|
{
|
||||||
return m_activatedPlugin;
|
return m_activatedPlugin;
|
||||||
|
|
|
@ -50,12 +50,14 @@ public:
|
||||||
QString activatedProvider() const;
|
QString activatedProvider() const;
|
||||||
void activateProvider(const QString &id);
|
void activateProvider(const QString &id);
|
||||||
QVector<DataEntity> data() const;
|
QVector<DataEntity> data() const;
|
||||||
|
QVector<LabelItem> labels() const;
|
||||||
void forceUpdate() const;
|
void forceUpdate() const;
|
||||||
void forceUpdate(QString &key) const;
|
void forceUpdate(QString &key) const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void pluginChanged(const QString &id, PluginGroup::Group group);
|
void pluginChanged(const QString &id, PluginGroup::Group group);
|
||||||
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
||||||
|
void labelChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataProviderManager();
|
DataProviderManager();
|
||||||
|
|
|
@ -29,6 +29,12 @@ class LabelItem
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
public:
|
public:
|
||||||
|
enum PropertyName {
|
||||||
|
IsDisable = 0,
|
||||||
|
Index,
|
||||||
|
Id,
|
||||||
|
DisplayName
|
||||||
|
};
|
||||||
LabelItem() = default;
|
LabelItem() = default;
|
||||||
explicit LabelItem(bool disable, int index, QString id, QString displayName);
|
explicit LabelItem(bool disable, int index, QString id, QString displayName);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "label-model.h"
|
||||||
|
#include "data-provider-manager.h"
|
||||||
|
|
||||||
|
namespace UkuiMenu {
|
||||||
|
|
||||||
|
LabelModel::LabelModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
|
{
|
||||||
|
reloadLabelData();
|
||||||
|
connect(DataProviderManager::instance(),&DataProviderManager::pluginChanged, this,&LabelModel::reloadLabelData);
|
||||||
|
connect(DataProviderManager::instance(),&DataProviderManager::labelChanged, this,&LabelModel::reloadLabelData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LabelModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return m_labels.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LabelModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
int i = index.row();
|
||||||
|
if (i < 0 || i >= m_labels.size()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case LabelItem::IsDisable:
|
||||||
|
return m_labels.at(i).isDisable();
|
||||||
|
case LabelItem::Id:
|
||||||
|
return m_labels.at(i).id();
|
||||||
|
case LabelItem::Index:
|
||||||
|
return m_labels.at(i).index();
|
||||||
|
case LabelItem::DisplayName:
|
||||||
|
return m_labels.at(i).displayName();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray> LabelModel::roleNames() const
|
||||||
|
{
|
||||||
|
QHash<int, QByteArray> names;
|
||||||
|
names.insert(LabelItem::IsDisable, "isDisable");
|
||||||
|
names.insert(LabelItem::Id, "id");
|
||||||
|
names.insert(LabelItem::Index, "index");
|
||||||
|
names.insert(LabelItem::DisplayName, "displayName");
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LabelModel::reloadLabelData()
|
||||||
|
{
|
||||||
|
QVector<LabelItem> labels = DataProviderManager::instance()->labels();
|
||||||
|
Q_EMIT beginResetModel();
|
||||||
|
m_labels.swap(labels);
|
||||||
|
Q_EMIT endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // UkuiMenu
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UKUI_MENU_LABEL_MODEL_H
|
||||||
|
#define UKUI_MENU_LABEL_MODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
#include "commons.h"
|
||||||
|
|
||||||
|
namespace UkuiMenu {
|
||||||
|
|
||||||
|
class LabelModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LabelModel(QObject *parent = nullptr);
|
||||||
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void reloadLabelData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<LabelItem> m_labels;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // UkuiMenu
|
||||||
|
|
||||||
|
#endif //UKUI_MENU_LABEL_MODEL_H
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "model-manager.h"
|
#include "model-manager.h"
|
||||||
|
#include "label-model.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
@ -24,11 +25,13 @@ namespace UkuiMenu {
|
||||||
void ModelManager::registerMetaTypes()
|
void ModelManager::registerMetaTypes()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<AppModel*>("AppModel*");
|
qRegisterMetaType<AppModel*>("AppModel*");
|
||||||
|
qRegisterMetaType<LabelModel*>("LabelModel*");
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelManager::ModelManager(QObject *parent) : QObject(parent)
|
ModelManager::ModelManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
appModel = new AppModel(this);
|
appModel = new AppModel(this);
|
||||||
|
labelModel = new LabelModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppModel *ModelManager::getAppModel()
|
AppModel *ModelManager::getAppModel()
|
||||||
|
@ -39,4 +42,12 @@ AppModel *ModelManager::getAppModel()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelModel *ModelManager::getLabelModel()
|
||||||
|
{
|
||||||
|
if (labelModel) {
|
||||||
|
return labelModel;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
|
||||||
class AppModel;
|
class AppModel;
|
||||||
|
class LabelModel;
|
||||||
|
|
||||||
class ModelManager : public QObject
|
class ModelManager : public QObject
|
||||||
{
|
{
|
||||||
|
@ -34,9 +35,11 @@ public:
|
||||||
~ModelManager() override = default;
|
~ModelManager() override = default;
|
||||||
|
|
||||||
Q_INVOKABLE AppModel *getAppModel();
|
Q_INVOKABLE AppModel *getAppModel();
|
||||||
|
Q_INVOKABLE LabelModel *getLabelModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppModel *appModel{nullptr};
|
AppModel *appModel{nullptr};
|
||||||
|
LabelModel *labelModel{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
|
@ -73,6 +73,16 @@ QHash<int, QByteArray> AppModel::roleNames() const
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AppModel::currentAppIndex(const QString &id)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < m_apps.count(); ++index) {
|
||||||
|
if (m_apps.at(index).type() == DataType::Label && m_apps.at(index).id() == id) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantList AppModel::folderApps(const QString &folderName)
|
QVariantList AppModel::folderApps(const QString &folderName)
|
||||||
{
|
{
|
||||||
DataEntity item1{DataType::Normal, "name 1", "icon", "comment", "extra"};
|
DataEntity item1{DataType::Normal, "name 1", "icon", "comment", "extra"};
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
Q_INVOKABLE int currentAppIndex(const QString &id);
|
||||||
Q_INVOKABLE QVariantList folderApps(const QString &folderName);
|
Q_INVOKABLE QVariantList folderApps(const QString &folderName);
|
||||||
Q_INVOKABLE void appClicked(const int &index);
|
Q_INVOKABLE void appClicked(const int &index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue