summaryrefslogtreecommitdiffstats
path: root/api/gui
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-10-20 01:02:28 +0200
committerPetr Mrázek <peterix@gmail.com>2016-10-26 18:23:39 +0200
commitcee53f7f3ceb120aac83dbb60683fb228b385c2e (patch)
treecd02a5c6a2398b09fdac58e648bdac60ba5f8d63 /api/gui
parent1b4851a941cbafb7bf7a45feee7149cefa7e0acb (diff)
downloadMultiMC-cee53f7f3ceb120aac83dbb60683fb228b385c2e.tar
MultiMC-cee53f7f3ceb120aac83dbb60683fb228b385c2e.tar.gz
MultiMC-cee53f7f3ceb120aac83dbb60683fb228b385c2e.tar.lz
MultiMC-cee53f7f3ceb120aac83dbb60683fb228b385c2e.tar.xz
MultiMC-cee53f7f3ceb120aac83dbb60683fb228b385c2e.zip
Revert "NOISSUE nuke builtin Minecraft versions"
This reverts commit 5ae3b2c11416eb897a08b0d9531843d0357332f8. We need those builtin versions for now.
Diffstat (limited to 'api/gui')
-rw-r--r--api/gui/icons/IconList.cpp26
-rw-r--r--api/gui/icons/IconList.h6
2 files changed, 17 insertions, 15 deletions
diff --git a/api/gui/icons/IconList.cpp b/api/gui/icons/IconList.cpp
index b6be007f..bdcada32 100644
--- a/api/gui/icons/IconList.cpp
+++ b/api/gui/icons/IconList.cpp
@@ -292,7 +292,7 @@ bool IconList::deleteIcon(const QString &key)
return false;
}
-bool IconList::addIcon(QString key, QString name, QString path, IconType type)
+bool IconList::addIcon(const QString &key, const QString &name, const QString &path, const IconType type)
{
// replace the icon even? is the input valid?
QIcon icon(path);
@@ -323,6 +323,14 @@ bool IconList::addIcon(QString key, QString name, QString path, IconType type)
}
}
+void IconList::saveIcon(const QString &key, const QString &path, const char * format) const
+{
+ auto icon = getIcon(key);
+ auto pixmap = icon.pixmap(128, 128);
+ pixmap.save(path, format);
+}
+
+
void IconList::reindex()
{
name_index.clear();
@@ -334,7 +342,7 @@ void IconList::reindex()
}
}
-QIcon IconList::getIcon(QString key)
+QIcon IconList::getIcon(const QString &key) const
{
int icon_index = getIconIndex(key);
@@ -349,15 +357,12 @@ QIcon IconList::getIcon(QString key)
return QIcon();
}
-QIcon IconList::getBigIcon(QString key)
+QIcon IconList::getBigIcon(const QString &key) const
{
int icon_index = getIconIndex(key);
- if (icon_index == -1)
- key = "infinity";
-
// Fallback for icons that don't exist.
- icon_index = getIconIndex(key);
+ icon_index = getIconIndex(icon_index == -1 ? "infinity" : key);
if (icon_index == -1)
return QIcon();
@@ -366,12 +371,9 @@ QIcon IconList::getBigIcon(QString key)
return QIcon(bigone);
}
-int IconList::getIconIndex(QString key)
+int IconList::getIconIndex(const QString &key) const
{
- if (key == "default")
- key = "infinity";
-
- auto iter = name_index.find(key);
+ auto iter = name_index.find(key == "default" ? "infinity" : key);
if (iter != name_index.end())
return *iter;
diff --git a/api/gui/icons/IconList.h b/api/gui/icons/IconList.h
index 24ff4454..7b07797f 100644
--- a/api/gui/icons/IconList.h
+++ b/api/gui/icons/IconList.h
@@ -37,9 +37,9 @@ public:
explicit IconList(QString builtinPath, QString path, QObject *parent = 0);
virtual ~IconList() {};
- QIcon getIcon(QString key);
- QIcon getBigIcon(QString key);
- int getIconIndex(QString key);
+ QIcon getIcon(const QString &key) const;
+ QIcon getBigIcon(const QString &key) const;
+ int getIconIndex(const QString &key) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;