扩展接口增加隐藏界面组件功能,更新接口版本号
This commit is contained in:
parent
42958efa36
commit
287081aaad
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"Type": "UKUI_MENU_EXTENSION",
|
"Type": "UKUI_MENU_EXTENSION",
|
||||||
"Version": "1.0.0"
|
"Version": "1.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,29 +24,46 @@ 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
|
||||||
import org.ukui.menu.utils 1.0
|
import org.ukui.menu.utils 1.0
|
||||||
|
import org.ukui.menu.extension 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
id: sidebarLayout
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: 12
|
anchors.topMargin: 12
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Row {
|
function updateSidebarLayout(options) {
|
||||||
|
sidebarBottomBar.visible = !options.includes(MenuExtension.HideBottomBar);
|
||||||
|
fullScreenbutton.visible = !options.includes(MenuExtension.HideFullScreenButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: sidebarTopBar
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 40
|
||||||
Layout.rightMargin: 12
|
Layout.rightMargin: 12
|
||||||
Layout.leftMargin: 16
|
Layout.leftMargin: 12
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
// spacing: 5
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: extensionListView
|
id: extensionInfoList
|
||||||
width: parent.width - 34
|
|
||||||
height: parent.height
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.leftMargin: 4
|
||||||
|
Layout.rightMargin: 4
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
spacing: 24
|
spacing: 24
|
||||||
interactive: false
|
interactive: false
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
model: extensionManager.extensionModel()
|
model: extensionManager.extensionModel()
|
||||||
delegate: headerDelegate
|
delegate: extensionInfoDelegate
|
||||||
|
|
||||||
function send(data) {
|
function send(data) {
|
||||||
if (currentItem !== null) {
|
if (currentItem !== null) {
|
||||||
|
@ -62,7 +79,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
width: 34; height: width
|
id: fullScreenbutton
|
||||||
|
Layout.preferredWidth: 34
|
||||||
|
Layout.preferredHeight: 34
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
radius: 4
|
radius: 4
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00
|
alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00
|
||||||
|
@ -70,7 +91,7 @@ Item {
|
||||||
border.width: buttonMouseArea.activeFocus ? 2 : 0
|
border.width: buttonMouseArea.activeFocus ? 2 : 0
|
||||||
ThemeIcon {
|
ThemeIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: parent.width / 2; height: width
|
width: 16; height: 16
|
||||||
source: "image://appicon/view-fullscreen-symbolic"
|
source: "image://appicon/view-fullscreen-symbolic"
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: buttonMouseArea
|
id: buttonMouseArea
|
||||||
|
@ -91,6 +112,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -101,23 +123,34 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
item.send.connect(extensionListView.send);
|
item.send.connect(extensionInfoList.send);
|
||||||
|
sidebarLayout.updateSidebarLayout(extensionInfoList.currentItem.extensionOptions);
|
||||||
}
|
}
|
||||||
Keys.onTabPressed: {
|
Keys.onTabPressed: {
|
||||||
extensionListView.focus = true
|
extensionInfoList.focus = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
|
id: sidebarBottomBar
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 32
|
||||||
|
Layout.topMargin: 5
|
||||||
|
Layout.bottomMargin: 8
|
||||||
|
Layout.leftMargin: 12
|
||||||
Layout.rightMargin: 12
|
Layout.rightMargin: 12
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
layoutDirection: Qt.RightToLeft
|
layoutDirection: Qt.RightToLeft
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
width: 32
|
Layout.preferredWidth: 32
|
||||||
height: 32
|
Layout.preferredHeight: 32
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
paletteRole: Palette.Base
|
paletteRole: Palette.Base
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
alpha: powerButtonArea.containsPress ? 0.85 : powerButtonArea.containsMouse ? 0.65 : 0
|
alpha: powerButtonArea.containsPress ? 0.85 : powerButtonArea.containsMouse ? 0.65 : 0
|
||||||
|
@ -130,8 +163,8 @@ Item {
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: Math.floor(parent.width / 2)
|
width: 24
|
||||||
height: width
|
height: 24
|
||||||
source: powerButtonBase.icon
|
source: powerButtonBase.icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,20 +193,21 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: headerDelegate
|
id: extensionInfoDelegate
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
id: headerDelegateItem
|
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
paletteRole: Palette.Highlight
|
paletteRole: Palette.Highlight
|
||||||
alpha: 0
|
alpha: 0
|
||||||
radius: 4
|
radius: 4
|
||||||
borderColor: Palette.Highlight
|
borderColor: Palette.Highlight
|
||||||
border.width: headerDelegateItem.activeFocus ? 2 : 0
|
border.width: activeFocus ? 2 : 0
|
||||||
|
|
||||||
property var extensionData: model.data
|
property var extensionData: model.data
|
||||||
|
property var extensionOptions: model.options
|
||||||
width: styleText.width
|
width: styleText.width
|
||||||
height: ListView.view ? ListView.view.height : 0
|
height: ListView.view ? ListView.view.height : 0
|
||||||
|
|
||||||
|
@ -219,8 +253,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (extensionListView.count > 0) {
|
if (extensionInfoList.count > 0) {
|
||||||
extensionListView.currentIndex = 0;
|
extensionInfoList.currentIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define UKUI_MENU_EXTENSION_TYPE "UKUI_MENU_EXTENSION"
|
#define UKUI_MENU_EXTENSION_TYPE "UKUI_MENU_EXTENSION"
|
||||||
#define UKUI_MENU_EXTENSION_IFACE_IID "org.ukui.menu.extension"
|
#define UKUI_MENU_EXTENSION_IFACE_IID "org.ukui.menu.extension"
|
||||||
#define UKUI_MENU_EXTENSION_IFACE_VERSION "1.0.0"
|
#define UKUI_MENU_EXTENSION_IFACE_VERSION "1.0.1"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -35,11 +35,18 @@ class Q_DECL_EXPORT MenuExtensionIFace : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum Option {
|
||||||
|
HideBottomBar,
|
||||||
|
HideFullScreenButton
|
||||||
|
};
|
||||||
|
Q_ENUM(Option)
|
||||||
|
|
||||||
explicit MenuExtensionIFace(QObject *parent = nullptr) : QObject(parent) {};
|
explicit MenuExtensionIFace(QObject *parent = nullptr) : QObject(parent) {};
|
||||||
virtual int index() = 0;
|
virtual int index() = 0;
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
virtual QUrl url() = 0;
|
virtual QUrl url() = 0;
|
||||||
virtual QVariantMap data() = 0;
|
virtual QVariantMap data() = 0;
|
||||||
|
virtual QVariantList options() { return {}; };
|
||||||
virtual void receive(QVariantMap data) = 0;
|
virtual void receive(QVariantMap data) = 0;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ MenuExtension *MenuExtension::instance()
|
||||||
MenuExtension::MenuExtension()
|
MenuExtension::MenuExtension()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<ExtensionModel*>("ExtensionModel*");
|
qRegisterMetaType<ExtensionModel*>("ExtensionModel*");
|
||||||
|
qmlRegisterUncreatableType<MenuExtensionIFace>("org.ukui.menu.extension", 1, 0, "MenuExtension", "");
|
||||||
|
|
||||||
// TODO load extension from filesystem.
|
// TODO load extension from filesystem.
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
|
@ -121,6 +123,7 @@ ExtensionModel::ExtensionModel(const QVector<MenuExtensionIFace*> &extensions, Q
|
||||||
m_roleNames.insert(Name, "name");
|
m_roleNames.insert(Name, "name");
|
||||||
m_roleNames.insert(Url, "url");
|
m_roleNames.insert(Url, "url");
|
||||||
m_roleNames.insert(Data, "data");
|
m_roleNames.insert(Data, "data");
|
||||||
|
m_roleNames.insert(Options, "options");
|
||||||
|
|
||||||
for (int i = 0; i < m_extensions.size(); ++i) {
|
for (int i = 0; i < m_extensions.size(); ++i) {
|
||||||
connect(m_extensions.at(i), &MenuExtensionIFace::dataUpdated, this, [this, i] {
|
connect(m_extensions.at(i), &MenuExtensionIFace::dataUpdated, this, [this, i] {
|
||||||
|
@ -150,6 +153,8 @@ QVariant ExtensionModel::data(const QModelIndex &index, int role) const
|
||||||
case Data: {
|
case Data: {
|
||||||
return m_extensions.at(row)->data();
|
return m_extensions.at(row)->data();
|
||||||
}
|
}
|
||||||
|
case Options:
|
||||||
|
return m_extensions.at(row)->options();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ public:
|
||||||
enum Name {
|
enum Name {
|
||||||
Name,
|
Name,
|
||||||
Url,
|
Url,
|
||||||
Data
|
Data,
|
||||||
|
Options
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ExtensionModel(const QVector<MenuExtensionIFace*> &extensions, QObject *parent = nullptr);
|
explicit ExtensionModel(const QVector<MenuExtensionIFace*> &extensions, QObject *parent = nullptr);
|
||||||
|
|
Loading…
Reference in New Issue