Frontend: Gray out campaign/training start buttons when no human team available
authorWuzzy <Wuzzy2@mail.ru>
Mon, 21 Jan 2019 09:12:39 +0100
changeset 14651 e3e6b0c6543f
parent 14650 9e7092e5990a
child 14652 c09ac49ed1de
Frontend: Gray out campaign/training start buttons when no human team available
QTfrontend/hwform.cpp
QTfrontend/ui/page/pagetraining.cpp
QTfrontend/ui/page/pagetraining.h
--- a/QTfrontend/hwform.cpp	Mon Jan 21 07:10:59 2019 +0100
+++ b/QTfrontend/hwform.cpp	Mon Jan 21 09:12:39 2019 +0100
@@ -579,6 +579,7 @@
     ui.pageCampaign->CBTeam->clear();
     ui.pageTraining->CBTeam->clear();
     /* Only show human teams in campaign/training page */
+    bool playable = false;
     for(int i=0; i<teamslist.length(); i++)
     {
         HWTeam testTeam = HWTeam(teamslist[i]);
@@ -587,8 +588,13 @@
         {
             ui.pageCampaign->CBTeam->addItem(teamslist[i]);
             ui.pageTraining->CBTeam->addItem(teamslist[i]);
+            playable = true;
         }
     }
+    ui.pageCampaign->BtnStartCampaign->setEnabled(playable);
+    ui.pageCampaign->btnPreview->setEnabled(playable);
+    ui.pageTraining->btnStart->setEnabled(playable);
+    ui.pageTraining->btnPreview->setEnabled(playable);
     UpdateTrainingPageTeam(0);
 }
 
--- a/QTfrontend/ui/page/pagetraining.cpp	Mon Jan 21 07:10:59 2019 +0100
+++ b/QTfrontend/ui/page/pagetraining.cpp	Mon Jan 21 09:12:39 2019 +0100
@@ -304,7 +304,7 @@
     list = (QListWidget*) tbw->currentWidget();
     QListWidgetItem * curItem = list->currentItem();
 
-    if (curItem != NULL)
+    if ((curItem != NULL) && (CBTeam->currentIndex() != -1))
         emit startMission(curItem->data(Qt::UserRole).toString(), getSubFolderOfSelected());
 }
 
--- a/QTfrontend/ui/page/pagetraining.h	Mon Jan 21 07:10:59 2019 +0100
+++ b/QTfrontend/ui/page/pagetraining.h	Mon Jan 21 09:12:39 2019 +0100
@@ -30,6 +30,8 @@
         QListWidget * lstTrainings;
         QListWidget * lstChallenges;
         QListWidget * lstScenarios;
+        QPushButton * btnPreview;
+        QPushButton * btnStart;
         QComboBox * CBTeam;
 
     public slots:
@@ -46,8 +48,6 @@
 
 
     private:
-        QPushButton * btnPreview;
-        QPushButton * btnStart;
         QLabel * lblCaption;
         QLabel * lblDescription;
         QLabel * lblHighscores;