예제 #1
0
    def __init__(self, chatScreen, bot):
        self.nickname = ""
        self.password = ""
        self.refreshToken = ""
        self.refreshTimer = 0

        self.chatScreen = chatScreen
        if not SettingManager.checkLoginFilesAreCompleted(
        ) or GeneralLoginDialog.reFreshTokenAndGetLogin() is None:
            generalDialog = GeneralLoginDialog(self)
            generalDialog.exec()
            if not SettingManager.checkLoginFilesAreCompleted():
                self.chatScreen.chatUI.centralWidget.mainWindow.close()
        [self.nickname, self.password, self.refreshToken
         ] = SettingManager.getSettingFileContent(SettingManager.LOGIN_FILE)
        self.receiveSocket = socket.socket()
        self.sendSocket = socket.socket()
        self.receiveSocketRunning = False
        self.systemMessageProcessor = SystemMessageProcessor(
            self.chatScreen, bot.messageQueue)
        self.systemMessageThread = self.systemMessageProcessor.systemMessageThread
        self.isHoldingMessage = False
        self.heldMessage = ''
        self.channelMessagePattern = re.compile('.*PRIVMSG (#[^ ]*) :')
        bot.connectIRC(self)
 def closeEvent(self, event):
     if SettingManager.checkLoginFilesAreCompleted():
         if self.loginChanged:
             self.connect()
         else:
             self.close()
     else:
         self.clientIRC.chatScreen.chatUI.centralWidget.mainWindow.close()
    def __init__(self, clientIRC):
        super(GeneralLoginDialog, self).__init__()
        self.loginChanged = False
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.clientIRC = clientIRC
        self.setWindowFlags(Qt.WindowCloseButtonHint)
        self.setWindowTitle('Login')
        position = self.clientIRC.chatScreen.chatUI.centralWidget.mainWindow.getPopUpPosition(
            400, 100)
        self.setGeometry(position.x(), position.y(), 400, 100)
        self.nickname = ""
        self.oauthToken = ""
        self.expire_in = 0
        self.refreshToken = ""
        self.hasLogin = SettingManager.checkLoginFilesAreCompleted()
        if self.hasLogin:
            [self.nickname, self.oauthToken,
             self.refreshToken] = SettingManager.getSettingFileContent(
                 SettingManager.LOGIN_FILE)
        layout = QVBoxLayout()
        self.label = QLabel()
        changeAccountButton = QPushButton()
        changeAccountButton.setText('Change account')
        changeAccountButton.clicked.connect(self.changeAccount)
        self.connectButton = QPushButton()
        self.connectButton.setText('Connect')
        self.connectButton.clicked.connect(self.connect)

        buttonLayout = QHBoxLayout()
        removeLoginButton = QPushButton()
        removeLoginButton.setText("Remove login")
        removeLoginButton.clicked.connect(self.removeLogin)
        buttonLayout.addWidget(changeAccountButton)
        buttonLayout.addWidget(removeLoginButton)

        self.defaultChannelLineEdit = QLineEdit()
        if self.hasLogin:
            self.defaultChannelLineEdit.setText(
                SettingManager.getSettingFileContent(
                    SettingManager.DEFAULT_CHANNEL_FILE)[0])
        else:
            self.defaultChannelLineEdit.setText("")
        self.defaultChannelLineEdit.returnPressed.connect(self.connect)
        self.defaultChannelLineEdit.textChanged[str].connect(
            self.enableConnectButton)

        layout.addWidget(self.label, 1)
        layout.addLayout(buttonLayout)
        layout.addWidget(
            QLabel(
                "Default list of channels to connect to, separated by comma"))
        layout.addWidget(self.defaultChannelLineEdit)
        layout.addWidget(self.connectButton, 1)

        self.setLayout(layout)
        self.updateUsername()