inlines fix, menu fix, settings upgrade
This commit is contained in:
parent
ee15359c19
commit
9b02089bff
3 changed files with 34 additions and 13 deletions
|
@ -339,11 +339,11 @@ class NotificationsSettings(CenteredWidget):
|
||||||
self.setMinimumSize(QtCore.QSize(350, 200))
|
self.setMinimumSize(QtCore.QSize(350, 200))
|
||||||
self.setMaximumSize(QtCore.QSize(350, 200))
|
self.setMaximumSize(QtCore.QSize(350, 200))
|
||||||
self.enableNotifications = QtGui.QCheckBox(self)
|
self.enableNotifications = QtGui.QCheckBox(self)
|
||||||
self.enableNotifications.setGeometry(QtCore.QRect(10, 20, 270, 20))
|
self.enableNotifications.setGeometry(QtCore.QRect(10, 20, 340, 18))
|
||||||
self.callsSound = QtGui.QCheckBox(self)
|
self.callsSound = QtGui.QCheckBox(self)
|
||||||
self.callsSound.setGeometry(QtCore.QRect(10, 120, 270, 20))
|
self.callsSound.setGeometry(QtCore.QRect(10, 120, 340, 18))
|
||||||
self.soundNotifications = QtGui.QCheckBox(self)
|
self.soundNotifications = QtGui.QCheckBox(self)
|
||||||
self.soundNotifications.setGeometry(QtCore.QRect(10, 70, 270, 20))
|
self.soundNotifications.setGeometry(QtCore.QRect(10, 70, 340, 18))
|
||||||
s = Settings.get_instance()
|
s = Settings.get_instance()
|
||||||
self.enableNotifications.setChecked(s['notifications'])
|
self.enableNotifications.setChecked(s['notifications'])
|
||||||
self.soundNotifications.setChecked(s['sound_notifications'])
|
self.soundNotifications.setChecked(s['sound_notifications'])
|
||||||
|
|
|
@ -219,6 +219,7 @@ class Friend(Contact):
|
||||||
if inline: # inline was loaded
|
if inline: # inline was loaded
|
||||||
i = self._corr.index(tr)
|
i = self._corr.index(tr)
|
||||||
self._corr.insert(i, inline)
|
self._corr.insert(i, inline)
|
||||||
|
return i - len(self._corr)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log('Update transfer data failed: ' + str(ex))
|
log('Update transfer data failed: ' + str(ex))
|
||||||
|
|
||||||
|
@ -787,6 +788,7 @@ class Profile(Contact, Singleton):
|
||||||
file_name,
|
file_name,
|
||||||
friend_number,
|
friend_number,
|
||||||
file_number)
|
file_number)
|
||||||
|
|
||||||
elif auto:
|
elif auto:
|
||||||
path = settings['auto_accept_path'] or curr_directory()
|
path = settings['auto_accept_path'] or curr_directory()
|
||||||
new_file_name, i = file_name, 1
|
new_file_name, i = file_name, 1
|
||||||
|
@ -797,7 +799,7 @@ class Profile(Contact, Singleton):
|
||||||
d = len(file_name)
|
d = len(file_name)
|
||||||
new_file_name = file_name[:d] + ' ({})'.format(i) + file_name[d:]
|
new_file_name = file_name[:d] + ' ({})'.format(i) + file_name[d:]
|
||||||
i += 1
|
i += 1
|
||||||
self.accept_transfer(None, path + '/' + new_file_name, friend_number, file_number)
|
self.accept_transfer(None, path + '/' + new_file_name, friend_number, file_number, size)
|
||||||
tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
|
tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
|
||||||
time.time(),
|
time.time(),
|
||||||
FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'],
|
FILE_TRANSFER_MESSAGE_STATUS['INCOMING_STARTED'],
|
||||||
|
@ -814,10 +816,13 @@ class Profile(Contact, Singleton):
|
||||||
friend_number,
|
friend_number,
|
||||||
file_number)
|
file_number)
|
||||||
if friend_number == self.get_active_number():
|
if friend_number == self.get_active_number():
|
||||||
self.create_file_transfer_item(tm)
|
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()
|
self._messages.scrollToBottom()
|
||||||
else:
|
else:
|
||||||
friend.set_messages(True)
|
friend.set_messages(True)
|
||||||
|
|
||||||
friend.append_message(tm)
|
friend.append_message(tm)
|
||||||
|
|
||||||
def cancel_transfer(self, friend_number, file_number, already_cancelled=False):
|
def cancel_transfer(self, friend_number, file_number, already_cancelled=False):
|
||||||
|
@ -841,7 +846,7 @@ class Profile(Contact, Singleton):
|
||||||
|
|
||||||
def accept_transfer(self, item, path, friend_number, file_number, size, inline=False):
|
def accept_transfer(self, item, path, friend_number, file_number, size, inline=False):
|
||||||
"""
|
"""
|
||||||
:param item: transfer item. None if auto accept
|
:param item: transfer item.
|
||||||
:param path: path for saving
|
:param path: path for saving
|
||||||
:param friend_number: friend number
|
:param friend_number: friend number
|
||||||
:param file_number: file number
|
:param file_number: file number
|
||||||
|
@ -909,12 +914,19 @@ class Profile(Contact, Singleton):
|
||||||
self.set_active(None)
|
self.set_active(None)
|
||||||
elif type(transfer) is ReceiveToBuffer:
|
elif type(transfer) is ReceiveToBuffer:
|
||||||
inline = InlineImage(transfer.get_data())
|
inline = InlineImage(transfer.get_data())
|
||||||
self.get_friend_by_number(friend_number).update_transfer_data(file_number,
|
i = self.get_friend_by_number(friend_number).update_transfer_data(file_number,
|
||||||
FILE_TRANSFER_MESSAGE_STATUS['FINISHED'],
|
FILE_TRANSFER_MESSAGE_STATUS['FINISHED'],
|
||||||
inline)
|
inline)
|
||||||
self.set_active(self._active_friend)
|
if friend_number == self.get_active_number():
|
||||||
|
count = self._messages.count()
|
||||||
|
item = InlineImageItem(transfer.get_data())
|
||||||
|
elem = QtGui.QListWidgetItem()
|
||||||
|
elem.setSizeHint(QtCore.QSize(600, item.height()))
|
||||||
|
self._messages.insertItem(count + i + 1, elem)
|
||||||
|
self._messages.setItemWidget(elem, item)
|
||||||
else:
|
else:
|
||||||
self.get_friend_by_number(friend_number).update_transfer_data(file_number, FILE_TRANSFER_MESSAGE_STATUS['FINISHED'])
|
self.get_friend_by_number(friend_number).update_transfer_data(file_number,
|
||||||
|
FILE_TRANSFER_MESSAGE_STATUS['FINISHED'])
|
||||||
del self._file_transfers[(friend_number, file_number)]
|
del self._file_transfers[(friend_number, file_number)]
|
||||||
|
|
||||||
def outgoing_chunk(self, friend_number, file_number, position, size):
|
def outgoing_chunk(self, friend_number, file_number, position, size):
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Settings(Singleton, dict):
|
||||||
with open(self.path) as fl:
|
with open(self.path) as fl:
|
||||||
data = fl.read()
|
data = fl.read()
|
||||||
super(self.__class__, self).__init__(json.loads(data))
|
super(self.__class__, self).__init__(json.loads(data))
|
||||||
|
self.upgrade()
|
||||||
else:
|
else:
|
||||||
super(self.__class__, self).__init__(Settings.get_default_settings())
|
super(self.__class__, self).__init__(Settings.get_default_settings())
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -37,7 +38,7 @@ class Settings(Singleton, dict):
|
||||||
p = Settings.get_default_path() + 'toxygen.json'
|
p = Settings.get_default_path() + 'toxygen.json'
|
||||||
data = json.dumps({'path': unicode(path.decode(locale.getpreferredencoding())), 'name': unicode(name)})
|
data = json.dumps({'path': unicode(path.decode(locale.getpreferredencoding())), 'name': unicode(name)})
|
||||||
with open(p, 'w') as fl:
|
with open(p, 'w') as fl:
|
||||||
fl.write(data)
|
fl.write(data)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_default_settings():
|
def get_default_settings():
|
||||||
|
@ -62,7 +63,8 @@ class Settings(Singleton, dict):
|
||||||
'auto_accept_from_friends': [],
|
'auto_accept_from_friends': [],
|
||||||
'friends_aliases': [],
|
'friends_aliases': [],
|
||||||
'typing_notifications': True,
|
'typing_notifications': True,
|
||||||
'calls_sound': True
|
'calls_sound': True,
|
||||||
|
'blocked': []
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -73,6 +75,13 @@ class Settings(Singleton, dict):
|
||||||
('French', 'fr_FR')
|
('French', 'fr_FR')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def upgrade(self):
|
||||||
|
default = Settings.get_default_settings()
|
||||||
|
for key in default:
|
||||||
|
if key not in self:
|
||||||
|
self[key] = default[key]
|
||||||
|
self.save()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
text = json.dumps(self)
|
text = json.dumps(self)
|
||||||
with open(self.path, 'w') as fl:
|
with open(self.path, 'w') as fl:
|
||||||
|
|
Loading…
Reference in a new issue