From b34160ea5e6451a0882801a702ae6ca5f718f3be Mon Sep 17 00:00:00 2001 From: hewenfei Date: Wed, 15 Nov 2023 16:05:40 +0800 Subject: [PATCH] =?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)); } });