Show error icon when selected theme is missing
authorWuzzy <Wuzzy2@mail.ru>
Sun, 18 Mar 2018 15:42:17 +0100
changeset 13249 d2b58cf339fe
parent 13248 b0022324fb4e
child 13250 0cc068e8a391
Show error icon when selected theme is missing
QTfrontend/hedgewars.qrc
QTfrontend/model/ThemeModel.cpp
QTfrontend/res/missingTheme.png
QTfrontend/res/missingTheme@2x.png
QTfrontend/ui/widget/mapContainer.cpp
QTfrontend/ui/widget/mapContainer.h
--- a/QTfrontend/hedgewars.qrc	Sun Mar 18 15:24:54 2018 +0100
+++ b/QTfrontend/hedgewars.qrc	Sun Mar 18 15:42:17 2018 +0100
@@ -99,6 +99,7 @@
         <file>res/missionFinished.png</file>
         <file>res/missionFinishedSelected.png</file>
         <file>res/missingMap.png</file>
+        <file>res/missingTheme@2x.png</file>
         <file>res/dlcMarker.png</file>
         <file>res/dlcMarkerSelected.png</file>
         <file>res/graphicsicon.png</file>
--- a/QTfrontend/model/ThemeModel.cpp	Sun Mar 18 15:24:54 2018 +0100
+++ b/QTfrontend/model/ThemeModel.cpp	Sun Mar 18 15:42:17 2018 +0100
@@ -131,7 +131,7 @@
             dataset.insert(IsHiddenRole, true);
 
         // detect if theme is dlc
-        QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data());
+        QString themeDir = PHYSFS_getRealDir(QString("Themes/%1").arg(theme).toLocal8Bit().data());
         bool isDLC = !themeDir.startsWith(datadir->absolutePath());
         dataset.insert(IsDlcRole, isDLC);
 
Binary file QTfrontend/res/missingTheme.png has changed
Binary file QTfrontend/res/missingTheme@2x.png has changed
--- a/QTfrontend/ui/widget/mapContainer.cpp	Sun Mar 18 15:24:54 2018 +0100
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Sun Mar 18 15:42:17 2018 +0100
@@ -541,7 +541,7 @@
     if(mdl.size())
         updateTheme(mdl.at(0));
     else
-        intSetIconlessTheme(theme);
+        setMissingTheme(theme);
 }
 
 void HWMapContainer::setRandomMap()
@@ -1197,13 +1197,18 @@
     }
 }
 
-void HWMapContainer::intSetIconlessTheme(const QString & name)
+void HWMapContainer::setMissingTheme(const QString & name)
 {
     if (name.isEmpty()) return;
 
     m_theme = name;
-    btnTheme->setIcon(QIcon());
+    QPixmap pixMissing = QPixmap(":/res/missingTheme@2x.png");
+    QIcon iconMissing  = QIcon();
+    iconMissing.addPixmap(pixMissing, QIcon::Normal);
+    iconMissing.addPixmap(pixMissing, QIcon::Disabled);
+    btnTheme->setIcon(iconMissing);
     btnTheme->setText(tr("Theme: %1").arg(name));
+    updateThemeButtonSize();
 }
 
 void HWMapContainer::setupMissionMapsView()
--- a/QTfrontend/ui/widget/mapContainer.h	Sun Mar 18 15:24:54 2018 +0100
+++ b/QTfrontend/ui/widget/mapContainer.h	Sun Mar 18 15:42:17 2018 +0100
@@ -174,7 +174,7 @@
         void intSetTemplateFilter(int);
         void intSetMazeSize(int size);
         void intSetFeatureSize(int size);
-        void intSetIconlessTheme(const QString & name);
+        void setMissingTheme(const QString & name);
         void mapChanged(const QModelIndex & map, int type, const QModelIndex & old = QModelIndex());
         void setMapInfo(MapModel::MapInfo mapInfo);
         void changeMapType(MapModel::MapType type, const QModelIndex & newMap = QModelIndex());