QTfrontend/hwform.cpp
changeset 14470 6ab8335fe0a6
parent 14469 bfacce4ff920
child 14509 64d73515abba
--- a/QTfrontend/hwform.cpp	Tue Dec 18 22:53:49 2018 +0100
+++ b/QTfrontend/hwform.cpp	Tue Dec 18 23:28:40 2018 +0100
@@ -219,6 +219,7 @@
     previousTeamName = "";
     UpdateTeamsLists();
     InitCampaignPage();
+    RestoreSingleplayerTeamSelection();
     UpdateCampaignPage(0);
     UpdateCampaignPageTeam(0);
     UpdateCampaignPageMission(0);
@@ -928,6 +929,11 @@
             GoBack();
         }
 
+    if (curid == ID_PAGE_CAMPAIGN)
+        config->setValue("frontend/lastSingleplayerTeam", ui.pageCampaign->CBTeam->currentText());
+    if (curid == ID_PAGE_TRAINING)
+        config->setValue("frontend/lastSingleplayerTeam", ui.pageTraining->CBTeam->currentText());
+
     if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect();
     if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom();
     // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick
@@ -2054,6 +2060,21 @@
         QString tName = team.name();
         ui.pageCampaign->CBCampaign->addItem(getRealCampName(campaignName), campaignName);
     }
+
+}
+
+void HWForm::RestoreSingleplayerTeamSelection()
+{
+    QString lastTeam = config->value("frontend/lastSingleplayerTeam", QString()).toString();
+    if (!lastTeam.isNull() && !lastTeam.isEmpty())
+    {
+        int index = ui.pageCampaign->CBTeam->findData(lastTeam, Qt::DisplayRole);
+        if(index != -1)
+            ui.pageCampaign->CBTeam->setCurrentIndex(index);
+        index = ui.pageTraining->CBTeam->findData(lastTeam, Qt::DisplayRole);
+        if(index != -1)
+            ui.pageTraining->CBTeam->setCurrentIndex(index);
+    }
 }
 
 void HWForm::UpdateCampaignPage(int index)