def __init__(self, nick, question, parent=None): QDialog.__init__(self, parent) self.clickedButton = constants.BUTTON_CANCEL # Set the title and icon self.setWindowTitle("Authenticate %s" % nick) self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) smpQuestionLabel = QLabel("Question: <b>%s</b>" % question, self) smpAnswerLabel = QLabel("Answer (case sensitive):", self) self.smpAnswerInput = QLineEdit(self) okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self) cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self) keyIcon = QLabel(self) keyIcon.setPixmap( QPixmap( qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth( 60, Qt.SmoothTransformation)) helpLabel = QLabel( "%s has requested to authenticate your conversation by asking you a\n" "question only you should know the answer to. Enter your answer below\n" "to authenticate your conversation.\n\n" "You may wish to ask your buddy a question as well." % nick) okayButton.clicked.connect( lambda: self.buttonClicked(constants.BUTTON_OKAY)) cancelButton.clicked.connect( lambda: self.buttonClicked(constants.BUTTON_CANCEL)) helpLayout = QHBoxLayout() helpLayout.addStretch(1) helpLayout.addWidget(keyIcon) helpLayout.addSpacing(15) helpLayout.addWidget(helpLabel) helpLayout.addStretch(1) # Float the buttons to the right buttons = QHBoxLayout() buttons.addStretch(1) buttons.addWidget(okayButton) buttons.addWidget(cancelButton) vbox = QVBoxLayout() vbox.addLayout(helpLayout) vbox.addWidget(QLine()) vbox.addWidget(smpQuestionLabel) vbox.addWidget(smpAnswerLabel) vbox.addWidget(self.smpAnswerInput) vbox.addLayout(buttons) self.setLayout(vbox)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.clickedButton = constants.BUTTON_CANCEL # Set the title and icon self.setWindowTitle("Authenticate Buddy") self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) smpQuestionLabel = QLabel("Question:", self) self.smpQuestionInput = QLineEdit(self) smpAnswerLabel = QLabel("Answer (case sensitive):", self) self.smpAnswerInput = QLineEdit(self) okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self) cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self) keyIcon = QLabel(self) keyIcon.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth(50, Qt.SmoothTransformation)) helpLabel = QLabel("In order to ensure that no one is listening in on your conversation\n" "it's best to verify the identity of your buddy by entering a question\n" "that only your buddy knows the answer to.") okayButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_OKAY)) cancelButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_CANCEL)) helpLayout = QHBoxLayout() helpLayout.addStretch(1) helpLayout.addWidget(keyIcon) helpLayout.addSpacing(15) helpLayout.addWidget(helpLabel) helpLayout.addStretch(1) # Float the buttons to the right buttons = QHBoxLayout() buttons.addStretch(1) buttons.addWidget(okayButton) buttons.addWidget(cancelButton) vbox = QVBoxLayout() vbox.addLayout(helpLayout) vbox.addWidget(QLine()) vbox.addWidget(smpQuestionLabel) vbox.addWidget(self.smpQuestionInput) vbox.addWidget(smpAnswerLabel) vbox.addWidget(self.smpAnswerInput) vbox.addLayout(buttons) self.setLayout(vbox)
def __init__(self, nick, question, parent=None): QDialog.__init__(self, parent) self.clickedButton = constants.BUTTON_CANCEL # Set the title and icon self.setWindowTitle("Authenticate %s" % nick) self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) smpQuestionLabel = QLabel("Question: <b>%s</b>" % question, self) smpAnswerLabel = QLabel("Answer (case sensitive):", self) self.smpAnswerInput = QLineEdit(self) okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self) cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self) keyIcon = QLabel(self) keyIcon.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth(60, Qt.SmoothTransformation)) helpLabel = QLabel("%s has requested to authenticate your conversation by asking you a\n" "question only you should know the answer to. Enter your answer below\n" "to authenticate your conversation.\n\n" "You may wish to ask your buddy a question as well." % nick) okayButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_OKAY)) cancelButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_CANCEL)) helpLayout = QHBoxLayout() helpLayout.addStretch(1) helpLayout.addWidget(keyIcon) helpLayout.addSpacing(15) helpLayout.addWidget(helpLabel) helpLayout.addStretch(1) # Float the buttons to the right buttons = QHBoxLayout() buttons.addStretch(1) buttons.addWidget(okayButton) buttons.addWidget(cancelButton) vbox = QVBoxLayout() vbox.addLayout(helpLayout) vbox.addWidget(QLine()) vbox.addWidget(smpQuestionLabel) vbox.addWidget(smpAnswerLabel) vbox.addWidget(self.smpAnswerInput) vbox.addLayout(buttons) self.setLayout(vbox)
def __setMenubar(self): newChatIcon = QIcon(qtUtils.getAbsoluteImagePath('new_chat.png')) helpIcon = QIcon(qtUtils.getAbsoluteImagePath('help.png')) exitIcon = QIcon(qtUtils.getAbsoluteImagePath('exit.png')) menuIcon = QIcon(qtUtils.getAbsoluteImagePath('menu.png')) newChatAction = QAction(newChatIcon, '&New chat', self) authChatAction = QAction(newChatIcon, '&Authenticate chat', self) helpAction = QAction(helpIcon, 'Show &help', self) exitAction = QAction(exitIcon, '&Exit', self) newChatAction.triggered.connect(lambda: self.addNewTab()) authChatAction.triggered.connect(self.__showAuthDialog) helpAction.triggered.connect(self.__showHelpDialog) exitAction.triggered.connect(self.__exit) newChatAction.setShortcut('Ctrl+N') helpAction.setShortcut('Ctrl+H') exitAction.setShortcut('Ctrl+Q') optionsMenu = QMenu() optionsMenu.addAction(newChatAction) optionsMenu.addAction(authChatAction) optionsMenu.addAction(helpAction) optionsMenu.addAction(exitAction) optionsMenuButton = QToolButton() newChatButton = QToolButton() exitButton = QToolButton() newChatButton.clicked.connect(lambda: self.addNewTab()) exitButton.clicked.connect(self.__exit) optionsMenuButton.setIcon(menuIcon) newChatButton.setIcon(newChatIcon) exitButton.setIcon(exitIcon) optionsMenuButton.setMenu(optionsMenu) optionsMenuButton.setPopupMode(QToolButton.InstantPopup) toolbar = QToolBar(self) toolbar.addWidget(optionsMenuButton) toolbar.addWidget(newChatButton) toolbar.addWidget(exitButton) self.addToolBar(Qt.LeftToolBarArea, toolbar)
def __init__(self, image, imageWidth, connectClickedSlot, nick='', parent=None): QWidget.__init__(self, parent) self.connectClickedSlot = connectClickedSlot # Image self.image = QLabel(self) self.image.setPixmap( QPixmap(qtUtils.getAbsoluteImagePath(image)).scaledToWidth( imageWidth, Qt.SmoothTransformation)) # Nick field self.nickLabel = QLabel("Nickname:", self) self.nickEdit = QLineEdit(nick, self) self.nickEdit.setMaxLength(constants.NICK_MAX_LEN) self.nickEdit.returnPressed.connect(self.__connectClicked) self.nickEdit.setFocus() # Connect button self.connectButton = QPushButton("Connect", self) self.connectButton.resize(self.connectButton.sizeHint()) self.connectButton.setAutoDefault(False) self.connectButton.clicked.connect(self.__connectClicked) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.nickLabel) hbox.addWidget(self.nickEdit) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) vbox.addWidget(self.connectButton) vbox.addStretch(1) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.image) hbox.addSpacing(10) hbox.addLayout(vbox) hbox.addStretch(1) self.setLayout(hbox)
def __init__(self, parent, text=""): QDialog.__init__(self, parent) # Create waiting image waitingImage = QMovie(qtUtils.getAbsoluteImagePath('waiting.gif')) waitingImage.start() waitingImageLabel = QLabel(self) waitingImageLabel.setMovie(waitingImage) waitingLabel = QLabel(text, self) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(waitingImageLabel) hbox.addSpacing(10) hbox.addWidget(waitingLabel) hbox.addStretch(1) self.setLayout(hbox)
def __init__(self, parent=None): QWidget.__init__(self, parent) # Create connecting image self.connectingGif = QMovie( qtUtils.getAbsoluteImagePath('waiting.gif')) self.connectingGif.start() self.connetingImageLabel = QLabel(self) self.connetingImageLabel.setMovie(self.connectingGif) self.connectingLabel = QLabel(self) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.connetingImageLabel, alignment=Qt.AlignCenter) hbox.addSpacing(10) hbox.addWidget(self.connectingLabel, alignment=Qt.AlignCenter) hbox.addStretch(1) self.setLayout(hbox)
def __init__(self, verify=False, showForgotButton=True): QDialog.__init__(self) self.passphrase = None self.clickedButton = constants.BUTTON_CANCEL # Set the title and icon self.setWindowTitle("Save Keys Passphrase") self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) label = QLabel("Encryption keys passphrase:" if not verify else "Confirm passphrase:", self) self.passphraseInput = QLineEdit(self) self.passphraseInput.setEchoMode(QLineEdit.Password) okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self) cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self) if showForgotButton: forgotButton = QPushButton(QIcon.fromTheme('edit-undo'), "Forgot Passphrase", self) okayButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_OKAY)) cancelButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_CANCEL)) if showForgotButton: forgotButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_FORGOT)) # Float the buttons to the right hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(okayButton) hbox.addWidget(cancelButton) if showForgotButton: hbox.addWidget(forgotButton) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(label) vbox.addWidget(self.passphraseInput) vbox.addLayout(hbox) vbox.addStretch(1) self.setLayout(vbox)
def __init__(self, image, imageWidth, connectClickedSlot, nick='', parent=None): QWidget.__init__(self, parent) self.connectClickedSlot = connectClickedSlot # Image self.image = QLabel(self) self.image.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath(image)).scaledToWidth(imageWidth, Qt.SmoothTransformation)) # Nick field self.nickLabel = QLabel("Nickname:", self) self.nickEdit = QLineEdit(nick, self) self.nickEdit.setMaxLength(constants.NICK_MAX_LEN) self.nickEdit.returnPressed.connect(self.__connectClicked) self.nickEdit.setFocus() # Connect button self.connectButton = QPushButton("Connect", self) self.connectButton.resize(self.connectButton.sizeHint()) self.connectButton.setAutoDefault(False) self.connectButton.clicked.connect(self.__connectClicked) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.nickLabel) hbox.addWidget(self.nickEdit) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) vbox.addWidget(self.connectButton) vbox.addStretch(1) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.image) hbox.addSpacing(10) hbox.addLayout(vbox) hbox.addStretch(1) self.setLayout(hbox)
def __init__(self, parent, nick=""): QDialog.__init__(self, parent) self.nick = None # Set the title and icon self.setWindowTitle("Cryptully") self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) helpLink = QLinkLabel("Confused? Read the docs.", "https://cryptully.readthedocs.org/en/latest/", self) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(QNickInputWidget('splash_icon.png', 200, self.connectClicked, nick, self)) vbox.addStretch(1) vbox.addWidget(helpLink, alignment=Qt.AlignRight) self.setLayout(vbox) qtUtils.resizeWindow(self, 500, 200) qtUtils.centerWindow(self)
def __init__(self, restartCallback, connectionManager=None, messageQueue=None): QMainWindow.__init__(self) self.restartCallback = restartCallback self.connectionManager = connectionManager self.messageQueue = messageQueue self.newClientSignal.connect(self.newClientSlot) self.clientReadySignal.connect(self.clientReadySlot) self.smpRequestSignal.connect(self.smpRequestSlot) self.handleErrorSignal.connect(self.handleErrorSlot) self.sendMessageToTabSignal.connect(self.sendMessageToTab) self.chatTabs = QTabWidget(self) self.chatTabs.setTabsClosable(True) self.chatTabs.setMovable(True) self.chatTabs.tabCloseRequested.connect(self.closeTab) self.chatTabs.currentChanged.connect(self.tabChanged) self.statusBar = self.statusBar() self.systemTrayIcon = QSystemTrayIcon(self) self.systemTrayIcon.setVisible(True) self.__setMenubar() vbox = QVBoxLayout() vbox.addWidget(self.chatTabs) # Add the completeted layout to the window self.centralWidget = QWidget() self.centralWidget.setLayout(vbox) self.setCentralWidget(self.centralWidget) qtUtils.resizeWindow(self, 700, 400) qtUtils.centerWindow(self) # Title and icon self.setWindowTitle("Cryptully") self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png')))
def __init__(self, parent, nick=""): QDialog.__init__(self, parent) self.nick = None # Set the title and icon self.setWindowTitle("Cryptully") self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png'))) helpLink = QLinkLabel("Confused? Read the docs.", "https://cryptully.readthedocs.org/en/latest/", self) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget( QNickInputWidget('splash_icon.png', 200, self.connectClicked, nick, self)) vbox.addStretch(1) vbox.addWidget(helpLink, alignment=Qt.AlignRight) self.setLayout(vbox) qtUtils.resizeWindow(self, 500, 200) qtUtils.centerWindow(self)