diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-12-14 23:15:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 23:15:21 +0100 |
commit | d193ed9eebb392b259edb88a227dce4cee773df6 (patch) | |
tree | 7daad65334e540fae9c9bea892503f24f6a259d4 /launcher | |
parent | b2285be5bcbf02da72e4912f6a1354d3763022c4 (diff) | |
parent | 2d5820e910476f7eab32ac5cd48cce18c0c5a1e5 (diff) | |
download | PrismLauncher-d193ed9eebb392b259edb88a227dce4cee773df6.tar.gz PrismLauncher-d193ed9eebb392b259edb88a227dce4cee773df6.tar.bz2 PrismLauncher-d193ed9eebb392b259edb88a227dce4cee773df6.zip |
Merge pull request #561 from leo78913/iconpicker-stuff
closes https://github.com/PrismLauncher/PrismLauncher/issues/494
Diffstat (limited to 'launcher')
-rw-r--r-- | launcher/icons/IconList.cpp | 19 | ||||
-rw-r--r-- | launcher/icons/IconList.h | 1 | ||||
-rw-r--r-- | launcher/ui/dialogs/IconPickerDialog.cpp | 6 | ||||
-rw-r--r-- | launcher/ui/dialogs/IconPickerDialog.h | 1 |
4 files changed, 18 insertions, 9 deletions
diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp index 01043ad2..1dfc6432 100644 --- a/launcher/icons/IconList.cpp +++ b/launcher/icons/IconList.cpp @@ -354,15 +354,18 @@ const MMCIcon *IconList::icon(const QString &key) const bool IconList::deleteIcon(const QString &key) { - int iconIdx = getIconIndex(key); - if (iconIdx == -1) + if (!iconFileExists(key)) return false; - auto &iconEntry = icons[iconIdx]; - if (iconEntry.has(IconType::FileBased)) - { - return QFile::remove(iconEntry.m_images[IconType::FileBased].filename); - } - return false; + + return QFile::remove(icon(key)->getFilePath()); +} + +bool IconList::trashIcon(const QString &key) +{ + if (!iconFileExists(key)) + return false; + + return FS::trash(icon(key)->getFilePath(), nullptr); } bool IconList::addThemeIcon(const QString& key) diff --git a/launcher/icons/IconList.h b/launcher/icons/IconList.h index f9f49e7f..97141e4a 100644 --- a/launcher/icons/IconList.h +++ b/launcher/icons/IconList.h @@ -52,6 +52,7 @@ public: bool addIcon(const QString &key, const QString &name, const QString &path, const IconType type); void saveIcon(const QString &key, const QString &path, const char * format) const; bool deleteIcon(const QString &key); + bool trashIcon(const QString &key); bool iconFileExists(const QString &key) const; void installIcons(const QStringList &iconFiles); diff --git a/launcher/ui/dialogs/IconPickerDialog.cpp b/launcher/ui/dialogs/IconPickerDialog.cpp index fcb645db..0551a1ef 100644 --- a/launcher/ui/dialogs/IconPickerDialog.cpp +++ b/launcher/ui/dialogs/IconPickerDialog.cpp @@ -63,7 +63,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) // NOTE: ResetRole forces the button to be on the left, while the OK/Cancel ones are on the right. We win. auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole); - auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole); + buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole); connect(buttonAdd, SIGNAL(clicked(bool)), SLOT(addNewIcon())); connect(buttonRemove, SIGNAL(clicked(bool)), SLOT(removeSelectedIcon())); @@ -111,6 +111,9 @@ void IconPickerDialog::addNewIcon() void IconPickerDialog::removeSelectedIcon() { + if (APPLICATION->icons()->trashIcon(selectedIconKey)) + return; + APPLICATION->icons()->deleteIcon(selectedIconKey); } @@ -129,6 +132,7 @@ void IconPickerDialog::selectionChanged(QItemSelection selected, QItemSelection if (!key.isEmpty()) { selectedIconKey = key; } + buttonRemove->setEnabled(APPLICATION->icons()->iconFileExists(selectedIconKey)); } int IconPickerDialog::execWithSelection(QString selection) diff --git a/launcher/ui/dialogs/IconPickerDialog.h b/launcher/ui/dialogs/IconPickerDialog.h index 9af6a678..c93f565f 100644 --- a/launcher/ui/dialogs/IconPickerDialog.h +++ b/launcher/ui/dialogs/IconPickerDialog.h @@ -37,6 +37,7 @@ protected: private: Ui::IconPickerDialog *ui; + QPushButton *buttonRemove; private slots: |