feat: 适配ukui-lite
This commit is contained in:
parent
7d4779be04
commit
b34160ea5e
|
@ -70,36 +70,53 @@ Item {
|
|||
}
|
||||
]
|
||||
|
||||
transitions:[
|
||||
Transition {
|
||||
to: "normal"
|
||||
SequentialAnimation {
|
||||
ScriptAction {
|
||||
script: {
|
||||
pluginSelectionBar.visible = true;
|
||||
pluginSelectMenu.visible = true;
|
||||
onStateChanged: {
|
||||
if (isLiteMode) {
|
||||
if (state === "search") {
|
||||
setPluginSelectionVisible(false);
|
||||
setSearchBarVisible(true);
|
||||
} else {
|
||||
setPluginSelectionVisible(true);
|
||||
setSearchBarVisible(false);
|
||||
}
|
||||
}
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||
ScriptAction { script: searchBar.visible = false }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "search"
|
||||
SequentialAnimation {
|
||||
ScriptAction {
|
||||
script: {
|
||||
searchBar.visible = true;
|
||||
|
||||
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: { setPluginSelectionVisible(true); }
|
||||
}
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||
ScriptAction { script: { setSearchBarVisible(false); } }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "search"
|
||||
enabled: !isLiteMode
|
||||
SequentialAnimation {
|
||||
ScriptAction {
|
||||
script: { setSearchBarVisible(true); }
|
||||
}
|
||||
NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
|
||||
ScriptAction {
|
||||
script: {
|
||||
pluginSelectionBar.visible = false;
|
||||
pluginSelectMenu.visible = false;
|
||||
}
|
||||
script: { setPluginSelectionVisible(false); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include <QtQml>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
|
||||
#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<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()
|
||||
{
|
||||
static MenuSetting setting(nullptr);
|
||||
|
|
|
@ -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<QString, QVariant> map);
|
||||
|
||||
private:
|
||||
explicit GlobalSetting(QObject *parent = nullptr);
|
||||
void initStyleSetting();
|
||||
void initGlobalSettings();
|
||||
void initUSDSetting();
|
||||
void updateData(const GlobalSetting::Key& key, const QVariant &value);
|
||||
|
||||
private:
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue