Esempio n. 1
0
class QtSampWidget(QWidget):
    def __init__(self, parent=None):
        self.SampMESSAGE = "A Web application which declares to be\n\nName: {name}\n"+\
            "Origin: {origin}\n\nis requesting to be registered with the SAMP Hub.  "+\
            "Pay attention\nthat if you permit its registration, "+\
            "such application will acquire\nall current user privileges, like file "+\
            "read/write.\n\nDo you give your consent?"
        super(QtSampWidget, self).__init__(parent)
        #        self.setWindowIcon(QWidget.QIcon('web.png')) ## <= MM: What is this??
        self.setWindowIcon(QIcon('iconVESPA.png'))
        self.initUI()
        self.setGeometry(300, 300, 290, 150)
        self.setWindowTitle('SAMP Root window')
        self.show()

    def initUI(self):
        self.lbl = QLabel(
            "HUB root window. \n Close this terminates \n SAMP Hub Server",
            self)
        self.lbl.move(20, 20)
        self.c = Communicate()
        self.c.M.connect(self.showDialog)
        self.WPD = QtWebProfileDialog(self.c)
        self.mymaster = HubMaster(self.WPD)
        self.mymaster.work()

    def showDialog(self):
        text = self.SampMESSAGE.format(name=self.WPD.samp_name,
                                       origin=self.WPD.origin)
        reply = QMessageBox.question(self, 'Continue?', text, QMessageBox.Yes,
                                     QMessageBox.No)
        if reply == QMessageBox.Yes:
            print('accepted')
            self.WPD.consent()
        else:
            print('rejected')
            self.WPD.reject()

    def closeEvent(self, event):
        self.mymaster.isOpen = False
        self.mymaster.h.stop()
        self.WPD.running = False
        say('dialog closed')