mirror of https://github.com/cutefishos/core
Fix the desktop margin
parent
584f659d66
commit
4175dec9b9
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: rekols <revenmartin@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dock.h"
|
||||
#include "dockadaptor.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QDBusInterface>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
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<Direction>(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<Direction>(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<Visibility>(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();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: rekols <revenmartin@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DOCK_H
|
||||
#define DOCK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
|
||||
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
|
||||
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.cutefish.Dock">
|
||||
<property name="iconSize" type="i" access="read"/>
|
||||
<method name="setIconSize">
|
||||
<arg name="value" type="i" direction="in"/>
|
||||
</method>
|
||||
<property name="direction" type="i" access="read"/>
|
||||
<method name="setDirection">
|
||||
<arg name="value" type="i" direction="in"/>
|
||||
</method>
|
||||
<signal name="iconSizeChanged"></signal>
|
||||
<signal name="directionChanged"></signal>
|
||||
</interface>
|
||||
</node>
|
||||
Loading…
Reference in New Issue