forked from openkylin/ukui-menu
主界面跟随主题透明度,调整ui细节,model监听插件数据变化
This commit is contained in:
parent
7ccf808411
commit
cad6456a44
|
@ -41,19 +41,18 @@ Item {
|
||||||
ListView {
|
ListView {
|
||||||
Layout.preferredWidth: childrenRect.width
|
Layout.preferredWidth: childrenRect.width
|
||||||
Layout.preferredHeight: 32
|
Layout.preferredHeight: 32
|
||||||
|
Layout.maximumWidth: 68
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
spacing: 4
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
|
|
||||||
model: appPageHeaderUtils.model(PluginGroup.Button)
|
model: appPageHeaderUtils.model(PluginGroup.Button)
|
||||||
delegate: Item {
|
delegate: Image {
|
||||||
width: 32
|
width: height
|
||||||
height: ListView.view ? ListView.view.height : 0
|
height: ListView.view ? ListView.view.height : 0
|
||||||
Image {
|
source: model.icon
|
||||||
anchors.fill: parent
|
|
||||||
source: model.icon
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +106,8 @@ Item {
|
||||||
Menu {
|
Menu {
|
||||||
id: sortMenu
|
id: sortMenu
|
||||||
width: 128
|
width: 128
|
||||||
height: 112
|
height: 120
|
||||||
|
padding: 8
|
||||||
clip: true
|
clip: true
|
||||||
property var sortMenuModel: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
property var sortMenuModel: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
||||||
|
|
||||||
|
@ -132,54 +132,51 @@ Item {
|
||||||
|
|
||||||
contentItem: ListView {
|
contentItem: ListView {
|
||||||
clip: true
|
clip: true
|
||||||
|
spacing: 4
|
||||||
model: sortMenu.sortMenuModel
|
model: sortMenu.sortMenuModel
|
||||||
delegate: Item {
|
delegate: AppControls2.StyleBackground {
|
||||||
width: ListView.view ? ListView.view.width : 0
|
width: ListView.view ? ListView.view.width : 0
|
||||||
height: 48
|
height: 32
|
||||||
AppControls2.StyleBackground {
|
radius: 4
|
||||||
|
alpha: (model.isChecked || mouseArea.isHoverd) ? 0.2 : 1
|
||||||
|
paletteRole: (model.isChecked || mouseArea.isHoverd) ? Palette.Text : Palette.Window
|
||||||
|
useStyleTransparent: false
|
||||||
|
|
||||||
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 8
|
anchors.margins: 8
|
||||||
radius: 4
|
Image {
|
||||||
paletteRole: (model.isChecked || mouseArea.isHoverd) ? Palette.Text : Palette.Window
|
visible: model.isChecked
|
||||||
useStyleTransparent: false
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
alpha: (model.isChecked || mouseArea.isHoverd) ? 0.2 : 1
|
width: 16
|
||||||
|
height: 16
|
||||||
Item {
|
source: "image://appicon/object-select.symbolic"
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 8
|
|
||||||
Image {
|
|
||||||
visible: model.isChecked
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
width: 16
|
|
||||||
height: 16
|
|
||||||
source: "image://appicon/object-select.symbolic"
|
|
||||||
}
|
|
||||||
AppControls2.StyleText {
|
|
||||||
x: 24
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
width: parent.width - x
|
|
||||||
height: parent.height
|
|
||||||
text: model.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
AppControls2.StyleText {
|
||||||
|
x: 24
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
width: parent.width - x
|
||||||
|
height: parent.height
|
||||||
|
text: model.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
property bool isHoverd: false
|
property bool isHoverd: false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (model.isChecked) {
|
if (model.isChecked) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
appPageHeaderUtils.activateProvider(model.id);
|
|
||||||
}
|
|
||||||
onEntered: {
|
|
||||||
isHoverd = true;
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
isHoverd = false;
|
|
||||||
}
|
}
|
||||||
|
appPageHeaderUtils.activateProvider(model.id);
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
isHoverd = true;
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
isHoverd = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import org.ukui.menu.core 1.0
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
paletteRole: Palette.Window
|
paletteRole: Palette.Window
|
||||||
radius: 12
|
radius: 12
|
||||||
useStyleTransparent: false
|
|
||||||
alpha: 0.75
|
|
||||||
Row {
|
Row {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,9 @@ namespace UkuiMenu {
|
||||||
|
|
||||||
AppModel::AppModel(QObject *parent) : QAbstractListModel(parent)
|
AppModel::AppModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
m_apps.append(DataProviderManager::instance()->data());
|
reloadPluginData();
|
||||||
connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, [this] (QVector<DataEntity> data) {
|
connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged);
|
||||||
Q_EMIT beginResetModel();
|
connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData);
|
||||||
m_apps.swap(data);
|
|
||||||
Q_EMIT endResetModel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AppModel::rowCount(const QModelIndex &parent) const
|
int AppModel::rowCount(const QModelIndex &parent) const
|
||||||
|
@ -102,4 +99,16 @@ void AppModel::appClicked(const int &index)
|
||||||
AppManager::instance()->launchApp(m_apps.at(index).id());
|
AppManager::instance()->launchApp(m_apps.at(index).id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppModel::reloadPluginData()
|
||||||
|
{
|
||||||
|
onPluginDataChanged(DataProviderManager::instance()->data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppModel::onPluginDataChanged(QVector<DataEntity> data)
|
||||||
|
{
|
||||||
|
Q_EMIT beginResetModel();
|
||||||
|
m_apps.swap(data);
|
||||||
|
Q_EMIT endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
|
@ -39,6 +39,10 @@ public:
|
||||||
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);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onPluginDataChanged(QVector<DataEntity> data);
|
||||||
|
void reloadPluginData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<DataEntity> m_apps;
|
QVector<DataEntity> m_apps;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue