80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2023 Unisoc (Shanghai) Technologies Co., Ltd.
|
|
*
|
|
* SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0
|
|
*/
|
|
|
|
#include "appmanager.h"
|
|
#include <QSettings>
|
|
#include <QDebug>
|
|
|
|
static QString inisettings = "/etc/qtapps/qt_app.ini";
|
|
|
|
appManager::appManager(MainWindow* w):
|
|
m_main(w){
|
|
m_applist.clear();
|
|
InitAppList();
|
|
}
|
|
|
|
void appManager::InitAppList(){
|
|
//Read Others from INI files
|
|
QSettings* settings = new QSettings(inisettings, QSettings::IniFormat);
|
|
const QStringList groups = settings->childGroups();
|
|
qDebug() <<"groups:"<<groups.count();
|
|
|
|
foreach (const QString &group, groups) {
|
|
settings->beginGroup(group);
|
|
|
|
qDebug()<<"Info:" <<settings->value("name").toString()
|
|
<<"--"<<settings->value("url").toString();
|
|
qDebug()<<"Info:" <<settings->value("icon").toString()
|
|
<<"--"<<settings->value("arg").toString();
|
|
AppInfo app(settings->value("name").toString(),
|
|
settings->value("icon").toString(),
|
|
settings->value("url").toString(),
|
|
settings->value("arg").toString());
|
|
|
|
m_applist.append(app);
|
|
settings->endGroup();
|
|
}
|
|
delete settings;
|
|
}
|
|
|
|
int appManager::GetAppCount(){
|
|
return m_applist.count();
|
|
}
|
|
|
|
void appManager::RunApp(int index){
|
|
if(index>=m_applist.count()){
|
|
return;
|
|
}
|
|
m_applist[index].RunApp();
|
|
}
|
|
|
|
QString appManager::GetAppName(int index){
|
|
if(index>=m_applist.count()){
|
|
return "NULL";
|
|
}
|
|
return m_applist[index].GetName();
|
|
}
|
|
|
|
QString appManager::GetAppIcon(int index){
|
|
if(index>=m_applist.count()){
|
|
return "NULL";
|
|
}
|
|
return m_applist[index].GetIcon();
|
|
}
|
|
|
|
void appManager::KillOne(int index){
|
|
if(index>=m_applist.count()){
|
|
return;
|
|
}
|
|
m_applist[index].KillApp();
|
|
}
|
|
|
|
void appManager::KillAll(void){
|
|
for(int i=0;i<m_applist.count();i++){
|
|
m_applist[i].KillApp();
|
|
}
|
|
}
|