feat: 玲珑包后缀提供配置功能实现

玲珑包后缀提供配置功能的实现

Log:
Influence: 默认隐藏后缀,开启,玲珑应用则显示,否则,隐藏.
Task: https://pms.uniontech.com/task-view-152805.html
Change-Id: I72e390a8e25396454c451cde28a795e923b28144
This commit is contained in:
songwentao 2022-07-13 10:45:22 +08:00
parent 7667dbc05a
commit 20a2642e74
9 changed files with 57 additions and 8 deletions

View File

@ -241,6 +241,16 @@
"description": "Launcher display mode.",
"permissions": "readwrite",
"visibility": "private"
},
"MagicaVoxelApp_Hide_SuffixName": {
"value": false,
"serial": 0,
"flags": [],
"name": "MagicaVoxelApp_Hide_SuffixName",
"name[zh_CN]": "玲珑包后缀提供配置,默认隐藏; 开启, 玲珑应用显示后缀, 关闭, 后缀隐藏",
"description": "***",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -37,6 +37,7 @@ const QString keyAppsUseProxy = "Apps_Use_Proxy";
const QString keyAppsDisableScaling = "Apps_Disable_Scaling";
const QString keyAppsHidden = "Apps_Hidden";
const QString keyPackageNameSearch = "Search_Package_Name";
const QString keySuffixHidden = "MagicaVoxelApp_Hide_SuffixName";
// 应用配置
const QString lastoreDataDir = "/var/lib/lastore";

View File

@ -34,6 +34,7 @@ DBusAdaptorLauncher::DBusAdaptorLauncher(QObject *parent)
connect(launcher, &Launcher::uninstallSuccess, this, &DBusAdaptorLauncher::UninstallSuccess);
connect(launcher, &Launcher::displayModeChanged, this, &DBusAdaptorLauncher::DisplayModeChanged);
connect(launcher, &Launcher::fullScreenChanged, this, &DBusAdaptorLauncher::FullScreenChanged);
connect(launcher, &Launcher::appSuffixChanged, this, &DBusAdaptorLauncher::AppSuffixChanged);
}
}

View File

@ -116,10 +116,11 @@ public:
public: // PROPERTIES
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged)
Q_PROPERTY(bool Fullscreen READ fullscreen WRITE setFullscreen NOTIFY FullScreenChanged)
int displayMode() const;
void setDisplayMode(int value);
Q_PROPERTY(bool Fullscreen READ fullscreen WRITE setFullscreen NOTIFY FullScreenChanged)
bool fullscreen() const;
void setFullscreen(bool value);
@ -135,6 +136,7 @@ public Q_SLOTS: // METHODS
void RequestUninstall(const QString &id);
void SetDisableScaling(const QString &id, bool value);
void SetUseProxy(const QString &id, bool value);
Q_SIGNALS: // SIGNALS
void ItemChanged(const QString &status, const LauncherItemInfo &itemInfo, qlonglong categoryID);
void NewAppLaunched(const QString &appID);
@ -143,6 +145,7 @@ Q_SIGNALS: // SIGNALS
void DisplayModeChanged(int mode);
void FullScreenChanged(bool isFull);
void AppSuffixChanged();
};
#endif

View File

@ -51,6 +51,7 @@ Launcher::Launcher(QObject *parent)
: SynModule(parent)
{
registeModule("launcher");
appsHidden = SETTING->getHiddenApps();
initSettings();
for (auto dir : BaseDir::appDirs()) {
@ -443,6 +444,13 @@ void Launcher::handleFSWatcherEvents(QDBusMessage msg)
}
}
void Launcher::onAppSuffixNameChanged(bool)
{
initItems();
Q_EMIT appSuffixChanged();
}
/**
* @brief Launcher::initSettings
*/
@ -453,8 +461,7 @@ void Launcher::initSettings()
});
connect(SETTING, &LauncherSettings::fullscreenChanged, this, &Launcher::fullScreenChanged);
connect(SETTING, &LauncherSettings::hiddenAppsChanged, this, &Launcher::handleAppHiddenChanged);
appsHidden = SETTING->getHiddenApps();
connect(SETTING, &LauncherSettings::appSuffixNameChanged, this, &Launcher::onAppSuffixNameChanged);
}
/**
@ -695,7 +702,6 @@ Categorytype Launcher::queryCategoryId(const Item *item)
if (category != Categorytype::CategoryErr)
return category;
return getXCategory(item);
}
@ -1131,7 +1137,7 @@ bool Launcher::isDeepinCustomDesktopFile(QString fileName)
&& fileInfo.baseName().startsWith("deepin-custom-");
}
Item Launcher:: NewItemWithDesktopInfo(DesktopInfo &info)
Item Launcher::NewItemWithDesktopInfo(DesktopInfo &info)
{
QString enName(info.getKeyFile()->getStr(MainSection, KeyName).c_str());
QString enComment(info.getKeyFile()->getStr(MainSection, KeyComment).c_str());
@ -1165,6 +1171,10 @@ Item Launcher:: NewItemWithDesktopInfo(DesktopInfo &info)
item.info.icon = info.getIcon().c_str();
}
// 玲珑应用添加后缀, 默认隐藏
if (SETTING->getMagicaVoxelSuffixHidden() && appFileName.startsWith("/persistent/linglong/entries/share/applications/"))
item.info.name = QString("%1(%2)").arg(appName).arg(tr("magicaVoxel"));
xDeepinCategory = xDeepinCategory.toLower();
for (auto &keyWord : info.getKeywords()) {

View File

@ -114,9 +114,11 @@ Q_SIGNALS:
void displayModeChanged(int mode);
void fullScreenChanged(bool isFull);
void appSuffixChanged();
private Q_SLOTS:
void handleFSWatcherEvents(QDBusMessage msg);
void onAppSuffixNameChanged(bool hidden);
private:
void initSettings();
@ -144,13 +146,14 @@ private:
bool removeDesktop(const Item &item);
void notifyUninstallDone(const Item &item, bool result);
QMap<QString, Item> itemsMap;
private:
QMap<QString, Item> itemsMap; // appKey, Item
QMap<QString, QString> desktopPkgMap;
QMap<QString, Categorytype> pkgCategoryMap;
QMap<QString, QString> nameMap;
QMap<QString, int> noPkgItemIds;
QVector<QString> appsHidden;
QStringList appDirs;
};

View File

@ -42,6 +42,8 @@ LauncherSettings::LauncherSettings(QObject *parent)
Q_EMIT fullscreenChanged(m_dconfig->value(key).toBool());
} else if (key == keyAppsHidden) {
Q_EMIT hiddenAppsChanged();
} else if (key == keySuffixHidden) {
Q_EMIT appSuffixNameChanged(m_dconfig->value(key).toBool());
}
});
}
@ -163,3 +165,18 @@ QVector<QString> LauncherSettings::getHiddenApps()
}
return ret;
}
bool LauncherSettings::getMagicaVoxelSuffixHidden() const
{
return m_dconfig ? m_dconfig->value(keySuffixHidden, false).toBool() : false;
}
void LauncherSettings::setMagicaVoxelSuffixHidden(bool state)
{
if (!m_dconfig) {
qInfo() << Q_FUNC_INFO << "set magicaVoxel suffix failed!";
return;
}
m_dconfig->setValue(keySuffixHidden, state);
}

View File

@ -64,10 +64,14 @@ public:
QVector<QString> getHiddenApps();
bool getMagicaVoxelSuffixHidden() const;
void setMagicaVoxelSuffixHidden(bool hidden);
Q_SIGNALS:
void displayModeChanged(QString mode);
void fullscreenChanged(bool isFull);
void hiddenAppsChanged();
void appSuffixNameChanged(bool);
};
#endif // LAUNCHERSETTINGS_H

View File

@ -53,7 +53,7 @@ QList<QSharedPointer<Application>> scanFiles()
user = getpwent();
}
endpwent();
auto linglong = scan("/deepin/linglong/entries/share/applications/");
auto linglong = scan("/persistent/linglong/entries/share/applications/");
for (const QFileInfo &info : linglong) {
applications << QSharedPointer<Application>(new Application(
"linglong",