Remove DBus interface for StatusBar
[apps/homescreen.git] / homescreen / src / statusbarserver.cpp
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include "statusbarserver.h"
19
20 class StatusBarServer::Private
21 {
22 public:
23     Private(StatusBarServer *parent);
24     QString texts[SupportedCount];
25     QString icons[SupportedCount];
26 };
27
28 StatusBarServer::Private::Private(StatusBarServer *parent)
29 {
30     icons[0] = QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_NoBars-01.png");
31     icons[1] = QStringLiteral("qrc:/images/Status/HMI_Status_Bluetooth_Inactive-01.png");
32     icons[2] = QStringLiteral("qrc:/images/Status/HMI_Status_Signal_NoBars-01.png");
33 }
34
35 StatusBarServer::StatusBarServer(QObject *parent)
36     : QObject(parent)
37     , d(new Private(this))
38 {
39 }
40
41 StatusBarServer::~StatusBarServer()
42 {
43     delete d;
44 }
45
46 QList<int> StatusBarServer::getAvailablePlaceholders() const
47 {
48     QList<int> ret;
49     for (int i = 0; i < SupportedCount; ++i) {
50         ret.append(i);
51     }
52     return ret;
53 }
54
55 QString StatusBarServer::getStatusIcon(int placeholderIndex) const
56 {
57     QString ret;
58     if (-1 < placeholderIndex && placeholderIndex < SupportedCount)
59         ret = d->icons[placeholderIndex];
60     return ret;
61 }
62
63 void StatusBarServer::setStatusIcon(int placeholderIndex, const QString &icon)
64 {
65     if (-1 < placeholderIndex && placeholderIndex < SupportedCount) {
66         if (d->icons[placeholderIndex] == icon) return;
67         d->icons[placeholderIndex] = icon;
68         emit statusIconChanged(placeholderIndex, icon);
69     }
70 }
71
72 QString StatusBarServer::getStatusText(int placeholderIndex) const
73 {
74     QString ret;
75     if (-1 < placeholderIndex && placeholderIndex < SupportedCount) {
76         ret = d->texts[placeholderIndex];
77     }
78     return ret;
79 }
80
81 void StatusBarServer::setStatusText(int placeholderIndex, const QString &text)
82 {
83     if (-1 < placeholderIndex && placeholderIndex < SupportedCount) {
84         if (d->texts[placeholderIndex] == text) return;
85         d->texts[placeholderIndex] = text;
86         emit statusTextChanged(placeholderIndex, text);
87     }
88 }