Merge tag 'upstream/4.0.0.4' into openkylin/yangtze
4.0.0.4-release
This commit is contained in:
commit
a50c3e290d
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"Type": "UKUI_MENU_EXTENSION",
|
||||
"Version": "1.0.0"
|
||||
"Version": "1.0.1"
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ void RecentFileExtension::creatMenu(const QString &path, const int &index)
|
|||
QDBusMessage message = QDBusMessage::createMethodCall(FREEDESKTOP_FILEMANAGER_NAME,
|
||||
FREEDESKTOP_FILEMANAGER_PATH,
|
||||
FREEDESKTOP_FILEMANAGER_INTERFACE, "ShowFolders");
|
||||
message << QStringList(path);
|
||||
message << QStringList(path) << "ukui-menu-recent-file";
|
||||
QDBusConnection::sessionBus().asyncCall(message);
|
||||
});
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ StyleBackground {
|
|||
width: iconGrid.cellWidth
|
||||
height: iconGrid.cellHeight
|
||||
source: modelData
|
||||
cache: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ Item {
|
|||
height: root.iconHeight
|
||||
width: root.iconWidth
|
||||
source: root.appIcon
|
||||
cache: false
|
||||
}
|
||||
|
||||
StyleText {
|
||||
|
|
|
@ -256,6 +256,7 @@ RowLayout {
|
|||
height: 96
|
||||
width: 96
|
||||
source: icon
|
||||
cache: false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,29 +24,46 @@ import QtQuick.Controls 2.5
|
|||
import AppControls2 1.0 as AppControls2
|
||||
import org.ukui.menu.core 1.0
|
||||
import org.ukui.menu.utils 1.0
|
||||
import org.ukui.menu.extension 1.0
|
||||
|
||||
Item {
|
||||
ColumnLayout {
|
||||
id: sidebarLayout
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 12
|
||||
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.preferredHeight: 40
|
||||
Layout.rightMargin: 12
|
||||
Layout.leftMargin: 16
|
||||
Layout.leftMargin: 12
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
// spacing: 5
|
||||
|
||||
ListView {
|
||||
id: extensionListView
|
||||
width: parent.width - 34
|
||||
height: parent.height
|
||||
id: extensionInfoList
|
||||
|
||||
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: headerDelegate
|
||||
delegate: extensionInfoDelegate
|
||||
|
||||
function send(data) {
|
||||
if (currentItem !== null) {
|
||||
|
@ -62,7 +79,11 @@ Item {
|
|||
}
|
||||
|
||||
AppControls2.StyleBackground {
|
||||
width: 34; height: width
|
||||
id: fullScreenbutton
|
||||
Layout.preferredWidth: 34
|
||||
Layout.preferredHeight: 34
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
radius: 4
|
||||
useStyleTransparent: false
|
||||
alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00
|
||||
|
@ -70,7 +91,7 @@ Item {
|
|||
border.width: buttonMouseArea.activeFocus ? 2 : 0
|
||||
ThemeIcon {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width / 2; height: width
|
||||
width: 16; height: 16
|
||||
source: "image://appicon/view-fullscreen-symbolic"
|
||||
MouseArea {
|
||||
id: buttonMouseArea
|
||||
|
@ -91,6 +112,7 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
|
@ -101,23 +123,34 @@ Item {
|
|||
anchors.fill: parent
|
||||
clip: true
|
||||
onLoaded: {
|
||||
item.send.connect(extensionListView.send);
|
||||
item.send.connect(extensionInfoList.send);
|
||||
sidebarLayout.updateSidebarLayout(extensionInfoList.currentItem.extensionOptions);
|
||||
}
|
||||
Keys.onTabPressed: {
|
||||
extensionListView.focus = true
|
||||
extensionInfoList.focus = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
Item {
|
||||
id: sidebarBottomBar
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
Layout.preferredHeight: 32
|
||||
Layout.topMargin: 5
|
||||
Layout.bottomMargin: 8
|
||||
Layout.leftMargin: 12
|
||||
Layout.rightMargin: 12
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
layoutDirection: Qt.RightToLeft
|
||||
spacing: 5
|
||||
|
||||
AppControls2.StyleBackground {
|
||||
width: 32
|
||||
height: 32
|
||||
Layout.preferredWidth: 32
|
||||
Layout.preferredHeight: 32
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
paletteRole: Palette.Base
|
||||
useStyleTransparent: false
|
||||
alpha: powerButtonArea.containsPress ? 0.85 : powerButtonArea.containsMouse ? 0.65 : 0
|
||||
|
@ -130,8 +163,8 @@ Item {
|
|||
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
width: Math.floor(parent.width / 2)
|
||||
height: width
|
||||
width: 24
|
||||
height: 24
|
||||
source: powerButtonBase.icon
|
||||
}
|
||||
|
||||
|
@ -160,20 +193,21 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: headerDelegate
|
||||
id: extensionInfoDelegate
|
||||
|
||||
AppControls2.StyleBackground {
|
||||
id: headerDelegateItem
|
||||
useStyleTransparent: false
|
||||
paletteRole: Palette.Highlight
|
||||
alpha: 0
|
||||
radius: 4
|
||||
borderColor: Palette.Highlight
|
||||
border.width: headerDelegateItem.activeFocus ? 2 : 0
|
||||
border.width: activeFocus ? 2 : 0
|
||||
|
||||
property var extensionData: model.data
|
||||
property var extensionOptions: model.options
|
||||
width: styleText.width
|
||||
height: ListView.view ? ListView.view.height : 0
|
||||
|
||||
|
@ -219,8 +253,8 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (extensionListView.count > 0) {
|
||||
extensionListView.currentIndex = 0;
|
||||
if (extensionInfoList.count > 0) {
|
||||
extensionInfoList.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ Q_SIGNALS:
|
|||
void pluginChanged(const QString &id, PluginGroup::Group group);
|
||||
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
||||
void labelChanged();
|
||||
void toUpdate();
|
||||
void toUpdate(bool isShowed);
|
||||
|
||||
private:
|
||||
DataProviderManager();
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
virtual void forceUpdate(QString &key) {};
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void update() {};
|
||||
virtual void update(bool isShowed) {};
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
|
|
@ -83,22 +83,34 @@ void AllAppDataProvider::forceUpdate()
|
|||
sendData();
|
||||
}
|
||||
|
||||
void AllAppDataProvider::update()
|
||||
void AllAppDataProvider::update(bool isShowed)
|
||||
{
|
||||
m_windowStatus = isShowed;
|
||||
if (isShowed) {
|
||||
m_timer->blockSignals(true);
|
||||
bool isRecentDataChanged = false;
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
for (DataEntity & appdata : m_appData) {
|
||||
for (DataEntity &appdata : m_appData) {
|
||||
bool info = appdata.isRecentInstall();
|
||||
setRecentState(appdata);
|
||||
if (appdata.isRecentInstall() != info) {
|
||||
isRecentDataChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRecentDataChanged) {
|
||||
std::sort(m_appData.begin(), m_appData.end(), appDataSort);
|
||||
sendData();
|
||||
}
|
||||
} else {
|
||||
m_timer->blockSignals(false);
|
||||
if (m_updateStatus) {
|
||||
reloadAppData();
|
||||
m_updateStatus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AllAppDataProvider::reloadAppData()
|
||||
|
@ -117,11 +129,13 @@ void AllAppDataProvider::reloadAppData()
|
|||
continue;
|
||||
}
|
||||
setRecentState(app);
|
||||
setSortPriority(app);
|
||||
appData.append(app);
|
||||
}
|
||||
|
||||
std::sort(appData.begin(), appData.end(), appDataSort);
|
||||
m_appData.swap(appData);
|
||||
updateTimer();
|
||||
}
|
||||
|
||||
void AllAppDataProvider::reloadFolderData()
|
||||
|
@ -163,6 +177,7 @@ void AllAppDataProvider::updateData(const QList<DataEntity> &apps)
|
|||
if (appdata.id() == app.id()) {
|
||||
appdata = app;
|
||||
setRecentState(appdata);
|
||||
setSortPriority(appdata);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +201,22 @@ void AllAppDataProvider::updateFolderData(QStringList &idList)
|
|||
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)
|
||||
{
|
||||
if ((a.top() != 0) && (b.top() != 0)) {
|
||||
|
@ -206,10 +237,10 @@ bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b)
|
|||
} else if (b.isRecentInstall()) {
|
||||
return false;
|
||||
} else {
|
||||
if (a.launchTimes() == b.launchTimes()) {
|
||||
if (a.priority() == b.priority()) {
|
||||
return letterSort(a.firstLetter(), b.firstLetter());
|
||||
} else {
|
||||
return a.launchTimes() > b.launchTimes();
|
||||
return a.priority() > b.priority();
|
||||
}
|
||||
}
|
||||
} 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)
|
||||
{
|
||||
if (!UserConfig::instance()->isPreInstalledApps(app.id())) {
|
||||
if (app.launched() == 0) {
|
||||
QDateTime installTime = QDateTime::fromString(app.insertTime(), "yyyy-MM-dd hh:mm:ss");
|
||||
if (installTime.isValid()) {
|
||||
int appTime = installTime.secsTo(QDateTime::currentDateTime());
|
||||
qint64 appTime = installTime.secsTo(QDateTime::currentDateTime());
|
||||
if ((appTime >= 0 ) && (appTime <= 3600*48)) {
|
||||
app.setRecentInstall(true);
|
||||
return;
|
||||
|
@ -260,6 +310,7 @@ void AllAppDataProvider::onAppAdded(const QList<DataEntity>& apps)
|
|||
QMutexLocker locker(&m_mutex);
|
||||
for (auto app : apps) {
|
||||
setRecentState(app);
|
||||
setSortPriority(app);
|
||||
m_appData.append(app);
|
||||
}
|
||||
std::sort(m_appData.begin(), m_appData.end(), appDataSort);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "data-provider-plugin-iface.h"
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QTimer>
|
||||
|
||||
namespace UkuiMenu {
|
||||
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
void forceUpdate() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void update() override;
|
||||
void update(bool isShowed) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAppAdded(const QList<DataEntity>& apps);
|
||||
|
@ -57,14 +58,19 @@ private:
|
|||
void mergeData(QVector<DataEntity> &data);
|
||||
void updateData(const QList<DataEntity>& apps);
|
||||
void updateFolderData(QStringList& idList);
|
||||
void updateTimer();
|
||||
static bool appDataSort(const DataEntity &a, const DataEntity &b);
|
||||
static void setSortPriority(DataEntity &app);
|
||||
static void setRecentState(DataEntity &app);
|
||||
static bool letterSort(const QString &a, const QString &b);
|
||||
|
||||
private:
|
||||
QTimer *m_timer = nullptr;
|
||||
QMutex m_mutex;
|
||||
QVector<DataEntity> m_appData;
|
||||
QVector<DataEntity> m_folderData;
|
||||
bool m_updateStatus = false;
|
||||
bool m_windowStatus = false;
|
||||
};
|
||||
|
||||
} // UkuiMenu
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
int top{0}; // 置顶状态及序号
|
||||
int favorite{0}; // 收藏状态及序号
|
||||
int launchTimes{0}; // 启动次数
|
||||
double priority{0};
|
||||
DataType::Type type {DataType::Normal};
|
||||
QString id; // 应用可执行文件路径
|
||||
QString icon;
|
||||
|
@ -112,6 +113,16 @@ void DataEntity::setLaunchTimes(int launchTimes)
|
|||
d->launchTimes = launchTimes;
|
||||
}
|
||||
|
||||
double DataEntity::priority() const
|
||||
{
|
||||
return d->priority;
|
||||
}
|
||||
|
||||
void DataEntity::setPriority(double priority)
|
||||
{
|
||||
d->priority = priority;
|
||||
}
|
||||
|
||||
QString DataEntity::insertTime() const
|
||||
{
|
||||
return d->insertTime;
|
||||
|
|
|
@ -89,6 +89,9 @@ public:
|
|||
int launchTimes() const;
|
||||
void setLaunchTimes(int launchTimes);
|
||||
|
||||
double priority() const;
|
||||
void setPriority(double priority);
|
||||
|
||||
QString insertTime() const;
|
||||
void setInsertTime(const QString& insertTime);
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "app-data-manager.h"
|
||||
#include "app-manager.h"
|
||||
#include "commons.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAbstractListModel>
|
||||
#include <application-info.h>
|
||||
|
@ -55,6 +57,7 @@ public:
|
|||
Q_INVOKABLE void openMenu(const int &index);
|
||||
public Q_SLOTS:
|
||||
void exchangedAppsOrder(int startIndex, int endIndex);
|
||||
void onStyleChanged(const GlobalSetting::Key &key);
|
||||
|
||||
private:
|
||||
QVector<DataEntity> m_favoriteAppsData;
|
||||
|
@ -72,6 +75,7 @@ FavoriteExtension::FavoriteExtension(QObject *parent) : MenuExtensionIFace(paren
|
|||
|
||||
updateFavoriteData();
|
||||
connect(AppDataManager::instance(),&AppDataManager::favoriteAppChanged, this,&FavoriteExtension::updateFavoriteData);
|
||||
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, m_favoriteAppsModel, &FavoriteAppsModel::onStyleChanged);
|
||||
}
|
||||
|
||||
FavoriteExtension::~FavoriteExtension()
|
||||
|
@ -181,6 +185,14 @@ void FavoriteAppsModel::exchangedAppsOrder(int startIndex, int endIndex)
|
|||
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)
|
||||
{
|
||||
return type == DataType;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#define UKUI_MENU_EXTENSION_TYPE "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 <QUrl>
|
||||
|
@ -35,11 +35,18 @@ class Q_DECL_EXPORT MenuExtensionIFace : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Option {
|
||||
HideBottomBar,
|
||||
HideFullScreenButton
|
||||
};
|
||||
Q_ENUM(Option)
|
||||
|
||||
explicit MenuExtensionIFace(QObject *parent = nullptr) : QObject(parent) {};
|
||||
virtual int index() = 0;
|
||||
virtual QString name() = 0;
|
||||
virtual QUrl url() = 0;
|
||||
virtual QVariantMap data() = 0;
|
||||
virtual QVariantList options() { return {}; };
|
||||
virtual void receive(QVariantMap data) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <QDir>
|
||||
#include <QPluginLoader>
|
||||
#include <QDebug>
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
namespace UkuiMenu {
|
||||
|
||||
|
@ -35,6 +36,7 @@ MenuExtension *MenuExtension::instance()
|
|||
MenuExtension::MenuExtension()
|
||||
{
|
||||
qRegisterMetaType<ExtensionModel*>("ExtensionModel*");
|
||||
qmlRegisterUncreatableType<MenuExtensionIFace>("org.ukui.menu.extension", 1, 0, "MenuExtension", "");
|
||||
|
||||
// TODO load extension from filesystem.
|
||||
loadExtensions();
|
||||
|
@ -121,6 +123,7 @@ ExtensionModel::ExtensionModel(const QVector<MenuExtensionIFace*> &extensions, Q
|
|||
m_roleNames.insert(Name, "name");
|
||||
m_roleNames.insert(Url, "url");
|
||||
m_roleNames.insert(Data, "data");
|
||||
m_roleNames.insert(Options, "options");
|
||||
|
||||
for (int i = 0; i < m_extensions.size(); ++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: {
|
||||
return m_extensions.at(row)->data();
|
||||
}
|
||||
case Options:
|
||||
return m_extensions.at(row)->options();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ public:
|
|||
enum Name {
|
||||
Name,
|
||||
Url,
|
||||
Data
|
||||
Data,
|
||||
Options
|
||||
};
|
||||
|
||||
explicit ExtensionModel(const QVector<MenuExtensionIFace*> &extensions, QObject *parent = nullptr);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "app-manager.h"
|
||||
#include "menu-manager.h"
|
||||
#include "app-folder-helper.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
@ -31,6 +32,7 @@ AppModel::AppModel(QObject *parent) : QAbstractListModel(parent)
|
|||
reloadPluginData();
|
||||
connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged);
|
||||
connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData);
|
||||
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this, &AppModel::onStyleChanged);
|
||||
}
|
||||
|
||||
int AppModel::rowCount(const QModelIndex &parent) const
|
||||
|
@ -121,6 +123,14 @@ void AppModel::reloadPluginData()
|
|||
resetModel(data);
|
||||
}
|
||||
|
||||
void AppModel::onStyleChanged(const GlobalSetting::Key &key)
|
||||
{
|
||||
if (key == GlobalSetting::IconThemeName) {
|
||||
Q_EMIT beginResetModel();
|
||||
Q_EMIT endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
void AppModel::toRenameFolder(QString id)
|
||||
{
|
||||
Q_EMIT renameText(id);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "commons.h"
|
||||
#include "data-provider-manager.h"
|
||||
#include "menu-provider.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace UkuiMenu {
|
||||
|
||||
|
@ -53,6 +54,7 @@ public Q_SLOTS:
|
|||
private Q_SLOTS:
|
||||
void onPluginDataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
||||
void reloadPluginData();
|
||||
void onStyleChanged(const GlobalSetting::Key& key);
|
||||
|
||||
private:
|
||||
void resetModel(QVector<DataEntity> &data);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#define UKUI_STYLE_NAME_KEY "styleName"
|
||||
#define UKUI_STYLE_THEME_COLOR_KEY "themeColor"
|
||||
#define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize"
|
||||
#define UKUI_STYLE_ICON_THEME_NAME_KEY "iconThemeName"
|
||||
|
||||
namespace UkuiMenu {
|
||||
|
||||
|
@ -83,6 +84,9 @@ void GlobalSetting::initStyleSetting()
|
|||
} else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) {
|
||||
updateData(SystemFontSize, settings->get(key));
|
||||
Q_EMIT styleChanged(SystemFontSize);
|
||||
} else if (key == UKUI_STYLE_ICON_THEME_NAME_KEY) {
|
||||
updateData(IconThemeName, settings->get(key));
|
||||
Q_EMIT styleChanged(IconThemeName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
UnKnowKey = 0,
|
||||
StyleName,
|
||||
ThemeColor,
|
||||
IconThemeName,
|
||||
Transparency,
|
||||
EffectEnabled,
|
||||
SystemFontSize
|
||||
|
|
|
@ -115,6 +115,14 @@ void UkuiMenuApplication::loadMenuUI()
|
|||
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
|
||||
m_mainWindow = new MenuWindow(m_engine, nullptr);
|
||||
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()
|
||||
|
@ -136,16 +144,12 @@ void UkuiMenuApplication::execCommand(Command command)
|
|||
case Active: {
|
||||
if (m_mainWindow) {
|
||||
m_mainWindow->setVisible(!m_mainWindow->isVisible());
|
||||
if (m_mainWindow->isVisible()) {
|
||||
DataProviderManager::instance()->toUpdate();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Show: {
|
||||
if (m_mainWindow) {
|
||||
m_mainWindow->setVisible(true);
|
||||
DataProviderManager::instance()->toUpdate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -166,6 +170,8 @@ void UkuiMenuApplication::execCommand(Command command)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
bool isShowed = m_mainWindow->isVisible();
|
||||
DataProviderManager::instance()->toUpdate(isShowed);
|
||||
}
|
||||
|
||||
UkuiMenuApplication::~UkuiMenuApplication()
|
||||
|
|
|
@ -399,7 +399,6 @@ void MenuWindow::init()
|
|||
|
||||
// 访问窗口api
|
||||
rootContext()->setContextProperty("mainWindow", this);
|
||||
connect(this, &QQuickView::activeFocusItemChanged, this, &MenuWindow::onActiveFocusItemChanged);
|
||||
|
||||
connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
|
||||
QEvent event(QEvent::Move);
|
||||
|
@ -526,15 +525,6 @@ void MenuWindow::showEvent(QShowEvent *event)
|
|||
QQuickView::showEvent(event);
|
||||
}
|
||||
|
||||
void MenuWindow::onActiveFocusItemChanged()
|
||||
{
|
||||
if (activeFocusItem()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
bool MenuWindow::effectEnabled() const
|
||||
{
|
||||
return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool();
|
||||
|
|
|
@ -133,9 +133,6 @@ Q_SIGNALS:
|
|||
void beforeFullScreenExited();
|
||||
void panelPosChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onActiveFocusItemChanged();
|
||||
|
||||
protected:
|
||||
void exposeEvent(QExposeEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
|
|
Loading…
Reference in New Issue