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 "applauncherwidget.h"
18 #include "ui_applauncherwidget.h"
19 #include <include/daynightmode.hpp>
25 #define APP_LIST_COLUMN_COUNT 5
27 AppLauncherWidget::AppLauncherWidget(QWidget *parent) :
29 mp_ui(new Ui::AppLauncherWidget),
32 mp_dBusAppFrameworkProxy()
37 for (int i = 0; i < 100; ++i)
39 ai.setName("test" + QString::number(i));
40 mp_appList->append(ai);
43 qDebug("D-Bus: connect to org.agl.homescreenappframeworkbinder /AppFramework");
44 mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbinder",
46 QDBusConnection::sessionBus(),
50 AppLauncherWidget::~AppLauncherWidget()
52 delete mp_dBusAppFrameworkProxy;
60 void AppLauncherWidget::updateColorScheme()
63 QSettings settings_cs(QApplication::applicationDirPath() +
65 settings.value("systemsettings/colorscheme", "default").toString() +
67 QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
69 QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
71 QSettings::IniFormat);
73 mp_ui->widget_background->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Background").toString());
74 mp_ui->widget_homeIcon->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Home_Icon").toString());
76 setStyleSheet(settings_cs.value("AppLauncherWidget/common_css").toString());
79 void AppLauncherWidget::populateAppList()
83 mp_appTable = new QTableWidget(this);
84 QObject::connect(mp_appTable, SIGNAL(cellClicked(int,int)), this, SLOT(on_tableView_clicked(int,int)));
91 mp_appTable->setShowGrid(false);
92 mp_appTable->setFrameShape(QFrame::NoFrame);
93 mp_appTable->move(40, 40);
94 mp_appTable->resize(1000, 1920 - 40 - 40 - 60 - 60);
95 mp_appTable->horizontalHeader()->setVisible(false);
96 mp_appTable->verticalHeader()->setVisible(false);
97 mp_appTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
98 mp_appTable->setRowCount(100);
99 mp_appTable->setColumnCount(APP_LIST_COLUMN_COUNT);
103 m_appList = mp_dBusAppFrameworkProxy->getAvailableApps();
105 mp_appTable->setRowCount((m_appList.size() + (APP_LIST_COLUMN_COUNT - 1)) / APP_LIST_COLUMN_COUNT);
107 if (m_appList.size() >= (9 * APP_LIST_COLUMN_COUNT))
109 mp_appTable->resize(1000, 1920 - 40 - 40 - 60 - 60);
113 mp_appTable->resize(1000, mp_appTable->rowCount() * 190);
117 /*for (i = 0; i < (mp_appTable->rowCount() * APP_LIST_COLUMN_COUNT); i++)
119 mp_appTable->verticalHeader()->resizeSection(i, 190);
120 mp_appTable->horizontalHeader()->resizeSection(i, 190);
123 for (i = 0; i < m_appList.size(); i++)
125 mp_appTable->setItem(i / APP_LIST_COLUMN_COUNT,
126 i % APP_LIST_COLUMN_COUNT,
127 new QTableWidgetItem(m_appList.at(i).name()));
128 mp_appTable->item(i / APP_LIST_COLUMN_COUNT,
129 i % APP_LIST_COLUMN_COUNT)->setFlags(Qt::ItemIsEnabled);
130 mp_appTable->item(i / APP_LIST_COLUMN_COUNT,
131 i % APP_LIST_COLUMN_COUNT)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
135 void AppLauncherWidget::on_tableView_clicked(int row, int col)
137 if (m_appList.size() > row * APP_LIST_COLUMN_COUNT + col)
139 int pid = mp_dBusAppFrameworkProxy->launchApp(m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id());
140 qDebug("%d, %d: start app %s", row, col, m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id().toStdString().c_str());
141 qDebug("pid: %d", pid);
143 // the new app wants to be visible by default
144 newRequestsToBeVisibleApp(pid);