diff --git a/qml/AppUI/AppPageHeader.qml b/qml/AppUI/AppPageHeader.qml index 4efe42f..e00a6f0 100644 --- a/qml/AppUI/AppPageHeader.qml +++ b/qml/AppUI/AppPageHeader.qml @@ -41,19 +41,18 @@ Item { 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: Item { - width: 32 + delegate: Image { + width: height height: ListView.view ? ListView.view.height : 0 - Image { - anchors.fill: parent - source: model.icon - } + source: model.icon } } @@ -107,7 +106,8 @@ Item { Menu { id: sortMenu width: 128 - height: 112 + height: 120 + padding: 8 clip: true property var sortMenuModel: appPageHeaderUtils.model(PluginGroup.SortMenuItem) @@ -132,54 +132,51 @@ Item { contentItem: ListView { clip: true + spacing: 4 model: sortMenu.sortMenuModel - delegate: Item { + delegate: AppControls2.StyleBackground { width: ListView.view ? ListView.view.width : 0 - height: 48 - AppControls2.StyleBackground { + height: 32 + 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.margins: 8 - radius: 4 - paletteRole: (model.isChecked || mouseArea.isHoverd) ? Palette.Text : Palette.Window - useStyleTransparent: false - alpha: (model.isChecked || mouseArea.isHoverd) ? 0.2 : 1 - - Item { - 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 - } + 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 + } + } - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - property bool isHoverd: false - onClicked: { - if (model.isChecked) { - return; - } - appPageHeaderUtils.activateProvider(model.id); - } - onEntered: { - isHoverd = true; - } - onExited: { - isHoverd = false; + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + property bool isHoverd: false + onClicked: { + if (model.isChecked) { + return; } + appPageHeaderUtils.activateProvider(model.id); + } + onEntered: { + isHoverd = true; + } + onExited: { + isHoverd = false; } } } diff --git a/qml/AppUI/NormalUI.qml b/qml/AppUI/NormalUI.qml index 18f6e86..48a6051 100644 --- a/qml/AppUI/NormalUI.qml +++ b/qml/AppUI/NormalUI.qml @@ -6,8 +6,6 @@ import org.ukui.menu.core 1.0 AppControls2.StyleBackground { paletteRole: Palette.Window radius: 12 - useStyleTransparent: false - alpha: 0.75 Row { anchors.fill: parent; diff --git a/src/model/model.cpp b/src/model/model.cpp index ab8fff9..fb22bd2 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -28,12 +28,9 @@ namespace UkuiMenu { AppModel::AppModel(QObject *parent) : QAbstractListModel(parent) { - m_apps.append(DataProviderManager::instance()->data()); - connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, [this] (QVector data) { - Q_EMIT beginResetModel(); - m_apps.swap(data); - Q_EMIT endResetModel(); - }); + reloadPluginData(); + connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged); + connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData); } 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()); } +void AppModel::reloadPluginData() +{ + onPluginDataChanged(DataProviderManager::instance()->data()); +} + +void AppModel::onPluginDataChanged(QVector data) +{ + Q_EMIT beginResetModel(); + m_apps.swap(data); + Q_EMIT endResetModel(); +} + } // UkuiMenu diff --git a/src/model/model.h b/src/model/model.h index 36de9e4..60fcb4e 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -39,6 +39,10 @@ public: Q_INVOKABLE QVariantList folderApps(const QString &folderName); Q_INVOKABLE void appClicked(const int &index); +private Q_SLOTS: + void onPluginDataChanged(QVector data); + void reloadPluginData(); + private: QVector m_apps; };