From 55f13cbfd1e09ba2e354daaced9211d1b387d4a7 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 23 Jun 2016 11:18:18 +0300 Subject: [PATCH] audio, smileys fixes --- src/callbacks.py | 4 ++-- src/calls.py | 2 +- src/mainscreen.py | 3 ++- src/mainscreen_widgets.py | 4 ++-- src/profile.py | 1 - src/smileys.py | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 6066dd9..a1d4a26 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -280,9 +280,9 @@ def callback_audio(toxav, friend_number, samples, audio_samples_per_channel, aud """ New audio chunk """ - # print audio_samples_per_channel, audio_channels_count, rate + # print(audio_samples_per_channel, audio_channels_count, rate) Profile.get_instance().call.chunk( - ''.join(chr(x) for x in samples[:audio_samples_per_channel * 2 * audio_channels_count]), + bytes(samples[:audio_samples_per_channel * 2 * audio_channels_count]), audio_channels_count, rate) diff --git a/src/calls.py b/src/calls.py index 6e0d936..16cef47 100644 --- a/src/calls.py +++ b/src/calls.py @@ -30,7 +30,7 @@ class AV: self._audio_rate = 8000 self._audio_channels = 1 self._audio_duration = 60 - self._audio_sample_count = self._audio_rate * self._audio_channels * self._audio_duration / 1000 + self._audio_sample_count = self._audio_rate * self._audio_channels * self._audio_duration // 1000 def __contains__(self, friend_number): return friend_number in self._calls diff --git a/src/mainscreen.py b/src/mainscreen.py index 4c3dbed..6dc10d0 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -423,7 +423,8 @@ class MainWindow(QtGui.QMainWindow): def send_smiley(self): self.menu.hide() if self.profile.active_friend + 1: - self.smiley = SmileyWindow(self) + if not hasattr(self, 'smiley'): + self.smiley = SmileyWindow(self) self.smiley.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(), self.y() + self.height() - 200, self.smiley.width(), diff --git a/src/mainscreen_widgets.py b/src/mainscreen_widgets.py index 77c993f..7027238 100644 --- a/src/mainscreen_widgets.py +++ b/src/mainscreen_widgets.py @@ -133,10 +133,10 @@ class SmileyWindow(QtGui.QWidget): count = len(self.data) self.page_size = int(pow(count / 8, 0.5) + 1) * 8 # smileys per page if count % self.page_size == 0: - self.page_count = count / self.page_size + self.page_count = count // self.page_size else: self.page_count = int(count / float(self.page_size) + 0.5) - self.page = 0 + self.page = -1 self.radio = [] self.parent = parent for i in range(self.page_count): # buttons with smileys diff --git a/src/profile.py b/src/profile.py index ac567c7..1780a6b 100644 --- a/src/profile.py +++ b/src/profile.py @@ -913,7 +913,6 @@ class Profile(contact.Contact, Singleton): self.send_inline(data, 'sticker.png') def send_inline(self, data, file_name, friend_number=None, is_resend=False): - print('Send inline:' + str(type(data))) friend_number = friend_number or self.get_active_number() friend = self.get_friend_by_number(friend_number) if friend.status is None and not is_resend: diff --git a/src/smileys.py b/src/smileys.py index f64c6f7..6ce0dd5 100644 --- a/src/smileys.py +++ b/src/smileys.py @@ -41,7 +41,7 @@ class SmileyLoader(util.Singleton): if value not in values: keys.append(key) values.append(value) - self._list = zip(keys, values) + self._list = list(zip(keys, values)) except Exception as ex: self._smileys = {} self._list = [] @@ -55,7 +55,7 @@ class SmileyLoader(util.Singleton): return [x[1] for x in os.walk(d)][0] def get_smileys(self): - return list(self._list)[:] + return list(self._list) def add_smileys_to_text(self, text, edit): """