60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2023 Unisoc (Shanghai) Technologies Co., Ltd.
|
|
*
|
|
* SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0
|
|
*/
|
|
|
|
#include "appinfo.h"
|
|
#include <QDebug>
|
|
|
|
AppInfo::AppInfo(QString name,QString icon,QString url,QString arg)
|
|
:m_appName(name)
|
|
,m_appIcon(icon)
|
|
,m_appUrl(url)
|
|
{
|
|
m_appProcess = new QProcess();
|
|
if(m_appIcon.isEmpty()){
|
|
m_appIcon =":/appicon/defaultappicon";
|
|
}
|
|
if(!arg.isEmpty()){
|
|
m_appArgs.append(arg);
|
|
}
|
|
}
|
|
|
|
QString AppInfo::GetName(){
|
|
qDebug()<<"app Name:"<<m_appName;
|
|
return m_appName;
|
|
}
|
|
|
|
QString AppInfo::GetIcon(){
|
|
return m_appIcon;
|
|
}
|
|
|
|
|
|
void AppInfo::RunApp(){
|
|
qDebug()<<"Run app"<<m_appUrl;
|
|
|
|
if(m_appProcess->state() != QProcess::Running){
|
|
qDebug()<<"start"<<m_appName;
|
|
m_appProcess->start(m_appUrl, QIODevice::ReadWrite);
|
|
} else {
|
|
qDebug()<<"activateWindow"<<m_appName;
|
|
if(m_appProcess->isOpen()){
|
|
m_appProcess->write("activateWindow\n");
|
|
} else {
|
|
qDebug()<<m_appName<<"is not Open";
|
|
}
|
|
}
|
|
//qDebug()<<m_appProcess->errorString();
|
|
}
|
|
|
|
void AppInfo::KillApp(){
|
|
//m_appProcess->kill();
|
|
qDebug()<<"kill app"<<m_appName;
|
|
if(m_appProcess->state() == QProcess::NotRunning){
|
|
qDebug()<<m_appName<<"app state is NotRunning";
|
|
return;
|
|
}
|
|
m_appProcess->close();
|
|
}
|