2 * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "mainwindow.h"
18 #include "ui_mainwindow.h"
19 #include "../interfaces/daynightmode.h"
21 MainWindow::MainWindow(QWidget *parent) :
23 mp_ui(new Ui::MainWindow),
24 mp_statusBarWidget(0),
25 mp_controlBarWidget(0),
28 mp_dayNightModeProxy(0)
30 // this has to be adopted to the system setup
31 mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
33 QDBusConnection::sessionBus(),
35 QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
38 QDBusConnection dbus = QDBusConnection::sessionBus();
40 dbus.registerObject("/MainWindow", this);
41 dbus.registerService("org.agl.homescreen");
43 // no window decoration
44 setWindowFlags(Qt::FramelessWindowHint);
47 mp_statusBarWidget = new StatusBarWidget(this);
48 mp_statusBarWidget->raise();
50 mp_statusBarWidget->move(0, 0);
52 mp_controlBarWidget = new ControlBarWidget(this);
53 mp_controlBarWidget->raise();
55 mp_controlBarWidget->move(0, 1920-60);
57 mp_settingsWidget = new SettingsWidget(this);
58 mp_settingsWidget->raise();
60 mp_settingsWidget->move(0, 60);
61 mp_settingsWidget->hide();
63 mp_popupWidget = new PopupWidget(this);
64 mp_controlBarWidget->raise();
66 mp_popupWidget->move(0, 0);
68 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), this, SLOT(updateColorScheme()));
69 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_statusBarWidget, SLOT(updateColorScheme()));
70 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_controlBarWidget, SLOT(updateColorScheme()));
71 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_settingsWidget, SLOT(updateColorScheme()));
72 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_popupWidget, SLOT(updateColorScheme()));
74 QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(show()));
75 QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_settingsWidget, SLOT(hide()));
79 mp_statusBarWidget->updateColorScheme();
80 mp_controlBarWidget->updateColorScheme();
81 mp_settingsWidget->updateColorScheme();
82 mp_popupWidget->updateColorScheme();
84 setWindowIcon(QIcon(":/icons/home_day.png"));
87 MainWindow::~MainWindow()
89 delete mp_dayNightModeProxy;
90 delete mp_popupWidget;
91 delete mp_settingsWidget;
92 delete mp_controlBarWidget;
93 delete mp_statusBarWidget;
97 void MainWindow::dayNightModeSlot(int mode)
100 settings.setValue("systemsettings/daynightmode", mode);
101 // make sure that everything is written to the settings file before continuing
106 mp_statusBarWidget->updateColorScheme();
107 mp_controlBarWidget->updateColorScheme();
108 mp_settingsWidget->updateColorScheme();
109 mp_popupWidget->updateColorScheme();
112 void MainWindow::updateColorScheme()
115 QSettings settings_cs(QApplication::applicationDirPath() +
117 settings.value("systemsettings/colorscheme", "default").toString() +
119 QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
121 QSettings::IniFormat);
123 mp_ui->widget_Background->setStyleSheet(settings_cs.value("MainWindow/widget_Background").toString());
124 mp_ui->widget_Home_Icon->setStyleSheet(settings_cs.value("MainWindow/widget_Home_Icon").toString());
127 void MainWindow::changeEvent(QEvent* event)
129 if (QEvent::LanguageChange == event->type())
131 mp_ui->retranslateUi(this);
134 QMainWindow::changeEvent(event);