File: dock.cpp

package info (click to toggle)
cutefish-core 0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,076 kB
  • sloc: cpp: 11,327; xml: 443; sh: 29; makefile: 6
file content (121 lines) | stat: -rw-r--r-- 3,136 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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();
    }
}