+class RenewWindow(QDialog):
+ def __init__(self, parent=None):
+ super(RenewWindow, self).__init__(parent)
+ self.setWindowTitle("Renew Slivers")
+
+ self.duration = QComboBox()
+
+ self.expirations = []
+
+ durations = ( (1, "One Week"), (2, "Two Weeks"), (3, "Three Weeks"), (4, "One Month") )
+
+ now = datetime.datetime.utcnow()
+ for (weeks, desc) in durations:
+ exp = now + datetime.timedelta(days = weeks * 7)
+ desc = desc + " " + exp.strftime("%Y-%m-%d %H:%M:%S")
+ self.expirations.append(exp)
+ self.duration.addItem(desc)
+
+ self.duration.setCurrentIndex(0)
+
+ buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
+ buttonBox.button(QDialogButtonBox.Ok).setDefault(True)
+
+ layout = QVBoxLayout()
+ layout.addWidget(self.duration)
+ layout.addWidget(buttonBox)
+ self.setLayout(layout)
+
+ self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
+ self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
+
+ def accept(self):
+ QDialog.accept(self)
+
+ def get_new_expiration(self):
+ index = self.duration.currentIndex()
+ return self.expirations[index]
+