diff --git a/toxygen/main.py b/toxygen/main.py index 25eb716..9d7daba 100644 --- a/toxygen/main.py +++ b/toxygen/main.py @@ -94,6 +94,17 @@ class Toxygen: elif _login.t == 1: # create new profile _login.name = _login.name.strip() name = _login.name if _login.name else 'toxygen_user' + pr = map(lambda x: x[1], ProfileHelper.find_profiles()) + if name in list(pr): + msgBox = QtGui.QMessageBox() + msgBox.setWindowTitle( + QtGui.QApplication.translate("MainWindow", "Error", None, QtGui.QApplication.UnicodeUTF8)) + text = (QtGui.QApplication.translate("MainWindow", + 'Profile with this name already exists', + None, QtGui.QApplication.UnicodeUTF8)) + msgBox.setText(text) + msgBox.exec_() + return self.tox = profile.tox_factory() self.tox.self_set_name(bytes(_login.name, 'utf-8') if _login.name else b'Toxygen User') self.tox.self_set_status_message(b'Toxing on Toxygen') diff --git a/toxygen/menu.py b/toxygen/menu.py index aa65c93..075040a 100644 --- a/toxygen/menu.py +++ b/toxygen/menu.py @@ -4,7 +4,7 @@ except ImportError: from PyQt4 import QtCore, QtGui from settings import * from profile import Profile -from util import curr_directory +from util import curr_directory, copy from widgets import CenteredWidget, DataLabel, LineEdit import pyaudio import toxencryptsave @@ -554,8 +554,8 @@ class InterfaceSettings(CenteredWidget): def initUI(self): self.setObjectName("interfaceForm") - self.setMinimumSize(QtCore.QSize(400, 450)) - self.setMaximumSize(QtCore.QSize(400, 450)) + self.setMinimumSize(QtCore.QSize(400, 550)) + self.setMaximumSize(QtCore.QSize(400, 550)) self.label = QtGui.QLabel(self) self.label.setGeometry(QtCore.QRect(30, 10, 370, 20)) font = QtGui.QFont() @@ -610,13 +610,21 @@ class InterfaceSettings(CenteredWidget): self.messages_font_size.setCurrentIndex(settings['message_font_size'] - 10) self.unread = QtGui.QPushButton(self) - self.unread.setGeometry(QtCore.QRect(30, 380, 340, 30)) + self.unread.setGeometry(QtCore.QRect(30, 425, 340, 30)) self.unread.clicked.connect(self.select_color) self.compact_mode = QtGui.QCheckBox(self) - self.compact_mode.setGeometry(QtCore.QRect(30, 425, 370, 20)) + self.compact_mode.setGeometry(QtCore.QRect(30, 380, 370, 20)) self.compact_mode.setChecked(settings['compact_mode']) + self.import_smileys = QtGui.QPushButton(self) + self.import_smileys.setGeometry(QtCore.QRect(30, 465, 340, 30)) + self.import_smileys.clicked.connect(self.import_sm) + + self.import_stickers = QtGui.QPushButton(self) + self.import_stickers.setGeometry(QtCore.QRect(30, 505, 340, 30)) + self.import_stickers.clicked.connect(self.import_st) + self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(self) @@ -630,6 +638,36 @@ class InterfaceSettings(CenteredWidget): self.messages_font_size_label.setText(QtGui.QApplication.translate("interfaceForm", "Messages font size:", None, QtGui.QApplication.UnicodeUTF8)) self.unread.setText(QtGui.QApplication.translate("interfaceForm", "Select unread messages notification color", None, QtGui.QApplication.UnicodeUTF8)) self.compact_mode.setText(QtGui.QApplication.translate("interfaceForm", "Compact contact list", None, QtGui.QApplication.UnicodeUTF8)) + self.import_smileys.setText(QtGui.QApplication.translate("interfaceForm", "Import smiley pack", None, QtGui.QApplication.UnicodeUTF8)) + self.import_stickers.setText(QtGui.QApplication.translate("interfaceForm", "Import sticker pack", None, QtGui.QApplication.UnicodeUTF8)) + + def import_st(self): + directory = QtGui.QFileDialog.getExistingDirectory(self, + QtGui.QApplication.translate("MainWindow", + 'Choose folder with sticker pack', + None, + QtGui.QApplication.UnicodeUTF8), + curr_directory(), + QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog) + + if directory: + src = directory + '/' + dest = curr_directory() + '/stickers/' + os.path.basename(directory) + '/' + copy(src, dest) + + 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) def select_color(self): col = QtGui.QColorDialog.getColor()