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 <include/daynightmode.hpp>
21 MainWindow::MainWindow(QWidget *parent) :
23 mp_ui(new Ui::MainWindow),
24 mp_statusBarWidget(0),
25 mp_controlBarWidget(0),
27 mp_applauncherwidget(0),
29 mp_dBusDayNightModeProxy(0),
30 mp_homeScreenControlInterface(0)
32 // this has to be adopted to the system setup
33 mp_dBusDayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
35 QDBusConnection::sessionBus(),
37 QObject::connect(mp_dBusDayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
40 QDBusConnection dbus = QDBusConnection::sessionBus();
42 dbus.registerObject("/MainWindow", this);
43 dbus.registerService("org.agl.homescreen");
45 // no window decoration
46 setWindowFlags(Qt::FramelessWindowHint);
50 mp_statusBarWidget = new StatusBarWidget(this);
51 mp_statusBarWidget->raise();
53 mp_statusBarWidget->move(0, 0);
55 mp_controlBarWidget = new ControlBarWidget(this);
56 mp_controlBarWidget->raise();
58 mp_controlBarWidget->move(0, 1920-60);
60 mp_settingsWidget = new SettingsWidget(this);
61 mp_settingsWidget->raise();
63 mp_settingsWidget->move(0, 60);
64 //mp_settingsWidget->hide();
66 mp_applauncherwidget = new AppLauncherWidget(this);
67 mp_applauncherwidget->raise();
69 mp_applauncherwidget->move(0, 60);
71 mp_popupWidget = new PopupWidget();
72 mp_controlBarWidget->raise();
74 mp_popupWidget->move(0, 0);
77 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), this, SLOT(updateColorScheme()));
78 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_statusBarWidget, SLOT(updateColorScheme()));
79 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_controlBarWidget, SLOT(updateColorScheme()));
80 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_settingsWidget, SLOT(updateColorScheme()));
81 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_popupWidget, SLOT(updateColorScheme()));
83 QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(raise()));
84 QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_applauncherwidget, SLOT(raise()));
88 mp_statusBarWidget->updateColorScheme();
89 mp_controlBarWidget->updateColorScheme();
90 mp_settingsWidget->updateColorScheme();
91 mp_applauncherwidget->updateColorScheme();
92 mp_popupWidget->updateColorScheme();
94 // this is only useful during development and will be removed later
95 setWindowIcon(QIcon(":/icons/home_day.png"));
97 mp_homeScreenControlInterface = new HomeScreenControlInterface(this);
100 MainWindow::~MainWindow()
102 delete mp_homeScreenControlInterface;
104 delete mp_dBusDayNightModeProxy;
105 delete mp_popupWidget;
106 delete mp_applauncherwidget;
107 delete mp_settingsWidget;
108 delete mp_controlBarWidget;
109 delete mp_statusBarWidget;
113 void MainWindow::dayNightModeSlot(int mode)
116 settings.setValue("systemsettings/daynightmode", mode);
117 // make sure that everything is written to the settings file before continuing
122 mp_statusBarWidget->updateColorScheme();
123 mp_controlBarWidget->updateColorScheme();
124 mp_settingsWidget->updateColorScheme();
125 mp_applauncherwidget->updateColorScheme();
126 mp_popupWidget->updateColorScheme();
129 void MainWindow::updateColorScheme()
132 QSettings settings_cs(QApplication::applicationDirPath() +
134 settings.value("systemsettings/colorscheme", "default").toString() +
136 QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
138 QSettings::IniFormat);
140 mp_ui->widget_Background->setStyleSheet(settings_cs.value("MainWindow/widget_Background").toString());
141 mp_ui->widget_Home_Icon->setStyleSheet(settings_cs.value("MainWindow/widget_Home_Icon").toString());
144 void MainWindow::changeEvent(QEvent* event)
146 if (QEvent::LanguageChange == event->type())
148 mp_ui->retranslateUi(this);
151 QMainWindow::changeEvent(event);
154 void MainWindow::on_pushButton_clicked()
158 QString file = "vlc";
159 process.startDetached(file);