From b34160ea5e6451a0882801a702ae6ca5f718f3be Mon Sep 17 00:00:00 2001 From: hewenfei Date: Wed, 15 Nov 2023 16:05:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8Dukui-lite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/AppPageHeader.qml | 47 ++++++++++++++++++++++---------- qml/AppUI/Sidebar.qml | 7 ++++- src/settings/settings.cpp | 32 ++++++++++++++++++++++ src/settings/settings.h | 7 ++++- src/windows/menu-main-window.cpp | 6 ++-- 5 files changed, 80 insertions(+), 19 deletions(-) diff --git a/qml/AppUI/AppPageHeader.qml b/qml/AppUI/AppPageHeader.qml index f47bc41..58468ff 100644 --- a/qml/AppUI/AppPageHeader.qml +++ b/qml/AppUI/AppPageHeader.qml @@ -70,36 +70,53 @@ Item { } ] + onStateChanged: { + if (isLiteMode) { + if (state === "search") { + setPluginSelectionVisible(false); + setSearchBarVisible(true); + } else { + setPluginSelectionVisible(true); + setSearchBarVisible(false); + } + } + } + + function setPluginSelectionVisible(vis) { + pluginSelectionBar.visible = vis; + pluginSelectMenu.visible = vis; + } + + function setSearchBarVisible(vis) { + searchBar.visible = vis; + if (vis) { + searchInputBar.providerId = "search"; + searchInputBar.textInputFocus(); + } + } + transitions:[ Transition { to: "normal" + enabled: !isLiteMode SequentialAnimation { ScriptAction { - script: { - pluginSelectionBar.visible = true; - pluginSelectMenu.visible = true; - } + script: { setPluginSelectionVisible(true); } } NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 } - ScriptAction { script: searchBar.visible = false } + ScriptAction { script: { setSearchBarVisible(false); } } } }, Transition { to: "search" + enabled: !isLiteMode SequentialAnimation { ScriptAction { - script: { - searchBar.visible = true; - searchInputBar.providerId = "search"; - searchInputBar.textInputFocus(); - } + script: { setSearchBarVisible(true); } } - NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300} + NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 } ScriptAction { - script: { - pluginSelectionBar.visible = false; - pluginSelectMenu.visible = false; - } + script: { setPluginSelectionVisible(false); } } } } diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index 2037d83..2f52693 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -34,9 +34,14 @@ Item { anchors.topMargin: 12 spacing: 0 + property bool liteMode: isLiteMode + onLiteModeChanged: { + updateSidebarLayout(extensionInfoList.currentItem.extensionOptions) + } + function updateSidebarLayout(options) { sidebarBottomBar.visible = !options.includes(MenuExtension.HideBottomBar); - fullScreenbutton.visible = !options.includes(MenuExtension.HideFullScreenButton); + fullScreenbutton.visible = !isLiteMode && !options.includes(MenuExtension.HideFullScreenButton); } Item { diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 50aee94..4bd5e6a 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -21,6 +21,8 @@ #include #include #include +#include +#include #define UKUI_MENU_SCHEMA "org.ukui.menu.settings" #define CONTROL_CENTER_SETTING "org.ukui.control-center.personalise" @@ -51,6 +53,7 @@ GlobalSetting::GlobalSetting(QObject *parent) : QObject(parent) { initStyleSetting(); initGlobalSettings(); + initUSDSetting(); } void GlobalSetting::initStyleSetting() @@ -173,6 +176,35 @@ void GlobalSetting::initGlobalSettings() } } +void GlobalSetting::initUSDSetting() +{ + m_cache.insert(IsLiteMode, true); + + const QString service = QStringLiteral("org.ukui.SettingsDaemon"); + const QString path = QStringLiteral("/GlobalSignal"); + const QString interface = QStringLiteral("org.ukui.SettingsDaemon.GlobalSignal"); + + QDBusInterface dBusInterface(service, path, interface); + if (dBusInterface.isValid()) { + QDBusReply reply = dBusInterface.call(QStringLiteral("getUKUILiteAnimation")); + if (reply.isValid()) { + QMap m; + m.insert("animation", reply.value()); + onSysModeChanged(m); + } + } + + QDBusConnection::sessionBus().connect(service, path, interface, "UKUILiteChanged", this, SLOT(onSysModeChanged)); +} + +void GlobalSetting::onSysModeChanged(QMap map) +{ + if (map.contains("animation")) { + m_cache.insert(IsLiteMode, (map.value("animation").toString() == "off")); + Q_EMIT styleChanged(IsLiteMode); + } +} + MenuSetting *MenuSetting::instance() { static MenuSetting setting(nullptr); diff --git a/src/settings/settings.h b/src/settings/settings.h index af33fb4..063adc0 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -55,7 +55,8 @@ public: IconThemeName, Transparency, EffectEnabled, - SystemFontSize + SystemFontSize, + IsLiteMode }; Q_ENUM(Key) @@ -75,10 +76,14 @@ public: Q_SIGNALS: void styleChanged(const GlobalSetting::Key& key); +private Q_SLOTS: + void onSysModeChanged(QMap map); + private: explicit GlobalSetting(QObject *parent = nullptr); void initStyleSetting(); void initGlobalSettings(); + void initUSDSetting(); void updateData(const GlobalSetting::Key& key, const QVariant &value); private: diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp index cf19fb4..9a4e6ad 100644 --- a/src/windows/menu-main-window.cpp +++ b/src/windows/menu-main-window.cpp @@ -407,12 +407,14 @@ void MenuWindow::init() Q_EMIT panelPosChanged(); }); + rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(GlobalSetting::IsLiteMode)); connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this , [this] (const GlobalSetting::Key& key) { if (key == GlobalSetting::EffectEnabled) { Q_EMIT effectEnabledChanged(); - } - if (key == GlobalSetting::Transparency) { + } else if (key == GlobalSetting::Transparency) { Q_EMIT transparencyChanged(); + } else if (key == GlobalSetting::IsLiteMode) { + rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(key)); } }); From 84ffa42c2334342810fd116c15e803921c880dc3 Mon Sep 17 00:00:00 2001 From: hewenfei Date: Thu, 16 Nov 2023 10:43:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ui:=20=E6=9B=B4=E6=96=B0=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translations/ukui-menu_zh_CN.ts | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts index 871def1..6d118d3 100644 --- a/translations/ukui-menu_zh_CN.ts +++ b/translations/ukui-menu_zh_CN.ts @@ -273,27 +273,4 @@ 关机 - - UkuiMenu::RecentFileExtension - - Recent Files - 最近文件 - - - Open - 打开 - - - Remove from list - 从列表删除 - - - Clear list - 清空全部 - - - Open the directory where the file is located - 打开文件所在目录 - - From 5d2f696677b1084c99c5f013156d85a46dea458c Mon Sep 17 00:00:00 2001 From: hewenfei Date: Tue, 21 Nov 2023 16:02:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=9F=8B=E7=82=B9?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=90=8D=E7=A7=B0,=E9=80=82=E9=85=8Dsdk?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/AppPageContent.qml | 4 +- qml/AppUI/Sidebar.qml | 3 +- src/appdata/app-folder-helper.cpp | 6 +-- src/appdata/data-provider-manager.cpp | 10 ++-- src/appdata/data-provider-manager.h | 2 +- .../extensions/favorite-extension.cpp | 4 +- src/utils/event-track.cpp | 50 ++++++++++++++++++- src/utils/event-track.h | 5 +- 8 files changed, 68 insertions(+), 16 deletions(-) diff --git a/qml/AppUI/AppPageContent.qml b/qml/AppUI/AppPageContent.qml index cc4fad6..4be3b86 100644 --- a/qml/AppUI/AppPageContent.qml +++ b/qml/AppUI/AppPageContent.qml @@ -100,14 +100,14 @@ SwipeView { appPageHeader.title = folderName; appPageHeader.content = folderPageHeader; root.currentIndex = SwipeView.index; - EventTrack.sendClickEvent("EnterFolderPage", "AppView"); + EventTrack.sendClickEvent("enter_folder_page", "AppView"); } function hideFolderPage() { root.currentIndex = appListBase.SwipeView.index; appPageHeader.title = appList.title; appPageHeader.content = null; //active = false; - EventTrack.sendClickEvent("ExitFolderPage", "AppView"); + EventTrack.sendClickEvent("exit_folder_page", "AppView"); } Component.onCompleted: { diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index 2f52693..2d1ed21 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -242,6 +242,7 @@ Item { Keys.onPressed: { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { ListView.view.currentIndex = model.index; + EventTrack.sendClickEvent("switch_plugin", "Sidebar", {"plugin": model.name}); } } @@ -254,7 +255,6 @@ Item { function select() { if (extensionLoader.source !== model.url) { extensionLoader.setSource(model.url, {extensionData: extensionData}); - EventTrack.sendClickEvent("Switch Plugin: " + model.name, "Sidebar"); } } @@ -274,6 +274,7 @@ Item { onClicked: { normalUI.focusToFalse(); parent.ListView.view.currentIndex = model.index; + EventTrack.sendClickEvent("switch_plugin", "Sidebar", {"plugin": model.name}); } } } diff --git a/src/appdata/app-folder-helper.cpp b/src/appdata/app-folder-helper.cpp index 2b0235b..7227600 100644 --- a/src/appdata/app-folder-helper.cpp +++ b/src/appdata/app-folder-helper.cpp @@ -221,7 +221,7 @@ void AppFolderHelper::addAppToFolder(const QString &appId, const int &folderId) forceSync(); Q_EMIT folderDataChanged(folderId); - EventTrack::instance()->sendDefaultEvent("AddAppToFolder", "AppView"); + EventTrack::instance()->sendDefaultEvent("add_app_to_folder", "AppView"); } void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &folderName) @@ -245,7 +245,7 @@ void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &fol insertFolder(folder); Q_EMIT folderAdded(folder.id); - EventTrack::instance()->sendDefaultEvent("AddAppToNewFolder", "AppView"); + EventTrack::instance()->sendDefaultEvent("add_app_to_new_folder", "AppView"); } void AppFolderHelper::addAppsToNewFolder(const QString &appIdA, const QString &appIdB, const QString &folderName) @@ -311,7 +311,7 @@ bool AppFolderHelper::deleteFolder(const int& folderId) } Q_EMIT folderDeleted(folderId); - EventTrack::instance()->sendDefaultEvent("DeleteFolder", "AppView"); + EventTrack::instance()->sendDefaultEvent("delete_folder", "AppView"); return true; } diff --git a/src/appdata/data-provider-manager.cpp b/src/appdata/data-provider-manager.cpp index 85bcf5f..85dcf74 100644 --- a/src/appdata/data-provider-manager.cpp +++ b/src/appdata/data-provider-manager.cpp @@ -60,7 +60,7 @@ void DataProviderManager::initProviders() connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update); registerProvider(sort); - activateProvider(allProvider->id()); + activateProvider(allProvider->id(), false); allProvider->moveToThread(&m_worker); search->moveToThread(&m_worker); category->moveToThread(&m_worker); @@ -152,7 +152,7 @@ ProviderInfo DataProviderManager::providerInfo(const QString &id) const return info; } -void DataProviderManager::activateProvider(const QString &id) +void DataProviderManager::activateProvider(const QString &id, bool record) { if (!m_providers.contains(id) || m_activatedPlugin == id) { return; @@ -160,7 +160,11 @@ void DataProviderManager::activateProvider(const QString &id) m_activatedPlugin = id; Q_EMIT pluginChanged(m_activatedPlugin, m_providers.value(m_activatedPlugin)->group()); - EventTrack::instance()->sendClickEvent("Switch AppView: " + id, "AppView"); + if (record) { + QMap map; + map.insert("viewName", id); + EventTrack::instance()->sendClickEvent("switch_app_view", "AppView", map); + } } DataProviderManager::~DataProviderManager() diff --git a/src/appdata/data-provider-manager.h b/src/appdata/data-provider-manager.h index 584bfe0..f973ada 100644 --- a/src/appdata/data-provider-manager.h +++ b/src/appdata/data-provider-manager.h @@ -49,7 +49,7 @@ public: QVector providers(PluginGroup::Group group) const; ProviderInfo providerInfo(const QString &id) const; QString activatedProvider() const; - void activateProvider(const QString &id); + void activateProvider(const QString &id, bool record = true); QVector data() const; QVector labels() const; void forceUpdate() const; diff --git a/src/extension/extensions/favorite-extension.cpp b/src/extension/extensions/favorite-extension.cpp index 51d79fa..bf3be59 100644 --- a/src/extension/extensions/favorite-extension.cpp +++ b/src/extension/extensions/favorite-extension.cpp @@ -219,13 +219,13 @@ FavoriteMenuProvider::generateActions(QObject *parent, const QVariant &data, con list << new QAction(QObject::tr("Fix to favorite"), parent); QObject::connect(list.last(), &QAction::triggered, parent, [app] { Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 1); - EventTrack::instance()->sendDefaultEvent("Fix to favorite", "Right-click Menu"); + EventTrack::instance()->sendDefaultEvent("fix_to_favorite", "Right-click Menu"); }); } else if (locationId == "favorite") { list << new QAction(QObject::tr("Remove from favorite"), parent); QObject::connect(list.last(), &QAction::triggered, parent, [app] { Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 0); - EventTrack::instance()->sendDefaultEvent("Remove from favorite", "Right-click Menu"); + EventTrack::instance()->sendDefaultEvent("remove_from_favorite", "Right-click Menu"); }); } break; diff --git a/src/utils/event-track.cpp b/src/utils/event-track.cpp index d76555a..3650149 100644 --- a/src/utils/event-track.cpp +++ b/src/utils/event-track.cpp @@ -22,6 +22,40 @@ namespace UkuiMenu { +KCustomProperty* appendCustomProp(KTrackData *data, const QVariantMap &map) +{ + if (!data || map.isEmpty()) { + return nullptr; + } + + int i = 0; + auto properties = new KCustomProperty[map.size()]; + QMapIterator it(map); + while (it.hasNext()) { + it.next(); + + std::string string = it.key().toStdString(); + properties[i].key = strdup(string.c_str()); + + string = it.value().toString().toStdString(); + properties[i].value = strdup(string.c_str()); + + ++i; + } + + return properties; +} + +void freeKCustomProperty(KCustomProperty *customProperty, int size) +{ + for (int i = 0; i < size; ++i) { + delete customProperty[i].key; + delete customProperty[i].value; + } + + delete [] customProperty; +} + EventTrack::EventTrack(QObject *parent) : QObject(parent) { @@ -39,18 +73,30 @@ EventTrack *EventTrack::instance() return &eventTrack; } -void EventTrack::sendClickEvent(const QString &event, const QString &page) +void EventTrack::sendClickEvent(const QString &event, const QString &page, const QVariantMap &map) { KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK); + KCustomProperty* properties = appendCustomProp(data, map); + if (properties) { + kdk_dia_append_custom_property(data, properties, map.size()); + } + kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); kdk_dia_data_free(data); + freeKCustomProperty(properties, map.size()); } -void EventTrack::sendDefaultEvent(const QString& event, const QString& page) +void EventTrack::sendDefaultEvent(const QString& event, const QString& page, const QVariantMap &map) { KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CUSTOM); + KCustomProperty* properties = appendCustomProp(data, map); + if (properties) { + kdk_dia_append_custom_property(data, properties, map.size()); + } + kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); kdk_dia_data_free(data); + freeKCustomProperty(properties, map.size()); } void EventTrack::sendSearchEvent(const QString &event, const QString &page, const QString &content) diff --git a/src/utils/event-track.h b/src/utils/event-track.h index 56c3cf0..432f27d 100644 --- a/src/utils/event-track.h +++ b/src/utils/event-track.h @@ -20,6 +20,7 @@ #define UKUI_MENU_EVENT_TRACK_H #include +#include #include namespace UkuiMenu { @@ -32,8 +33,8 @@ public: static EventTrack *instance(); explicit EventTrack(QObject *parent = nullptr); - Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page); - Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page); + Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page, const QVariantMap &map = {}); + Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page, const QVariantMap &map = {}); Q_INVOKABLE void sendSearchEvent(const QString& event, const QString& page, const QString& content); };