class UpdateCheckerView(QDialog): '''Displays a small notification indicating new updates have been received''' def __init__(self, application, controller, model, systemTrayIcon, timeout = 10000): QDialog.__init__(self) self._application = application self._controller = controller self._model = model self._systemTrayIcon = systemTrayIcon self.diffDialog = None self._timeout = timeout def _truncate(self, string, length = 40, suffix = '...'): if len(string) > length: string = string[:length] + suffix return string def show(self, webPages): settings = Settings() server = xmlrpclib.Server(settings.serverAddress) self.setWindowTitle('updates') layout = self.layout() if layout == None: layout = QVBoxLayout() label = QLabel('Some Web Pages have changed:') layout.addWidget(label) for webPage in webPages: label = QLabel('<a href=' + webPage + '>' + self._truncate(webPage) + '</a>' ) label.setOpenExternalLinks(True) layout.addWidget(label) #buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) moreButton = QPushButton('More...') moreButton.setMaximumWidth(60) self.connect(moreButton, SIGNAL('clicked()'), self.showDiffWindow) layout.addWidget(moreButton) self.setLayout(layout) if debug.verbose: print('DEBUG: Showing notification dialog') QDialog.show(self) QTimer.singleShot(0, self.fixPosition) QTimer.singleShot(self._timeout, self.hide) def reject(self): QDialog.reject(self) for widget in self.children(): widget.deleteLater() import sip sip.delete(self.layout()) def showDiffWindow(self): from consider.updatedisplay import UpdateDisplayController if self.diffDialog == None: self.diffDialog = UpdateDisplayController(updateChecker = self._controller) self.diffDialog.show() def fixPosition(self): self.move(self._systemTrayIcon.geometry().x(), self._systemTrayIcon.geometry().y() - self.height() - 30) self.raise_() self.update()
def showDiffWindow(self): from consider.updatedisplay import UpdateDisplayController if self.diffDialog == None: self.diffDialog = UpdateDisplayController(updateChecker = self._controller) self.diffDialog.show()