lastSetup support in question frontends
[lilass.git] / question_frontend.py
index a17b7ca95b2229f0eb9bc6a1d6bbfd68d55a7e5f..fc9e8c6dd0048f7c585f500d671451843c24e26e 100644 (file)
@@ -40,6 +40,13 @@ class QuestionFrontend:
         return self.userChoose("Select resolution for %s"%displayname, modedescs, availablemodes, None)
 
     def setup (self, situation):
+        if situation.lastSetup:
+            applyLast = self.userChoose("This display is known. The last setup for it was like this:\n%s.\nApply the last used configuration?" % str(situation.lastSetup), ("Apply last setup", "Enter different setup"), (True,False), None)
+            if applyLast is None:
+                return None
+            if applyLast is True:
+                return situation.lastSetup
+            assert applyLast is False
         operationmodes = list(OperationMode)
         operationmodedescs = list(map(lambda x: x.text, operationmodes))
         operationmode = self.userChoose ("Display setup", operationmodedescs, operationmodes, None)