UI: Programs: Show app's icon in Edit dialog

This commit is contained in:
Nodir Temirkhodjaev 2024-01-28 12:05:04 +03:00
parent 5963539d5f
commit bed396a7b0
3 changed files with 17 additions and 7 deletions

View File

@ -37,7 +37,7 @@ QString AppInfoCache::appName(const QString &appPath)
return appInfo.fileDescription; return appInfo.fileDescription;
} }
QIcon AppInfoCache::appIcon(const QString &appPath, const QString &nullIconPath) QPixmap AppInfoCache::appIcon(const QString &appPath, const QString &nullIconPath)
{ {
QPixmap pixmap; QPixmap pixmap;
if (IconCache::find(appPath, &pixmap)) if (IconCache::find(appPath, &pixmap))

View File

@ -20,7 +20,7 @@ public:
void tearDown() override; void tearDown() override;
QString appName(const QString &appPath); QString appName(const QString &appPath);
QIcon appIcon(const QString &appPath, const QString &nullIconPath = QString()); QPixmap appIcon(const QString &appPath, const QString &nullIconPath = QString());
AppInfo appInfo(const QString &appPath); AppInfo appInfo(const QString &appPath);

View File

@ -104,10 +104,6 @@ void ProgramEditDialog::initializePathNameFields()
initializePathField(isSingleSelection, isPathEditable); initializePathField(isSingleSelection, isPathEditable);
initializeNameField(isSingleSelection, isPathEditable); initializeNameField(isSingleSelection, isPathEditable);
if (isSingleSelection && m_appRow.appName.isEmpty()) {
fillEditName(); // Auto-fill the name
}
} }
void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathEditable) void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathEditable)
@ -131,8 +127,20 @@ void ProgramEditDialog::initializeNameField(bool isSingleSelection, bool isPathE
m_editName->setEnabled(isSingleSelection); m_editName->setEnabled(isSingleSelection);
m_editName->setClearButtonEnabled(isSingleSelection); m_editName->setClearButtonEnabled(isSingleSelection);
m_btGetName->setEnabled(isSingleSelection); m_btGetName->setEnabled(isSingleSelection);
m_editNotes->setText(m_appRow.notes); m_editNotes->setText(m_appRow.notes);
m_editNotes->setEnabled(isSingleSelection); m_editNotes->setEnabled(isSingleSelection);
constexpr QLatin1String nullIconPath(":/icons/application.png");
m_labelEditNotes->setPixmap(isSingleSelection
? IoC<AppInfoCache>()->appIcon(m_appRow.appPath, nullIconPath)
: IconCache::file(nullIconPath));
if (isSingleSelection) {
if (m_appRow.appName.isEmpty()) {
fillEditName(); // Auto-fill the name
}
}
} }
void ProgramEditDialog::activate() void ProgramEditDialog::activate()
@ -163,7 +171,7 @@ void ProgramEditDialog::retranslateUi()
m_labelEditName->setText(tr("Name:")); m_labelEditName->setText(tr("Name:"));
m_btGetName->setToolTip(tr("Get Program Name")); m_btGetName->setToolTip(tr("Get Program Name"));
m_labelEditNotes->setText(tr("Notes:")); m_editNotes->setPlaceholderText(tr("Notes"));
m_labelAppGroup->setText(tr("Application Group:")); m_labelAppGroup->setText(tr("Application Group:"));
m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State")); m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State"));
@ -307,6 +315,8 @@ QLayout *ProgramEditDialog::setupAppLayout()
layout->addRow("Notes:", notesLayout); layout->addRow("Notes:", notesLayout);
m_labelEditNotes = qobject_cast<QLabel *>(layout->labelForField(notesLayout)); m_labelEditNotes = qobject_cast<QLabel *>(layout->labelForField(notesLayout));
m_labelEditNotes->setScaledContents(true);
m_labelEditNotes->setFixedSize(32, 32);
// App Group // App Group
setupComboAppGroups(); setupComboAppGroups();