feat: 适配ukui-lite
This commit is contained in:
parent
7d4779be04
commit
b34160ea5e
|
@ -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:[
|
transitions:[
|
||||||
Transition {
|
Transition {
|
||||||
to: "normal"
|
to: "normal"
|
||||||
|
enabled: !isLiteMode
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
ScriptAction {
|
ScriptAction {
|
||||||
script: {
|
script: { setPluginSelectionVisible(true); }
|
||||||
pluginSelectionBar.visible = true;
|
|
||||||
pluginSelectMenu.visible = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||||
ScriptAction { script: searchBar.visible = false }
|
ScriptAction { script: { setSearchBarVisible(false); } }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Transition {
|
Transition {
|
||||||
to: "search"
|
to: "search"
|
||||||
|
enabled: !isLiteMode
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
ScriptAction {
|
ScriptAction {
|
||||||
script: {
|
script: { setSearchBarVisible(true); }
|
||||||
searchBar.visible = true;
|
|
||||||
searchInputBar.providerId = "search";
|
|
||||||
searchInputBar.textInputFocus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300}
|
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||||
ScriptAction {
|
ScriptAction {
|
||||||
script: {
|
script: { setPluginSelectionVisible(false); }
|
||||||
pluginSelectionBar.visible = false;
|
|
||||||
pluginSelectMenu.visible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,14 @@ Item {
|
||||||
anchors.topMargin: 12
|
anchors.topMargin: 12
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
property bool liteMode: isLiteMode
|
||||||
|
onLiteModeChanged: {
|
||||||
|
updateSidebarLayout(extensionInfoList.currentItem.extensionOptions)
|
||||||
|
}
|
||||||
|
|
||||||
function updateSidebarLayout(options) {
|
function updateSidebarLayout(options) {
|
||||||
sidebarBottomBar.visible = !options.includes(MenuExtension.HideBottomBar);
|
sidebarBottomBar.visible = !options.includes(MenuExtension.HideBottomBar);
|
||||||
fullScreenbutton.visible = !options.includes(MenuExtension.HideFullScreenButton);
|
fullScreenbutton.visible = !isLiteMode && !options.includes(MenuExtension.HideFullScreenButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
|
|
||||||
#define UKUI_MENU_SCHEMA "org.ukui.menu.settings"
|
#define UKUI_MENU_SCHEMA "org.ukui.menu.settings"
|
||||||
#define CONTROL_CENTER_SETTING "org.ukui.control-center.personalise"
|
#define CONTROL_CENTER_SETTING "org.ukui.control-center.personalise"
|
||||||
|
@ -51,6 +53,7 @@ GlobalSetting::GlobalSetting(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
initStyleSetting();
|
initStyleSetting();
|
||||||
initGlobalSettings();
|
initGlobalSettings();
|
||||||
|
initUSDSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSetting::initStyleSetting()
|
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<QString> reply = dBusInterface.call(QStringLiteral("getUKUILiteAnimation"));
|
||||||
|
if (reply.isValid()) {
|
||||||
|
QMap<QString, QVariant> m;
|
||||||
|
m.insert("animation", reply.value());
|
||||||
|
onSysModeChanged(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusConnection::sessionBus().connect(service, path, interface, "UKUILiteChanged", this, SLOT(onSysModeChanged));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSetting::onSysModeChanged(QMap<QString, QVariant> map)
|
||||||
|
{
|
||||||
|
if (map.contains("animation")) {
|
||||||
|
m_cache.insert(IsLiteMode, (map.value("animation").toString() == "off"));
|
||||||
|
Q_EMIT styleChanged(IsLiteMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuSetting *MenuSetting::instance()
|
MenuSetting *MenuSetting::instance()
|
||||||
{
|
{
|
||||||
static MenuSetting setting(nullptr);
|
static MenuSetting setting(nullptr);
|
||||||
|
|
|
@ -55,7 +55,8 @@ public:
|
||||||
IconThemeName,
|
IconThemeName,
|
||||||
Transparency,
|
Transparency,
|
||||||
EffectEnabled,
|
EffectEnabled,
|
||||||
SystemFontSize
|
SystemFontSize,
|
||||||
|
IsLiteMode
|
||||||
};
|
};
|
||||||
Q_ENUM(Key)
|
Q_ENUM(Key)
|
||||||
|
|
||||||
|
@ -75,10 +76,14 @@ public:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void styleChanged(const GlobalSetting::Key& key);
|
void styleChanged(const GlobalSetting::Key& key);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onSysModeChanged(QMap<QString, QVariant> map);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GlobalSetting(QObject *parent = nullptr);
|
explicit GlobalSetting(QObject *parent = nullptr);
|
||||||
void initStyleSetting();
|
void initStyleSetting();
|
||||||
void initGlobalSettings();
|
void initGlobalSettings();
|
||||||
|
void initUSDSetting();
|
||||||
void updateData(const GlobalSetting::Key& key, const QVariant &value);
|
void updateData(const GlobalSetting::Key& key, const QVariant &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -407,12 +407,14 @@ void MenuWindow::init()
|
||||||
Q_EMIT panelPosChanged();
|
Q_EMIT panelPosChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(GlobalSetting::IsLiteMode));
|
||||||
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this , [this] (const GlobalSetting::Key& key) {
|
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this , [this] (const GlobalSetting::Key& key) {
|
||||||
if (key == GlobalSetting::EffectEnabled) {
|
if (key == GlobalSetting::EffectEnabled) {
|
||||||
Q_EMIT effectEnabledChanged();
|
Q_EMIT effectEnabledChanged();
|
||||||
}
|
} else if (key == GlobalSetting::Transparency) {
|
||||||
if (key == GlobalSetting::Transparency) {
|
|
||||||
Q_EMIT transparencyChanged();
|
Q_EMIT transparencyChanged();
|
||||||
|
} else if (key == GlobalSetting::IsLiteMode) {
|
||||||
|
rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(key));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue