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()
Exemple #2
0
    def __init__(self, settingDialog):
        super(MainWidget, self).__init__(settingDialog)
        self.settingDialog = settingDialog
        layout = QVBoxLayout()

        settings = SettingManager.getSettingFileContent(
            SettingManager.MAIN_SETTING_FILE)
        chatFontGroupBox = QGroupBox(self)
        chatFontGroupBox.setTitle("Chat Font")
        chatFontLayout = QGridLayout()
        chatFontLayout.addWidget(QLabel("Font Name:"), 0, 0)
        self.chatFont = QLineEdit()
        self.chatFont.setText(settings[0])
        self.chatFont.setEnabled(False)
        chatFontLayout.setContentsMargins(5, 5, 5, 5)
        chatFontLayout.addWidget(self.chatFont, 0, 1)
        selectFontButton = QPushButton("Select Font")
        selectFontButton.clicked.connect(self.chooseFont)
        chatFontLayout.addWidget(selectFontButton, 1, 2)
        chatFontLayout.addWidget(QLabel("Font Size:"), 1, 0)
        self.chatFontSize = QLineEdit()
        self.chatFontSize.setText(settings[1])
        self.chatFontSize.setEnabled(False)
        chatFontLayout.addWidget(self.chatFontSize, 1, 1)
        chatFontLayout.addWidget(QLabel("Line Spacing:"), 2, 0)
        self.chatLineSpacing = QLineEdit()
        self.chatLineSpacing.setText(settings[2])
        self.chatLineSpacing.setEnabled(False)
        chatFontLayout.addWidget(self.chatLineSpacing, 2, 1)
        chatFontGroupBox.setLayout(chatFontLayout)
        layout.addWidget(chatFontGroupBox)

        self.setLayout(layout)
Exemple #3
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)
Exemple #4
0
 def updateSetting(self):
     settings = SettingManager.getSettingFileContent(
         SettingManager.NOTIFICATION_SETTING_FILE)
     self.font = QFont(settings[0], int(settings[1]), -1, False)
     self.chatScreen.chatUI.centralWidget.mainWindow.setStyleSheet(
         "QLabel#NotificationLabel { background-color : " + settings[2] +
         "; color : " + settings[3] + "; }")
     self.qSound = QSound(settings[4])
 def reFreshTokenAndGetLogin():
     response = GeneralLoginDialog.refreshAccessToken()
     if response:
         GeneralLoginDialog.writeLoginFile(response[0], response[1],
                                           response[2])
     else:
         return None
     return SettingManager.getSettingFileContent(SettingManager.LOGIN_FILE)
Exemple #6
0
 def reconnect(self):
     old_nickName = self.nickname
     [self.nickname, self.password, self.refreshToken
      ] = SettingManager.getSettingFileContent(SettingManager.LOGIN_FILE)
     if old_nickName != self.nickname:
         while self.chatScreen.count() > 0:
             self.chatScreen.closeTab(False)
         self.reLogin()
     self.chatScreen.joinDefaultChannel()
 def __init__(self, parent):
     super(ChatScreen, self).__init__(parent)
     self.showMessage = True
     self.chatUI = parent
     settings = SettingManager.getSettingFileContent(
         SettingManager.MAIN_SETTING_FILE)
     self.font = QFont(settings[0], int(settings[1]), -1, False)
     self.jsonDecoder = JSONDecoder()
     self.tabs = {}
     self.clientIRC = ClientIRC(self)
     self.clientIRC.start()
     self.notificationManager = NotificationManager(self)
     self.setAutoFillBackground(True)
     self.joinDefaultChannel()
     QShortcut(QKeySequence('Ctrl+Tab'), self, self.nextTab)
     QShortcut(QKeySequence('Ctrl+W'), self, self.closeTabOrExit)
     self.newWhisperSignal.connect(self.newWhisper)
 def refreshAccessToken():
     [username, _, refreshToken
      ] = SettingManager.getSettingFileContent(SettingManager.LOGIN_FILE)
     return GeneralLoginDialog.refreshAccessTokenWithName(
         username, refreshToken)
 def loadAndUpdateLogin(self):
     [self.nickname, self.oauthToken, self.refreshToken
      ] = SettingManager.getSettingFileContent(SettingManager.LOGIN_FILE)
     self.hasLogin = True
     self.updateUsername()
 def parseListFromDefaultChannelFile(self):
     return SettingManager.getSettingFileContent(
         SettingManager.DEFAULT_CHANNEL_FILE)[0].replace(" ", "").split(",")