Merge tag 'upstream/4.0.0.4' into openkylin/yangtze

4.0.0.4-release
This commit is contained in:
hewenfei 2023-06-19 16:41:17 +08:00
commit a50c3e290d
23 changed files with 272 additions and 129 deletions

View File

@ -1,4 +1,4 @@
{ {
"Type": "UKUI_MENU_EXTENSION", "Type": "UKUI_MENU_EXTENSION",
"Version": "1.0.0" "Version": "1.0.1"
} }

View File

@ -404,7 +404,7 @@ void RecentFileExtension::creatMenu(const QString &path, const int &index)
QDBusMessage message = QDBusMessage::createMethodCall(FREEDESKTOP_FILEMANAGER_NAME, QDBusMessage message = QDBusMessage::createMethodCall(FREEDESKTOP_FILEMANAGER_NAME,
FREEDESKTOP_FILEMANAGER_PATH, FREEDESKTOP_FILEMANAGER_PATH,
FREEDESKTOP_FILEMANAGER_INTERFACE, "ShowFolders"); FREEDESKTOP_FILEMANAGER_INTERFACE, "ShowFolders");
message << QStringList(path); message << QStringList(path) << "ukui-menu-recent-file";
QDBusConnection::sessionBus().asyncCall(message); QDBusConnection::sessionBus().asyncCall(message);
}); });

View File

@ -41,6 +41,7 @@ StyleBackground {
width: iconGrid.cellWidth width: iconGrid.cellWidth
height: iconGrid.cellHeight height: iconGrid.cellHeight
source: modelData source: modelData
cache: false
} }
} }
} }

View File

@ -61,6 +61,7 @@ Item {
height: root.iconHeight height: root.iconHeight
width: root.iconWidth width: root.iconWidth
source: root.appIcon source: root.appIcon
cache: false
} }
StyleText { StyleText {

View File

@ -256,6 +256,7 @@ RowLayout {
height: 96 height: 96
width: 96 width: 96
source: icon source: icon
cache: false
} }
} }

View File

@ -24,67 +24,89 @@ 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
ListView { RowLayout {
id: extensionListView anchors.fill: parent
width: parent.width - 34 // spacing: 5
height: parent.height
clip: true
spacing: 24
interactive: false
orientation: ListView.Horizontal
model: extensionManager.extensionModel()
delegate: headerDelegate
function send(data) { ListView {
if (currentItem !== null) { id: extensionInfoList
model.send(currentIndex, data);
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 4
Layout.rightMargin: 4
clip: true
spacing: 24
interactive: false
orientation: ListView.Horizontal
model: extensionManager.extensionModel()
delegate: extensionInfoDelegate
function send(data) {
if (currentItem !== null) {
model.send(currentIndex, data);
}
}
onCurrentIndexChanged: {
if (currentItem !== null) {
currentItem.select();
}
} }
} }
onCurrentIndexChanged: { AppControls2.StyleBackground {
if (currentItem !== null) { id: fullScreenbutton
currentItem.select(); Layout.preferredWidth: 34
} Layout.preferredHeight: 34
} Layout.alignment: Qt.AlignVCenter
}
AppControls2.StyleBackground { radius: 4
width: 34; height: width useStyleTransparent: false
radius: 4 alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00
useStyleTransparent: false borderColor: Palette.Highlight
alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00 border.width: buttonMouseArea.activeFocus ? 2 : 0
borderColor: Palette.Highlight ThemeIcon {
border.width: buttonMouseArea.activeFocus ? 2 : 0 anchors.centerIn: parent
ThemeIcon { width: 16; height: 16
anchors.centerIn: parent source: "image://appicon/view-fullscreen-symbolic"
width: parent.width / 2; height: width MouseArea {
source: "image://appicon/view-fullscreen-symbolic" id: buttonMouseArea
MouseArea { hoverEnabled: true
id: buttonMouseArea anchors.fill: parent
hoverEnabled: true ToolTip.delay: 500
anchors.fill: parent ToolTip.text: qsTr("Expand")
ToolTip.delay: 500 ToolTip.visible: containsMouse
ToolTip.text: qsTr("Expand")
ToolTip.visible: containsMouse
onClicked: mainWindow.isFullScreen = true onClicked: mainWindow.isFullScreen = true
activeFocusOnTab: true activeFocusOnTab: true
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
mainWindow.isFullScreen = true; mainWindow.isFullScreen = true;
}
} }
} }
} }
@ -101,60 +123,72 @@ 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
layoutDirection: Qt.RightToLeft
AppControls2.StyleBackground { RowLayout {
width: 32 anchors.fill: parent
height: 32 layoutDirection: Qt.RightToLeft
paletteRole: Palette.Base spacing: 5
useStyleTransparent: false
alpha: powerButtonArea.containsPress ? 0.85 : powerButtonArea.containsMouse ? 0.65 : 0
radius: height / 2
borderColor: Palette.Highlight
border.width: powerButtonArea.activeFocus ? 2 : 0
PowerButton {
id: powerButtonBase
}
Image { AppControls2.StyleBackground {
anchors.centerIn: parent Layout.preferredWidth: 32
width: Math.floor(parent.width / 2) Layout.preferredHeight: 32
height: width Layout.alignment: Qt.AlignVCenter
source: powerButtonBase.icon
}
MouseArea { paletteRole: Palette.Base
id: powerButtonArea useStyleTransparent: false
anchors.fill: parent alpha: powerButtonArea.containsPress ? 0.85 : powerButtonArea.containsMouse ? 0.65 : 0
hoverEnabled: true radius: height / 2
ToolTip.delay: 500 borderColor: Palette.Highlight
ToolTip.visible: containsMouse border.width: powerButtonArea.activeFocus ? 2 : 0
ToolTip.text: powerButtonBase.toolTip PowerButton {
acceptedButtons: Qt.LeftButton | Qt.RightButton id: powerButtonBase
property int spacingFromMenu: 16
activeFocusOnTab: true
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
powerButtonBase.clicked(true, 0, 0, mainWindow.isFullScreen);
}
} }
onClicked: { Image {
var buttonPosition = powerButtonArea.mapToGlobal(width, height); anchors.centerIn: parent
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen); width: 24
height: 24
source: powerButtonBase.icon
}
MouseArea {
id: powerButtonArea
anchors.fill: parent
hoverEnabled: true
ToolTip.delay: 500
ToolTip.visible: containsMouse
ToolTip.text: powerButtonBase.toolTip
acceptedButtons: Qt.LeftButton | Qt.RightButton
property int spacingFromMenu: 16
activeFocusOnTab: true
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
powerButtonBase.clicked(true, 0, 0, mainWindow.isFullScreen);
}
}
onClicked: {
var buttonPosition = powerButtonArea.mapToGlobal(width, height);
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
}
} }
} }
} }
@ -162,18 +196,18 @@ 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;
} }
} }
} }

View File

@ -59,7 +59,7 @@ 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(); void labelChanged();
void toUpdate(); void toUpdate(bool isShowed);
private: private:
DataProviderManager(); DataProviderManager();

View File

@ -80,7 +80,7 @@ public:
virtual void forceUpdate(QString &key) {}; virtual void forceUpdate(QString &key) {};
public Q_SLOTS: public Q_SLOTS:
virtual void update() {}; virtual void update(bool isShowed) {};
Q_SIGNALS: Q_SIGNALS:
/** /**

View File

@ -83,21 +83,33 @@ void AllAppDataProvider::forceUpdate()
sendData(); sendData();
} }
void AllAppDataProvider::update() void AllAppDataProvider::update(bool isShowed)
{ {
bool isRecentDataChanged = false; m_windowStatus = isShowed;
{ if (isShowed) {
QMutexLocker locker(&m_mutex); m_timer->blockSignals(true);
for (DataEntity & appdata : m_appData) { bool isRecentDataChanged = false;
bool info = appdata.isRecentInstall(); {
setRecentState(appdata); QMutexLocker locker(&m_mutex);
if (appdata.isRecentInstall() != info) { for (DataEntity &appdata : m_appData) {
isRecentDataChanged = true; bool info = appdata.isRecentInstall();
setRecentState(appdata);
if (appdata.isRecentInstall() != info) {
isRecentDataChanged = true;
break;
}
} }
} }
} if (isRecentDataChanged) {
if (isRecentDataChanged) { std::sort(m_appData.begin(), m_appData.end(), appDataSort);
sendData(); sendData();
}
} else {
m_timer->blockSignals(false);
if (m_updateStatus) {
reloadAppData();
m_updateStatus = false;
}
} }
} }
@ -117,11 +129,13 @@ void AllAppDataProvider::reloadAppData()
continue; continue;
} }
setRecentState(app); setRecentState(app);
setSortPriority(app);
appData.append(app); appData.append(app);
} }
std::sort(appData.begin(), appData.end(), appDataSort); std::sort(appData.begin(), appData.end(), appDataSort);
m_appData.swap(appData); m_appData.swap(appData);
updateTimer();
} }
void AllAppDataProvider::reloadFolderData() void AllAppDataProvider::reloadFolderData()
@ -163,6 +177,7 @@ void AllAppDataProvider::updateData(const QList<DataEntity> &apps)
if (appdata.id() == app.id()) { if (appdata.id() == app.id()) {
appdata = app; appdata = app;
setRecentState(appdata); setRecentState(appdata);
setSortPriority(appdata);
break; break;
} }
} }
@ -186,6 +201,22 @@ void AllAppDataProvider::updateFolderData(QStringList &idList)
AppFolderHelper::instance()->forceSync(); AppFolderHelper::instance()->forceSync();
} }
void AllAppDataProvider::updateTimer()
{
if (m_timer == nullptr) {
m_timer = new QTimer(this);
m_timer->setInterval(3600000*48);
connect(m_timer, &QTimer::timeout, this, [this]{
if (m_windowStatus) {
m_updateStatus = true;
} else {
reloadAppData();
}
});
}
m_timer->start();
}
bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b) bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b)
{ {
if ((a.top() != 0) && (b.top() != 0)) { if ((a.top() != 0) && (b.top() != 0)) {
@ -206,10 +237,10 @@ bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b)
} else if (b.isRecentInstall()) { } else if (b.isRecentInstall()) {
return false; return false;
} else { } else {
if (a.launchTimes() == b.launchTimes()) { if (a.priority() == b.priority()) {
return letterSort(a.firstLetter(), b.firstLetter()); return letterSort(a.firstLetter(), b.firstLetter());
} else { } else {
return a.launchTimes() > b.launchTimes(); return a.priority() > b.priority();
} }
} }
} else { } else {
@ -217,13 +248,32 @@ bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b)
} }
} }
void AllAppDataProvider::setSortPriority(DataEntity &app)
{
QDateTime installTime = QDateTime::fromString(app.insertTime(), "yyyy-MM-dd hh:mm:ss");
if (installTime.isValid()) {
qint64 appTime = installTime.secsTo(QDateTime::currentDateTime());
if (appTime <= 3600*240) {
appTime = appTime / (3600*24);
double priority = app.launchTimes() * (-0.4 * (appTime^2) + 100);
app.setPriority(priority);
return;
} else {
appTime = appTime / (3600*24);
double priority = app.launchTimes() * (240 / (appTime - 6));
app.setPriority(priority);
return;
}
}
}
void AllAppDataProvider::setRecentState(DataEntity &app) void AllAppDataProvider::setRecentState(DataEntity &app)
{ {
if (!UserConfig::instance()->isPreInstalledApps(app.id())) { if (!UserConfig::instance()->isPreInstalledApps(app.id())) {
if (app.launched() == 0) { if (app.launched() == 0) {
QDateTime installTime = QDateTime::fromString(app.insertTime(), "yyyy-MM-dd hh:mm:ss"); QDateTime installTime = QDateTime::fromString(app.insertTime(), "yyyy-MM-dd hh:mm:ss");
if (installTime.isValid()) { if (installTime.isValid()) {
int appTime = installTime.secsTo(QDateTime::currentDateTime()); qint64 appTime = installTime.secsTo(QDateTime::currentDateTime());
if ((appTime >= 0 ) && (appTime <= 3600*48)) { if ((appTime >= 0 ) && (appTime <= 3600*48)) {
app.setRecentInstall(true); app.setRecentInstall(true);
return; return;
@ -260,6 +310,7 @@ void AllAppDataProvider::onAppAdded(const QList<DataEntity>& apps)
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
for (auto app : apps) { for (auto app : apps) {
setRecentState(app); setRecentState(app);
setSortPriority(app);
m_appData.append(app); m_appData.append(app);
} }
std::sort(m_appData.begin(), m_appData.end(), appDataSort); std::sort(m_appData.begin(), m_appData.end(), appDataSort);

View File

@ -22,6 +22,7 @@
#include "data-provider-plugin-iface.h" #include "data-provider-plugin-iface.h"
#include <QSet> #include <QSet>
#include <QList> #include <QList>
#include <QTimer>
namespace UkuiMenu { namespace UkuiMenu {
@ -40,7 +41,7 @@ public:
void forceUpdate() override; void forceUpdate() override;
public Q_SLOTS: public Q_SLOTS:
void update() override; void update(bool isShowed) override;
private Q_SLOTS: private Q_SLOTS:
void onAppAdded(const QList<DataEntity>& apps); void onAppAdded(const QList<DataEntity>& apps);
@ -57,14 +58,19 @@ private:
void mergeData(QVector<DataEntity> &data); void mergeData(QVector<DataEntity> &data);
void updateData(const QList<DataEntity>& apps); void updateData(const QList<DataEntity>& apps);
void updateFolderData(QStringList& idList); void updateFolderData(QStringList& idList);
void updateTimer();
static bool appDataSort(const DataEntity &a, const DataEntity &b); static bool appDataSort(const DataEntity &a, const DataEntity &b);
static void setSortPriority(DataEntity &app);
static void setRecentState(DataEntity &app); static void setRecentState(DataEntity &app);
static bool letterSort(const QString &a, const QString &b); static bool letterSort(const QString &a, const QString &b);
private: private:
QTimer *m_timer = nullptr;
QMutex m_mutex; QMutex m_mutex;
QVector<DataEntity> m_appData; QVector<DataEntity> m_appData;
QVector<DataEntity> m_folderData; QVector<DataEntity> m_folderData;
bool m_updateStatus = false;
bool m_windowStatus = false;
}; };
} // UkuiMenu } // UkuiMenu

View File

@ -33,6 +33,7 @@ public:
int top{0}; // 置顶状态及序号 int top{0}; // 置顶状态及序号
int favorite{0}; // 收藏状态及序号 int favorite{0}; // 收藏状态及序号
int launchTimes{0}; // 启动次数 int launchTimes{0}; // 启动次数
double priority{0};
DataType::Type type {DataType::Normal}; DataType::Type type {DataType::Normal};
QString id; // 应用可执行文件路径 QString id; // 应用可执行文件路径
QString icon; QString icon;
@ -112,6 +113,16 @@ void DataEntity::setLaunchTimes(int launchTimes)
d->launchTimes = launchTimes; d->launchTimes = launchTimes;
} }
double DataEntity::priority() const
{
return d->priority;
}
void DataEntity::setPriority(double priority)
{
d->priority = priority;
}
QString DataEntity::insertTime() const QString DataEntity::insertTime() const
{ {
return d->insertTime; return d->insertTime;

View File

@ -89,6 +89,9 @@ public:
int launchTimes() const; int launchTimes() const;
void setLaunchTimes(int launchTimes); void setLaunchTimes(int launchTimes);
double priority() const;
void setPriority(double priority);
QString insertTime() const; QString insertTime() const;
void setInsertTime(const QString& insertTime); void setInsertTime(const QString& insertTime);

View File

@ -20,6 +20,8 @@
#include "app-data-manager.h" #include "app-data-manager.h"
#include "app-manager.h" #include "app-manager.h"
#include "commons.h" #include "commons.h"
#include "settings.h"
#include <QDebug> #include <QDebug>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <application-info.h> #include <application-info.h>
@ -55,6 +57,7 @@ public:
Q_INVOKABLE void openMenu(const int &index); Q_INVOKABLE void openMenu(const int &index);
public Q_SLOTS: public Q_SLOTS:
void exchangedAppsOrder(int startIndex, int endIndex); void exchangedAppsOrder(int startIndex, int endIndex);
void onStyleChanged(const GlobalSetting::Key &key);
private: private:
QVector<DataEntity> m_favoriteAppsData; QVector<DataEntity> m_favoriteAppsData;
@ -72,6 +75,7 @@ FavoriteExtension::FavoriteExtension(QObject *parent) : MenuExtensionIFace(paren
updateFavoriteData(); updateFavoriteData();
connect(AppDataManager::instance(),&AppDataManager::favoriteAppChanged, this,&FavoriteExtension::updateFavoriteData); connect(AppDataManager::instance(),&AppDataManager::favoriteAppChanged, this,&FavoriteExtension::updateFavoriteData);
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, m_favoriteAppsModel, &FavoriteAppsModel::onStyleChanged);
} }
FavoriteExtension::~FavoriteExtension() FavoriteExtension::~FavoriteExtension()
@ -181,6 +185,14 @@ void FavoriteAppsModel::exchangedAppsOrder(int startIndex, int endIndex)
AppDataManager::instance()->changedFavoriteOrderSignal(startId, endNum); AppDataManager::instance()->changedFavoriteOrderSignal(startId, endNum);
} }
void FavoriteAppsModel::onStyleChanged(const GlobalSetting::Key &key)
{
if (key == GlobalSetting::IconThemeName) {
beginResetModel();
endResetModel();
}
}
bool FavoriteMenuProvider::isSupport(const MenuProvider::RequestType &type) bool FavoriteMenuProvider::isSupport(const MenuProvider::RequestType &type)
{ {
return type == DataType; return type == DataType;

View File

@ -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:

View File

@ -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;
} }

View File

@ -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);

View File

@ -20,6 +20,7 @@
#include "app-manager.h" #include "app-manager.h"
#include "menu-manager.h" #include "menu-manager.h"
#include "app-folder-helper.h" #include "app-folder-helper.h"
#include "settings.h"
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@ -31,6 +32,7 @@ AppModel::AppModel(QObject *parent) : QAbstractListModel(parent)
reloadPluginData(); reloadPluginData();
connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged); connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged);
connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData); connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData);
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this, &AppModel::onStyleChanged);
} }
int AppModel::rowCount(const QModelIndex &parent) const int AppModel::rowCount(const QModelIndex &parent) const
@ -121,6 +123,14 @@ void AppModel::reloadPluginData()
resetModel(data); resetModel(data);
} }
void AppModel::onStyleChanged(const GlobalSetting::Key &key)
{
if (key == GlobalSetting::IconThemeName) {
Q_EMIT beginResetModel();
Q_EMIT endResetModel();
}
}
void AppModel::toRenameFolder(QString id) void AppModel::toRenameFolder(QString id)
{ {
Q_EMIT renameText(id); Q_EMIT renameText(id);

View File

@ -25,6 +25,7 @@
#include "commons.h" #include "commons.h"
#include "data-provider-manager.h" #include "data-provider-manager.h"
#include "menu-provider.h" #include "menu-provider.h"
#include "settings.h"
namespace UkuiMenu { namespace UkuiMenu {
@ -53,6 +54,7 @@ public Q_SLOTS:
private Q_SLOTS: private Q_SLOTS:
void onPluginDataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index); void onPluginDataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
void reloadPluginData(); void reloadPluginData();
void onStyleChanged(const GlobalSetting::Key& key);
private: private:
void resetModel(QVector<DataEntity> &data); void resetModel(QVector<DataEntity> &data);

View File

@ -31,6 +31,7 @@
#define UKUI_STYLE_NAME_KEY "styleName" #define UKUI_STYLE_NAME_KEY "styleName"
#define UKUI_STYLE_THEME_COLOR_KEY "themeColor" #define UKUI_STYLE_THEME_COLOR_KEY "themeColor"
#define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize" #define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize"
#define UKUI_STYLE_ICON_THEME_NAME_KEY "iconThemeName"
namespace UkuiMenu { namespace UkuiMenu {
@ -83,6 +84,9 @@ void GlobalSetting::initStyleSetting()
} else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) { } else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) {
updateData(SystemFontSize, settings->get(key)); updateData(SystemFontSize, settings->get(key));
Q_EMIT styleChanged(SystemFontSize); Q_EMIT styleChanged(SystemFontSize);
} else if (key == UKUI_STYLE_ICON_THEME_NAME_KEY) {
updateData(IconThemeName, settings->get(key));
Q_EMIT styleChanged(IconThemeName);
} }
}); });
} }

View File

@ -52,6 +52,7 @@ public:
UnKnowKey = 0, UnKnowKey = 0,
StyleName, StyleName,
ThemeColor, ThemeColor,
IconThemeName,
Transparency, Transparency,
EffectEnabled, EffectEnabled,
SystemFontSize SystemFontSize

View File

@ -115,6 +115,14 @@ void UkuiMenuApplication::loadMenuUI()
const QUrl url(QStringLiteral("qrc:/qml/main.qml")); const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
m_mainWindow = new MenuWindow(m_engine, nullptr); m_mainWindow = new MenuWindow(m_engine, nullptr);
m_mainWindow->setSource(url); m_mainWindow->setSource(url);
connect(m_mainWindow, &QQuickView::activeFocusItemChanged, m_mainWindow, [this] {
if (m_mainWindow->activeFocusItem()) {
return;
}
execCommand(Hide);
DataProviderManager::instance()->toUpdate(false);
});
} }
void UkuiMenuApplication::initDbusService() void UkuiMenuApplication::initDbusService()
@ -136,16 +144,12 @@ void UkuiMenuApplication::execCommand(Command command)
case Active: { case Active: {
if (m_mainWindow) { if (m_mainWindow) {
m_mainWindow->setVisible(!m_mainWindow->isVisible()); m_mainWindow->setVisible(!m_mainWindow->isVisible());
if (m_mainWindow->isVisible()) {
DataProviderManager::instance()->toUpdate();
}
} }
break; break;
} }
case Show: { case Show: {
if (m_mainWindow) { if (m_mainWindow) {
m_mainWindow->setVisible(true); m_mainWindow->setVisible(true);
DataProviderManager::instance()->toUpdate();
} }
break; break;
} }
@ -166,6 +170,8 @@ void UkuiMenuApplication::execCommand(Command command)
default: default:
break; break;
} }
bool isShowed = m_mainWindow->isVisible();
DataProviderManager::instance()->toUpdate(isShowed);
} }
UkuiMenuApplication::~UkuiMenuApplication() UkuiMenuApplication::~UkuiMenuApplication()

View File

@ -399,7 +399,6 @@ void MenuWindow::init()
// 访问窗口api // 访问窗口api
rootContext()->setContextProperty("mainWindow", this); rootContext()->setContextProperty("mainWindow", this);
connect(this, &QQuickView::activeFocusItemChanged, this, &MenuWindow::onActiveFocusItemChanged);
connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] { connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
QEvent event(QEvent::Move); QEvent event(QEvent::Move);
@ -526,15 +525,6 @@ void MenuWindow::showEvent(QShowEvent *event)
QQuickView::showEvent(event); QQuickView::showEvent(event);
} }
void MenuWindow::onActiveFocusItemChanged()
{
if (activeFocusItem()) {
return;
}
setVisible(false);
}
bool MenuWindow::effectEnabled() const bool MenuWindow::effectEnabled() const
{ {
return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool(); return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool();

View File

@ -133,9 +133,6 @@ Q_SIGNALS:
void beforeFullScreenExited(); void beforeFullScreenExited();
void panelPosChanged(); void panelPosChanged();
private Q_SLOTS:
void onActiveFocusItemChanged();
protected: protected:
void exposeEvent(QExposeEvent *event) override; void exposeEvent(QExposeEvent *event) override;
void focusOutEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override;