2016-05-24 20:22:21 +02:00
try :
from PySide import QtCore , QtGui
except ImportError :
from PyQt4 import QtCore , QtGui
2016-04-03 22:51:46 +02:00
from settings import *
from profile import Profile
2016-06-11 14:37:52 +02:00
from util import curr_directory
2016-06-16 23:10:26 +02:00
from widgets import CenteredWidget , DataLabel , LineEdit
2016-04-24 12:45:11 +02:00
import pyaudio
2016-05-15 15:06:41 +02:00
import toxencryptsave
2016-05-28 12:06:13 +02:00
import plugin_support
2016-03-11 12:37:45 +01:00
class AddContact ( CenteredWidget ) :
2016-02-19 17:04:01 +01:00
""" Add contact form """
2016-02-19 16:04:53 +01:00
2016-06-03 20:53:02 +02:00
def __init__ ( self , tox_id = ' ' ) :
2016-02-19 16:04:53 +01:00
super ( AddContact , self ) . __init__ ( )
2016-06-03 20:53:02 +02:00
self . initUI ( tox_id )
2016-02-19 16:04:53 +01:00
2016-06-03 20:53:02 +02:00
def initUI ( self , tox_id ) :
2016-02-19 16:04:53 +01:00
self . setObjectName ( ' AddContact ' )
self . resize ( 568 , 306 )
self . sendRequestButton = QtGui . QPushButton ( self )
self . sendRequestButton . setGeometry ( QtCore . QRect ( 50 , 270 , 471 , 31 ) )
self . sendRequestButton . setMinimumSize ( QtCore . QSize ( 0 , 0 ) )
self . sendRequestButton . setBaseSize ( QtCore . QSize ( 0 , 0 ) )
self . sendRequestButton . setObjectName ( " sendRequestButton " )
2016-03-09 19:11:36 +01:00
self . sendRequestButton . clicked . connect ( self . add_friend )
2016-06-16 23:10:26 +02:00
self . tox_id = LineEdit ( self )
2016-03-09 19:11:36 +01:00
self . tox_id . setGeometry ( QtCore . QRect ( 50 , 40 , 471 , 27 ) )
self . tox_id . setObjectName ( " lineEdit " )
2016-06-03 20:53:02 +02:00
self . tox_id . setText ( tox_id )
2016-02-19 16:04:53 +01:00
self . label = QtGui . QLabel ( self )
2016-06-03 20:53:02 +02:00
self . label . setGeometry ( QtCore . QRect ( 50 , 10 , 80 , 20 ) )
2016-05-08 12:51:56 +02:00
self . error_label = DataLabel ( self )
self . error_label . setGeometry ( QtCore . QRect ( 120 , 10 , 420 , 20 ) )
2016-02-19 16:04:53 +01:00
font = QtGui . QFont ( )
2016-05-08 12:51:56 +02:00
font . setPointSize ( 10 )
font . setWeight ( 30 )
2016-03-09 19:11:36 +01:00
self . error_label . setFont ( font )
2016-06-20 22:25:35 +02:00
self . error_label . setStyleSheet ( " QLabel { color: #BC1C1C; } " )
2016-02-19 16:04:53 +01:00
self . label . setObjectName ( " label " )
2016-03-09 19:11:36 +01:00
self . message_edit = QtGui . QTextEdit ( self )
self . message_edit . setGeometry ( QtCore . QRect ( 50 , 110 , 471 , 151 ) )
self . message_edit . setObjectName ( " textEdit " )
2016-05-09 22:09:07 +02:00
self . message = QtGui . QLabel ( self )
2016-06-03 20:53:02 +02:00
self . message . setGeometry ( QtCore . QRect ( 50 , 70 , 101 , 31 ) )
2016-05-09 22:09:07 +02:00
self . message . setFont ( font )
self . message . setObjectName ( " label_2 " )
2016-02-19 16:04:53 +01:00
self . retranslateUi ( )
2016-05-08 12:51:56 +02:00
self . message_edit . setText ( ' Hello! Add me to your contact list please ' )
2016-05-09 22:09:07 +02:00
font = QtGui . QFont ( )
font . setPointSize ( 12 )
font . setBold ( True )
self . label . setFont ( font )
self . message . setFont ( font )
2016-02-19 16:04:53 +01:00
QtCore . QMetaObject . connectSlotsByName ( self )
2016-03-09 19:11:36 +01:00
def add_friend ( self ) :
profile = Profile . get_instance ( )
send = profile . send_friend_request ( self . tox_id . text ( ) , self . message_edit . toPlainText ( ) )
if send is True :
# request was successful
self . close ( )
else : # print error data
self . error_label . setText ( send )
2016-02-19 16:04:53 +01:00
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( ' AddContact ' , " Add contact " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . sendRequestButton . setText ( QtGui . QApplication . translate ( " Form " , " Send request " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label . setText ( QtGui . QApplication . translate ( ' AddContact ' , " TOX ID: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-09 22:09:07 +02:00
self . message . setText ( QtGui . QApplication . translate ( ' AddContact ' , " Message: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-03 20:53:02 +02:00
self . tox_id . setPlaceholderText ( QtGui . QApplication . translate ( ' AddContact ' , " TOX ID or public key of contact " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-02-19 16:04:53 +01:00
2016-02-19 17:04:01 +01:00
2016-03-11 12:37:45 +01:00
class ProfileSettings ( CenteredWidget ) :
2016-02-19 17:04:01 +01:00
""" Form with profile settings such as name, status, TOX ID """
2016-03-07 19:00:00 +01:00
def __init__ ( self ) :
2016-02-19 17:04:01 +01:00
super ( ProfileSettings , self ) . __init__ ( )
self . initUI ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-02-19 17:04:01 +01:00
def initUI ( self ) :
self . setObjectName ( " ProfileSettingsForm " )
2016-06-18 21:32:14 +02:00
self . setMinimumSize ( QtCore . QSize ( 700 , 600 ) )
self . setMaximumSize ( QtCore . QSize ( 700 , 600 ) )
2016-06-16 23:10:26 +02:00
self . nick = LineEdit ( self )
2016-04-04 11:20:32 +02:00
self . nick . setGeometry ( QtCore . QRect ( 30 , 60 , 350 , 27 ) )
2016-03-07 19:00:00 +01:00
profile = Profile . get_instance ( )
self . nick . setText ( profile . name )
2016-06-18 21:32:14 +02:00
self . status = QtGui . 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 )
2016-02-19 17:04:01 +01:00
self . label = QtGui . QLabel ( self )
2016-05-09 22:09:07 +02:00
self . label . setGeometry ( QtCore . QRect ( 40 , 30 , 91 , 25 ) )
2016-02-19 17:04:01 +01:00
font = QtGui . QFont ( )
font . setPointSize ( 18 )
font . setWeight ( 75 )
font . setBold ( True )
self . label . setFont ( font )
self . label_2 = QtGui . QLabel ( self )
2016-05-09 22:09:07 +02:00
self . label_2 . setGeometry ( QtCore . QRect ( 40 , 100 , 100 , 25 ) )
2016-02-19 17:04:01 +01:00
self . label_2 . setFont ( font )
self . label_3 = QtGui . QLabel ( self )
2016-05-09 22:09:07 +02:00
self . label_3 . setGeometry ( QtCore . QRect ( 40 , 180 , 100 , 25 ) )
2016-02-19 17:04:01 +01:00
self . label_3 . setFont ( font )
self . tox_id = QtGui . QLabel ( self )
2016-06-20 19:39:10 +02:00
self . tox_id . setGeometry ( QtCore . QRect ( 15 , 210 , 685 , 21 ) )
2016-02-29 17:39:43 +01:00
font . setPointSize ( 10 )
2016-02-19 17:04:01 +01:00
self . tox_id . setFont ( font )
2016-03-07 19:00:00 +01:00
s = profile . tox_id
2016-02-25 09:32:40 +01:00
self . tox_id . setText ( s )
2016-02-19 17:04:01 +01:00
self . copyId = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . copyId . setGeometry ( QtCore . QRect ( 40 , 250 , 180 , 30 ) )
2016-02-25 09:32:40 +01:00
self . copyId . clicked . connect ( self . copy )
2016-03-12 11:09:58 +01:00
self . export = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . export . setGeometry ( QtCore . QRect ( 230 , 250 , 180 , 30 ) )
2016-03-12 11:09:58 +01:00
self . export . clicked . connect ( self . export_profile )
2016-05-03 21:02:56 +02:00
self . new_nospam = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . new_nospam . setGeometry ( QtCore . QRect ( 420 , 250 , 180 , 30 ) )
2016-05-03 21:02:56 +02:00
self . new_nospam . clicked . connect ( self . new_no_spam )
2016-06-18 21:32:14 +02:00
2016-03-11 12:37:45 +01:00
self . new_avatar = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . new_avatar . setGeometry ( QtCore . QRect ( 40 , 300 , 180 , 30 ) )
2016-03-11 12:37:45 +01:00
self . delete_avatar = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . delete_avatar . setGeometry ( QtCore . QRect ( 230 , 300 , 180 , 30 ) )
2016-03-11 12:37:45 +01:00
self . delete_avatar . clicked . connect ( self . reset_avatar )
self . new_avatar . clicked . connect ( self . set_avatar )
2016-05-15 15:06:41 +02:00
self . profile_pass = QtGui . QLabel ( self )
2016-06-18 21:32:14 +02:00
self . profile_pass . setGeometry ( QtCore . QRect ( 40 , 340 , 300 , 30 ) )
2016-05-15 15:06:41 +02:00
font . setPointSize ( 18 )
self . profile_pass . setFont ( font )
2016-06-16 23:10:26 +02:00
self . password = LineEdit ( self )
2016-06-18 21:32:14 +02:00
self . password . setGeometry ( QtCore . QRect ( 40 , 380 , 300 , 30 ) )
2016-05-15 15:06:41 +02:00
self . password . setEchoMode ( QtGui . QLineEdit . EchoMode . Password )
self . leave_blank = QtGui . QLabel ( self )
2016-06-18 21:32:14 +02:00
self . leave_blank . setGeometry ( QtCore . QRect ( 350 , 380 , 300 , 30 ) )
2016-06-16 23:10:26 +02:00
self . confirm_password = LineEdit ( self )
2016-06-18 21:32:14 +02:00
self . confirm_password . setGeometry ( QtCore . QRect ( 40 , 420 , 300 , 30 ) )
2016-05-15 15:06:41 +02:00
self . confirm_password . setEchoMode ( QtGui . QLineEdit . EchoMode . Password )
self . set_password = QtGui . QPushButton ( self )
2016-06-18 21:32:14 +02:00
self . set_password . setGeometry ( QtCore . QRect ( 40 , 470 , 300 , 30 ) )
2016-05-15 15:06:41 +02:00
self . set_password . clicked . connect ( self . new_password )
self . not_match = QtGui . QLabel ( self )
2016-06-20 22:25:35 +02:00
self . not_match . setGeometry ( QtCore . QRect ( 350 , 420 , 300 , 30 ) )
2016-05-15 15:06:41 +02:00
self . not_match . setVisible ( False )
2016-06-20 22:25:35 +02:00
self . not_match . setStyleSheet ( ' QLabel { color: #BC1C1C; } ' )
2016-05-15 15:06:41 +02:00
self . warning = QtGui . QLabel ( self )
2016-06-18 21:32:14 +02:00
self . warning . setGeometry ( QtCore . QRect ( 40 , 510 , 500 , 30 ) )
2016-06-20 22:25:35 +02:00
self . warning . setStyleSheet ( ' QLabel { color: #BC1C1C; } ' )
2016-06-18 21:32:14 +02:00
self . default = QtGui . QPushButton ( self )
2016-06-20 19:39:10 +02:00
self . default . setGeometry ( QtCore . QRect ( 40 , 550 , 620 , 30 ) )
2016-06-18 21:32:14 +02:00
path , name = Settings . get_auto_profile ( )
self . auto = path + name == ProfileHelper . get_path ( ) + Settings . get_instance ( ) . name
self . default . clicked . connect ( self . auto_profile )
2016-02-19 17:04:01 +01:00
self . retranslateUi ( )
2016-06-18 21:32:14 +02:00
if profile . status is not None :
self . status . setCurrentIndex ( profile . status )
else :
self . status . setVisible ( False )
2016-02-19 17:04:01 +01:00
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
2016-03-12 11:09:58 +01:00
self . export . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Export profile " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-02-19 17:04:01 +01:00
self . setWindowTitle ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Profile settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Name: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label_2 . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Status: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label_3 . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " TOX ID: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . copyId . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Copy TOX ID " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-03-11 12:37:45 +01:00
self . new_avatar . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " New avatar " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . delete_avatar . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Reset avatar " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-03 21:02:56 +02:00
self . new_nospam . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " New NoSpam " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-15 15:06:41 +02:00
self . profile_pass . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Profile password " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-16 14:25:51 +02:00
self . password . setPlaceholderText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Password (at least 8 symbols) " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-15 15:06:41 +02:00
self . confirm_password . setPlaceholderText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Confirm password " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . set_password . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Set password " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . not_match . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Passwords do not match " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . leave_blank . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Leaving blank will reset current password " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . warning . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " There is no way to recover lost passwords " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-18 21:32:14 +02:00
self . status . addItem ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Online " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . status . addItem ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Away " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . status . addItem ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Busy " , None , QtGui . QApplication . UnicodeUTF8 ) )
if self . auto :
self . default . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Mark as not default profile " , None , QtGui . QApplication . UnicodeUTF8 ) )
else :
self . default . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Mark as default profile " , None , QtGui . QApplication . UnicodeUTF8 ) )
def auto_profile ( self ) :
if self . auto :
Settings . reset_auto_profile ( )
else :
Settings . set_auto_profile ( ProfileHelper . get_path ( ) , Settings . get_instance ( ) . name )
self . auto = not self . auto
if self . auto :
self . default . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Mark as not default profile " , None ,
QtGui . QApplication . UnicodeUTF8 ) )
else :
self . default . setText (
QtGui . QApplication . translate ( " ProfileSettingsForm " , " Mark as default profile " , None ,
QtGui . QApplication . UnicodeUTF8 ) )
2016-05-15 15:06:41 +02:00
def new_password ( self ) :
if self . password . text ( ) == self . confirm_password . text ( ) :
2016-05-16 14:25:51 +02:00
if not len ( self . password . text ( ) ) or len ( self . password . text ( ) ) > = 8 :
2016-07-01 22:15:00 +02:00
e = toxencryptsave . ToxEncryptSave . get_instance ( )
2016-05-16 14:25:51 +02:00
e . set_password ( self . password . text ( ) )
self . close ( )
else :
self . not_match . setText (
QtGui . QApplication . translate ( " ProfileSettingsForm " , " Password must be at least 8 symbols " , None ,
QtGui . QApplication . UnicodeUTF8 ) )
self . not_match . setVisible ( True )
2016-05-15 15:06:41 +02:00
else :
2016-05-16 14:25:51 +02:00
self . not_match . setText ( QtGui . QApplication . translate ( " ProfileSettingsForm " , " Passwords do not match " , None ,
QtGui . QApplication . UnicodeUTF8 ) )
2016-05-15 15:06:41 +02:00
self . not_match . setVisible ( True )
2016-02-19 17:04:01 +01:00
2016-02-25 09:32:40 +01:00
def copy ( self ) :
clipboard = QtGui . QApplication . clipboard ( )
2016-03-07 19:00:00 +01:00
profile = Profile . get_instance ( )
clipboard . setText ( profile . tox_id )
2016-05-09 22:09:07 +02:00
pixmap = QtGui . QPixmap ( curr_directory ( ) + ' /images/accept.png ' )
icon = QtGui . QIcon ( pixmap )
self . copyId . setIcon ( icon )
self . copyId . setIconSize ( QtCore . QSize ( 10 , 10 ) )
2016-02-25 09:32:40 +01:00
2016-05-03 21:02:56 +02:00
def new_no_spam ( self ) :
self . tox_id . setText ( Profile . get_instance ( ) . new_nospam ( ) )
2016-03-11 12:37:45 +01:00
def reset_avatar ( self ) :
Profile . get_instance ( ) . reset_avatar ( )
def set_avatar ( self ) :
2016-05-15 15:06:41 +02:00
choose = QtGui . QApplication . translate ( " ProfileSettingsForm " , " Choose avatar " , None , QtGui . QApplication . UnicodeUTF8 )
2016-06-18 21:32:14 +02:00
name = QtGui . QFileDialog . getOpenFileName ( self , choose , None , ' Images (*.png) ' )
2016-03-11 12:37:45 +01:00
if name [ 0 ] :
2016-06-04 14:19:15 +02:00
bitmap = QtGui . QPixmap ( name [ 0 ] )
bitmap . scaled ( QtCore . QSize ( 128 , 128 ) , aspectMode = QtCore . Qt . KeepAspectRatio ,
mode = QtCore . Qt . SmoothTransformation )
byte_array = QtCore . QByteArray ( )
buffer = QtCore . QBuffer ( byte_array )
buffer . open ( QtCore . QIODevice . WriteOnly )
bitmap . save ( buffer , ' PNG ' )
Profile . get_instance ( ) . set_avatar ( str ( byte_array . data ( ) ) )
2016-03-11 12:37:45 +01:00
2016-03-12 11:09:58 +01:00
def export_profile ( self ) :
2016-03-13 13:06:06 +01:00
directory = QtGui . QFileDialog . getExistingDirectory ( ) + ' / '
2016-03-18 17:33:54 +01:00
if directory != ' / ' :
2016-05-14 12:18:17 +02:00
ProfileHelper . get_instance ( ) . export_profile ( directory )
2016-03-18 17:33:54 +01:00
settings = Settings . get_instance ( )
settings . export ( directory )
profile = Profile . get_instance ( )
profile . export_history ( directory )
2016-03-12 11:09:58 +01:00
2016-02-29 17:39:43 +01:00
def closeEvent ( self , event ) :
profile = Profile . get_instance ( )
2016-06-24 14:00:13 +02:00
profile . set_name ( self . nick . text ( ) )
2016-06-18 21:32:14 +02:00
profile . set_status_message ( self . status_message . text ( ) . encode ( ' utf-8 ' ) )
profile . set_status ( self . status . currentIndex ( ) )
2016-02-29 17:39:43 +01:00
2016-02-19 17:04:01 +01:00
2016-03-11 12:37:45 +01:00
class NetworkSettings ( CenteredWidget ) :
2016-02-19 17:04:01 +01:00
""" Network settings form: UDP, Ipv6 and proxy """
2016-03-15 18:05:19 +01:00
def __init__ ( self , reset ) :
2016-02-19 17:04:01 +01:00
super ( NetworkSettings , self ) . __init__ ( )
2016-03-15 18:05:19 +01:00
self . reset = reset
2016-02-19 17:04:01 +01:00
self . initUI ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-02-19 17:04:01 +01:00
def initUI ( self ) :
self . setObjectName ( " NetworkSettings " )
2016-05-15 18:54:44 +02:00
self . resize ( 300 , 330 )
self . setMinimumSize ( QtCore . QSize ( 300 , 330 ) )
self . setMaximumSize ( QtCore . QSize ( 300 , 330 ) )
self . setBaseSize ( QtCore . QSize ( 300 , 330 ) )
2016-02-19 17:04:01 +01:00
self . ipv = QtGui . QCheckBox ( self )
self . ipv . setGeometry ( QtCore . QRect ( 20 , 10 , 97 , 22 ) )
self . ipv . setObjectName ( " ipv " )
self . udp = QtGui . QCheckBox ( self )
2016-04-26 21:56:06 +02:00
self . udp . setGeometry ( QtCore . QRect ( 150 , 10 , 97 , 22 ) )
2016-02-19 17:04:01 +01:00
self . udp . setObjectName ( " udp " )
self . proxy = QtGui . QCheckBox ( self )
2016-04-26 21:56:06 +02:00
self . proxy . setGeometry ( QtCore . QRect ( 20 , 40 , 97 , 22 ) )
self . http = QtGui . QCheckBox ( self )
self . http . setGeometry ( QtCore . QRect ( 20 , 70 , 97 , 22 ) )
2016-02-19 17:04:01 +01:00
self . proxy . setObjectName ( " proxy " )
2016-06-16 23:10:26 +02:00
self . proxyip = LineEdit ( self )
2016-04-26 21:56:06 +02:00
self . proxyip . setGeometry ( QtCore . QRect ( 40 , 130 , 231 , 27 ) )
2016-02-19 17:04:01 +01:00
self . proxyip . setObjectName ( " proxyip " )
2016-06-16 23:10:26 +02:00
self . proxyport = LineEdit ( self )
2016-04-26 21:56:06 +02:00
self . proxyport . setGeometry ( QtCore . QRect ( 40 , 190 , 231 , 27 ) )
2016-02-19 17:04:01 +01:00
self . proxyport . setObjectName ( " proxyport " )
self . label = QtGui . QLabel ( self )
2016-04-26 21:56:06 +02:00
self . label . setGeometry ( QtCore . QRect ( 40 , 100 , 66 , 17 ) )
2016-02-19 17:04:01 +01:00
self . label_2 = QtGui . QLabel ( self )
2016-04-26 21:56:06 +02:00
self . label_2 . setGeometry ( QtCore . QRect ( 40 , 165 , 66 , 17 ) )
2016-04-16 10:54:29 +02:00
self . reconnect = QtGui . QPushButton ( self )
2016-05-09 21:37:11 +02:00
self . reconnect . setGeometry ( QtCore . QRect ( 40 , 230 , 231 , 30 ) )
2016-04-16 10:54:29 +02:00
self . reconnect . clicked . connect ( self . restart_core )
2016-03-13 17:14:17 +01:00
settings = Settings . get_instance ( )
self . ipv . setChecked ( settings [ ' ipv6_enabled ' ] )
self . udp . setChecked ( settings [ ' udp_enabled ' ] )
2016-05-08 21:29:50 +02:00
self . proxy . setChecked ( settings [ ' proxy_type ' ] )
2016-03-13 17:14:17 +01:00
self . proxyip . setText ( settings [ ' proxy_host ' ] )
2016-06-21 13:58:11 +02:00
self . proxyport . setText ( str ( settings [ ' proxy_port ' ] ) )
2016-05-02 22:20:02 +02:00
self . http . setChecked ( settings [ ' proxy_type ' ] == 1 )
2016-05-15 18:54:44 +02:00
self . warning = QtGui . QLabel ( self )
2016-05-28 21:43:51 +02:00
self . warning . setGeometry ( QtCore . QRect ( 5 , 270 , 290 , 60 ) )
2016-06-20 22:25:35 +02:00
self . warning . setStyleSheet ( ' QLabel { color: #BC1C1C; } ' )
2016-02-19 17:04:01 +01:00
self . retranslateUi ( )
2016-04-26 21:56:06 +02:00
self . proxy . stateChanged . connect ( lambda x : self . activate ( ) )
self . activate ( )
2016-02-19 17:04:01 +01:00
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( " NetworkSettings " , " Network settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . ipv . setText ( QtGui . QApplication . translate ( " Form " , " IPv6 " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . udp . setText ( QtGui . QApplication . translate ( " Form " , " UDP " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . proxy . setText ( QtGui . QApplication . translate ( " Form " , " Proxy " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label . setText ( QtGui . QApplication . translate ( " Form " , " IP: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label_2 . setText ( QtGui . QApplication . translate ( " Form " , " Port: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-16 10:54:29 +02:00
self . reconnect . setText ( QtGui . QApplication . translate ( " NetworkSettings " , " Restart TOX core " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-26 21:56:06 +02:00
self . http . setText ( QtGui . QApplication . translate ( " Form " , " HTTP " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-15 18:54:44 +02:00
self . warning . setText ( QtGui . QApplication . translate ( " Form " , " WARNING: \n using proxy with enabled UDP \n can produce IP leak " ,
None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-26 21:56:06 +02:00
def activate ( self ) :
bl = self . proxy . isChecked ( )
self . proxyip . setEnabled ( bl )
self . http . setEnabled ( bl )
self . proxyport . setEnabled ( bl )
2016-02-19 17:04:01 +01:00
2016-04-16 10:54:29 +02:00
def restart_core ( self ) :
2016-05-09 21:37:11 +02:00
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 . save ( )
# recreate tox instance
Profile . get_instance ( ) . reset ( self . reset )
self . close ( )
2016-05-28 12:06:13 +02:00
except Exception as ex :
log ( ' Exception in restart: ' + str ( ex ) )
2016-04-16 10:54:29 +02:00
2016-02-19 17:04:01 +01:00
2016-03-11 12:37:45 +01:00
class PrivacySettings ( CenteredWidget ) :
2016-02-20 21:50:10 +01:00
""" Privacy settings form: history, typing notifications """
def __init__ ( self ) :
super ( PrivacySettings , self ) . __init__ ( )
self . initUI ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-02-20 21:50:10 +01:00
def initUI ( self ) :
self . setObjectName ( " privacySettings " )
2016-06-29 14:39:44 +02:00
self . resize ( 370 , 600 )
self . setMinimumSize ( QtCore . QSize ( 370 , 600 ) )
self . setMaximumSize ( QtCore . QSize ( 370 , 600 ) )
2016-02-20 21:50:10 +01:00
self . saveHistory = QtGui . QCheckBox ( self )
2016-06-29 14:39:44 +02:00
self . saveHistory . setGeometry ( QtCore . QRect ( 10 , 20 , 350 , 22 ) )
2016-06-28 11:44:27 +02:00
self . saveUnsentOnly = QtGui . QCheckBox ( self )
2016-06-29 14:39:44 +02:00
self . saveUnsentOnly . setGeometry ( QtCore . QRect ( 10 , 60 , 350 , 22 ) )
2016-06-28 11:44:27 +02:00
2016-02-20 21:50:10 +01:00
self . fileautoaccept = QtGui . QCheckBox ( self )
2016-06-29 14:39:44 +02:00
self . fileautoaccept . setGeometry ( QtCore . QRect ( 10 , 100 , 350 , 22 ) )
2016-06-18 22:29:49 +02:00
2016-02-20 21:50:10 +01:00
self . typingNotifications = QtGui . QCheckBox ( self )
2016-06-28 11:44:27 +02:00
self . typingNotifications . setGeometry ( QtCore . QRect ( 10 , 140 , 350 , 30 ) )
2016-04-14 10:29:59 +02:00
self . inlines = QtGui . QCheckBox ( self )
2016-06-28 11:44:27 +02:00
self . inlines . setGeometry ( QtCore . QRect ( 10 , 180 , 350 , 30 ) )
2016-03-18 17:33:54 +01:00
self . auto_path = QtGui . QLabel ( self )
2016-06-28 11:44:27 +02:00
self . auto_path . setGeometry ( QtCore . QRect ( 10 , 230 , 350 , 30 ) )
2016-03-18 17:33:54 +01:00
self . path = QtGui . QPlainTextEdit ( self )
2016-06-28 11:44:27 +02:00
self . path . setGeometry ( QtCore . QRect ( 10 , 265 , 330 , 45 ) )
2016-03-18 17:33:54 +01:00
self . change_path = QtGui . QPushButton ( self )
2016-06-29 14:39:44 +02:00
self . change_path . setGeometry ( QtCore . QRect ( 10 , 320 , 350 , 30 ) )
2016-03-03 20:19:09 +01:00
settings = Settings . get_instance ( )
2016-03-03 17:44:01 +01:00
self . typingNotifications . setChecked ( settings [ ' typing_notifications ' ] )
self . fileautoaccept . setChecked ( settings [ ' allow_auto_accept ' ] )
self . saveHistory . setChecked ( settings [ ' save_history ' ] )
2016-04-14 10:29:59 +02:00
self . inlines . setChecked ( settings [ ' allow_inline ' ] )
2016-06-28 11:44:27 +02:00
self . saveUnsentOnly . setChecked ( settings [ ' save_unsent_only ' ] )
self . saveUnsentOnly . setEnabled ( settings [ ' save_history ' ] )
self . saveHistory . stateChanged . connect ( self . update )
2016-03-18 17:33:54 +01:00
self . path . setPlainText ( settings [ ' auto_accept_path ' ] or curr_directory ( ) )
self . change_path . clicked . connect ( self . new_path )
2016-04-25 14:48:56 +02:00
self . block_user_label = QtGui . QLabel ( self )
2016-06-29 14:39:44 +02:00
self . block_user_label . setGeometry ( QtCore . QRect ( 10 , 360 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . block_id = QtGui . QPlainTextEdit ( self )
2016-06-29 14:39:44 +02:00
self . block_id . setGeometry ( QtCore . QRect ( 10 , 390 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . block = QtGui . QPushButton ( self )
2016-06-29 14:39:44 +02:00
self . block . setGeometry ( QtCore . QRect ( 10 , 430 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . block . clicked . connect ( lambda : Profile . get_instance ( ) . block_user ( self . block_id . toPlainText ( ) ) or self . close ( ) )
self . blocked_users_label = QtGui . QLabel ( self )
2016-06-29 14:39:44 +02:00
self . blocked_users_label . setGeometry ( QtCore . QRect ( 10 , 470 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . comboBox = QtGui . QComboBox ( self )
2016-06-29 14:39:44 +02:00
self . comboBox . setGeometry ( QtCore . QRect ( 10 , 500 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . comboBox . addItems ( settings [ ' blocked ' ] )
self . unblock = QtGui . QPushButton ( self )
2016-06-29 14:39:44 +02:00
self . unblock . setGeometry ( QtCore . QRect ( 10 , 540 , 350 , 30 ) )
2016-04-25 14:48:56 +02:00
self . unblock . clicked . connect ( lambda : self . unblock_user ( ) )
self . retranslateUi ( )
2016-02-20 21:50:10 +01:00
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( " privacySettings " , " Privacy settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . saveHistory . setText ( QtGui . QApplication . translate ( " privacySettings " , " Save chat history " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-03-18 17:33:54 +01:00
self . fileautoaccept . setText ( QtGui . QApplication . translate ( " privacySettings " , " Allow file auto accept " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-02-20 21:50:10 +01:00
self . typingNotifications . setText ( QtGui . QApplication . translate ( " privacySettings " , " Send typing notifications " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-03-18 17:33:54 +01:00
self . auto_path . setText ( QtGui . QApplication . translate ( " privacySettings " , " Auto accept default path: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . change_path . setText ( QtGui . QApplication . translate ( " privacySettings " , " Change " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-14 10:29:59 +02:00
self . inlines . setText ( QtGui . QApplication . translate ( " privacySettings " , " Allow inlines " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-18 22:29:49 +02:00
self . block_user_label . setText ( QtGui . QApplication . translate ( " privacySettings " , " Block by public key: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-25 14:48:56 +02:00
self . blocked_users_label . setText ( QtGui . QApplication . translate ( " privacySettings " , " Blocked users: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . unblock . setText ( QtGui . QApplication . translate ( " privacySettings " , " Unblock " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . block . setText ( QtGui . QApplication . translate ( " privacySettings " , " Block user " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-28 11:44:27 +02:00
self . saveUnsentOnly . setText ( QtGui . QApplication . translate ( " privacySettings " , " Save unsent messages only " , None , QtGui . QApplication . UnicodeUTF8 ) )
def update ( self , new_state ) :
self . saveUnsentOnly . setEnabled ( new_state )
if not new_state :
self . saveUnsentOnly . setChecked ( False )
2016-04-25 14:48:56 +02:00
def unblock_user ( self ) :
if not self . comboBox . count ( ) :
return
title = QtGui . QApplication . translate ( " privacySettings " , " Add to friend list " , None , QtGui . QApplication . UnicodeUTF8 )
info = QtGui . QApplication . translate ( " privacySettings " , " Do you want to add this user to friend list? " , None , QtGui . QApplication . UnicodeUTF8 )
reply = QtGui . QMessageBox . question ( None , title , info , QtGui . QMessageBox . Yes , QtGui . QMessageBox . No )
Profile . get_instance ( ) . unblock_user ( self . comboBox . currentText ( ) , reply == QtGui . QMessageBox . Yes )
self . close ( )
2016-02-20 21:50:10 +01:00
2016-03-03 17:44:01 +01:00
def closeEvent ( self , event ) :
2016-03-03 20:19:09 +01:00
settings = Settings . get_instance ( )
2016-03-03 17:44:01 +01:00
settings [ ' typing_notifications ' ] = self . typingNotifications . isChecked ( )
settings [ ' allow_auto_accept ' ] = self . fileautoaccept . isChecked ( )
2016-06-28 11:44:27 +02:00
2016-03-13 17:14:17 +01:00
if settings [ ' save_history ' ] and not self . saveHistory . isChecked ( ) : # clear history
2016-04-14 10:29:59 +02:00
reply = QtGui . QMessageBox . question ( None ,
QtGui . QApplication . translate ( " privacySettings " ,
' Chat history ' ,
None , QtGui . QApplication . UnicodeUTF8 ) ,
QtGui . QApplication . translate ( " privacySettings " ,
' History will be cleaned! Continue? ' ,
None , QtGui . QApplication . UnicodeUTF8 ) ,
QtGui . QMessageBox . Yes ,
QtGui . QMessageBox . No )
if reply == QtGui . QMessageBox . Yes :
Profile . get_instance ( ) . clear_history ( )
settings [ ' save_history ' ] = self . saveHistory . isChecked ( )
else :
settings [ ' save_history ' ] = self . saveHistory . isChecked ( )
2016-06-28 11:44:27 +02:00
if self . saveUnsentOnly . isChecked ( ) and not settings [ ' save_unsent_only ' ] :
reply = QtGui . QMessageBox . question ( None ,
QtGui . QApplication . translate ( " privacySettings " ,
' Chat history ' ,
None , QtGui . QApplication . UnicodeUTF8 ) ,
QtGui . QApplication . translate ( " privacySettings " ,
' History will be cleaned! Continue? ' ,
None , QtGui . QApplication . UnicodeUTF8 ) ,
QtGui . QMessageBox . Yes ,
QtGui . QMessageBox . No )
if reply == QtGui . QMessageBox . Yes :
Profile . get_instance ( ) . clear_history ( None , True )
settings [ ' save_unsent_only ' ] = self . saveUnsentOnly . isChecked ( )
else :
settings [ ' save_unsent_only ' ] = self . saveUnsentOnly . isChecked ( )
2016-03-18 17:33:54 +01:00
settings [ ' auto_accept_path ' ] = self . path . toPlainText ( )
2016-04-14 10:29:59 +02:00
settings [ ' allow_inline ' ] = self . inlines . isChecked ( )
2016-03-03 17:44:01 +01:00
settings . save ( )
2016-03-18 17:33:54 +01:00
def new_path ( self ) :
directory = QtGui . QFileDialog . getExistingDirectory ( ) + ' / '
if directory != ' / ' :
self . path . setPlainText ( directory )
2016-02-20 21:50:10 +01:00
2016-03-11 12:37:45 +01:00
class NotificationsSettings ( CenteredWidget ) :
2016-02-20 21:50:10 +01:00
""" Notifications settings form """
def __init__ ( self ) :
super ( NotificationsSettings , self ) . __init__ ( )
self . initUI ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-02-20 21:50:10 +01:00
def initUI ( self ) :
self . setObjectName ( " notificationsForm " )
2016-06-18 22:29:49 +02:00
self . resize ( 350 , 180 )
self . setMinimumSize ( QtCore . QSize ( 350 , 180 ) )
self . setMaximumSize ( QtCore . QSize ( 350 , 180 ) )
2016-02-20 21:50:10 +01:00
self . enableNotifications = QtGui . QCheckBox ( self )
2016-04-24 22:24:48 +02:00
self . enableNotifications . setGeometry ( QtCore . QRect ( 10 , 20 , 340 , 18 ) )
2016-02-25 12:22:15 +01:00
self . callsSound = QtGui . QCheckBox ( self )
2016-04-24 22:24:48 +02:00
self . callsSound . setGeometry ( QtCore . QRect ( 10 , 120 , 340 , 18 ) )
2016-04-14 21:09:23 +02:00
self . soundNotifications = QtGui . QCheckBox ( self )
2016-04-24 22:24:48 +02:00
self . soundNotifications . setGeometry ( QtCore . QRect ( 10 , 70 , 340 , 18 ) )
2016-05-02 22:20:02 +02:00
font = QtGui . QFont ( )
font . setPointSize ( 12 )
self . callsSound . setFont ( font )
self . soundNotifications . setFont ( font )
self . enableNotifications . setFont ( font )
2016-03-03 20:19:09 +01:00
s = Settings . get_instance ( )
2016-02-25 12:22:15 +01:00
self . enableNotifications . setChecked ( s [ ' notifications ' ] )
self . soundNotifications . setChecked ( s [ ' sound_notifications ' ] )
self . callsSound . setChecked ( s [ ' calls_sound ' ] )
2016-02-20 21:50:10 +01:00
self . retranslateUi ( )
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( " notificationsForm " , " Notification settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . enableNotifications . setText ( QtGui . QApplication . translate ( " notificationsForm " , " Enable notifications " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-03-11 17:46:30 +01:00
self . callsSound . setText ( QtGui . QApplication . translate ( " notificationsForm " , " Enable call \' s sound " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . soundNotifications . setText ( QtGui . QApplication . translate ( " notificationsForm " , " Enable sound notifications " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-02-25 12:22:15 +01:00
def closeEvent ( self , * args , * * kwargs ) :
2016-03-03 20:19:09 +01:00
settings = Settings . get_instance ( )
2016-02-25 12:22:15 +01:00
settings [ ' notifications ' ] = self . enableNotifications . isChecked ( )
settings [ ' sound_notifications ' ] = self . soundNotifications . isChecked ( )
settings [ ' calls_sound ' ] = self . callsSound . isChecked ( )
settings . save ( )
2016-02-20 21:50:10 +01:00
2016-03-11 12:37:45 +01:00
class InterfaceSettings ( CenteredWidget ) :
2016-02-20 21:50:10 +01:00
""" Interface settings form """
def __init__ ( self ) :
super ( InterfaceSettings , self ) . __init__ ( )
self . initUI ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-02-20 21:50:10 +01:00
def initUI ( self ) :
self . setObjectName ( " interfaceForm " )
2016-06-21 16:17:52 +02:00
self . setMinimumSize ( QtCore . QSize ( 400 , 450 ) )
self . setMaximumSize ( QtCore . QSize ( 400 , 450 ) )
2016-02-20 21:50:10 +01:00
self . label = QtGui . QLabel ( self )
2016-06-20 22:25:35 +02:00
self . label . setGeometry ( QtCore . QRect ( 30 , 10 , 370 , 20 ) )
2016-02-20 21:50:10 +01:00
font = QtGui . QFont ( )
2016-06-21 16:17:52 +02:00
font . setPointSize ( 14 )
2016-02-20 21:50:10 +01:00
font . setBold ( True )
self . label . setFont ( font )
self . themeSelect = QtGui . QComboBox ( self )
2016-06-20 22:25:35 +02:00
self . themeSelect . setGeometry ( QtCore . QRect ( 30 , 40 , 120 , 30 ) )
2016-06-11 14:37:52 +02:00
list_of_themes = [ ' dark ' ]
2016-03-03 17:44:01 +01:00
self . themeSelect . addItems ( list_of_themes )
2016-04-04 11:20:32 +02:00
settings = Settings . get_instance ( )
theme = settings [ ' theme ' ]
2016-06-11 14:37:52 +02:00
if theme in list_of_themes :
index = list_of_themes . index ( theme )
else :
index = 0
2016-03-03 17:44:01 +01:00
self . themeSelect . setCurrentIndex ( index )
2016-04-04 11:20:32 +02:00
self . lang_choose = QtGui . QComboBox ( self )
2016-06-20 22:25:35 +02:00
self . lang_choose . setGeometry ( QtCore . QRect ( 30 , 110 , 120 , 30 ) )
2016-04-04 11:20:32 +02:00
supported = Settings . supported_languages ( )
2016-06-18 22:50:12 +02:00
for key in supported :
self . lang_choose . insertItem ( 0 , key )
if settings [ ' language ' ] == key :
self . lang_choose . setCurrentIndex ( 0 )
2016-04-04 11:20:32 +02:00
self . lang = QtGui . QLabel ( self )
2016-06-20 22:25:35 +02:00
self . lang . setGeometry ( QtCore . QRect ( 30 , 80 , 370 , 20 ) )
2016-04-04 11:20:32 +02:00
self . lang . setFont ( font )
2016-06-11 14:37:52 +02:00
self . mirror_mode = QtGui . QCheckBox ( self )
2016-06-20 22:25:35 +02:00
self . mirror_mode . setGeometry ( QtCore . QRect ( 30 , 160 , 370 , 20 ) )
2016-06-11 14:37:52 +02:00
self . mirror_mode . setChecked ( settings [ ' mirror_mode ' ] )
self . smileys = QtGui . QCheckBox ( self )
self . smileys . setGeometry ( QtCore . QRect ( 30 , 190 , 120 , 20 ) )
self . smileys . setChecked ( settings [ ' smileys ' ] )
self . smiley_pack_label = QtGui . QLabel ( self )
2016-06-20 22:25:35 +02:00
self . smiley_pack_label . setGeometry ( QtCore . QRect ( 30 , 230 , 370 , 20 ) )
2016-06-11 14:37:52 +02:00
self . smiley_pack_label . setFont ( font )
self . smiley_pack = QtGui . QComboBox ( self )
self . smiley_pack . setGeometry ( QtCore . QRect ( 30 , 260 , 160 , 30 ) )
sm = smileys . SmileyLoader . get_instance ( )
self . smiley_pack . addItems ( sm . get_packs_list ( ) )
try :
ind = sm . get_packs_list ( ) . index ( settings [ ' smiley_pack ' ] )
except :
ind = sm . get_packs_list ( ) . index ( ' default ' )
self . smiley_pack . setCurrentIndex ( ind )
2016-06-18 22:29:49 +02:00
self . messages_font_size_label = QtGui . QLabel ( self )
2016-06-20 22:25:35 +02:00
self . messages_font_size_label . setGeometry ( QtCore . QRect ( 30 , 300 , 370 , 20 ) )
2016-06-18 22:29:49 +02:00
self . messages_font_size_label . setFont ( font )
self . messages_font_size = QtGui . QComboBox ( self )
self . messages_font_size . setGeometry ( QtCore . QRect ( 30 , 330 , 160 , 30 ) )
self . messages_font_size . addItems ( [ str ( x ) for x in range ( 10 , 19 ) ] )
self . messages_font_size . setCurrentIndex ( settings [ ' message_font_size ' ] - 10 )
2016-06-21 16:17:52 +02:00
self . unread = QtGui . QPushButton ( self )
2016-07-01 15:25:46 +02:00
self . unread . setGeometry ( QtCore . QRect ( 30 , 380 , 340 , 30 ) )
2016-06-21 16:17:52 +02:00
self . unread . clicked . connect ( self . select_color )
2016-07-01 15:25:46 +02:00
self . compact_mode = QtGui . QCheckBox ( self )
self . compact_mode . setGeometry ( QtCore . QRect ( 30 , 425 , 370 , 20 ) )
self . compact_mode . setChecked ( settings [ ' compact_mode ' ] )
2016-02-20 21:50:10 +01:00
self . retranslateUi ( )
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( " interfaceForm " , " Interface settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Theme: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-04-04 11:20:32 +02:00
self . lang . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Language: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-11 14:37:52 +02:00
self . smileys . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Smileys " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . smiley_pack_label . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Smiley pack: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . mirror_mode . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Mirror mode " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-18 22:29:49 +02:00
self . messages_font_size_label . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Messages font size: " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-21 16:17:52 +02:00
self . unread . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Select unread messages notification color " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-07-01 15:25:46 +02:00
self . compact_mode . setText ( QtGui . QApplication . translate ( " interfaceForm " , " Compact contact list " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-06-21 16:17:52 +02:00
def select_color ( self ) :
col = QtGui . QColorDialog . getColor ( )
if col . isValid ( ) :
settings = Settings . get_instance ( )
name = col . name ( )
settings [ ' unread_color ' ] = name
settings . save ( )
2016-03-03 17:44:01 +01:00
def closeEvent ( self , event ) :
2016-03-03 20:19:09 +01:00
settings = Settings . get_instance ( )
2016-06-11 14:37:52 +02:00
settings [ ' theme ' ] = str ( self . themeSelect . currentText ( ) )
settings [ ' smileys ' ] = self . smileys . isChecked ( )
2016-07-01 15:25:46 +02:00
restart = False
2016-06-18 22:29:49 +02:00
if settings [ ' mirror_mode ' ] != self . mirror_mode . isChecked ( ) :
settings [ ' mirror_mode ' ] = self . mirror_mode . isChecked ( )
2016-07-01 15:25:46 +02:00
restart = True
if settings [ ' compact_mode ' ] != self . compact_mode . isChecked ( ) :
settings [ ' compact_mode ' ] = self . compact_mode . isChecked ( )
restart = True
2016-06-11 14:37:52 +02:00
settings [ ' smiley_pack ' ] = self . smiley_pack . currentText ( )
smileys . SmileyLoader . get_instance ( ) . load_pack ( )
2016-04-04 11:20:32 +02:00
language = self . lang_choose . currentText ( )
if settings [ ' language ' ] != language :
settings [ ' language ' ] = language
2016-06-18 22:50:12 +02:00
text = self . lang_choose . currentText ( )
path = Settings . supported_languages ( ) [ text ]
2016-04-04 11:20:32 +02:00
app = QtGui . QApplication . instance ( )
app . removeTranslator ( app . translator )
app . translator . load ( curr_directory ( ) + ' /translations/ ' + path )
app . installTranslator ( app . translator )
2016-06-18 22:29:49 +02:00
settings [ ' message_font_size ' ] = self . messages_font_size . currentIndex ( ) + 10
Profile . get_instance ( ) . update ( )
2016-04-04 11:20:32 +02:00
settings . save ( )
2016-07-01 15:25:46 +02:00
if restart :
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_ ( )
2016-04-04 11:20:32 +02:00
2016-04-24 12:45:11 +02:00
class AudioSettings ( CenteredWidget ) :
2016-06-05 19:17:39 +02:00
"""
Audio calls settings form
"""
2016-04-24 12:45:11 +02:00
def __init__ ( self ) :
super ( AudioSettings , self ) . __init__ ( )
self . initUI ( )
self . retranslateUi ( )
2016-05-18 23:38:21 +02:00
self . center ( )
2016-04-24 12:45:11 +02:00
def initUI ( self ) :
self . setObjectName ( " audioSettingsForm " )
self . resize ( 400 , 150 )
self . setMinimumSize ( QtCore . QSize ( 400 , 150 ) )
self . setMaximumSize ( QtCore . QSize ( 400 , 150 ) )
self . in_label = QtGui . QLabel ( self )
self . in_label . setGeometry ( QtCore . QRect ( 25 , 5 , 350 , 20 ) )
self . out_label = QtGui . QLabel ( self )
self . out_label . setGeometry ( QtCore . QRect ( 25 , 65 , 350 , 20 ) )
font = QtGui . QFont ( )
font . setPointSize ( 16 )
font . setBold ( True )
self . in_label . setFont ( font )
self . out_label . setFont ( font )
self . input = QtGui . QComboBox ( self )
self . input . setGeometry ( QtCore . QRect ( 25 , 30 , 350 , 30 ) )
self . output = QtGui . QComboBox ( self )
self . output . setGeometry ( QtCore . QRect ( 25 , 90 , 350 , 30 ) )
p = pyaudio . PyAudio ( )
settings = Settings . get_instance ( )
self . in_indexes , self . out_indexes = [ ] , [ ]
2016-06-21 13:58:11 +02:00
for i in range ( p . get_device_count ( ) ) :
2016-04-24 12:45:11 +02:00
device = p . get_device_info_by_index ( i )
if device [ " maxInputChannels " ] :
2016-06-21 13:58:11 +02:00
self . input . addItem ( str ( device [ " name " ] ) )
2016-04-24 12:45:11 +02:00
self . in_indexes . append ( i )
if device [ " maxOutputChannels " ] :
2016-06-21 13:58:11 +02:00
self . output . addItem ( str ( device [ " name " ] ) )
2016-04-24 12:45:11 +02:00
self . out_indexes . append ( i )
self . input . setCurrentIndex ( self . in_indexes . index ( settings . audio [ ' input ' ] ) )
self . output . setCurrentIndex ( self . out_indexes . index ( settings . audio [ ' output ' ] ) )
QtCore . QMetaObject . connectSlotsByName ( self )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( " audioSettingsForm " , " Audio settings " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . in_label . setText ( QtGui . QApplication . translate ( " audioSettingsForm " , " Input device: " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . out_label . setText ( QtGui . QApplication . translate ( " audioSettingsForm " , " Output device: " , None , QtGui . QApplication . UnicodeUTF8 ) )
def closeEvent ( self , event ) :
settings = Settings . get_instance ( )
settings . audio [ ' input ' ] = self . in_indexes [ self . input . currentIndex ( ) ]
settings . audio [ ' output ' ] = self . out_indexes [ self . output . currentIndex ( ) ]
settings . save ( )
2016-05-28 12:06:13 +02:00
class PluginsSettings ( CenteredWidget ) :
2016-06-05 19:17:39 +02:00
"""
Plugins settings form
"""
2016-05-28 12:06:13 +02:00
def __init__ ( self ) :
super ( PluginsSettings , self ) . __init__ ( )
self . initUI ( )
self . center ( )
self . retranslateUi ( )
def initUI ( self ) :
self . resize ( 400 , 210 )
self . setMinimumSize ( QtCore . QSize ( 400 , 210 ) )
self . setMaximumSize ( QtCore . QSize ( 400 , 210 ) )
self . comboBox = QtGui . QComboBox ( self )
self . comboBox . setGeometry ( QtCore . QRect ( 30 , 10 , 340 , 30 ) )
self . label = QtGui . QLabel ( self )
self . label . setGeometry ( QtCore . QRect ( 30 , 40 , 340 , 90 ) )
self . label . setWordWrap ( True )
self . button = QtGui . QPushButton ( self )
self . button . setGeometry ( QtCore . QRect ( 30 , 130 , 340 , 30 ) )
self . button . clicked . connect ( self . button_click )
self . open = QtGui . QPushButton ( self )
self . open . setGeometry ( QtCore . QRect ( 30 , 170 , 340 , 30 ) )
self . open . clicked . connect ( self . open_plugin )
self . pl_loader = plugin_support . PluginLoader . get_instance ( )
self . update_list ( )
self . comboBox . currentIndexChanged . connect ( self . show_data )
self . show_data ( )
def retranslateUi ( self ) :
self . setWindowTitle ( QtGui . QApplication . translate ( ' PluginsForm ' , " Plugins " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . open . setText ( QtGui . QApplication . translate ( ' PluginsForm ' , " Open selected plugin " , None , QtGui . QApplication . UnicodeUTF8 ) )
def open_plugin ( self ) :
ind = self . comboBox . currentIndex ( )
plugin = self . data [ ind ]
window = self . pl_loader . plugin_window ( plugin [ - 1 ] )
if window is not None :
self . window = window
self . window . show ( )
else :
msgBox = QtGui . QMessageBox ( )
2016-06-15 15:15:23 +02:00
text = QtGui . QApplication . translate ( " PluginsForm " , ' No GUI found for this plugin ' , None ,
QtGui . QApplication . UnicodeUTF8 )
msgBox . setWindowTitle ( QtGui . QApplication . translate ( " PluginsForm " , ' Error ' , None ,
QtGui . QApplication . UnicodeUTF8 ) )
2016-05-28 12:06:13 +02:00
msgBox . setText ( text )
msgBox . exec_ ( )
def update_list ( self ) :
self . comboBox . clear ( )
data = self . pl_loader . get_plugins_list ( )
2016-06-21 22:43:43 +02:00
self . comboBox . addItems ( list ( map ( lambda x : x [ 0 ] , data ) ) )
2016-05-28 12:06:13 +02:00
self . data = data
def show_data ( self ) :
ind = self . comboBox . currentIndex ( )
2016-06-05 13:59:36 +02:00
if len ( self . data ) :
plugin = self . data [ ind ]
descr = plugin [ 2 ] or QtGui . QApplication . translate ( " PluginsForm " , " No description available " , None , QtGui . QApplication . UnicodeUTF8 )
self . label . setText ( descr )
if plugin [ 1 ] :
self . button . setText ( QtGui . QApplication . translate ( " PluginsForm " , " Disable plugin " , None , QtGui . QApplication . UnicodeUTF8 ) )
else :
self . button . setText ( QtGui . QApplication . translate ( " PluginsForm " , " Enable plugin " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-28 12:06:13 +02:00
else :
2016-06-05 13:59:36 +02:00
self . open . setVisible ( False )
self . button . setVisible ( False )
self . label . setText ( QtGui . QApplication . translate ( " PluginsForm " , " No plugins found " , None , QtGui . QApplication . UnicodeUTF8 ) )
2016-05-28 12:06:13 +02:00
def button_click ( self ) :
ind = self . comboBox . currentIndex ( )
plugin = self . data [ ind ]
self . pl_loader . toggle_plugin ( plugin [ - 1 ] )
plugin [ 1 ] = not plugin [ 1 ]
if plugin [ 1 ] :
self . button . setText ( QtGui . QApplication . translate ( " PluginsForm " , " Disable plugin " , None , QtGui . QApplication . UnicodeUTF8 ) )
else :
self . button . setText ( QtGui . QApplication . translate ( " PluginsForm " , " Enable plugin " , None , QtGui . QApplication . UnicodeUTF8 ) )