UI: Programs: Improve name of wildcard paths

This commit is contained in:
Nodir Temirkhodjaev 2024-04-26 19:30:39 +03:00
parent 89ee96ba1f
commit f200563ee4
2 changed files with 6 additions and 12 deletions

View File

@ -196,19 +196,13 @@ void ConfAppManager::updateAppEndTimer()
bool ConfAppManager::addAppPathBlocked(App &app) bool ConfAppManager::addAppPathBlocked(App &app)
{ {
// app.blocked
// app.alerted
// app.groupIndex
// app.appOriginPath
// app.scheduleAction
app.appId = appIdByPath(app.appOriginPath, app.appPath); app.appId = appIdByPath(app.appOriginPath, app.appPath);
if (app.appId > 0) if (app.appId > 0)
return false; // already added by user return false; // already exists
app.isWildcard = ConfUtil::matchWildcard(app.appPath).hasMatch(); app.isWildcard = ConfUtil::matchWildcard(app.appPath).hasMatch();
app.appName = IoC<AppInfoCache>()->appName(app.appPath); app.appName = app.isWildcard ? app.appOriginPath : IoC<AppInfoCache>()->appName(app.appPath);
const bool ok = addOrUpdateApp(app); const bool ok = addOrUpdateApp(app);
if (ok) { if (ok) {

View File

@ -708,16 +708,16 @@ QLayout *ProgramEditDialog::setupButtonsLayout()
void ProgramEditDialog::fillEditName() void ProgramEditDialog::fillEditName()
{ {
auto appPath = getEditText(); const QString appPath = getEditText();
if (appPath.isEmpty()) if (appPath.isEmpty())
return; return;
QString appName; QString appName;
if (isWildcard()) { if (isWildcard()) {
appName = appPath.left(64).replace('\n', ' '); appName = StringUtil::firstLine(appPath);
} else { } else {
appPath = FileUtil::normalizePath(appPath); const QString normPath = FileUtil::normalizePath(appPath);
appName = IoC<AppInfoCache>()->appName(appPath); appName = IoC<AppInfoCache>()->appName(normPath);
} }
m_editName->setStartText(appName); m_editName->setStartText(appName);