deps creation - improvements. db and history fixes. widgets creation - factory
This commit is contained in:
parent
a9d2d3d809
commit
e9272eee2a
18 changed files with 419 additions and 319 deletions
|
@ -11,7 +11,7 @@ from util.util import curr_directory
|
|||
class IncomingCallWidget(widgets.CenteredWidget):
|
||||
|
||||
def __init__(self, friend_number, text, name):
|
||||
super(IncomingCallWidget, self).__init__()
|
||||
super().__init__()
|
||||
self.setWindowFlags(QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowStaysOnTopHint)
|
||||
self.resize(QtCore.QSize(500, 270))
|
||||
self.avatar_label = QtWidgets.QLabel(self)
|
||||
|
|
|
@ -360,7 +360,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
if self._saved:
|
||||
return
|
||||
self._saved = True
|
||||
self.profile.save_history()
|
||||
self.profile.close()
|
||||
self._settings['x'] = self.geometry().x()
|
||||
self._settings['y'] = self.geometry().y()
|
||||
|
@ -500,7 +499,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
def show_menu(self):
|
||||
if not hasattr(self, 'menu'):
|
||||
self.menu = DropdownMenu(self)
|
||||
self.menu.setGeometry(QtCore.QRect(0 if Settings.get_instance()['mirror_mode'] else 270,
|
||||
self.menu.setGeometry(QtCore.QRect(0 if self._settings['mirror_mode'] else 270,
|
||||
self.height() - 120,
|
||||
180,
|
||||
120))
|
||||
|
|
|
@ -2,14 +2,16 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
from ui.widgets import RubberBandWindow, create_menu, QRightClickButton, CenteredWidget, LineEdit
|
||||
from contacts.profile import Profile
|
||||
import smileys
|
||||
import urllib
|
||||
import util.util as util
|
||||
import util.ui as util_ui
|
||||
|
||||
|
||||
class MessageArea(QtWidgets.QPlainTextEdit):
|
||||
"""User types messages here"""
|
||||
|
||||
def __init__(self, parent, form):
|
||||
super(MessageArea, self).__init__(parent)
|
||||
super().__init__(parent)
|
||||
self.parent = form
|
||||
self.setAcceptDrops(True)
|
||||
self.timer = QtCore.QTimer(self)
|
||||
|
@ -76,15 +78,18 @@ class MessageArea(QtWidgets.QPlainTextEdit):
|
|||
self.insertPlainText(text)
|
||||
|
||||
def parse_file_name(self, file_name):
|
||||
import urllib
|
||||
if file_name.endswith('\r\n'):
|
||||
file_name = file_name[:-2]
|
||||
file_name = urllib.parse.unquote(file_name)
|
||||
return file_name[8 if platform.system() == 'Windows' else 7:]
|
||||
return file_name[8 if util.get_platform() == 'Windows' else 7:]
|
||||
|
||||
|
||||
class ScreenShotWindow(RubberBandWindow):
|
||||
|
||||
def __init__(self, file_transfer_handler, *args):
|
||||
super().__init__(*args)
|
||||
self._file_transfer_handler = file_transfer_handler
|
||||
|
||||
def closeEvent(self, *args):
|
||||
if self.parent.isHidden():
|
||||
self.parent.show()
|
||||
|
@ -104,7 +109,7 @@ class ScreenShotWindow(RubberBandWindow):
|
|||
buffer = QtCore.QBuffer(byte_array)
|
||||
buffer.open(QtCore.QIODevice.WriteOnly)
|
||||
p.save(buffer, 'PNG')
|
||||
Profile.get_instance().send_screenshot(bytes(byte_array.data()))
|
||||
self._file_transfer_handler.send_screenshot(bytes(byte_array.data()))
|
||||
self.close()
|
||||
|
||||
|
||||
|
@ -113,11 +118,10 @@ class SmileyWindow(QtWidgets.QWidget):
|
|||
Smiley selection window
|
||||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
super(SmileyWindow, self).__init__()
|
||||
def __init__(self, parent, smiley_loader):
|
||||
super().__init__(parent)
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||
inst = smileys.SmileyLoader.get_instance()
|
||||
self.data = inst.get_smileys()
|
||||
self.data = smiley_loader.get_smileys()
|
||||
count = len(self.data)
|
||||
if not count:
|
||||
self.close()
|
||||
|
@ -172,18 +176,18 @@ class SmileyWindow(QtWidgets.QWidget):
|
|||
class MenuButton(QtWidgets.QPushButton):
|
||||
|
||||
def __init__(self, parent, enter):
|
||||
super(MenuButton, self).__init__(parent)
|
||||
super().__init__(parent)
|
||||
self.enter = enter
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.enter()
|
||||
super(MenuButton, self).enterEvent(event)
|
||||
super().enterEvent(event)
|
||||
|
||||
|
||||
class DropdownMenu(QtWidgets.QWidget):
|
||||
|
||||
def __init__(self, parent):
|
||||
super(DropdownMenu, self).__init__(parent)
|
||||
super().__init__(parent)
|
||||
self.installEventFilter(self)
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||
self.setMaximumSize(120, 120)
|
||||
|
@ -245,7 +249,7 @@ class DropdownMenu(QtWidgets.QWidget):
|
|||
class StickerItem(QtWidgets.QWidget):
|
||||
|
||||
def __init__(self, fl):
|
||||
super(StickerItem, self).__init__()
|
||||
super().__init__()
|
||||
self._image_label = QtWidgets.QLabel(self)
|
||||
self.path = fl
|
||||
self.pixmap = QtGui.QPixmap()
|
||||
|
@ -260,7 +264,7 @@ class StickerWindow(QtWidgets.QWidget):
|
|||
"""Sticker selection window"""
|
||||
|
||||
def __init__(self, parent):
|
||||
super(StickerWindow, self).__init__()
|
||||
super().__init__()
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||
self.setMaximumSize(250, 200)
|
||||
self.setMinimumSize(250, 200)
|
||||
|
@ -289,8 +293,9 @@ class StickerWindow(QtWidgets.QWidget):
|
|||
|
||||
class WelcomeScreen(CenteredWidget):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, settings):
|
||||
super().__init__()
|
||||
self._settings = settings
|
||||
self.setMaximumSize(250, 200)
|
||||
self.setMinimumSize(250, 200)
|
||||
self.center()
|
||||
|
@ -300,51 +305,39 @@ class WelcomeScreen(CenteredWidget):
|
|||
self.text.setOpenExternalLinks(True)
|
||||
self.checkbox = QtWidgets.QCheckBox(self)
|
||||
self.checkbox.setGeometry(QtCore.QRect(5, 170, 240, 30))
|
||||
self.checkbox.setText(QtWidgets.QApplication.translate('WelcomeScreen', "Don't show again"))
|
||||
self.setWindowTitle(QtWidgets.QApplication.translate('WelcomeScreen', 'Tip of the day'))
|
||||
self.checkbox.setText(util_ui.tr( "Don't show again"))
|
||||
self.setWindowTitle(util_ui.tr( 'Tip of the day'))
|
||||
import random
|
||||
num = random.randint(0, 10)
|
||||
if num == 0:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen', 'Press Esc if you want hide app to tray.')
|
||||
text = util_ui.tr('Press Esc if you want hide app to tray.')
|
||||
elif num == 1:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Right click on screenshot button hides app to tray during screenshot.')
|
||||
text = util_ui.tr('Right click on screenshot button hides app to tray during screenshot.')
|
||||
elif num == 2:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'You can use Tox over Tor. For more info read <a href="https://wiki.tox.chat/users/tox_over_tor_tot">this post</a>')
|
||||
text = util_ui.tr('You can use Tox over Tor. For more info read <a href="https://wiki.tox.chat/users/tox_over_tor_tot">this post</a>')
|
||||
elif num == 3:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Use Settings -> Interface to customize interface.')
|
||||
text = util_ui.tr('Use Settings -> Interface to customize interface.')
|
||||
elif num == 4:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.')
|
||||
text = util_ui.tr('Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.')
|
||||
elif num == 5:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Since v0.1.3 Toxygen supports plugins. <a href="https://github.com/toxygen-project/toxygen/blob/master/docs/plugins.md">Read more</a>')
|
||||
text = util_ui.tr('Since v0.1.3 Toxygen supports plugins. <a href="https://github.com/toxygen-project/toxygen/blob/master/docs/plugins.md">Read more</a>')
|
||||
elif num == 6:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Toxygen supports faux offline messages and file transfers. Send message or file to offline friend and he will get it later.')
|
||||
text = util_ui.tr('Toxygen supports faux offline messages and file transfers. Send message or file to offline friend and he will get it later.')
|
||||
elif num == 7:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'New in Toxygen 0.4.1:<br>Downloading nodes from tox.chat<br>Bug fixes')
|
||||
text = util_ui.tr('New in Toxygen 0.4.1:<br>Downloading nodes from tox.chat<br>Bug fixes')
|
||||
elif num == 8:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu')
|
||||
text = util_ui.tr('Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu')
|
||||
elif num == 9:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Use right click on inline image to save it')
|
||||
text = util_ui.tr( 'Use right click on inline image to save it')
|
||||
else:
|
||||
text = QtWidgets.QApplication.translate('WelcomeScreen',
|
||||
'Set new NoSpam to avoid spam friend requests: Profile -> Settings -> Set new NoSpam.')
|
||||
text = util_ui.tr('Set new NoSpam to avoid spam friend requests: Profile -> Settings -> Set new NoSpam.')
|
||||
self.text.setHtml(text)
|
||||
self.checkbox.stateChanged.connect(self.not_show)
|
||||
QtCore.QTimer.singleShot(1000, self.show)
|
||||
|
||||
def not_show(self):
|
||||
from user_data import settings
|
||||
s = settings.Settings.get_instance()
|
||||
s['show_welcome_screen'] = False
|
||||
s.save()
|
||||
self._settings['show_welcome_screen'] = False
|
||||
self._settings.save()
|
||||
|
||||
|
||||
class MainMenuButton(QtWidgets.QPushButton):
|
||||
|
@ -417,7 +410,7 @@ class SearchScreen(QtWidgets.QWidget):
|
|||
self.retranslateUi()
|
||||
|
||||
def retranslateUi(self):
|
||||
self.search_text.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "Search"))
|
||||
self.search_text.setPlaceholderText(util_ui.tr('Search'))
|
||||
|
||||
def show(self):
|
||||
super().show()
|
||||
|
@ -473,11 +466,4 @@ class SearchScreen(QtWidgets.QWidget):
|
|||
|
||||
@staticmethod
|
||||
def not_found(text):
|
||||
mbox = QtWidgets.QMessageBox()
|
||||
mbox_text = QtWidgets.QApplication.translate("MainWindow",
|
||||
'Text "{}" was not found')
|
||||
|
||||
mbox.setText(mbox_text.format(text))
|
||||
mbox.setWindowTitle(QtWidgets.QApplication.translate("MainWindow",
|
||||
'Not found'))
|
||||
mbox.exec_()
|
||||
util_ui.message_box(util_ui.tr('Text "{}" was not found').format(text), util_ui.tr('Not found'))
|
||||
|
|
|
@ -7,13 +7,15 @@ import pyaudio
|
|||
from user_data import toxes
|
||||
import plugin_support
|
||||
import updater
|
||||
import util.ui as util_ui
|
||||
|
||||
|
||||
class AddContact(CenteredWidget):
|
||||
"""Add contact form"""
|
||||
|
||||
def __init__(self, tox_id=''):
|
||||
super(AddContact, self).__init__()
|
||||
def __init__(self, contacts_manager, tox_id=''):
|
||||
super().__init__()
|
||||
self._contacts_manager = contacts_manager
|
||||
self.initUI(tox_id)
|
||||
self._adding = False
|
||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
|
@ -61,8 +63,10 @@ class AddContact(CenteredWidget):
|
|||
if self._adding:
|
||||
return
|
||||
self._adding = True
|
||||
profile = Profile.get_instance()
|
||||
send = profile.send_friend_request(self.tox_id.text().strip(), self.message_edit.toPlainText())
|
||||
tox_id = self.tox_id.text().strip()
|
||||
if tox_id.startswith('tox:'):
|
||||
tox_id = tox_id[4:]
|
||||
send = self._contacts_manager.send_friend_request(tox_id, self.message_edit.toPlainText())
|
||||
self._adding = False
|
||||
if send is True:
|
||||
# request was successful
|
||||
|
@ -71,17 +75,18 @@ class AddContact(CenteredWidget):
|
|||
self.error_label.setText(send)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(QtWidgets.QApplication.translate('AddContact', "Add contact"))
|
||||
self.sendRequestButton.setText(QtWidgets.QApplication.translate("Form", "Send request"))
|
||||
self.label.setText(QtWidgets.QApplication.translate('AddContact', "TOX ID:"))
|
||||
self.message.setText(QtWidgets.QApplication.translate('AddContact', "Message:"))
|
||||
self.tox_id.setPlaceholderText(QtWidgets.QApplication.translate('AddContact', "TOX ID or public key of contact"))
|
||||
self.setWindowTitle(util_ui.tr('Add contact'))
|
||||
self.sendRequestButton.setText(util_ui.tr('Send request'))
|
||||
self.label.setText(util_ui.tr('TOX ID:'))
|
||||
self.message.setText(util_ui.tr('Message:'))
|
||||
self.tox_id.setPlaceholderText(util_ui.tr('TOX ID or public key of contact'))
|
||||
|
||||
|
||||
class ProfileSettings(CenteredWidget):
|
||||
"""Form with profile settings such as name, status, TOX ID"""
|
||||
def __init__(self):
|
||||
super(ProfileSettings, self).__init__()
|
||||
def __init__(self, profile):
|
||||
super().__init__()
|
||||
self._profile = profile
|
||||
self.initUI()
|
||||
self.center()
|
||||
|
||||
|
@ -91,13 +96,12 @@ class ProfileSettings(CenteredWidget):
|
|||
self.setMaximumSize(QtCore.QSize(700, 600))
|
||||
self.nick = LineEdit(self)
|
||||
self.nick.setGeometry(QtCore.QRect(30, 60, 350, 27))
|
||||
profile = Profile.get_instance()
|
||||
self.nick.setText(profile.name)
|
||||
self.nick.setText(self._profile.name)
|
||||
self.status = QtWidgets.QComboBox(self)
|
||||
self.status.setGeometry(QtCore.QRect(400, 60, 200, 27))
|
||||
self.status_message = LineEdit(self)
|
||||
self.status_message.setGeometry(QtCore.QRect(30, 130, 350, 27))
|
||||
self.status_message.setText(profile.status_message)
|
||||
self.status_message.setText(self._profile.status_message)
|
||||
self.label = QtWidgets.QLabel(self)
|
||||
self.label.setGeometry(QtCore.QRect(40, 30, 91, 25))
|
||||
font = QtGui.QFont()
|
||||
|
@ -164,37 +168,37 @@ class ProfileSettings(CenteredWidget):
|
|||
self.auto = path + name == ProfileManager.get_path() + Settings.get_instance().name
|
||||
self.default.clicked.connect(self.auto_profile)
|
||||
self.retranslateUi()
|
||||
if profile.status is not None:
|
||||
self.status.setCurrentIndex(profile.status)
|
||||
if self._profile.status is not None:
|
||||
self.status.setCurrentIndex(self._profile.status)
|
||||
else:
|
||||
self.status.setVisible(False)
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.export.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Export profile"))
|
||||
self.setWindowTitle(QtWidgets.QApplication.translate("ProfileSettingsForm", "Profile settings"))
|
||||
self.label.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Name:"))
|
||||
self.label_2.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Status:"))
|
||||
self.label_3.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "TOX ID:"))
|
||||
self.copyId.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Copy TOX ID"))
|
||||
self.new_avatar.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "New avatar"))
|
||||
self.delete_avatar.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Reset avatar"))
|
||||
self.new_nospam.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "New NoSpam"))
|
||||
self.profilepass.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Profile password"))
|
||||
self.password.setPlaceholderText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Password (at least 8 symbols)"))
|
||||
self.confirm_password.setPlaceholderText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Confirm password"))
|
||||
self.set_password.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Set password"))
|
||||
self.not_match.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Passwords do not match"))
|
||||
self.leave_blank.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Leaving blank will reset current password"))
|
||||
self.warning.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "There is no way to recover lost passwords"))
|
||||
self.status.addItem(QtWidgets.QApplication.translate("ProfileSettingsForm", "Online"))
|
||||
self.status.addItem(QtWidgets.QApplication.translate("ProfileSettingsForm", "Away"))
|
||||
self.status.addItem(QtWidgets.QApplication.translate("ProfileSettingsForm", "Busy"))
|
||||
self.copy_pk.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Copy public key"))
|
||||
self.export.setText(util_ui.tr("Export profile"))
|
||||
self.setWindowTitle(util_ui.tr("Profile settings"))
|
||||
self.label.setText(util_ui.tr("Name:"))
|
||||
self.label_2.setText(util_ui.tr("Status:"))
|
||||
self.label_3.setText(util_ui.tr("TOX ID:"))
|
||||
self.copyId.setText(util_ui.tr("Copy TOX ID"))
|
||||
self.new_avatar.setText(util_ui.tr("New avatar"))
|
||||
self.delete_avatar.setText(util_ui.tr("Reset avatar"))
|
||||
self.new_nospam.setText(util_ui.tr("New NoSpam"))
|
||||
self.profilepass.setText(util_ui.tr("Profile password"))
|
||||
self.password.setPlaceholderText(util_ui.tr("Password (at least 8 symbols)"))
|
||||
self.confirm_password.setPlaceholderText(util_ui.tr("Confirm password"))
|
||||
self.set_password.setText(util_ui.tr("Set password"))
|
||||
self.not_match.setText(util_ui.tr("Passwords do not match"))
|
||||
self.leave_blank.setText(util_ui.tr("Leaving blank will reset current password"))
|
||||
self.warning.setText(util_ui.tr("There is no way to recover lost passwords"))
|
||||
self.status.addItem(util_ui.tr("Online"))
|
||||
self.status.addItem(util_ui.tr("Away"))
|
||||
self.status.addItem(util_ui.tr("Busy"))
|
||||
self.copy_pk.setText(util_ui.tr("Copy public key"))
|
||||
if self.auto:
|
||||
self.default.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as not default profile"))
|
||||
self.default.setText(util_ui.tr("Mark as not default profile"))
|
||||
else:
|
||||
self.default.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as default profile"))
|
||||
self.default.setText(util_ui.tr("Mark as default profile"))
|
||||
|
||||
def auto_profile(self):
|
||||
if self.auto:
|
||||
|
@ -203,10 +207,10 @@ class ProfileSettings(CenteredWidget):
|
|||
Settings.set_auto_profile(ProfileManager.get_path(), Settings.get_instance().name)
|
||||
self.auto = not self.auto
|
||||
if self.auto:
|
||||
self.default.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as not default profile"))
|
||||
self.default.setText(util_ui.tr("Mark as not default profile"))
|
||||
else:
|
||||
self.default.setText(
|
||||
QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as default profile"))
|
||||
util_ui.tr("Mark as default profile"))
|
||||
|
||||
def new_password(self):
|
||||
if self.password.text() == self.confirm_password.text():
|
||||
|
@ -216,10 +220,10 @@ class ProfileSettings(CenteredWidget):
|
|||
self.close()
|
||||
else:
|
||||
self.not_match.setText(
|
||||
QtWidgets.QApplication.translate("ProfileSettingsForm", "Password must be at least 8 symbols"))
|
||||
util_ui.tr("Password must be at least 8 symbols"))
|
||||
self.not_match.setVisible(True)
|
||||
else:
|
||||
self.not_match.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Passwords do not match"))
|
||||
self.not_match.setText(util_ui.tr("Passwords do not match"))
|
||||
self.not_match.setVisible(True)
|
||||
|
||||
def copy(self):
|
||||
|
@ -244,10 +248,10 @@ class ProfileSettings(CenteredWidget):
|
|||
self.tox_id.setText(Profile.get_instance().new_nospam())
|
||||
|
||||
def reset_avatar(self):
|
||||
Profile.get_instance().reset_avatar()
|
||||
self._profile.reset_avatar()
|
||||
|
||||
def set_avatar(self):
|
||||
choose = QtWidgets.QApplication.translate("ProfileSettingsForm", "Choose avatar")
|
||||
choose = util_ui.tr("Choose avatar")
|
||||
name = QtWidgets.QFileDialog.getOpenFileName(self, choose, None, 'Images (*.png)',
|
||||
options=QtWidgets.QFileDialog.DontUseNativeDialog)
|
||||
if name[0]:
|
||||
|
@ -262,21 +266,15 @@ class ProfileSettings(CenteredWidget):
|
|||
Profile.get_instance().set_avatar(bytes(byte_array.data()))
|
||||
|
||||
def export_profile(self):
|
||||
directory = QtWidgets.QFileDialog.getExistingDirectory(self, '', curr_directory(),
|
||||
QtWidgets.QFileDialog.DontUseNativeDialog) + '/'
|
||||
directory = util_ui.directory_dialog() + '/'
|
||||
if directory != '/':
|
||||
reply = QtWidgets.QMessageBox.question(None,
|
||||
QtWidgets.QApplication.translate("ProfileSettingsForm",
|
||||
'Use new path'),
|
||||
QtWidgets.QApplication.translate("ProfileSettingsForm",
|
||||
'Do you want to move your profile to this location?'),
|
||||
QtWidgets.QMessageBox.Yes,
|
||||
QtWidgets.QMessageBox.No)
|
||||
reply = util_ui.question(util_ui.tr('Do you want to move your profile to this location?'),
|
||||
util_ui.tr('Use new path'))
|
||||
settings = Settings.get_instance()
|
||||
settings.export(directory)
|
||||
profile = Profile.get_instance()
|
||||
profile.export_db(directory)
|
||||
ProfileManager.get_instance().export_profile(directory, reply == QtWidgets.QMessageBox.Yes)
|
||||
ProfileManager.get_instance().export_profile(directory, reply)
|
||||
|
||||
def closeEvent(self, event):
|
||||
profile = Profile.get_instance()
|
||||
|
@ -287,8 +285,9 @@ class ProfileSettings(CenteredWidget):
|
|||
|
||||
class NetworkSettings(CenteredWidget):
|
||||
"""Network settings form: UDP, Ipv6 and proxy"""
|
||||
def __init__(self, reset):
|
||||
super(NetworkSettings, self).__init__()
|
||||
def __init__(self, settings, reset):
|
||||
super().__init__()
|
||||
self._settings = settings
|
||||
self.reset = reset
|
||||
self.initUI()
|
||||
self.center()
|
||||
|
@ -323,35 +322,34 @@ class NetworkSettings(CenteredWidget):
|
|||
self.reconnect = QtWidgets.QPushButton(self)
|
||||
self.reconnect.setGeometry(QtCore.QRect(40, 230, 231, 30))
|
||||
self.reconnect.clicked.connect(self.restart_core)
|
||||
settings = Settings.get_instance()
|
||||
self.ipv.setChecked(settings['ipv6_enabled'])
|
||||
self.udp.setChecked(settings['udp_enabled'])
|
||||
self.proxy.setChecked(settings['proxy_type'])
|
||||
self.proxyip.setText(settings['proxy_host'])
|
||||
self.proxyport.setText(str(settings['proxy_port']))
|
||||
self.http.setChecked(settings['proxy_type'] == 1)
|
||||
self.ipv.setChecked(self._settings['ipv6_enabled'])
|
||||
self.udp.setChecked(self._settings['udp_enabled'])
|
||||
self.proxy.setChecked(self._settings['proxy_type'])
|
||||
self.proxyip.setText(self._settings['proxy_host'])
|
||||
self.proxyport.setText(str(self._settings['proxy_port']))
|
||||
self.http.setChecked(self._settings['proxy_type'] == 1)
|
||||
self.warning = QtWidgets.QLabel(self)
|
||||
self.warning.setGeometry(QtCore.QRect(5, 270, 290, 60))
|
||||
self.warning.setStyleSheet('QLabel { color: #BC1C1C; }')
|
||||
self.nodes = QtWidgets.QCheckBox(self)
|
||||
self.nodes.setGeometry(QtCore.QRect(20, 350, 270, 22))
|
||||
self.nodes.setChecked(settings['download_nodes_list'])
|
||||
self.nodes.setChecked(self._settings['download_nodes_list'])
|
||||
self.retranslateUi()
|
||||
self.proxy.stateChanged.connect(lambda x: self.activate())
|
||||
self.activate()
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(QtWidgets.QApplication.translate("NetworkSettings", "Network settings"))
|
||||
self.ipv.setText(QtWidgets.QApplication.translate("Form", "IPv6"))
|
||||
self.udp.setText(QtWidgets.QApplication.translate("Form", "UDP"))
|
||||
self.proxy.setText(QtWidgets.QApplication.translate("Form", "Proxy"))
|
||||
self.label.setText(QtWidgets.QApplication.translate("Form", "IP:"))
|
||||
self.label_2.setText(QtWidgets.QApplication.translate("Form", "Port:"))
|
||||
self.reconnect.setText(QtWidgets.QApplication.translate("NetworkSettings", "Restart TOX core"))
|
||||
self.http.setText(QtWidgets.QApplication.translate("Form", "HTTP"))
|
||||
self.nodes.setText(QtWidgets.QApplication.translate("Form", "Download nodes list from tox.chat"))
|
||||
self.warning.setText(QtWidgets.QApplication.translate("Form", "WARNING:\nusing proxy with enabled UDP\ncan produce IP leak"))
|
||||
self.setWindowTitle(util_ui.tr("Network settings"))
|
||||
self.ipv.setText(util_ui.tr("IPv6"))
|
||||
self.udp.setText(util_ui.tr("UDP"))
|
||||
self.proxy.setText(util_ui.tr("Proxy"))
|
||||
self.label.setText(util_ui.tr("IP:"))
|
||||
self.label_2.setText(util_ui.tr("Port:"))
|
||||
self.reconnect.setText(util_ui.tr("Restart TOX core"))
|
||||
self.http.setText(util_ui.tr("HTTP"))
|
||||
self.nodes.setText(util_ui.tr("Download nodes list from tox.chat"))
|
||||
self.warning.setText(util_ui.tr("WARNING:\nusing proxy with enabled UDP\ncan produce IP leak"))
|
||||
|
||||
def activate(self):
|
||||
bl = self.proxy.isChecked()
|
||||
|
@ -361,14 +359,13 @@ class NetworkSettings(CenteredWidget):
|
|||
|
||||
def restart_core(self):
|
||||
try:
|
||||
settings = Settings.get_instance()
|
||||
settings['ipv6_enabled'] = self.ipv.isChecked()
|
||||
settings['udp_enabled'] = self.udp.isChecked()
|
||||
settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0
|
||||
settings['proxy_host'] = str(self.proxyip.text())
|
||||
settings['proxy_port'] = int(self.proxyport.text())
|
||||
settings['download_nodes_list'] = self.nodes.isChecked()
|
||||
settings.save()
|
||||
self._settings['ipv6_enabled'] = self.ipv.isChecked()
|
||||
self._settings['udp_enabled'] = self.udp.isChecked()
|
||||
self._settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0
|
||||
self._settings['proxy_host'] = str(self.proxyip.text())
|
||||
self._settings['proxy_port'] = int(self.proxyport.text())
|
||||
self._settings['download_nodes_list'] = self.nodes.isChecked()
|
||||
self._settings.save()
|
||||
# recreate tox instance
|
||||
Profile.get_instance().reset(self.reset)
|
||||
self.close()
|
||||
|
@ -380,7 +377,7 @@ class PrivacySettings(CenteredWidget):
|
|||
"""Privacy settings form: history, typing notifications"""
|
||||
|
||||
def __init__(self):
|
||||
super(PrivacySettings, self).__init__()
|
||||
super().__init__()
|
||||
self.initUI()
|
||||
self.center()
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class QRightClickButton(QtWidgets.QPushButton):
|
|||
class RubberBand(QtWidgets.QRubberBand):
|
||||
|
||||
def __init__(self):
|
||||
super(RubberBand, self).__init__(QtWidgets.QRubberBand.Rectangle, None)
|
||||
super().__init__(QtWidgets.QRubberBand.Rectangle, None)
|
||||
self.setPalette(QtGui.QPalette(QtCore.Qt.transparent))
|
||||
self.pen = QtGui.QPen(QtCore.Qt.blue, 4)
|
||||
self.pen.setStyle(QtCore.Qt.SolidLine)
|
||||
|
|
27
toxygen/ui/widgets_factory.py
Normal file
27
toxygen/ui/widgets_factory.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from ui.main_screen_widgets import *
|
||||
from ui.menu import *
|
||||
|
||||
|
||||
class WidgetsFactory:
|
||||
|
||||
def __init__(self, settings, profile, contacts_manager, file_transfer_handler, smiley_loader):
|
||||
self._settings = settings
|
||||
self._profile = profile
|
||||
self._contacts_manager = contacts_manager
|
||||
self._file_transfer_handler = file_transfer_handler
|
||||
self._smiley_loader = smiley_loader
|
||||
|
||||
def create_screenshot_window(self, *args):
|
||||
return ScreenShotWindow(self._file_transfer_handler, *args)
|
||||
|
||||
def create_smiley_window(self, parent):
|
||||
return SmileyWindow(parent, self._smiley_loader)
|
||||
|
||||
def create_welcome_window(self):
|
||||
return WelcomeScreen(self._settings)
|
||||
|
||||
def create_profile_settings_window(self):
|
||||
return ProfileSettings(self._profile)
|
||||
|
||||
def create_network_settings_window(self):
|
||||
return NetworkSettings(self._settings, self._profile.reset)
|
Loading…
Add table
Add a link
Reference in a new issue