diff --git a/session/processmanager.cpp b/session/processmanager.cpp index 91cee04..d3c759a 100644 --- a/session/processmanager.cpp +++ b/session/processmanager.cpp @@ -104,9 +104,9 @@ void ProcessManager::startDesktopProcess() QList> list; // Desktop components - list << qMakePair(QString("cutefish-filemanager"), QStringList("--desktop")); list << qMakePair(QString("cutefish-statusbar"), QStringList()); list << qMakePair(QString("cutefish-dock"), QStringList()); + list << qMakePair(QString("cutefish-filemanager"), QStringList("--desktop")); list << qMakePair(QString("cutefish-launcher"), QStringList()); for (QPair pair : list) { diff --git a/settings-daemon/CMakeLists.txt b/settings-daemon/CMakeLists.txt index 49eb59d..3a96f01 100644 --- a/settings-daemon/CMakeLists.txt +++ b/settings-daemon/CMakeLists.txt @@ -17,6 +17,8 @@ file (GLOB_RECURSE SRCS "battery/*.h" "language/*.cpp" "language/*.h" + "dock/*.cpp" + "dock/*.h" ) set(SOURCES ${SRCS}) @@ -39,7 +41,9 @@ qt5_add_dbus_adaptor(DBUS_SOURCES qt5_add_dbus_adaptor(DBUS_SOURCES language/org.cutefish.Language.xml language/language.h Language) - +qt5_add_dbus_adaptor(DBUS_SOURCES + dock/org.cutefish.Dock.xml + dock/dock.h Dock) set_source_files_properties(${DBUS_SOURCES} PROPERTIES SKIP_AUTOGEN ON) add_executable(${TARGET} ${SOURCES} ${DBUS_SOURCES} ${HEADERS} ${FORMS} ${RESOURCES}) diff --git a/settings-daemon/dock/dock.cpp b/settings-daemon/dock/dock.cpp new file mode 100644 index 0000000..2492745 --- /dev/null +++ b/settings-daemon/dock/dock.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: rekols + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "dock.h" +#include "dockadaptor.h" + +#include +#include +#include + +#include +#include + +Dock::Dock(QObject *parent) + : QObject(parent) + , m_iconSize(0) + , m_edgeMargins(10) + , m_roundedWindowEnabled(true) + , m_direction(Left) + , m_visibility(AlwaysVisible) + , m_settings(new QSettings(QSettings::UserScope, "cutefishos", "dock")) +{ + new DockAdaptor(this); + QDBusConnection::sessionBus().registerObject(QStringLiteral("/Dock"), this); + + if (!m_settings->contains("IconSize")) + m_settings->setValue("IconSize", 64); + if (!m_settings->contains("Direction")) + m_settings->setValue("Direction", Bottom); + if (!m_settings->contains("Visibility")) + m_settings->setValue("Visibility", AlwaysVisible); + if (!m_settings->contains("RoundedWindow")) + m_settings->setValue("RoundedWindow", true); + + m_settings->sync(); + + m_iconSize = m_settings->value("IconSize").toInt(); + m_direction = static_cast(m_settings->value("Direction").toInt()); + m_roundedWindowEnabled = m_settings->value("RoundedWindow").toBool(); +} + +int Dock::iconSize() const +{ + return m_iconSize; +} + +void Dock::setIconSize(int iconSize) +{ + if (m_iconSize != iconSize) { + m_iconSize = iconSize; + m_settings->setValue("IconSize", iconSize); + emit iconSizeChanged(); + } +} + +Dock::Direction Dock::direction() const +{ + return m_direction; +} + +void Dock::setDirection(int value) +{ + if (m_direction != value) { + m_direction = static_cast(value); + m_settings->setValue("Direction", value); + emit directionChanged(); + } +} + +Dock::Visibility Dock::visibility() const +{ + return m_visibility; +} + +void Dock::setVisibility(int value) +{ + if (m_visibility != value) { + m_visibility = static_cast(value); + m_settings->setValue("Visibility", value); + emit visibilityChanged(); + } +} + +int Dock::edgeMargins() const +{ + return m_edgeMargins; +} + +void Dock::setEdgeMargins(int edgeMargins) +{ + m_edgeMargins = edgeMargins; +} + +bool Dock::roundedWindowEnabled() const +{ + return m_roundedWindowEnabled; +} + +void Dock::setRoundedWindowEnabled(bool enabled) +{ + if (m_roundedWindowEnabled != enabled) { + m_roundedWindowEnabled = enabled; + emit roundedWindowEnabledChanged(); + } +} diff --git a/settings-daemon/dock/dock.h b/settings-daemon/dock/dock.h new file mode 100644 index 0000000..fdbd362 --- /dev/null +++ b/settings-daemon/dock/dock.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: rekols + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DOCK_H +#define DOCK_H + +#include +#include + +class Dock : public QObject +{ + Q_OBJECT + Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged) + Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) + Q_PROPERTY(int edgeMargins READ edgeMargins WRITE setEdgeMargins) + Q_PROPERTY(bool roundedWindowEnabled READ roundedWindowEnabled WRITE setRoundedWindowEnabled NOTIFY roundedWindowEnabledChanged) + +public: + enum Direction { + Left = 0, + Bottom, + Right + }; + Q_ENUMS(Direction) + + enum Visibility { + AlwaysVisible = 0, + AutoHide, + AlwaysHide + }; + Q_ENUMS(Visibility) + + explicit Dock(QObject *parent = nullptr); + + int iconSize() const; + void setIconSize(int iconSize); + + Direction direction() const; + void setDirection(int value); + + Visibility visibility() const; + void setVisibility(int value); + + int edgeMargins() const; + void setEdgeMargins(int edgeMargins); + + bool roundedWindowEnabled() const; + void setRoundedWindowEnabled(bool enabled); + +signals: + void iconSizeChanged(); + void directionChanged(); + void visibilityChanged(); + void roundedWindowEnabledChanged(); + +private: + int m_iconSize; + int m_edgeMargins; + bool m_roundedWindowEnabled; + Direction m_direction; + Visibility m_visibility; + QSettings *m_settings; +}; + +#endif // DOCK_H diff --git a/settings-daemon/dock/org.cutefish.Dock.xml b/settings-daemon/dock/org.cutefish.Dock.xml new file mode 100644 index 0000000..70823e6 --- /dev/null +++ b/settings-daemon/dock/org.cutefish.Dock.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +