Пример #1
0
def updater_available():
    if is_from_sources():
        return os.path.exists(util.curr_directory() + '/toxygen_updater.py')
    elif platform.system() == 'Windows':
        return os.path.exists(util.curr_directory() + '/toxygen_updater.exe')
    else:
        return os.path.exists(util.curr_directory() + '/toxygen_updater')
Пример #2
0
    def incoming_file_transfer(self, friend_number, file_number, size,
                               file_name):
        """
        New transfer
        :param friend_number: number of friend who sent file
        :param file_number: file number
        :param size: file size in bytes
        :param file_name: file name without path
        """
        settings = Settings.get_instance()
        friend = self.get_friend_by_number(friend_number)
        auto = settings['allow_auto_accept'] and friend.tox_id in settings[
            'auto_accept_from_friends']
        inline = (file_name == 'toxygen_inline.png' or file_name
                  == 'utox-inline.png') and settings['allow_inline']
        if inline and size < 1024 * 1024:
            self.accept_transfer(None, '', friend_number, file_number, size,
                                 True)
            tm = TransferMessage(
                MESSAGE_OWNER['FRIEND'], time.time(),
                FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'], size,
                file_name, friend_number, file_number)

        elif auto:
            path = settings['auto_accept_path'] or curr_directory()
            if not os.path.isdir(path):
                path = curr_directory()
            new_file_name, i = file_name, 1
            while os.path.isfile(
                    path + '/' +
                    new_file_name):  # file with same name already exists
                if '.' in file_name:  # has extension
                    d = file_name.rindex('.')
                else:  # no extension
                    d = len(file_name)
                new_file_name = file_name[:d] + ' ({})'.format(
                    i) + file_name[d:]
                i += 1
            self.accept_transfer(None, path + '/' + new_file_name,
                                 friend_number, file_number, size)
            tm = TransferMessage(
                MESSAGE_OWNER['FRIEND'], time.time(),
                FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'], size,
                new_file_name, friend_number, file_number)
        else:
            tm = TransferMessage(
                MESSAGE_OWNER['FRIEND'], time.time(),
                FILE_TRANSFER_MESSAGE_STATUS['INCOMING_NOT_STARTED'], size,
                file_name, friend_number, file_number)
        if friend_number == self.get_active_number():
            item = self.create_file_transfer_item(tm)
            if (inline and size < 1024 * 1024) or auto:
                self._file_transfers[(friend_number,
                                      file_number)].set_state_changed_handler(
                                          item.update)
            self._messages.scrollToBottom()
        else:
            friend.set_messages(True)

        friend.append_message(tm)
Пример #3
0
def updater_available():
    if is_from_sources():
        return os.path.exists(util.curr_directory() + '/toxygen_updater.py')
    elif platform.system() == 'Windows':
        return os.path.exists(util.curr_directory() + '/toxygen_updater.exe')
    else:
        return os.path.exists(util.curr_directory() + '/toxygen_updater')
Пример #4
0
    def incoming_file_transfer(self, friend_number, file_number, size, file_name):
        """
        New transfer
        :param friend_number: number of friend who sent file
        :param file_number: file number
        :param size: file size in bytes
        :param file_name: file name without path
        """
        settings = Settings.get_instance()
        friend = self.get_friend_by_number(friend_number)
        auto = settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends']
        inline = (file_name == 'toxygen_inline.png' or file_name == 'utox-inline.png') and settings['allow_inline']
        if inline and size < 1024 * 1024:
            self.accept_transfer(None, '', friend_number, file_number, size, True)
            tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
                                 time.time(),
                                 FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'],
                                 size,
                                 file_name,
                                 friend_number,
                                 file_number)

        elif auto:
            path = settings['auto_accept_path'] or curr_directory()
            if not os.path.isdir(path):
                path = curr_directory()
            new_file_name, i = file_name, 1
            while os.path.isfile(path + '/' + new_file_name):  # file with same name already exists
                if '.' in file_name:  # has extension
                    d = file_name.rindex('.')
                else:  # no extension
                    d = len(file_name)
                new_file_name = file_name[:d] + ' ({})'.format(i) + file_name[d:]
                i += 1
            self.accept_transfer(None, path + '/' + new_file_name, friend_number, file_number, size)
            tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
                                 time.time(),
                                 FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'],
                                 size,
                                 new_file_name,
                                 friend_number,
                                 file_number)
        else:
            tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
                                 time.time(),
                                 FILE_TRANSFER_MESSAGE_STATUS['INCOMING_NOT_STARTED'],
                                 size,
                                 file_name,
                                 friend_number,
                                 file_number)
        if friend_number == self.get_active_number():
            item = self.create_file_transfer_item(tm)
            if (inline and size < 1024 * 1024) or auto:
                self._file_transfers[(friend_number, file_number)].set_state_changed_handler(item.update)
            self._messages.scrollToBottom()
        else:
            friend.set_messages(True)

        friend.append_message(tm)
Пример #5
0
    def __init__(self, parent):
        super(DropdownMenu, self).__init__(parent)
        self.installEventFilter(self)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setMaximumSize(120, 120)
        self.setMinimumSize(120, 120)
        self.screenshotButton = QRightClickButton(self)
        self.screenshotButton.setGeometry(QtCore.QRect(0, 60, 60, 60))
        self.screenshotButton.setObjectName("screenshotButton")

        self.fileTransferButton = QtWidgets.QPushButton(self)
        self.fileTransferButton.setGeometry(QtCore.QRect(60, 60, 60, 60))
        self.fileTransferButton.setObjectName("fileTransferButton")

        self.smileyButton = QtWidgets.QPushButton(self)
        self.smileyButton.setGeometry(QtCore.QRect(0, 0, 60, 60))

        self.stickerButton = QtWidgets.QPushButton(self)
        self.stickerButton.setGeometry(QtCore.QRect(60, 0, 60, 60))

        pixmap = QtGui.QPixmap(util.curr_directory() + '/images/file.png')
        icon = QtGui.QIcon(pixmap)
        self.fileTransferButton.setIcon(icon)
        self.fileTransferButton.setIconSize(QtCore.QSize(50, 50))

        pixmap = QtGui.QPixmap(util.curr_directory() +
                               '/images/screenshot.png')
        icon = QtGui.QIcon(pixmap)
        self.screenshotButton.setIcon(icon)
        self.screenshotButton.setIconSize(QtCore.QSize(50, 60))

        pixmap = QtGui.QPixmap(util.curr_directory() + '/images/smiley.png')
        icon = QtGui.QIcon(pixmap)
        self.smileyButton.setIcon(icon)
        self.smileyButton.setIconSize(QtCore.QSize(50, 50))

        pixmap = QtGui.QPixmap(util.curr_directory() + '/images/sticker.png')
        icon = QtGui.QIcon(pixmap)
        self.stickerButton.setIcon(icon)
        self.stickerButton.setIconSize(QtCore.QSize(55, 55))

        self.screenshotButton.setToolTip(
            QtWidgets.QApplication.translate("MenuWindow", "Send screenshot"))
        self.fileTransferButton.setToolTip(
            QtWidgets.QApplication.translate("MenuWindow", "Send file"))
        self.smileyButton.setToolTip(
            QtWidgets.QApplication.translate("MenuWindow", "Add smiley"))
        self.stickerButton.setToolTip(
            QtWidgets.QApplication.translate("MenuWindow", "Send sticker"))

        self.fileTransferButton.clicked.connect(parent.send_file)
        self.screenshotButton.clicked.connect(parent.send_screenshot)
        self.screenshotButton.rightClicked.connect(
            lambda: parent.send_screenshot(True))
        self.smileyButton.clicked.connect(parent.send_smiley)
        self.stickerButton.clicked.connect(parent.send_sticker)
Пример #6
0
 def get_default_settings():
     return {
         'read': [],
         'write': [],
         'delete': [],
         'master': [],
         'folder': curr_directory(),
         'folder_save': curr_directory(),
         'auto_rights': 'r'
     }
Пример #7
0
 def get_default_settings():
     return {
         'read': [],
         'write': [],
         'delete': [],
         'master': [],
         'folder': curr_directory(),
         'folder_save': curr_directory(),
         'auto_rights': 'r'
     }
Пример #8
0
 def __init__(self):
     if system() == 'Windows':
         self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         # libtoxcore and libsodium must be installed in your os
         try:
             self._libtoxcore = CDLL('libtoxcore.so')
         except:
             self._libtoxcore = CDLL(util.curr_directory() +
                                     '/libs/libtoxcore.so')
Пример #9
0
 def __init__(self):
     if system() == 'Windows':
         self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
     elif system() == 'Darwin':
         self._libtoxcore = CDLL('libtoxcore.dylib')
     else:
         # libtoxcore and libsodium must be installed in your os
         try:
             self._libtoxcore = CDLL('libtoxcore.so')
         except:
             self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtoxcore.so')
Пример #10
0
 def __init__(self):
     if system() == 'Windows':
         # on Windows av api is in libtox.dll
         self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         # /usr/lib/libtoxav.so must exists
         try:
             self._libtoxav = CDLL('libtoxav.so')
         except:
             self._libtoxav = CDLL(util.curr_directory() +
                                   '/libs/libtoxav.so')
Пример #11
0
 def __init__(self):
     if system() == 'Windows':
         # on Windows av api is in libtox.dll
         self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
     elif system() == 'Darwin':
         self._libtoxav = CDLL('libtoxav.dylib')
     else:
         # /usr/lib/libtoxav.so must exists
         try:
             self._libtoxav = CDLL('libtoxav.so')
         except:
             self._libtoxav = CDLL(util.curr_directory() + '/libs/libtoxav.so')
Пример #12
0
 def __init__(self):
     if system() == 'Windows':
         # on Windows profile encryption api is in libtox.dll
         self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
     elif system() == 'Darwin':
         self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.dylib')
     else:
         # /usr/lib/libtoxencryptsave.so must exists
         try:
             self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
         except:
             self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtoxencryptsave.so')
Пример #13
0
 def __init__(self):
     if system() == 'Windows':
         # on Windows profile encryption api is in libtox.dll
         self._lib_tox_encrypt_save = CDLL(util.curr_directory() +
                                           '/libs/libtox.dll')
     else:
         # /usr/lib/libtoxencryptsave.so must exists
         try:
             self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
         except:
             self._lib_tox_encrypt_save = CDLL(util.curr_directory() +
                                               '/libs/libtoxencryptsave.so')
Пример #14
0
    def import_sm(self):
        directory = QtGui.QFileDialog.getExistingDirectory(self,
                                                           QtGui.QApplication.translate("MainWindow",
                                                                                        'Choose folder with smiley pack',
                                                                                        None,
                                                                                        QtGui.QApplication.UnicodeUTF8),
                                                           curr_directory(),
                                                           QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog)

        if directory:
            src = directory + '/'
            dest = curr_directory() + '/smileys/' + os.path.basename(directory) + '/'
            copy(src, dest)
Пример #15
0
def sound_notification(t):
    """
    Plays sound notification
    :param t: type of notification
    """
    if t == SOUND_NOTIFICATION['MESSAGE']:
        f = curr_directory() + '/sounds/message.wav'
    elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
        f = curr_directory() + '/sounds/file.wav'
    else:
        f = curr_directory() + '/sounds/contact.wav'
    a = AudioFile(f)
    a.play()
    a.close()
Пример #16
0
def sound_notification(t):
    """
    Plays sound notification
    :param t: type of notification
    """
    if t == SOUND_NOTIFICATION['MESSAGE']:
        f = curr_directory() + '/sounds/message.wav'
    elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
        f = curr_directory() + '/sounds/file.wav'
    else:
        f = curr_directory() + '/sounds/contact.wav'
    a = AudioFile(f)
    a.play()
    a.close()
Пример #17
0
def generate_nodes():
    with open(curr_directory() + '/nodes.json', 'rt') as fl:
        json_nodes = json.loads(fl.read())['nodes']
    nodes = map(lambda json_node: Node(json_node), json_nodes)
    sorted_nodes = sorted(nodes, key=lambda x: x.priority)[-4:]
    for node in sorted_nodes:
        yield node.get_data()
Пример #18
0
            def run(self):
                class AudioFile:
                    chunk = 1024

                    def __init__(self, fl):
                        self.stop = False
                        self.fl = fl
                        self.wf = wave.open(self.fl, 'rb')
                        self.p = pyaudio.PyAudio()
                        self.stream = self.p.open(
                            format=self.p.get_format_from_width(
                                self.wf.getsampwidth()),
                            channels=self.wf.getnchannels(),
                            rate=self.wf.getframerate(),
                            output=True)

                    def play(self):
                        while not self.stop:
                            data = self.wf.readframes(self.chunk)
                            while data and not self.stop:
                                self.stream.write(data)
                                data = self.wf.readframes(self.chunk)
                            self.wf = wave.open(self.fl, 'rb')

                    def close(self):
                        self.stream.close()
                        self.p.terminate()

                self.a = AudioFile(curr_directory() + '/sounds/call.wav')
                self.a.play()
                self.a.close()
Пример #19
0
def get_params(url, version):
    if is_from_sources():
        return ['python3', 'toxygen_updater.py', url, version]
    elif platform.system() == 'Windows':
        return [util.curr_directory() + '/toxygen_updater.exe', url, version]
    else:
        return ['./toxygen_updater', url, version]
Пример #20
0
 def accept_or_pause_transfer(self, friend_number, file_number, size):
     if self.state == TOX_FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']:
         directory = QtGui.QFileDialog.getExistingDirectory(
             self,
             QtGui.QApplication.translate("MainWindow", 'Choose folder',
                                          None,
                                          QtGui.QApplication.UnicodeUTF8),
             curr_directory(), QtGui.QFileDialog.ShowDirsOnly
             | QtGui.QFileDialog.DontUseNativeDialog)
         self.pb.setVisible(True)
         if directory:
             pr = profile.Profile.get_instance()
             pr.accept_transfer(self, directory + '/' + self.saved_name,
                                friend_number, file_number, size)
             self.button_update('pause')
     elif self.state == TOX_FILE_TRANSFER_STATE['PAUSED_BY_USER']:  # resume
         self.paused = False
         profile.Profile.get_instance().resume_transfer(
             friend_number, file_number)
         self.button_update('pause')
         self.state = TOX_FILE_TRANSFER_STATE['RUNNING']
     else:  # pause
         self.paused = True
         self.state = TOX_FILE_TRANSFER_STATE['PAUSED_BY_USER']
         profile.Profile.get_instance().pause_transfer(
             friend_number, file_number)
         self.button_update('resume')
     self.accept_or_pause.clearFocus()
Пример #21
0
            def run(self):
                class AudioFile:
                    chunk = 1024

                    def __init__(self, fl):
                        self.stop = False
                        self.fl = fl
                        self.wf = wave.open(self.fl, 'rb')
                        self.p = pyaudio.PyAudio()
                        self.stream = self.p.open(
                            format=self.p.get_format_from_width(self.wf.getsampwidth()),
                            channels=self.wf.getnchannels(),
                            rate=self.wf.getframerate(),
                            output=True)

                    def play(self):
                        while not self.stop:
                            data = self.wf.readframes(self.chunk)
                            while data and not self.stop:
                                self.stream.write(data)
                                data = self.wf.readframes(self.chunk)
                            self.wf = wave.open(self.fl, 'rb')

                    def close(self):
                        self.stream.close()
                        self.p.terminate()

                self.a = AudioFile(curr_directory() + '/sounds/call.wav')
                self.a.play()
                self.a.close()
Пример #22
0
    def mouseReleaseEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton and self._resize_needed:  # scale inline
            if self._full_size:
                pixmap = self._pixmap.scaled(self._max_size, self._max_size, QtCore.Qt.KeepAspectRatio)
                self._image_label.setPixmap(pixmap)
                self.resize(QtCore.QSize(self._max_size, pixmap.height()))
                self._image_label.setGeometry(5, 0, pixmap.width(), pixmap.height())
            else:
                self._image_label.setPixmap(self._pixmap)
                self.resize(QtCore.QSize(self._max_size, self._pixmap.height() + 17))
                self._image_label.setGeometry(5, 0, self._pixmap.width(), self._pixmap.height())
            self._full_size = not self._full_size
            self._elem.setSizeHint(QtCore.QSize(self.width(), self.height()))
        elif event.button() == QtCore.Qt.RightButton:  # save inline
            directory = QtGui.QFileDialog.getExistingDirectory(self,
                                                               QtGui.QApplication.translate("MainWindow",
                                                                                            'Choose folder', None,
                                                                                            QtGui.QApplication.UnicodeUTF8),
                                                               curr_directory(),
                                                               QtGui.QFileDialog.ShowDirsOnly)
            if directory:
                fl = QtCore.QFile(directory + '/toxygen_inline_' + curr_time().replace(':', '_') + '.png')
                self._pixmap.save(fl, 'PNG')

        return False
Пример #23
0
 def closeEvent(self, event):
     settings = Settings.get_instance()
     settings['theme'] = str(self.themeSelect.currentText())
     settings['smileys'] = self.smileys.isChecked()
     if settings['mirror_mode'] != self.mirror_mode.isChecked():
         settings['mirror_mode'] = self.mirror_mode.isChecked()
         msgBox = QtGui.QMessageBox()
         text = QtGui.QApplication.translate(
             "interfaceForm", 'Restart app to apply settings', None,
             QtGui.QApplication.UnicodeUTF8)
         msgBox.setWindowTitle(
             QtGui.QApplication.translate("interfaceForm",
                                          'Restart required', None,
                                          QtGui.QApplication.UnicodeUTF8))
         msgBox.setText(text)
         msgBox.exec_()
     settings['smiley_pack'] = self.smiley_pack.currentText()
     smileys.SmileyLoader.get_instance().load_pack()
     language = self.lang_choose.currentText()
     if settings['language'] != language:
         settings['language'] = language
         text = self.lang_choose.currentText()
         path = Settings.supported_languages()[text]
         app = QtGui.QApplication.instance()
         app.removeTranslator(app.translator)
         app.translator.load(curr_directory() + '/translations/' + path)
         app.installTranslator(app.translator)
     settings['message_font_size'] = self.messages_font_size.currentIndex(
     ) + 10
     Profile.get_instance().update()
     settings.save()
Пример #24
0
    def __init__(self, text, time, user="", sent=True, message_type=TOX_MESSAGE_TYPE["NORMAL"], parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.name = DataLabel(self)
        self.name.setGeometry(QtCore.QRect(2, 2, 95, 23))
        self.name.setTextFormat(QtCore.Qt.PlainText)
        font = QtGui.QFont()
        font.setFamily(settings.Settings.get_instance()["font"])
        font.setPointSize(11)
        font.setBold(True)
        self.name.setFont(font)
        self.name.setText(user)

        self.time = QtGui.QLabel(self)
        self.time.setGeometry(QtCore.QRect(parent.width() - 60, 0, 50, 25))
        font.setPointSize(10)
        font.setBold(False)
        self.time.setFont(font)
        self._time = time
        if not sent:
            movie = QtGui.QMovie(curr_directory() + "/images/spinner.gif")
            self.time.setMovie(movie)
            movie.start()
            self.t = True
        else:
            self.time.setText(convert_time(time))
            self.t = False

        self.message = MessageEdit(text, parent.width() - 160, message_type, self)
        if message_type != TOX_MESSAGE_TYPE["NORMAL"]:
            self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
            self.message.setAlignment(QtCore.Qt.AlignCenter)
            self.time.setStyleSheet("QLabel { color: #5CB3FF; }")
        self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 160, self.message.height()))
        self.setFixedHeight(self.message.height())
Пример #25
0
    def mouseReleaseEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton and self._resize_needed:  # scale inline
            if self._full_size:
                pixmap = self._pixmap.scaled(self._max_size, self._max_size, QtCore.Qt.KeepAspectRatio)
                self._image_label.setPixmap(pixmap)
                self.resize(QtCore.QSize(self._max_size, pixmap.height()))
                self._image_label.setGeometry(5, 0, pixmap.width(), pixmap.height())
            else:
                self._image_label.setPixmap(self._pixmap)
                self.resize(QtCore.QSize(self._max_size, self._pixmap.height() + 17))
                self._image_label.setGeometry(5, 0, self._pixmap.width(), self._pixmap.height())
            self._full_size = not self._full_size
            self._elem.setSizeHint(QtCore.QSize(self.width(), self.height()))
        elif event.button() == QtCore.Qt.RightButton:  # save inline
            directory = QtGui.QFileDialog.getExistingDirectory(
                self,
                QtGui.QApplication.translate("MainWindow", "Choose folder", None, QtGui.QApplication.UnicodeUTF8),
                curr_directory(),
                QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog,
            )
            if directory:
                fl = QtCore.QFile(directory + "/toxygen_inline_" + curr_time().replace(":", "_") + ".png")
                self._pixmap.save(fl, "PNG")

        return False
Пример #26
0
    def import_plugin(self):
        import util

        directory = QtGui.QFileDialog.getExistingDirectory(
            self,
            QtGui.QApplication.translate(
                "MainWindow", "Choose folder with plugin", None, QtGui.QApplication.UnicodeUTF8
            ),
            util.curr_directory(),
            QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog,
        )
        if directory:
            src = directory + "/"
            dest = curr_directory() + "/plugins/"
            util.copy(src, dest)
            msgBox = QtGui.QMessageBox()
            msgBox.setWindowTitle(
                QtGui.QApplication.translate("MainWindow", "Restart Toxygen", None, QtGui.QApplication.UnicodeUTF8)
            )
            msgBox.setText(
                QtGui.QApplication.translate(
                    "MainWindow", "Plugin will be loaded after restart", None, QtGui.QApplication.UnicodeUTF8
                )
            )
            msgBox.exec_()
Пример #27
0
    def __init__(self, text, time, user='', sent=True, message_type=TOX_MESSAGE_TYPE['NORMAL'], parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.name = DataLabel(self)
        self.name.setGeometry(QtCore.QRect(2, 2, 95, 23))
        self.name.setTextFormat(QtCore.Qt.PlainText)
        font = QtGui.QFont()
        font.setFamily(settings.Settings.get_instance()['font'])
        font.setPointSize(11)
        font.setBold(True)
        self.name.setFont(font)
        self.name.setText(user)

        self.time = QtWidgets.QLabel(self)
        self.time.setGeometry(QtCore.QRect(parent.width() - 60, 0, 50, 25))
        font.setPointSize(10)
        font.setBold(False)
        self.time.setFont(font)
        self._time = time
        if not sent:
            movie = QtGui.QMovie(curr_directory() + '/images/spinner.gif')
            self.time.setMovie(movie)
            movie.start()
            self.t = True
        else:
            self.time.setText(convert_time(time))
            self.t = False

        self.message = MessageEdit(text, parent.width() - 160, message_type, self)
        if message_type != TOX_MESSAGE_TYPE['NORMAL']:
            self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
            self.message.setAlignment(QtCore.Qt.AlignCenter)
            self.time.setStyleSheet("QLabel { color: #5CB3FF; }")
        self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 160, self.message.height()))
        self.setFixedHeight(self.message.height())
Пример #28
0
def get_params(url, version):
    if is_from_sources():
        return ['python3', 'toxygen_updater.py', url, version]
    elif platform.system() == 'Windows':
        return [util.curr_directory() + '/toxygen_updater.exe', url, version]
    else:
        return ['./toxygen_updater', url, version]
Пример #29
0
 def copy_public_key(self):
     clipboard = QtGui.QApplication.clipboard()
     profile = Profile.get_instance()
     clipboard.setText(profile.tox_id[:64])
     pixmap = QtGui.QPixmap(curr_directory() + '/images/accept.png')
     icon = QtGui.QIcon(pixmap)
     self.copy_pk.setIcon(icon)
     self.copy_pk.setIconSize(QtCore.QSize(10, 10))
Пример #30
0
 def __init__(self):
     if system() == 'Linux':
         # libtoxcore and libsodium must be installed in your os
         self._libtoxcore = CDLL('libtoxcore.so')
     elif system() == 'Windows':
         self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #31
0
 def __init__(self, file_name, size, user, time, width, parent=None):
     super(UnsentFileItem, self).__init__(file_name, size, time, user, -1, -1,
                                          TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND'], width, parent)
     self._time = time
     self.pb.setVisible(False)
     movie = QtGui.QMovie(curr_directory() + '/images/spinner.gif')
     self.time.setMovie(movie)
     movie.start()
Пример #32
0
 def copy(self):
     clipboard = QtGui.QApplication.clipboard()
     profile = Profile.get_instance()
     clipboard.setText(profile.tox_id)
     pixmap = QtGui.QPixmap(curr_directory() + '/images/accept.png')
     icon = QtGui.QIcon(pixmap)
     self.copyId.setIcon(icon)
     self.copyId.setIconSize(QtCore.QSize(10, 10))
Пример #33
0
 def __init__(self):
     if system() == 'Linux':
         # libtoxcore and libsodium must be installed in your os
         self._libtoxcore = CDLL('libtoxcore.so')
     elif system() == 'Windows':
         self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #34
0
 def __init__(self, file_name, size, user, time, width, parent=None):
     super(UnsentFileItem, self).__init__(file_name, size, time, user, -1, -1,
                                          TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND'], width, parent)
     self._time = time
     self.pb.setVisible(False)
     movie = QtGui.QMovie(curr_directory() + '/images/spinner.gif')
     self.time.setMovie(movie)
     movie.start()
Пример #35
0
 def load_avatar(self):
     path = util.curr_directory() + '/images/group.png'
     width = self._widget.avatar_label.width()
     pixmap = QtGui.QPixmap(path)
     self._widget.avatar_label.setPixmap(
         pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio,
                       QtCore.Qt.SmoothTransformation))
     self._widget.avatar_label.repaint()
Пример #36
0
 def __init__(self):
     if system() == 'Linux':
         # /usr/lib/libtoxencryptsave.so must exists
         self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
     elif system() == 'Windows':
         # on Windows profile encryption api is in libtox.dll
         self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #37
0
 def __init__(self):
     if system() == 'Linux':
         # that /usr/lib/libtoxav.so must exists
         self._libtoxav = CDLL('libtoxav.so')
     elif system() == 'Windows':
         # on Windows av api is in libtox.dll
         self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #38
0
 def __init__(self):
     if system() == 'Linux':
         # that /usr/lib/libtoxav.so must exists
         self._libtoxav = CDLL('libtoxav.so')
     elif system() == 'Windows':
         # on Windows av api is in libtox.dll
         self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #39
0
def download(version):
    os.chdir(util.curr_directory())
    url = get_url(version)
    params = get_params(url, version)
    print('Updating Toxygen')
    util.log('Updating Toxygen')
    try:
        subprocess.Popen(params)
    except Exception as ex:
        util.log('Exception: running updater failed with ' + str(ex))
Пример #40
0
 def __init__(self):
     if system() == 'Linux':
         # /usr/lib/libtoxencryptsave.so must exists
         self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
     elif system() == 'Windows':
         # on Windows profile encryption api is in libtox.dll
         self._lib_tox_encrypt_save = CDLL(util.curr_directory() +
                                           '/libs/libtox.dll')
     else:
         raise OSError('Unknown system.')
Пример #41
0
def download(version):
    os.chdir(util.curr_directory())
    url = get_url(version)
    params = get_params(url, version)
    print('Updating Toxygen')
    util.log('Updating Toxygen')
    try:
        subprocess.Popen(params)
    except Exception as ex:
        util.log('Exception: running updater failed with ' + str(ex))
Пример #42
0
    def initUI(self):
        self.setObjectName("privacySettings")
        self.resize(370, 600)
        self.setMinimumSize(QtCore.QSize(370, 600))
        self.setMaximumSize(QtCore.QSize(370, 600))
        self.saveHistory = QtGui.QCheckBox(self)
        self.saveHistory.setGeometry(QtCore.QRect(10, 20, 350, 22))
        self.saveUnsentOnly = QtGui.QCheckBox(self)
        self.saveUnsentOnly.setGeometry(QtCore.QRect(10, 60, 350, 22))

        self.fileautoaccept = QtGui.QCheckBox(self)
        self.fileautoaccept.setGeometry(QtCore.QRect(10, 100, 350, 22))

        self.typingNotifications = QtGui.QCheckBox(self)
        self.typingNotifications.setGeometry(QtCore.QRect(10, 140, 350, 30))
        self.inlines = QtGui.QCheckBox(self)
        self.inlines.setGeometry(QtCore.QRect(10, 180, 350, 30))
        self.auto_path = QtGui.QLabel(self)
        self.auto_path.setGeometry(QtCore.QRect(10, 230, 350, 30))
        self.path = QtGui.QPlainTextEdit(self)
        self.path.setGeometry(QtCore.QRect(10, 265, 330, 45))
        self.change_path = QtGui.QPushButton(self)
        self.change_path.setGeometry(QtCore.QRect(10, 320, 350, 30))
        settings = Settings.get_instance()
        self.typingNotifications.setChecked(settings['typing_notifications'])
        self.fileautoaccept.setChecked(settings['allow_auto_accept'])
        self.saveHistory.setChecked(settings['save_history'])
        self.inlines.setChecked(settings['allow_inline'])
        self.saveUnsentOnly.setChecked(settings['save_unsent_only'])
        self.saveUnsentOnly.setEnabled(settings['save_history'])
        self.saveHistory.stateChanged.connect(self.update)
        self.path.setPlainText(settings['auto_accept_path']
                               or curr_directory())
        self.change_path.clicked.connect(self.new_path)
        self.block_user_label = QtGui.QLabel(self)
        self.block_user_label.setGeometry(QtCore.QRect(10, 360, 350, 30))
        self.block_id = QtGui.QPlainTextEdit(self)
        self.block_id.setGeometry(QtCore.QRect(10, 390, 350, 30))
        self.block = QtGui.QPushButton(self)
        self.block.setGeometry(QtCore.QRect(10, 430, 350, 30))
        self.block.clicked.connect(lambda: Profile.get_instance().block_user(
            self.block_id.toPlainText()) or self.close())
        self.blocked_users_label = QtGui.QLabel(self)
        self.blocked_users_label.setGeometry(QtCore.QRect(10, 470, 350, 30))
        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setGeometry(QtCore.QRect(10, 500, 350, 30))
        self.comboBox.addItems(settings['blocked'])
        self.unblock = QtGui.QPushButton(self)
        self.unblock.setGeometry(QtCore.QRect(10, 540, 350, 30))
        self.unblock.clicked.connect(lambda: self.unblock_user())
        self.retranslateUi()
        QtCore.QMetaObject.connectSlotsByName(self)
Пример #43
0
def sticker_loader():
    """
    :return list of stickers
    """
    result = []
    d = util.curr_directory() + '/stickers/'
    keys = [x[1] for x in os.walk(d)][0]
    for key in keys:
        path = d + key + '/'
        files = filter(lambda f: f.endswith('.png'), os.listdir(path))
        files = map(lambda f: str(path + f), files)
        result.extend(files)
    return result
Пример #44
0
def sticker_loader():
    """
    :return list of stickers
    """
    result = []
    d = util.curr_directory() + '/stickers/'
    keys = [x[1] for x in os.walk(d)][0]
    for key in keys:
        path = d + key + '/'
        files = filter(lambda f: f.endswith('.png'), os.listdir(path))
        files = map(lambda f: str(path + f), files)
        result.extend(files)
    return result
Пример #45
0
    def initUI(self):
        self.setObjectName("privacySettings")
        self.resize(370, 600)
        self.setMinimumSize(QtCore.QSize(370, 600))
        self.setMaximumSize(QtCore.QSize(370, 600))
        self.saveHistory = QtGui.QCheckBox(self)
        self.saveHistory.setGeometry(QtCore.QRect(10, 20, 350, 22))
        self.saveUnsentOnly = QtGui.QCheckBox(self)
        self.saveUnsentOnly.setGeometry(QtCore.QRect(10, 60, 350, 22))

        self.fileautoaccept = QtGui.QCheckBox(self)
        self.fileautoaccept.setGeometry(QtCore.QRect(10, 100, 350, 22))

        self.typingNotifications = QtGui.QCheckBox(self)
        self.typingNotifications.setGeometry(QtCore.QRect(10, 140, 350, 30))
        self.inlines = QtGui.QCheckBox(self)
        self.inlines.setGeometry(QtCore.QRect(10, 180, 350, 30))
        self.auto_path = QtGui.QLabel(self)
        self.auto_path.setGeometry(QtCore.QRect(10, 230, 350, 30))
        self.path = QtGui.QPlainTextEdit(self)
        self.path.setGeometry(QtCore.QRect(10, 265, 350, 45))
        self.change_path = QtGui.QPushButton(self)
        self.change_path.setGeometry(QtCore.QRect(10, 320, 350, 30))
        settings = Settings.get_instance()
        self.typingNotifications.setChecked(settings['typing_notifications'])
        self.fileautoaccept.setChecked(settings['allow_auto_accept'])
        self.saveHistory.setChecked(settings['save_history'])
        self.inlines.setChecked(settings['allow_inline'])
        self.saveUnsentOnly.setChecked(settings['save_unsent_only'])
        self.saveUnsentOnly.setEnabled(settings['save_history'])
        self.saveHistory.stateChanged.connect(self.update)
        self.path.setPlainText(settings['auto_accept_path'] or curr_directory())
        self.change_path.clicked.connect(self.new_path)
        self.block_user_label = QtGui.QLabel(self)
        self.block_user_label.setGeometry(QtCore.QRect(10, 360, 350, 30))
        self.block_id = QtGui.QPlainTextEdit(self)
        self.block_id.setGeometry(QtCore.QRect(10, 390, 350, 30))
        self.block = QtGui.QPushButton(self)
        self.block.setGeometry(QtCore.QRect(10, 430, 350, 30))
        self.block.clicked.connect(lambda: Profile.get_instance().block_user(self.block_id.toPlainText()) or self.close())
        self.blocked_users_label = QtGui.QLabel(self)
        self.blocked_users_label.setGeometry(QtCore.QRect(10, 470, 350, 30))
        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setGeometry(QtCore.QRect(10, 500, 350, 30))
        self.comboBox.addItems(settings['blocked'])
        self.unblock = QtGui.QPushButton(self)
        self.unblock.setGeometry(QtCore.QRect(10, 540, 350, 30))
        self.unblock.clicked.connect(lambda: self.unblock_user())
        self.retranslateUi()
        QtCore.QMetaObject.connectSlotsByName(self)
Пример #46
0
 def load_avatar(self):
     """
     Tries to load avatar of contact or uses default avatar
     """
     avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2])
     os.chdir(ProfileHelper.get_path() + 'avatars/')
     if not os.path.isfile(avatar_path):  # load default image
         avatar_path = 'avatar.png'
         os.chdir(curr_directory() + '/images/')
     pixmap = QtGui.QPixmap(QtCore.QSize(64, 64))
     pixmap.load(avatar_path)
     self._widget.avatar_label.setScaledContents(False)
     self._widget.avatar_label.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio))
     self._widget.avatar_label.repaint()
Пример #47
0
 def load(self):
     """
     Load all plugins in plugins folder
     """
     path = util.curr_directory() + '/plugins/'
     if not os.path.exists(path):
         util.log('Plugin dir not found')
         return
     else:
         sys.path.append(path)
     files = [
         f for f in os.listdir(path)
         if os.path.isfile(os.path.join(path, f))
     ]
     for fl in files:
         if fl in ('plugin_super_class.py',
                   '__init__.py') or not fl.endswith('.py'):
             continue
         name = fl[:-3]  # module name without .py
         try:
             module = importlib.import_module(name)  # import plugin
         except ImportError:
             util.log('Import error in module ' + name)
             continue
         except Exception as ex:
             util.log('Exception in module ' + name + ' Exception: ' +
                      str(ex))
             continue
         for elem in dir(module):
             obj = getattr(module, elem)
             if inspect.isclass(obj) and hasattr(
                     obj, 'is_plugin'
             ) and obj.is_plugin:  # looking for plugin class in module
                 print('Plugin', elem)
                 try:  # create instance of plugin class
                     inst = obj(self._tox, self._profile, self._settings,
                                self._encr)
                     autostart = inst.get_short_name(
                     ) in self._settings['plugins']
                     if autostart:
                         inst.start()
                 except Exception as ex:
                     util.log('Exception in module ' + name +
                              ' Exception: ' + str(ex))
                     continue
                 self._plugins[inst.get_short_name()] = [
                     inst, autostart
                 ]  # (inst, is active)
                 break
Пример #48
0
 def closeEvent(self, event):
     settings = Settings.get_instance()
     style = str(self.themeSelect.currentText())
     settings['theme'] = style
     QtGui.QApplication.setStyle(get_style(style))
     language = self.lang_choose.currentText()
     if settings['language'] != language:
         settings['language'] = language
         index = self.lang_choose.currentIndex()
         path = Settings.supported_languages()[index][1]
         app = QtGui.QApplication.instance()
         app.removeTranslator(app.translator)
         app.translator.load(curr_directory() + '/translations/' + path)
         app.installTranslator(app.translator)
     settings.save()
Пример #49
0
 def load_avatar(self):
     """
     Tries to load avatar of contact or uses default avatar
     """
     avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2])
     os.chdir(ProfileHelper.get_path() + 'avatars/')
     if not os.path.isfile(avatar_path):  # load default image
         avatar_path = 'avatar.png'
         os.chdir(curr_directory() + '/images/')
     pixmap = QtGui.QPixmap(QtCore.QSize(64, 64))
     pixmap.load(avatar_path)
     self._widget.avatar_label.setScaledContents(False)
     self._widget.avatar_label.setPixmap(
         pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio))
     self._widget.avatar_label.repaint()
Пример #50
0
 def __init__(self):
     self.path = curr_directory() + '/settings.json'
     if os.path.isfile(self.path):
         with open(self.path) as fl:
             data = fl.read()
         super(self.__class__, self).__init__(json.loads(data))
     else:
         super(self.__class__, self).__init__(Settings.get_default_settings())
     self['read'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['read']))
     self['write'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['write']))
     self['delete'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['delete']))
     self['master'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['master']))
     if self['folder'][-1] == '/' or self['folder'][-1] == '\\':
         self['folder'] = self['folder'][:-1]
     self.save()
Пример #51
0
 def __init__(self):
     self.path = curr_directory() + '/settings.json'
     if os.path.isfile(self.path):
         with open(self.path) as fl:
             data = fl.read()
         super(self.__class__, self).__init__(json.loads(data))
     else:
         super(self.__class__, self).__init__(Settings.get_default_settings())
     self['read'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['read']))
     self['write'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['write']))
     self['delete'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['delete']))
     self['master'] = map(lambda x: x[:TOX_PUBLIC_KEY_SIZE * 2], set(self['master']))
     if self['folder'][-1] == '/' or self['folder'][-1] == '\\':
         self['folder'] = self['folder'][:-1]
     self.save()
Пример #52
0
 def find_profiles():
     path = Settings.get_default_path()
     result = []
     # check default path
     if not os.path.exists(path):
         os.makedirs(path)
     for fl in os.listdir(path):
         if fl.endswith('.tox'):
             name = fl[:-4]
             result.append((path, name))
     path = curr_directory()
     # check current directory
     for fl in os.listdir(path):
         if fl.endswith('.tox'):
             name = fl[:-4]
             result.append((path + '/', name))
     return result
Пример #53
0
    def __init__(self, messages, width, *args):
        super().__init__(*args)
        self.setMaximumSize(width, 40)
        self.setMinimumSize(width, 40)
        self._messages = messages

        self.search_text = LineEdit(self)
        self.search_text.setGeometry(0, 0, width - 160, 40)

        self.search_button = ClickableLabel(self)
        self.search_button.setGeometry(width - 160, 0, 40, 40)
        pixmap = QtGui.QPixmap()
        pixmap.load(util.curr_directory() + '/images/search.png')
        self.search_button.setScaledContents(False)
        self.search_button.setAlignment(QtCore.Qt.AlignCenter)
        self.search_button.setPixmap(pixmap)
        self.connect(self.search_button, QtCore.SIGNAL('clicked()'),
                     self.search)

        font = QtGui.QFont()
        font.setPointSize(32)
        font.setBold(True)

        self.prev_button = QtGui.QPushButton(self)
        self.prev_button.setGeometry(width - 120, 0, 40, 40)
        self.prev_button.clicked.connect(self.prev)
        self.prev_button.setText('\u25B2')

        self.next_button = QtGui.QPushButton(self)
        self.next_button.setGeometry(width - 80, 0, 40, 40)
        self.next_button.clicked.connect(self.next)
        self.next_button.setText('\u25BC')

        self.close_button = QtGui.QPushButton(self)
        self.close_button.setGeometry(width - 40, 0, 40, 40)
        self.close_button.clicked.connect(self.close)
        self.close_button.setText('×')
        self.close_button.setFont(font)

        font.setPointSize(18)
        self.next_button.setFont(font)
        self.prev_button.setFont(font)

        self.retranslateUi()
Пример #54
0
def configure():
    """Removes unused libs"""
    d = curr_directory() + "/libs/"
    is_64bits = is_64_bit()
    if not is_64bits:
        if os.path.exists(d + "libtox64.dll"):
            os.remove(d + "libtox64.dll")
        if os.path.exists(d + "libsodium64.a"):
            os.remove(d + "libsodium64.a")
    else:
        if os.path.exists(d + "libtox.dll"):
            os.remove(d + "libtox.dll")
        if os.path.exists(d + "libsodium.a"):
            os.remove(d + "libsodium.a")
        try:
            os.rename(d + "libtox64.dll", d + "libtox.dll")
            os.rename(d + "libsodium64.a", d + "libsodium.a")
        except:
            pass
Пример #55
0
    def __init__(self, messages, width, *args):
        super().__init__(*args)
        self.setMaximumSize(width, 40)
        self.setMinimumSize(width, 40)
        self._messages = messages

        self.search_text = LineEdit(self)
        self.search_text.setGeometry(0, 0, width - 160, 40)

        self.search_button = ClickableLabel(self)
        self.search_button.setGeometry(width - 160, 0, 40, 40)
        pixmap = QtGui.QPixmap()
        pixmap.load(util.curr_directory() + '/images/search.png')
        self.search_button.setScaledContents(False)
        self.search_button.setAlignment(QtCore.Qt.AlignCenter)
        self.search_button.setPixmap(pixmap)
        self.connect(self.search_button, QtCore.SIGNAL('clicked()'), self.search)

        font = QtGui.QFont()
        font.setPointSize(32)
        font.setBold(True)

        self.prev_button = QtGui.QPushButton(self)
        self.prev_button.setGeometry(width - 120, 0, 40, 40)
        self.prev_button.clicked.connect(self.prev)
        self.prev_button.setText('\u25B2')

        self.next_button = QtGui.QPushButton(self)
        self.next_button.setGeometry(width - 80, 0, 40, 40)
        self.next_button.clicked.connect(self.next)
        self.next_button.setText('\u25BC')

        self.close_button = QtGui.QPushButton(self)
        self.close_button.setGeometry(width - 40, 0, 40, 40)
        self.close_button.clicked.connect(self.close)
        self.close_button.setText('×')
        self.close_button.setFont(font)

        font.setPointSize(18)
        self.next_button.setFont(font)
        self.prev_button.setFont(font)

        self.retranslateUi()
Пример #56
0
def configure():
    """Removes unused libs"""
    d = curr_directory() + '/libs/'
    is_64bits = sys.maxsize > 2 ** 32
    if not is_64bits:
        if os.path.exists(d + 'libtox64.dll'):
            os.remove(d + 'libtox64.dll')
        if os.path.exists(d + 'libsodium64.a'):
            os.remove(d + 'libsodium64.a')
    else:
        if os.path.exists(d + 'libtox.dll'):
            os.remove(d + 'libtox.dll')
        if os.path.exists(d + 'libsodium.a'):
            os.remove(d + 'libsodium.a')
        try:
            os.rename(d + 'libtox64.dll', d + 'libtox.dll')
            os.rename(d + 'libsodium64.a', d + 'libsodium.a')
        except:
            pass
Пример #57
0
 def find_profiles():
     """
     Find available tox profiles
     """
     path = Settings.get_default_path()
     result = []
     # check default path
     if not os.path.exists(path):
         os.makedirs(path)
     for fl in os.listdir(path):
         if fl.endswith('.tox'):
             name = fl[:-4]
             result.append((path, name))
     path = curr_directory()
     # check current directory
     for fl in os.listdir(path):
         if fl.endswith('.tox'):
             name = fl[:-4]
             result.append((path + '/', name))
     return result
Пример #58
0
 def update(self, status, unread_messages=None):
     if unread_messages is None:
         unread_messages = self.unread
     else:
         self.unread = unread_messages
     if status == TOX_USER_STATUS['NONE']:
         name = 'online'
     elif status == TOX_USER_STATUS['AWAY']:
         name = 'idle'
     elif status == TOX_USER_STATUS['BUSY']:
         name = 'busy'
     else:
         name = 'offline'
     if unread_messages:
         name += '_notification'
         self.label.setGeometry(QtCore.QRect(0, 0, 32, 32))
     else:
         self.label.setGeometry(QtCore.QRect(2, 0, 32, 32))
     pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(name))
     self.label.setPixmap(pixmap)
Пример #59
0
 def update(self, status, unread_messages=None):
     if unread_messages is None:
         unread_messages = self.unread
     else:
         self.unread = unread_messages
     if status == TOX_USER_STATUS["NONE"]:
         name = "online"
     elif status == TOX_USER_STATUS["AWAY"]:
         name = "idle"
     elif status == TOX_USER_STATUS["BUSY"]:
         name = "busy"
     else:
         name = "offline"
     if unread_messages:
         name += "_notification"
         self.label.setGeometry(QtCore.QRect(0, 0, 32, 32))
     else:
         self.label.setGeometry(QtCore.QRect(2, 0, 32, 32))
     pixmap = QtGui.QPixmap(curr_directory() + "/images/{}.png".format(name))
     self.label.setPixmap(pixmap)