|
|
|
@ -35,6 +35,17 @@ UkuiMenuInterface::UkuiMenuInterface()
|
|
|
|
|
QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini";
|
|
|
|
|
syssetting = new QSettings(syspath, QSettings::IniFormat);
|
|
|
|
|
}
|
|
|
|
|
m_categoriesVector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公
|
|
|
|
|
m_categoriesVector.append(QStringList() << "develop" << "Development"); //1开发
|
|
|
|
|
m_categoriesVector.append(QStringList() << "graphic" << "Graphics"); //2图像
|
|
|
|
|
m_categoriesVector.append(QStringList() << "video" << "Audio" << "Video"); //3影音
|
|
|
|
|
m_categoriesVector.append(QStringList() << "network" << "Network"); //4网络
|
|
|
|
|
m_categoriesVector.append(QStringList() << "game" << "Game"); //5游戏
|
|
|
|
|
m_categoriesVector.append(QStringList() << "education" << "Education"); //6教育
|
|
|
|
|
m_categoriesVector.append(QStringList() << "social" << "Messaging"); //7社交
|
|
|
|
|
m_categoriesVector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统
|
|
|
|
|
m_categoriesVector.append(QStringList() << "safe"); //9安全
|
|
|
|
|
m_categoriesVector.append(QStringList() << "others"); //10其他
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<QStringList> UkuiMenuInterface::appInfoVector = QVector<QStringList>();
|
|
|
|
@ -130,6 +141,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath)
|
|
|
|
|
keyfile = g_key_file_new();
|
|
|
|
|
|
|
|
|
|
if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) {
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,7 +149,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath)
|
|
|
|
|
|
|
|
|
|
if (ret_1 != nullptr) {
|
|
|
|
|
QString str = QString::fromLocal8Bit(ret_1);
|
|
|
|
|
|
|
|
|
|
g_free(ret_1);
|
|
|
|
|
if (str.contains("true")) {
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
i++;
|
|
|
|
@ -149,7 +161,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath)
|
|
|
|
|
|
|
|
|
|
if (ret_2 != nullptr) {
|
|
|
|
|
QString str = QString::fromLocal8Bit(ret_2);
|
|
|
|
|
|
|
|
|
|
g_free(ret_2);
|
|
|
|
|
if (str.contains("UKUI")) {
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
i++;
|
|
|
|
@ -162,7 +174,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath)
|
|
|
|
|
|
|
|
|
|
if (ret != nullptr) {
|
|
|
|
|
QString str = QString::fromLocal8Bit(ret);
|
|
|
|
|
|
|
|
|
|
g_free(ret);
|
|
|
|
|
if (str.contains("LXQt") || str.contains("KDE")) {
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
i++;
|
|
|
|
@ -540,18 +552,7 @@ QVector<QStringList> UkuiMenuInterface::createAppInfoVector()
|
|
|
|
|
{
|
|
|
|
|
desktopfpVector.clear();
|
|
|
|
|
QVector<QStringList> appInfoVector;
|
|
|
|
|
QVector<QStringList> vector;
|
|
|
|
|
vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公
|
|
|
|
|
vector.append(QStringList() << "develop" << "Development"); //1开发
|
|
|
|
|
vector.append(QStringList() << "graphic" << "Graphics"); //2图像
|
|
|
|
|
vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音
|
|
|
|
|
vector.append(QStringList() << "network" << "Network"); //4网络
|
|
|
|
|
vector.append(QStringList() << "game" << "Game"); //5游戏
|
|
|
|
|
vector.append(QStringList() << "education" << "Education"); //6教育
|
|
|
|
|
vector.append(QStringList() << "social" << "Messaging"); //7社交
|
|
|
|
|
vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统
|
|
|
|
|
vector.append(QStringList() << "safe"); //9安全
|
|
|
|
|
vector.append(QStringList() << "others"); //10其他
|
|
|
|
|
|
|
|
|
|
QStringList desktopfpList = getDesktopFilePath();
|
|
|
|
|
QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase");
|
|
|
|
|
QSqlQuery sql(db);
|
|
|
|
@ -575,8 +576,8 @@ QVector<QStringList> UkuiMenuInterface::createAppInfoVector()
|
|
|
|
|
sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName));
|
|
|
|
|
|
|
|
|
|
if (sql.next()) {
|
|
|
|
|
for (int j = 0; j < vector.size(); j++) {
|
|
|
|
|
if (vector.at(j).contains(sql.value(0).toString())) {
|
|
|
|
|
for (int j = 0; j < m_categoriesVector.size(); j++) {
|
|
|
|
|
if (m_categoriesVector.at(j).contains(sql.value(0).toString())) {
|
|
|
|
|
appInfoList.append(QString::number(j));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -588,8 +589,8 @@ QVector<QStringList> UkuiMenuInterface::createAppInfoVector()
|
|
|
|
|
|
|
|
|
|
bool is_owned = false;
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < vector.size(); j++) {
|
|
|
|
|
if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类
|
|
|
|
|
for (int j = 0; j < m_categoriesVector.size(); j++) {
|
|
|
|
|
if (matchingAppCategories(desktopfpList.at(i), m_categoriesVector.at(j))) { //有对应分类
|
|
|
|
|
is_owned = true;
|
|
|
|
|
appInfoList.append(QString::number(j));
|
|
|
|
|
}
|
|
|
|
@ -630,6 +631,7 @@ QString UkuiMenuInterface::getAppName(QString desktopfp)
|
|
|
|
|
char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr);
|
|
|
|
|
QString namestr = QString::fromLocal8Bit(name);
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
g_free(name);
|
|
|
|
|
return namestr;
|
|
|
|
|
}
|
|
|
|
|
//获取英应用英文名
|
|
|
|
@ -643,6 +645,8 @@ QString UkuiMenuInterface::getAppEnglishName(QString desktopfp)
|
|
|
|
|
g_key_file_load_from_file(keyfile, filepath, flags, error);
|
|
|
|
|
char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr);
|
|
|
|
|
QString namestr = QString::fromLocal8Bit(name);
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
g_free(name);
|
|
|
|
|
return namestr;
|
|
|
|
|
}
|
|
|
|
|
//获取应用分类
|
|
|
|
@ -656,7 +660,9 @@ QString UkuiMenuInterface::getAppCategories(QString desktopfp)
|
|
|
|
|
g_key_file_load_from_file(keyfile, filepath, flags, error);
|
|
|
|
|
char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr);
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
return QString::fromLocal8Bit(category);
|
|
|
|
|
QString categorystr = QString::fromLocal8Bit(category);
|
|
|
|
|
g_free(category);
|
|
|
|
|
return categorystr;
|
|
|
|
|
}
|
|
|
|
|
//获取应用图标
|
|
|
|
|
QString UkuiMenuInterface::getAppIcon(QString desktopfp)
|
|
|
|
@ -669,7 +675,9 @@ QString UkuiMenuInterface::getAppIcon(QString desktopfp)
|
|
|
|
|
g_key_file_load_from_file(keyfile, filepath, flags, error);
|
|
|
|
|
char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr);
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
return QString::fromLocal8Bit(icon);
|
|
|
|
|
QString iconstr = QString::fromLocal8Bit(icon);
|
|
|
|
|
g_free(icon);
|
|
|
|
|
return iconstr;
|
|
|
|
|
}
|
|
|
|
|
//获取应用命令
|
|
|
|
|
QString UkuiMenuInterface::getAppExec(QString desktopfp)
|
|
|
|
@ -682,7 +690,9 @@ QString UkuiMenuInterface::getAppExec(QString desktopfp)
|
|
|
|
|
g_key_file_load_from_file(keyfile, filepath, flags, error);
|
|
|
|
|
char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr);
|
|
|
|
|
g_key_file_free(keyfile);
|
|
|
|
|
return QString::fromLocal8Bit(exec);
|
|
|
|
|
QString execstr = QString::fromLocal8Bit(exec);
|
|
|
|
|
g_free(exec);
|
|
|
|
|
return execstr;
|
|
|
|
|
}
|
|
|
|
|
//获取应用注释
|
|
|
|
|
QString UkuiMenuInterface::getAppComment(QString desktopfp)
|
|
|
|
@ -1562,6 +1572,7 @@ void UkuiMenuInterface::getAndroidApp()
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
g_free(ret_1);
|
|
|
|
|
m_filePathList.append(filePathStr);
|
|
|
|
|
androidDesktopfnList.append(fileInfo.fileName());
|
|
|
|
|
// }
|
|
|
|
|