5 Commits

Author SHA1 Message Date
3546dbd75b some broken dialogs fixed 2017-05-08 23:58:23 +03:00
b081bff2ce some mainscreen widgets fixes 2017-04-16 22:56:31 +03:00
e257d8f96f signals && imports fixes 2017-04-13 19:22:46 +03:00
972a073cb9 missed translations fix, travis fix, updates 2017-04-11 21:38:00 +03:00
e4998cd5b5 pyqt5 initial commit 2017-04-11 21:10:03 +03:00
42 changed files with 2662 additions and 4392 deletions

3
.gitignore vendored
View File

@ -6,7 +6,6 @@ tests/tests
tests/libs tests/libs
tests/.cache tests/.cache
tests/__pycache__ tests/__pycache__
tests/avatars
toxygen/libs toxygen/libs
.idea .idea
*~ *~
@ -24,4 +23,4 @@ toxygen/__pycache__
html html
Toxygen.egg-info Toxygen.egg-info
*.tox *.tox
.cache

View File

@ -2,24 +2,16 @@ language: python
python: python:
- "3.5" - "3.5"
- "3.6" - "3.6"
os:
- linux
dist: trusty
notifications:
email: false
before_install: before_install:
- sudo apt-get update - sudo apt-get update
- sudo apt-get install -y checkinstall build-essential - sudo apt-get install -y checkinstall build-essential
- sudo apt-get install portaudio19-dev - sudo apt-get install portaudio19-dev
- sudo apt-get install libsecret-1-dev
- sudo apt-get install libconfig-dev libvpx-dev check -qq - sudo apt-get install libconfig-dev libvpx-dev check -qq
- sudo apt-get install -y python3-pyqt5
install: install:
- pip install sip
- pip install pyqt5
- pip install pyaudio - pip install pyaudio
- pip install opencv-python
before_script: before_script:
# Opus # OPUS
- wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz - wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
- tar xzf opus-1.0.3.tar.gz - tar xzf opus-1.0.3.tar.gz
- cd opus-1.0.3 - cd opus-1.0.3

View File

@ -12,7 +12,9 @@ include toxygen/smileys/starwars/*.png
include toxygen/smileys/starwars/config.json include toxygen/smileys/starwars/config.json
include toxygen/smileys/ksk/*.png include toxygen/smileys/ksk/*.png
include toxygen/smileys/ksk/config.json include toxygen/smileys/ksk/config.json
include toxygen/styles/*.qss include toxygen/styles/style.qss
include toxygen/translations/*.qm include toxygen/translations/*.qm
include toxygen/libs/libtox.dll include toxygen/libs/libtox.dll
include toxygen/libs/libsodium.a include toxygen/libs/libsodium.a
include toxygen/libs/libtox64.dll
include toxygen/libs/libsodium64.a

View File

@ -10,38 +10,41 @@ Toxygen is powerful cross-platform [Tox](https://tox.chat/) client written in pu
### [Install](/docs/install.md) - [Contribute](/docs/contributing.md) - [Plugins](/docs/plugins.md) - [Compile](/docs/compile.md) - [Contact](/docs/contact.md) - [Updater](https://github.com/toxygen-project/toxygen_updater) ### [Install](/docs/install.md) - [Contribute](/docs/contributing.md) - [Plugins](/docs/plugins.md) - [Compile](/docs/compile.md) - [Contact](/docs/contact.md) - [Updater](https://github.com/toxygen-project/toxygen_updater)
### Supported OS: Linux and Windows ### Supported OS:
![Linux, Windows and OS X](/docs/os.png)
### Features: ### Features:
- 1v1 messages - [x] 1v1 messages
- File transfers - [x] File transfers
- Audio calls - [x] Audio calls
- Video calls - [x] Plugins support
- Plugins support - [x] Chat history
- Desktop sharing - [x] Emoticons
- Chat history - [x] Stickers
- Emoticons - [x] Screenshots
- Stickers - [x] Name lookups (toxme.io support)
- Screenshots - [x] Save file encryption
- Name lookups (toxme.io support) - [x] Profile import and export
- Save file encryption - [x] Faux offline messaging
- Profile import and export - [x] Faux offline file transfers
- Faux offline messaging - [x] Inline images
- Faux offline file transfers - [x] Message splitting
- Inline images - [x] Proxy support
- Message splitting - [x] Avatars
- Proxy support - [x] Multiprofile
- Avatars - [x] Multilingual
- Multiprofile - [x] Sound notifications
- Multilingual - [x] Contact aliases
- Sound notifications - [x] Contact blocking
- Contact aliases - [x] Typing notifications
- Contact blocking - [x] Changing nospam
- Typing notifications - [x] File resuming
- Changing nospam - [x] Read receipts
- File resuming - [ ] Video calls
- Read receipts - [ ] Desktop sharing
- [ ] Group chats
### Downloads ### Downloads
[Releases](https://github.com/toxygen-project/toxygen/releases) [Releases](https://github.com/toxygen-project/toxygen/releases)

View File

@ -4,7 +4,7 @@ Help us find all bugs in Toxygen! Please provide following info:
- OS - OS
- Toxygen version - Toxygen version
- Toxygen executable info - python executable (.py), precompiled binary, from package etc. - Toxygen executable info - .py or precompiled binary, how was it installed in system
- Steps to reproduce the bug - Steps to reproduce the bug
Want to see new feature in Toxygen? [Ask for it!](https://github.com/toxygen-project/toxygen/issues) Want to see new feature in Toxygen? [Ask for it!](https://github.com/toxygen-project/toxygen/issues)
@ -15,8 +15,6 @@ Developer? Feel free to open pull request. Our dev team is small so we glad to g
Don't know what to do? Improve UI, fix [issues](https://github.com/toxygen-project/toxygen/issues) or implement features from our TODO list. Don't know what to do? Improve UI, fix [issues](https://github.com/toxygen-project/toxygen/issues) or implement features from our TODO list.
You can find our TODO's in code, issues list and [here](/README.md). Also you can implement [plugins](/docs/plugins.md) for Toxygen. You can find our TODO's in code, issues list and [here](/README.md). Also you can implement [plugins](/docs/plugins.md) for Toxygen.
Note that we have a lot of branches for different purposes. Master branch is for stable versions (releases) only, so I recommend to open PR's to develop branch. Development of next Toxygen version usually goes there. Other branches used for implementing different tasks such as file transfers improvements or audio calls implementation etc.
#Translations #Translations
Help us translate Toxygen! Translation can be created using pylupdate (``pylupdate5 toxygen.pro``) and QT Linguist. Help us translate Toxygen! Translation can be created using pyside-lupdate (``pyside-lupdate toxygen.pro``) and QT Linguist.

View File

@ -1,13 +1,13 @@
# How to install Toxygen # How to install Toxygen
## Use precompiled binary (recommended for users): ## Use precompiled binary:
[Check our releases page](https://github.com/toxygen-project/toxygen/releases) [Check our releases page](https://github.com/toxygen-project/toxygen/releases)
## Using pip3 ## Using pip3
### Windows ### Windows
``pip install toxygen`` ``pip3.4 install toxygen``
Run app using ``toxygen`` command. Run app using ``toxygen`` command.
@ -16,11 +16,19 @@ Run app using ``toxygen`` command.
1. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/) 1. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/)
2. Install PortAudio: 2. Install PortAudio:
``sudo apt-get install portaudio19-dev`` ``sudo apt-get install portaudio19-dev``
3. For 32-bit Linux install PyQt5: ``sudo apt-get install python3-pyqt5`` 3. Install PySide: ``sudo apt-get install python3-pyside``
4. Install [OpenCV](http://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html) or via ``sudo apt-get install python3-opencv`` 4. Install toxygen:
5. Install toxygen: ``sudo pip3.4 install toxygen``
``sudo pip3 install toxygen`` 5. Run toxygen using ``toxygen`` command.
6. Run toxygen using ``toxygen`` command.
### OS X
1. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system
2. Install PortAudio:
``brew install portaudio``
3. Install toxygen:
``pip3.4 install toxygen``
4. Run toxygen using ``toxygen`` command.
## Packages ## Packages
@ -32,19 +40,15 @@ Debian/Ubuntu: [tox.chat](https://tox.chat/download.html#gnulinux)
### Windows ### Windows
Note: 32-bit Python isn't supported due to bug with videocalls. It is strictly recommended to use 64-bit Python. 1. [Download and install latest Python 3.4](https://www.python.org/downloads/windows/)
2. [Install PySide](https://pypi.python.org/pypi/PySide/1.2.4#installing-pyside-on-a-windows-system) (recommended) or [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
3. Install PyAudio: ``pip3.4 install pyaudio``
4. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
5. Unpack archive
6. Download latest libtox.dll build, download latest libsodium.a build, put it into \src\libs\
7. Run \toxygen\main.py.
1. [Download and install latest Python 3 64-bit](https://www.python.org/downloads/windows/) Optional: install toxygen using setup.py: ``python3.4 setup.py install``
2. Install PyQt5: ``pip install pyqt5``
3. Install PyAudio: ``pip install pyaudio``
4. Install numpy: ``pip install numpy``
5. Install OpenCV: ``pip install opencv-python``
6. [Download toxygen](https://github.com/toxygen-project/toxygen/archive/master.zip)
7. Unpack archive
8. Download latest libtox.dll build, download latest libsodium.a build, put it into \toxygen\libs\
9. Run \toxygen\main.py.
Optional: install toxygen using setup.py: ``python setup.py install``
[libtox.dll for 32-bit Python](https://build.tox.chat/view/libtoxcore/job/libtoxcore_build_windows_x86_shared_release/lastSuccessfulBuild/artifact/libtoxcore_build_windows_x86_shared_release.zip) [libtox.dll for 32-bit Python](https://build.tox.chat/view/libtoxcore/job/libtoxcore_build_windows_x86_shared_release/lastSuccessfulBuild/artifact/libtoxcore_build_windows_x86_shared_release.zip)
@ -58,15 +62,27 @@ Optional: install toxygen using setup.py: ``python setup.py install``
1. Install latest Python3: 1. Install latest Python3:
``sudo apt-get install python3`` ``sudo apt-get install python3``
2. Install PyQt5: ``sudo apt-get install python3-pyqt5`` or ``sudo pip3 install pyqt5`` 2. Install PySide: ``sudo apt-get install python3-pyside`` or install [PyQt4](https://riverbankcomputing.com/software/pyqt/download) (``sudo apt-get install python3-pyqt4``).
3. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/) 3. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/)
4. Install PyAudio: 4. Install PyAudio:
``sudo apt-get install portaudio19-dev`` and ``sudo apt-get install python3-pyaudio`` (or ``sudo pip3 install pyaudio``) ``sudo apt-get install portaudio19-dev`` and ``sudo apt-get install python3-pyaudio`` (or ``pip3 install pyaudio``)
5. Install NumPy: ``sudo pip3 install numpy`` 5. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
6. Install [OpenCV](http://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html) or via ``sudo apt-get install python3-opencv`` 6. Unpack archive
7. [Download toxygen](https://github.com/toxygen-project/toxygen/archive/master.zip) 7. Run app:
8. Unpack archive ``python3.4 main.py``
9. Run app:
``python3 main.py`` Optional: install toxygen using setup.py: ``python3.4 setup.py install``
### OS X
1. [Download and install latest Python 3.4](https://www.python.org/downloads/mac-osx/)
2. [Install PySide](https://pypi.python.org/pypi/PySide/1.2.4#installing-pyside-on-a-mac-os-x-system) (recommended) or [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
3. Install PortAudio:
``brew install portaudio``
4. Install PyAudio: ``pip3 install pyaudio``
5. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system
6. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
7. Unpack archive
8. Run \toxygen\main.py.
Optional: install toxygen using setup.py: ``python3 setup.py install`` Optional: install toxygen using setup.py: ``python3 setup.py install``

BIN
docs/os.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,6 +1,6 @@
# Plugins API # Plugins API
In Toxygen plugin is single python (supported Python 3.4 - 3.6) module (.py file) and directory with data associated with it. In Toxygen plugin is single python (supported Python 3.0 - 3.4) module (.py file) and directory with data associated with it.
Every module must contain one class derived from PluginSuperClass defined in [plugin_super_class.py](/src/plugins/plugin_super_class.py). Instance of this class will be created by PluginLoader class (defined in [plugin_support.py](/src/plugin_support.py) ). This class can enable/disable plugins and send data to it. Every module must contain one class derived from PluginSuperClass defined in [plugin_super_class.py](/src/plugins/plugin_super_class.py). Instance of this class will be created by PluginLoader class (defined in [plugin_support.py](/src/plugin_support.py) ). This class can enable/disable plugins and send data to it.
Every plugin has its own full name and unique short name (1-5 symbols). Main app can get it using special methods. Every plugin has its own full name and unique short name (1-5 symbols). Main app can get it using special methods.
@ -45,7 +45,7 @@ Import statement will not work in case you import module that wasn't previously
About GUI: About GUI:
GUI is available via PyQt5. Plugin can have no GUI at all. It's strictly recommended to support both PySide and PyQt4 in GUI. Plugin can have no GUI at all.
Exceptions: Exceptions:

View File

@ -1,6 +1,6 @@
# Plugins # Plugins
Toxygen is the first [Tox](https://tox.chat/) client with plugins support. Plugin is Python 3.4 - 3.6 module (.py file) and directory with plugin's data which provide some additional functionality. Toxygen is the first [Tox](https://tox.chat/) client with plugins support. Plugin is Python 3.4 module (.py file) and directory with plugin's data which provide some additional functionality.
# How to write plugin # How to write plugin

View File

@ -8,23 +8,15 @@ import sys
version = program_version + '.0' version = program_version + '.0'
if system() == 'Windows':
MODULES = ['PyQt5', 'PyAudio', 'numpy', 'opencv-python']
else:
MODULES = [] MODULES = []
if system() in ('Windows', 'Darwin'):
MODULES = ['PyAudio', 'PyQt5']
else:
try: try:
import pyaudio import pyaudio
except ImportError: except ImportError:
MODULES.append('PyAudio') MODULES = ['PyAudio']
try:
import PyQt5
except ImportError:
MODULES.append('PyQt5')
try:
import numpy
except ImportError:
MODULES.append('numpy')
class InstallScript(install): class InstallScript(install):
@ -33,7 +25,9 @@ class InstallScript(install):
def run(self): def run(self):
install.run(self) install.run(self)
try: try:
if system() != 'Windows': if system() == 'Windows':
call(["toxygen", "--configure"])
else:
call(["toxygen", "--clean"]) call(["toxygen", "--clean"])
except: except:
try: try:
@ -43,7 +37,9 @@ class InstallScript(install):
if path[-1] not in ('/', '\\'): if path[-1] not in ('/', '\\'):
path += '/' path += '/'
path += 'bin/toxygen' path += 'bin/toxygen'
if system() != 'Windows': if system() == 'Windows':
call([path, "--configure"])
else:
call([path, "--clean"]) call([path, "--clean"])
except: except:
pass pass
@ -70,4 +66,5 @@ setup(name='Toxygen',
}, },
cmdclass={ cmdclass={
'install': InstallScript, 'install': InstallScript,
}) },
)

View File

@ -19,7 +19,6 @@ class IncomingCallWidget(widgets.CenteredWidget):
self.avatar_label.setScaledContents(False) self.avatar_label.setScaledContents(False)
self.name = widgets.DataLabel(self) self.name = widgets.DataLabel(self)
self.name.setGeometry(QtCore.QRect(90, 20, 300, 25)) self.name.setGeometry(QtCore.QRect(90, 20, 300, 25))
self._friend_number = friend_number
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily(settings.Settings.get_instance()['font']) font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(16) font.setPointSize(16)
@ -52,10 +51,10 @@ class IncomingCallWidget(widgets.CenteredWidget):
self.setWindowTitle(text) self.setWindowTitle(text)
self.name.setText(name) self.name.setText(name)
self.call_type.setText(text) self.call_type.setText(text)
self._processing = False pr = profile.Profile.get_instance()
self.accept_audio.clicked.connect(self.accept_call_with_audio) self.accept_audio.clicked.connect(lambda: pr.accept_call(friend_number, True, False) or self.stop())
self.accept_video.clicked.connect(self.accept_call_with_video) # self.accept_video.clicked.connect(lambda: pr.start_call(friend_number, True, True))
self.decline.clicked.connect(self.decline_call) self.decline.clicked.connect(lambda: pr.stop_call(friend_number, False) or self.stop())
class SoundPlay(QtCore.QThread): class SoundPlay(QtCore.QThread):
@ -106,29 +105,31 @@ class IncomingCallWidget(widgets.CenteredWidget):
self.thread.wait() self.thread.wait()
self.close() self.close()
def accept_call_with_audio(self):
if self._processing:
return
self._processing = True
pr = profile.Profile.get_instance()
pr.accept_call(self._friend_number, True, False)
self.stop()
def accept_call_with_video(self):
if self._processing:
return
self._processing = True
pr = profile.Profile.get_instance()
pr.accept_call(self._friend_number, True, True)
self.stop()
def decline_call(self):
if self._processing:
return
self._processing = True
pr = profile.Profile.get_instance()
pr.stop_call(self._friend_number, False)
self.stop()
def set_pixmap(self, pixmap): def set_pixmap(self, pixmap):
self.avatar_label.setPixmap(pixmap) self.avatar_label.setPixmap(pixmap)
class AudioMessageRecorder(widgets.CenteredWidget):
def __init__(self, friend_number, name):
super(AudioMessageRecorder, self).__init__()
self.label = QtWidgets.QLabel(self)
self.label.setGeometry(QtCore.QRect(10, 20, 250, 20))
text = QtWidgets.QApplication.translate("MenuWindow", "Send audio message to friend {}")
self.label.setText(text.format(name))
self.record = QtWidgets.QPushButton(self)
self.record.setGeometry(QtCore.QRect(20, 100, 150, 150))
self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Start recording"))
self.record.clicked.connect(self.start_or_stop_recording)
self.recording = False
self.friend_num = friend_number
def start_or_stop_recording(self):
if not self.recording:
self.recording = True
self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Stop recording"))
else:
self.close()

View File

@ -9,8 +9,7 @@ from plugin_support import PluginLoader
import queue import queue
import threading import threading
import util import util
import cv2
import numpy as np
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Threads # Threads
@ -313,67 +312,11 @@ def callback_audio(toxav, friend_number, samples, audio_samples_per_channel, aud
""" """
New audio chunk New audio chunk
""" """
Profile.get_instance().call.audio_chunk( Profile.get_instance().call.chunk(
bytes(samples[:audio_samples_per_channel * 2 * audio_channels_count]), bytes(samples[:audio_samples_per_channel * 2 * audio_channels_count]),
audio_channels_count, audio_channels_count,
rate) rate)
# -----------------------------------------------------------------------------------------------------------------
# Callbacks - video
# -----------------------------------------------------------------------------------------------------------------
def video_receive_frame(toxav, friend_number, width, height, y, u, v, ystride, ustride, vstride, user_data):
"""
Creates yuv frame from y, u, v and shows it using OpenCV
For yuv => bgr we need this YUV420 frame:
width
-------------------------
| |
| Y | height
| |
-------------------------
| | |
| U even | U odd | height // 4
| | |
-------------------------
| | |
| V even | V odd | height // 4
| | |
-------------------------
width // 2 width // 2
It can be created from initial y, u, v using slices
For more info see callback_video_receive_frame docs
"""
try:
y_size = abs(max(width, abs(ystride)))
u_size = abs(max(width // 2, abs(ustride)))
v_size = abs(max(width // 2, abs(vstride)))
y = np.asarray(y[:y_size * height], dtype=np.uint8).reshape(height, y_size)
u = np.asarray(u[:u_size * height // 2], dtype=np.uint8).reshape(height // 2, u_size)
v = np.asarray(v[:v_size * height // 2], dtype=np.uint8).reshape(height // 2, v_size)
width -= width % 4
height -= height % 4
frame = np.zeros((int(height * 1.5), width), dtype=np.uint8)
frame[:height, :] = y[:height, :width]
frame[height:height * 5 // 4, :width // 2] = u[:height // 2:2, :width // 2]
frame[height:height * 5 // 4, width // 2:] = u[1:height // 2:2, :width // 2]
frame[height * 5 // 4:, :width // 2] = v[:height // 2:2, :width // 2]
frame[height * 5 // 4:, width // 2:] = v[1:height // 2:2, :width // 2]
frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
invoke_in_main_thread(cv2.imshow, str(friend_number), frame)
except Exception as ex:
print(ex)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Callbacks - initialization # Callbacks - initialization
@ -407,7 +350,7 @@ def init_callbacks(tox, window, tray):
toxav.callback_call_state(call_state, 0) toxav.callback_call_state(call_state, 0)
toxav.callback_call(call, 0) toxav.callback_call(call, 0)
toxav.callback_audio_receive_frame(callback_audio, 0) toxav.callback_audio_receive_frame(callback_audio, 0)
toxav.callback_video_receive_frame(video_receive_frame, 0)
tox.callback_friend_lossless_packet(lossless_packet, 0) tox.callback_friend_lossless_packet(lossless_packet, 0)
tox.callback_friend_lossy_packet(lossy_packet, 0) tox.callback_friend_lossy_packet(lossy_packet, 0)

View File

@ -3,69 +3,14 @@ import time
import threading import threading
import settings import settings
from toxav_enums import * from toxav_enums import *
import cv2 # TODO: play sound until outgoing call will be started or cancelled and add timeout
import itertools # TODO: add widget for call
import numpy as np
import screen_sharing
# TODO: play sound until outgoing call will be started or cancelled
CALL_TYPE = {
class Call: 'NONE': 0,
'AUDIO': 1,
def __init__(self, out_audio, out_video, in_audio=False, in_video=False): 'VIDEO': 2
self._in_audio = in_audio }
self._in_video = in_video
self._out_audio = out_audio
self._out_video = out_video
self._is_active = False
def get_is_active(self):
return self._is_active
def set_is_active(self, value):
self._is_active = value
is_active = property(get_is_active, set_is_active)
# -----------------------------------------------------------------------------------------------------------------
# Audio
# -----------------------------------------------------------------------------------------------------------------
def get_in_audio(self):
return self._in_audio
def set_in_audio(self, value):
self._in_audio = value
in_audio = property(get_in_audio, set_in_audio)
def get_out_audio(self):
return self._out_audio
def set_out_audio(self, value):
self._out_audio = value
out_audio = property(get_out_audio, set_out_audio)
# -----------------------------------------------------------------------------------------------------------------
# Video
# -----------------------------------------------------------------------------------------------------------------
def get_in_video(self):
return self._in_video
def set_in_video(self, value):
self._in_video = value
in_video = property(get_in_video, set_in_video)
def get_out_video(self):
return self._out_video
def set_out_video(self, value):
self._in_video = value
out_video = property(get_out_video, set_out_video)
class AV: class AV:
@ -74,7 +19,7 @@ class AV:
self._toxav = toxav self._toxav = toxav
self._running = True self._running = True
self._calls = {} # dict: key - friend number, value - Call instance self._calls = {} # dict: key - friend number, value - call type
self._audio = None self._audio = None
self._audio_stream = None self._audio_stream = None
@ -87,75 +32,27 @@ class AV:
self._audio_duration = 60 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
self._video = None
self._video_thread = None
self._video_running = False
self._video_width = 640
self._video_height = 480
def stop(self):
self._running = False
self.stop_audio_thread()
self.stop_video_thread()
def __contains__(self, friend_number): def __contains__(self, friend_number):
return friend_number in self._calls return friend_number in self._calls
# -----------------------------------------------------------------------------------------------------------------
# Calls
# -----------------------------------------------------------------------------------------------------------------
def __call__(self, friend_number, audio, video): def __call__(self, friend_number, audio, video):
"""Call friend with specified number""" """Call friend with specified number"""
self._toxav.call(friend_number, 32 if audio else 0, 5000 if video else 0) self._toxav.call(friend_number, 32 if audio else 0, 5000 if video else 0)
self._calls[friend_number] = Call(audio, video) self._calls[friend_number] = CALL_TYPE['AUDIO']
threading.Timer(30.0, lambda: self.finish_not_started_call(friend_number)).start()
def accept_call(self, friend_number, audio_enabled, video_enabled):
if self._running:
self._calls[friend_number] = Call(audio_enabled, video_enabled)
self._toxav.answer(friend_number, 32 if audio_enabled else 0, 5000 if video_enabled else 0)
if audio_enabled:
self.start_audio_thread() self.start_audio_thread()
if video_enabled:
self.start_video_thread()
def finish_call(self, friend_number, by_friend=False): def finish_call(self, friend_number, by_friend=False):
if not by_friend: if not by_friend:
self._toxav.call_control(friend_number, TOXAV_CALL_CONTROL['CANCEL']) self._toxav.call_control(friend_number, TOXAV_CALL_CONTROL['CANCEL'])
if friend_number in self._calls: if friend_number in self._calls:
del self._calls[friend_number] del self._calls[friend_number]
if not len(list(filter(lambda c: c.out_audio, self._calls))): if not len(self._calls):
self.stop_audio_thread() self.stop_audio_thread()
if not len(list(filter(lambda c: c.out_video, self._calls))):
self.stop_video_thread()
def finish_not_started_call(self, friend_number): def stop(self):
if friend_number in self: self._running = False
call = self._calls[friend_number] self.stop_audio_thread()
if not call.is_active:
self.finish_call(friend_number)
def toxav_call_state_cb(self, friend_number, state):
"""
New call state
"""
call = self._calls[friend_number]
call.is_active = True
call.in_audio = state | TOXAV_FRIEND_CALL_STATE['SENDING_A']
call.in_video = state | TOXAV_FRIEND_CALL_STATE['SENDING_V']
if state | TOXAV_FRIEND_CALL_STATE['ACCEPTING_A'] and call.out_audio:
self.start_audio_thread()
if state | TOXAV_FRIEND_CALL_STATE['ACCEPTING_V'] and call.out_video:
self.start_video_thread()
# -----------------------------------------------------------------------------------------------------------------
# Threads
# -----------------------------------------------------------------------------------------------------------------
def start_audio_thread(self): def start_audio_thread(self):
""" """
@ -195,41 +92,7 @@ class AV:
self._out_stream.close() self._out_stream.close()
self._out_stream = None self._out_stream = None
def start_video_thread(self): def chunk(self, samples, channels_count, rate):
if self._video_thread is not None:
return
self._video_running = True
s = settings.Settings.get_instance()
self._video_width = s.video['width']
self._video_height = s.video['height']
if s.video['device'] == -1:
self._video = screen_sharing.DesktopGrabber(s.video['x'], s.video['y'],
s.video['width'], s.video['height'])
else:
self._video = cv2.VideoCapture(s.video['device'])
self._video.set(cv2.CAP_PROP_FPS, 25)
self._video.set(cv2.CAP_PROP_FRAME_WIDTH, self._video_width)
self._video.set(cv2.CAP_PROP_FRAME_HEIGHT, self._video_height)
self._video_thread = threading.Thread(target=self.send_video)
self._video_thread.start()
def stop_video_thread(self):
if self._video_thread is None:
return
self._video_running = False
self._video_thread.join()
self._video_thread = None
self._video = None
# -----------------------------------------------------------------------------------------------------------------
# Incoming chunks
# -----------------------------------------------------------------------------------------------------------------
def audio_chunk(self, samples, channels_count, rate):
""" """
Incoming chunk Incoming chunk
""" """
@ -242,10 +105,6 @@ class AV:
output=True) output=True)
self._out_stream.write(samples) self._out_stream.write(samples)
# -----------------------------------------------------------------------------------------------------------------
# AV sending
# -----------------------------------------------------------------------------------------------------------------
def send_audio(self): def send_audio(self):
""" """
This method sends audio to friends This method sends audio to friends
@ -255,10 +114,10 @@ class AV:
try: try:
pcm = self._audio_stream.read(self._audio_sample_count) pcm = self._audio_stream.read(self._audio_sample_count)
if pcm: if pcm:
for friend_num in self._calls: for friend in self._calls:
if self._calls[friend_num].out_audio: if self._calls[friend] & 1:
try: try:
self._toxav.audio_send_frame(friend_num, pcm, self._audio_sample_count, self._toxav.audio_send_frame(friend, pcm, self._audio_sample_count,
self._audio_channels, self._audio_rate) self._audio_channels, self._audio_rate)
except: except:
pass pass
@ -267,70 +126,19 @@ class AV:
time.sleep(0.01) time.sleep(0.01)
def send_video(self): def accept_call(self, friend_number, audio_enabled, video_enabled):
if self._running:
self._calls[friend_number] = int(video_enabled) * 2 + int(audio_enabled)
self._toxav.answer(friend_number, 32 if audio_enabled else 0, 5000 if video_enabled else 0)
self.start_audio_thread()
def toxav_call_state_cb(self, friend_number, state):
""" """
This method sends video to friends New call state
""" """
while self._video_running: if self._running:
try:
result, frame = self._video.read()
if result:
height, width, channels = frame.shape
for friend_num in self._calls:
if self._calls[friend_num].out_video:
try:
y, u, v = self.convert_bgr_to_yuv(frame)
self._toxav.video_send_frame(friend_num, width, height, y, u, v)
except Exception as e:
print(e)
except Exception as e:
print(e)
time.sleep(0.01) if state & TOXAV_FRIEND_CALL_STATE['ACCEPTING_A']:
self._calls[friend_number] |= 1
def convert_bgr_to_yuv(self, frame):
"""
:param frame: input bgr frame
:return y, u, v: y, u, v values of frame
How this function works:
OpenCV creates YUV420 frame from BGR
This frame has following structure and size:
width, height - dim of input frame
width, height * 1.5 - dim of output frame
width
-------------------------
| |
| Y | height
| |
-------------------------
| | |
| U even | U odd | height // 4
| | |
-------------------------
| | |
| V even | V odd | height // 4
| | |
-------------------------
width // 2 width // 2
Y, U, V can be extracted using slices and joined in one list using itertools.chain.from_iterable()
Function returns bytes(y), bytes(u), bytes(v), because it is required for ctypes
"""
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_I420)
y = frame[:self._video_height, :]
y = list(itertools.chain.from_iterable(y))
u = np.zeros((self._video_height // 2, self._video_width // 2), dtype=np.int)
u[::2, :] = frame[self._video_height:self._video_height * 5 // 4, :self._video_width // 2]
u[1::2, :] = frame[self._video_height:self._video_height * 5 // 4, self._video_width // 2:]
u = list(itertools.chain.from_iterable(u))
v = np.zeros((self._video_height // 2, self._video_width // 2), dtype=np.int)
v[::2, :] = frame[self._video_height * 5 // 4:, :self._video_width // 2]
v[1::2, :] = frame[self._video_height * 5 // 4:, self._video_width // 2:]
v = list(itertools.chain.from_iterable(v))
return bytes(y), bytes(u), bytes(v)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -541,6 +541,8 @@ class InlineImageItem(QtWidgets.QScrollArea):
fl = QtCore.QFile(directory + '/toxygen_inline_' + curr_time().replace(':', '_') + '.png') fl = QtCore.QFile(directory + '/toxygen_inline_' + curr_time().replace(':', '_') + '.png')
self._pixmap.save(fl, 'PNG') self._pixmap.save(fl, 'PNG')
return False
def mark_as_sent(self): def mark_as_sent(self):
return False return False

View File

@ -54,9 +54,10 @@ class Toxygen:
if platform.system() == 'Linux': if platform.system() == 'Linux':
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads) QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
with open(curr_directory() + '/styles/dark_style.qss') as fl: # application color scheme
style = fl.read() with open(curr_directory() + '/styles/style.qss') as fl:
app.setStyleSheet(style) dark_style = fl.read()
app.setStyleSheet(dark_style)
encrypt_save = toxes.ToxES() encrypt_save = toxes.ToxES()
@ -106,7 +107,7 @@ class Toxygen:
return return
self.tox = profile.tox_factory() 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_name(bytes(_login.name, 'utf-8') if _login.name else b'Toxygen User')
self.tox.self_set_status_message(b'Toxing on T03') self.tox.self_set_status_message(b'Toxing on Toxygen')
reply = QtWidgets.QMessageBox.question(None, reply = QtWidgets.QMessageBox.question(None,
'Profile {}'.format(name), 'Profile {}'.format(name),
QtWidgets.QApplication.translate("login", QtWidgets.QApplication.translate("login",
@ -171,13 +172,6 @@ class Toxygen:
else: else:
settings.set_active_profile() settings.set_active_profile()
# application color scheme
for theme in settings.built_in_themes().keys():
if settings['theme'] == theme:
with open(curr_directory() + settings.built_in_themes()[theme]) as fl:
style = fl.read()
app.setStyleSheet(style)
lang = Settings.supported_languages()[settings['language']] lang = Settings.supported_languages()[settings['language']]
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
translator.load(curr_directory() + '/translations/' + lang) translator.load(curr_directory() + '/translations/' + lang)
@ -454,6 +448,27 @@ def clean():
remove(d) remove(d)
def configure():
"""Removes unused libs"""
d = curr_directory() + '/libs/'
is_64bits = is_64_bit()
if not is_64bits:
if os.path.exists(d + 'libtox64.dll'):
os.remove(d + 'libtox64.dll')
if os.path.exists(d + 'libsodium64.a'):
os.remove(d + 'libsodium64.a')
else:
if os.path.exists(d + 'libtox.dll'):
os.remove(d + 'libtox.dll')
if os.path.exists(d + 'libsodium.a'):
os.remove(d + 'libsodium.a')
try:
os.rename(d + 'libtox64.dll', d + 'libtox.dll')
os.rename(d + 'libsodium64.a', d + 'libsodium.a')
except:
pass
def reset(): def reset():
Settings.reset_auto_profile() Settings.reset_auto_profile()
@ -469,6 +484,9 @@ def main():
elif arg == '--help': elif arg == '--help':
print('Usage:\ntoxygen path_to_profile\ntoxygen tox_id\ntoxygen --version\ntoxygen --reset') print('Usage:\ntoxygen path_to_profile\ntoxygen tox_id\ntoxygen --version\ntoxygen --reset')
return return
elif arg == '--configure':
configure()
return
elif arg == '--clean': elif arg == '--clean':
clean() clean()
return return

View File

@ -22,47 +22,51 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
if settings.Settings.get_instance()['show_welcome_screen']: if settings.Settings.get_instance()['show_welcome_screen']:
self.ws = WelcomeScreen() self.ws = WelcomeScreen()
def setup_menu(self, window): def setup_menu(self, Form):
self.menubar = QtWidgets.QMenuBar(window) box = QtWidgets.QHBoxLayout()
self.menubar.setObjectName("menubar") box.setContentsMargins(0, 0, 0, 0)
self.menubar.setNativeMenuBar(False) box.setAlignment(QtCore.Qt.AlignLeft)
self.menubar.setMinimumSize(self.width(), 25) self.profile_button = MainMenuButton(Form)
self.menubar.setMaximumSize(self.width(), 25) box.addWidget(self.profile_button)
self.menubar.setBaseSize(self.width(), 25) self.settings_button = MainMenuButton(Form)
self.menuProfile = QtWidgets.QMenu(self.menubar) box.addWidget(self.settings_button)
self.plugins_button = MainMenuButton(Form)
box.addWidget(self.plugins_button)
self.about_button = MainMenuButton(Form)
box.addWidget(self.about_button)
box.setSpacing(0)
self.menuProfile = QtWidgets.QMenu(self.menubar) self.menuProfile = QtWidgets.QMenu()
self.menuProfile.setObjectName("menuProfile") self.menuProfile.setObjectName("menuProfile")
self.menuSettings = QtWidgets.QMenu(self.menubar) self.menuSettings = QtWidgets.QMenu()
self.menuSettings.setObjectName("menuSettings") self.menuSettings.setObjectName("menuSettings")
self.menuPlugins = QtWidgets.QMenu(self.menubar) self.menuPlugins = QtWidgets.QMenu()
self.menuPlugins.setObjectName("menuPlugins") self.menuPlugins.setObjectName("menuPlugins")
self.menuAbout = QtWidgets.QMenu(self.menubar) self.menuAbout = QtWidgets.QMenu()
self.menuAbout.setObjectName("menuAbout") self.menuAbout.setObjectName("menuAbout")
self.actionAdd_friend = QtWidgets.QAction(window) self.actionAdd_friend = QtWidgets.QAction(Form)
self.actionAdd_friend.setObjectName("actionAdd_friend") self.actionAdd_friend.setObjectName("actionAdd_friend")
self.actionprofilesettings = QtWidgets.QAction(window) self.actionprofilesettings = QtWidgets.QAction(Form)
self.actionprofilesettings.setObjectName("actionprofilesettings") self.actionprofilesettings.setObjectName("actionprofilesettings")
self.actionPrivacy_settings = QtWidgets.QAction(window) self.actionPrivacy_settings = QtWidgets.QAction(Form)
self.actionPrivacy_settings.setObjectName("actionPrivacy_settings") self.actionPrivacy_settings.setObjectName("actionPrivacy_settings")
self.actionInterface_settings = QtWidgets.QAction(window) self.actionInterface_settings = QtWidgets.QAction(Form)
self.actionInterface_settings.setObjectName("actionInterface_settings") self.actionInterface_settings.setObjectName("actionInterface_settings")
self.actionNotifications = QtWidgets.QAction(window) self.actionNotifications = QtWidgets.QAction(Form)
self.actionNotifications.setObjectName("actionNotifications") self.actionNotifications.setObjectName("actionNotifications")
self.actionNetwork = QtWidgets.QAction(window) self.actionNetwork = QtWidgets.QAction(Form)
self.actionNetwork.setObjectName("actionNetwork") self.actionNetwork.setObjectName("actionNetwork")
self.actionAbout_program = QtWidgets.QAction(window) self.actionAbout_program = QtWidgets.QAction(Form)
self.actionAbout_program.setObjectName("actionAbout_program") self.actionAbout_program.setObjectName("actionAbout_program")
self.updateSettings = QtWidgets.QAction(window) self.updateSettings = QtWidgets.QAction(Form)
self.actionSettings = QtWidgets.QAction(window) self.actionSettings = QtWidgets.QAction(Form)
self.actionSettings.setObjectName("actionSettings") self.actionSettings.setObjectName("actionSettings")
self.audioSettings = QtWidgets.QAction(window) self.audioSettings = QtWidgets.QAction(Form)
self.videoSettings = QtWidgets.QAction(window) self.pluginData = QtWidgets.QAction(Form)
self.pluginData = QtWidgets.QAction(window) self.importPlugin = QtWidgets.QAction(Form)
self.importPlugin = QtWidgets.QAction(window) self.reloadPlugins = QtWidgets.QAction(Form)
self.reloadPlugins = QtWidgets.QAction(window) self.lockApp = QtWidgets.QAction(Form)
self.lockApp = QtWidgets.QAction(window)
self.menuProfile.addAction(self.actionAdd_friend) self.menuProfile.addAction(self.actionAdd_friend)
self.menuProfile.addAction(self.actionSettings) self.menuProfile.addAction(self.actionSettings)
self.menuProfile.addAction(self.lockApp) self.menuProfile.addAction(self.lockApp)
@ -71,17 +75,16 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
self.menuSettings.addAction(self.actionNotifications) self.menuSettings.addAction(self.actionNotifications)
self.menuSettings.addAction(self.actionNetwork) self.menuSettings.addAction(self.actionNetwork)
self.menuSettings.addAction(self.audioSettings) self.menuSettings.addAction(self.audioSettings)
self.menuSettings.addAction(self.videoSettings)
self.menuSettings.addAction(self.updateSettings) self.menuSettings.addAction(self.updateSettings)
self.menuPlugins.addAction(self.pluginData) self.menuPlugins.addAction(self.pluginData)
self.menuPlugins.addAction(self.importPlugin) self.menuPlugins.addAction(self.importPlugin)
self.menuPlugins.addAction(self.reloadPlugins) self.menuPlugins.addAction(self.reloadPlugins)
self.menuAbout.addAction(self.actionAbout_program) self.menuAbout.addAction(self.actionAbout_program)
self.menubar.addAction(self.menuProfile.menuAction()) self.profile_button.setMenu(self.menuProfile)
self.menubar.addAction(self.menuSettings.menuAction()) self.settings_button.setMenu(self.menuSettings)
self.menubar.addAction(self.menuPlugins.menuAction()) self.plugins_button.setMenu(self.menuPlugins)
self.menubar.addAction(self.menuAbout.menuAction()) self.about_button.setMenu(self.menuAbout)
self.actionAbout_program.triggered.connect(self.about_program) self.actionAbout_program.triggered.connect(self.about_program)
self.actionNetwork.triggered.connect(self.network_settings) self.actionNetwork.triggered.connect(self.network_settings)
@ -91,13 +94,15 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
self.actionInterface_settings.triggered.connect(self.interface_settings) self.actionInterface_settings.triggered.connect(self.interface_settings)
self.actionNotifications.triggered.connect(self.notification_settings) self.actionNotifications.triggered.connect(self.notification_settings)
self.audioSettings.triggered.connect(self.audio_settings) self.audioSettings.triggered.connect(self.audio_settings)
self.videoSettings.triggered.connect(self.video_settings)
self.updateSettings.triggered.connect(self.update_settings) self.updateSettings.triggered.connect(self.update_settings)
self.pluginData.triggered.connect(self.plugins_menu) self.pluginData.triggered.connect(self.plugins_menu)
self.lockApp.triggered.connect(self.lock_app) self.lockApp.triggered.connect(self.lock_app)
self.importPlugin.triggered.connect(self.import_plugin) self.importPlugin.triggered.connect(self.import_plugin)
self.reloadPlugins.triggered.connect(self.reload_plugins) self.reloadPlugins.triggered.connect(self.reload_plugins)
Form.setLayout(box)
QtCore.QMetaObject.connectSlotsByName(Form)
def languageChange(self, *args, **kwargs): def languageChange(self, *args, **kwargs):
self.retranslateUi() self.retranslateUi()
@ -109,11 +114,11 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
def retranslateUi(self): def retranslateUi(self):
self.lockApp.setText(QtWidgets.QApplication.translate("MainWindow", "Lock")) self.lockApp.setText(QtWidgets.QApplication.translate("MainWindow", "Lock"))
self.menuPlugins.setTitle(QtWidgets.QApplication.translate("MainWindow", "Plugins")) self.plugins_button.setText(QtWidgets.QApplication.translate("MainWindow", "Plugins"))
self.pluginData.setText(QtWidgets.QApplication.translate("MainWindow", "List of plugins")) self.pluginData.setText(QtWidgets.QApplication.translate("MainWindow", "List of plugins"))
self.menuProfile.setTitle(QtWidgets.QApplication.translate("MainWindow", "Profile")) self.profile_button.setText(QtWidgets.QApplication.translate("MainWindow", "Profile"))
self.menuSettings.setTitle(QtWidgets.QApplication.translate("MainWindow", "Settings")) self.settings_button.setText(QtWidgets.QApplication.translate("MainWindow", "Settings"))
self.menuAbout.setTitle(QtWidgets.QApplication.translate("MainWindow", "About")) self.about_button.setText(QtWidgets.QApplication.translate("MainWindow", "About"))
self.actionAdd_friend.setText(QtWidgets.QApplication.translate("MainWindow", "Add contact")) self.actionAdd_friend.setText(QtWidgets.QApplication.translate("MainWindow", "Add contact"))
self.actionprofilesettings.setText(QtWidgets.QApplication.translate("MainWindow", "Profile")) self.actionprofilesettings.setText(QtWidgets.QApplication.translate("MainWindow", "Profile"))
self.actionPrivacy_settings.setText(QtWidgets.QApplication.translate("MainWindow", "Privacy")) self.actionPrivacy_settings.setText(QtWidgets.QApplication.translate("MainWindow", "Privacy"))
@ -123,7 +128,6 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
self.actionAbout_program.setText(QtWidgets.QApplication.translate("MainWindow", "About program")) self.actionAbout_program.setText(QtWidgets.QApplication.translate("MainWindow", "About program"))
self.actionSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Settings")) self.actionSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Settings"))
self.audioSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Audio")) self.audioSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Audio"))
self.videoSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Video"))
self.updateSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Updates")) self.updateSettings.setText(QtWidgets.QApplication.translate("MainWindow", "Updates"))
self.contact_name.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "Search")) self.contact_name.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "Search"))
self.sendMessageButton.setToolTip(QtWidgets.QApplication.translate("MainWindow", "Send message")) self.sendMessageButton.setToolTip(QtWidgets.QApplication.translate("MainWindow", "Send message"))
@ -375,8 +379,12 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
self.close() self.close()
def resizeEvent(self, *args, **kwargs): def resizeEvent(self, *args, **kwargs):
if platform.system() == 'Windows':
self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 155) self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 155)
self.friends_list.setGeometry(0, 0, 270, self.height() - 125) self.friends_list.setGeometry(0, 0, 270, self.height() - 125)
else:
self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 159)
self.friends_list.setGeometry(0, 0, 270, self.height() - 129)
self.videocallButton.setGeometry(QtCore.QRect(self.width() - 330, 10, 50, 50)) self.videocallButton.setGeometry(QtCore.QRect(self.width() - 330, 10, 50, 50))
self.callButton.setGeometry(QtCore.QRect(self.width() - 390, 10, 50, 50)) self.callButton.setGeometry(QtCore.QRect(self.width() - 390, 10, 50, 50))
@ -451,10 +459,6 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
self.audio_s = AudioSettings() self.audio_s = AudioSettings()
self.audio_s.show() self.audio_s.show()
def video_settings(self):
self.video_s = VideoSettings()
self.video_s.show()
def update_settings(self): def update_settings(self):
self.update_s = UpdateSettings() self.update_s = UpdateSettings()
self.update_s.show() self.update_s.show()
@ -555,15 +559,14 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
def call_finished(self): def call_finished(self):
self.update_call_state('call') self.update_call_state('call')
def update_call_state(self, state): def update_call_state(self, fl):
# TODO: do smth with video call button
os.chdir(curr_directory() + '/images/') os.chdir(curr_directory() + '/images/')
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(fl))
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(state))
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.callButton.setIcon(icon) self.callButton.setIcon(icon)
self.callButton.setIconSize(QtCore.QSize(50, 50)) self.callButton.setIconSize(QtCore.QSize(50, 50))
pixmap = QtGui.QPixmap(curr_directory() + '/images/videocall.png')
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}_video.png'.format(state))
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.videocallButton.setIcon(icon) self.videocallButton.setIcon(icon)
self.videocallButton.setIconSize(QtCore.QSize(35, 35)) self.videocallButton.setIconSize(QtCore.QSize(35, 35))

View File

@ -1,5 +1,5 @@
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from widgets import RubberBandWindow, create_menu, QRightClickButton, CenteredWidget, LineEdit from widgets import RubberBand, create_menu, QRightClickButton, CenteredWidget, LineEdit
from profile import Profile from profile import Profile
import smileys import smileys
import util import util
@ -71,12 +71,38 @@ class MessageArea(QtWidgets.QPlainTextEdit):
self.insertPlainText(text) self.insertPlainText(text)
class ScreenShotWindow(RubberBandWindow): class ScreenShotWindow(QtWidgets.QWidget):
def __init__(self, parent):
super(ScreenShotWindow, self).__init__()
self.parent = parent
self.setMouseTracking(True)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.showFullScreen()
self.setWindowOpacity(0.5)
self.rubberband = RubberBand()
self.rubberband.setWindowFlags(self.rubberband.windowFlags() | QtCore.Qt.FramelessWindowHint)
self.rubberband.setAttribute(QtCore.Qt.WA_TranslucentBackground)
def closeEvent(self, *args): def closeEvent(self, *args):
if self.parent.isHidden(): if self.parent.isHidden():
self.parent.show() self.parent.show()
def mousePressEvent(self, event):
self.origin = event.pos()
self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
self.rubberband.show()
QtWidgets.QWidget.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
if self.rubberband.isVisible():
self.rubberband.setGeometry(QtCore.QRect(self.origin, event.pos()).normalized())
left = QtGui.QRegion(QtCore.QRect(0, 0, self.rubberband.x(), self.height()))
right = QtGui.QRegion(QtCore.QRect(self.rubberband.x() + self.rubberband.width(), 0, self.width(), self.height()))
top = QtGui.QRegion(0, 0, self.width(), self.rubberband.y())
bottom = QtGui.QRegion(0, self.rubberband.y() + self.rubberband.height(), self.width(), self.height())
self.setMask(left + right + top + bottom)
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
if self.rubberband.isVisible(): if self.rubberband.isVisible():
self.rubberband.hide() self.rubberband.hide()
@ -95,6 +121,13 @@ class ScreenShotWindow(RubberBandWindow):
Profile.get_instance().send_screenshot(bytes(byte_array.data())) Profile.get_instance().send_screenshot(bytes(byte_array.data()))
self.close() self.close()
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape:
self.rubberband.setHidden(True)
self.close()
else:
super(ScreenShotWindow, self).keyPressEvent(event)
class SmileyWindow(QtWidgets.QWidget): class SmileyWindow(QtWidgets.QWidget):
""" """
@ -120,7 +153,7 @@ class SmileyWindow(QtWidgets.QWidget):
for i in range(self.page_count): # buttons with smileys for i in range(self.page_count): # buttons with smileys
elem = QtWidgets.QRadioButton(self) elem = QtWidgets.QRadioButton(self)
elem.setGeometry(QtCore.QRect(i * 20 + 5, 180, 20, 20)) elem.setGeometry(QtCore.QRect(i * 20 + 5, 180, 20, 20))
elem.clicked.connect(lambda c, t=i: self.checked(t)) elem.clicked.connect(lambda i=i: self.checked(i))
self.radio.append(elem) self.radio.append(elem)
width = max(self.page_count * 20 + 30, (self.page_size + 5) * 8 // 10) width = max(self.page_count * 20 + 30, (self.page_size + 5) * 8 // 10)
self.setMaximumSize(width, 200) self.setMaximumSize(width, 200)
@ -129,7 +162,7 @@ class SmileyWindow(QtWidgets.QWidget):
for i in range(self.page_size): # pages - radio buttons for i in range(self.page_size): # pages - radio buttons
b = QtWidgets.QPushButton(self) b = QtWidgets.QPushButton(self)
b.setGeometry(QtCore.QRect((i // 8) * 20 + 5, (i % 8) * 20, 20, 20)) b.setGeometry(QtCore.QRect((i // 8) * 20 + 5, (i % 8) * 20, 20, 20))
b.clicked.connect(lambda c, t=i: self.clicked(t)) b.clicked.connect(lambda i=i: self.clicked(i))
self.buttons.append(b) self.buttons.append(b)
self.checked(0) self.checked(0)
@ -174,8 +207,8 @@ class DropdownMenu(QtWidgets.QWidget):
super(DropdownMenu, self).__init__(parent) super(DropdownMenu, self).__init__(parent)
self.installEventFilter(self) self.installEventFilter(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setMaximumSize(120, 120) self.setMaximumSize(180, 120)
self.setMinimumSize(120, 120) self.setMinimumSize(180, 120)
self.screenshotButton = QRightClickButton(self) self.screenshotButton = QRightClickButton(self)
self.screenshotButton.setGeometry(QtCore.QRect(0, 60, 60, 60)) self.screenshotButton.setGeometry(QtCore.QRect(0, 60, 60, 60))
self.screenshotButton.setObjectName("screenshotButton") self.screenshotButton.setObjectName("screenshotButton")
@ -184,9 +217,15 @@ class DropdownMenu(QtWidgets.QWidget):
self.fileTransferButton.setGeometry(QtCore.QRect(60, 60, 60, 60)) self.fileTransferButton.setGeometry(QtCore.QRect(60, 60, 60, 60))
self.fileTransferButton.setObjectName("fileTransferButton") self.fileTransferButton.setObjectName("fileTransferButton")
self.audioMessageButton = QtWidgets.QPushButton(self)
self.audioMessageButton.setGeometry(QtCore.QRect(120, 60, 60, 60))
self.smileyButton = QtWidgets.QPushButton(self) self.smileyButton = QtWidgets.QPushButton(self)
self.smileyButton.setGeometry(QtCore.QRect(0, 0, 60, 60)) self.smileyButton.setGeometry(QtCore.QRect(0, 0, 60, 60))
self.videoMessageButton = QtWidgets.QPushButton(self)
self.videoMessageButton.setGeometry(QtCore.QRect(120, 0, 60, 60))
self.stickerButton = QtWidgets.QPushButton(self) self.stickerButton = QtWidgets.QPushButton(self)
self.stickerButton.setGeometry(QtCore.QRect(60, 0, 60, 60)) self.stickerButton.setGeometry(QtCore.QRect(60, 0, 60, 60))
@ -194,17 +233,22 @@ class DropdownMenu(QtWidgets.QWidget):
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.fileTransferButton.setIcon(icon) self.fileTransferButton.setIcon(icon)
self.fileTransferButton.setIconSize(QtCore.QSize(50, 50)) self.fileTransferButton.setIconSize(QtCore.QSize(50, 50))
pixmap = QtGui.QPixmap(util.curr_directory() + '/images/screenshot.png') pixmap = QtGui.QPixmap(util.curr_directory() + '/images/screenshot.png')
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.screenshotButton.setIcon(icon) self.screenshotButton.setIcon(icon)
self.screenshotButton.setIconSize(QtCore.QSize(50, 60)) self.screenshotButton.setIconSize(QtCore.QSize(50, 60))
pixmap = QtGui.QPixmap(util.curr_directory() + '/images/audio_message.png')
icon = QtGui.QIcon(pixmap)
self.audioMessageButton.setIcon(icon)
self.audioMessageButton.setIconSize(QtCore.QSize(50, 50))
pixmap = QtGui.QPixmap(util.curr_directory() + '/images/smiley.png') pixmap = QtGui.QPixmap(util.curr_directory() + '/images/smiley.png')
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.smileyButton.setIcon(icon) self.smileyButton.setIcon(icon)
self.smileyButton.setIconSize(QtCore.QSize(50, 50)) self.smileyButton.setIconSize(QtCore.QSize(50, 50))
pixmap = QtGui.QPixmap(util.curr_directory() + '/images/video_message.png')
icon = QtGui.QIcon(pixmap)
self.videoMessageButton.setIcon(icon)
self.videoMessageButton.setIconSize(QtCore.QSize(55, 55))
pixmap = QtGui.QPixmap(util.curr_directory() + '/images/sticker.png') pixmap = QtGui.QPixmap(util.curr_directory() + '/images/sticker.png')
icon = QtGui.QIcon(pixmap) icon = QtGui.QIcon(pixmap)
self.stickerButton.setIcon(icon) self.stickerButton.setIcon(icon)
@ -212,6 +256,8 @@ class DropdownMenu(QtWidgets.QWidget):
self.screenshotButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send screenshot")) self.screenshotButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send screenshot"))
self.fileTransferButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send file")) self.fileTransferButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send file"))
self.audioMessageButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send audio message"))
self.videoMessageButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send video message"))
self.smileyButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Add smiley")) self.smileyButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Add smiley"))
self.stickerButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send sticker")) self.stickerButton.setToolTip(QtWidgets.QApplication.translate("MenuWindow", "Send sticker"))
@ -224,7 +270,7 @@ class DropdownMenu(QtWidgets.QWidget):
def leaveEvent(self, event): def leaveEvent(self, event):
self.close() self.close()
def eventFilter(self, obj, event): def eventFilter(self, object, event):
if event.type() == QtCore.QEvent.WindowDeactivate: if event.type() == QtCore.QEvent.WindowDeactivate:
self.close() self.close()
return False return False
@ -308,13 +354,10 @@ class WelcomeScreen(CenteredWidget):
'Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.') 'Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.')
elif num == 5: elif num == 5:
text = QtWidgets.QApplication.translate('WelcomeScreen', 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>') 'Since v0.1.3 Toxygen supports plugins. <a href="https://github.com/xveduk/toxygen/blob/master/docs/plugins.md">Read more</a>')
elif num == 6: elif num in (6, 7):
text = QtWidgets.QApplication.translate('WelcomeScreen', 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.') '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.3.0:<br>Video calls<br>Python3.6 support<br>Migration to PyQt5')
elif num == 8: elif num == 8:
text = QtWidgets.QApplication.translate('WelcomeScreen', text = QtWidgets.QApplication.translate('WelcomeScreen',
'Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu') 'Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu')

View File

@ -2,7 +2,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
from settings import * from settings import *
from profile import Profile from profile import Profile
from util import curr_directory, copy from util import curr_directory, copy
from widgets import CenteredWidget, DataLabel, LineEdit, RubberBandWindow from widgets import CenteredWidget, DataLabel, LineEdit
import pyaudio import pyaudio
import toxes import toxes
import plugin_support import plugin_support
@ -247,12 +247,12 @@ class ProfileSettings(CenteredWidget):
def set_avatar(self): def set_avatar(self):
choose = QtWidgets.QApplication.translate("ProfileSettingsForm", "Choose avatar") choose = QtWidgets.QApplication.translate("ProfileSettingsForm", "Choose avatar")
name = QtWidgets.QFileDialog.getOpenFileName(self, choose, None, 'Images (*.png)', name = QtWidgets.QFileDialog.getOpenFileName(self, choose, None, None, 'Images (*.png)',
options=QtWidgets.QFileDialog.DontUseNativeDialog) QtWidgets.QFileDialog.DontUseNativeDialog)
if name[0]: if name[0]:
bitmap = QtGui.QPixmap(name[0]) bitmap = QtGui.QPixmap(name[0])
bitmap.scaled(QtCore.QSize(128, 128), aspectRatioMode=QtCore.Qt.KeepAspectRatio, bitmap.scaled(128, 128, QtCore.Qt.KeepAspectRatio,
transformMode=QtCore.Qt.SmoothTransformation) QtCore.Qt.SmoothTransformation)
byte_array = QtCore.QByteArray() byte_array = QtCore.QByteArray()
buffer = QtCore.QBuffer(byte_array) buffer = QtCore.QBuffer(byte_array)
@ -261,8 +261,9 @@ class ProfileSettings(CenteredWidget):
Profile.get_instance().set_avatar(bytes(byte_array.data())) Profile.get_instance().set_avatar(bytes(byte_array.data()))
def export_profile(self): def export_profile(self):
directory = QtWidgets.QFileDialog.getExistingDirectory(self, '', curr_directory(), directory = QtWidgets.QFileDialog.getExistingDirectory(self, '', curr_directory() + '/',
QtWidgets.QFileDialog.DontUseNativeDialog) + '/' QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog)
if directory != '/': if directory != '/':
reply = QtWidgets.QMessageBox.question(None, reply = QtWidgets.QMessageBox.question(None,
QtWidgets.QApplication.translate("ProfileSettingsForm", QtWidgets.QApplication.translate("ProfileSettingsForm",
@ -493,7 +494,8 @@ class PrivacySettings(CenteredWidget):
settings.save() settings.save()
def new_path(self): def new_path(self):
directory = QtWidgets.QFileDialog.getExistingDirectory(options=QtWidgets.QFileDialog.DontUseNativeDialog) + '/' directory = QtWidgets.QFileDialog.getExistingDirectory(self, '', curr_directory() + '/',
QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) + '/'
if directory != '/': if directory != '/':
self.path.setPlainText(directory) self.path.setPlainText(directory)
@ -565,10 +567,11 @@ class InterfaceSettings(CenteredWidget):
self.label.setFont(font) self.label.setFont(font)
self.themeSelect = QtWidgets.QComboBox(self) self.themeSelect = QtWidgets.QComboBox(self)
self.themeSelect.setGeometry(QtCore.QRect(30, 40, 120, 30)) self.themeSelect.setGeometry(QtCore.QRect(30, 40, 120, 30))
self.themeSelect.addItems(list(settings.built_in_themes().keys())) list_of_themes = ['dark']
self.themeSelect.addItems(list_of_themes)
theme = settings['theme'] theme = settings['theme']
if theme in settings.built_in_themes().keys(): if theme in list_of_themes:
index = list(settings.built_in_themes().keys()).index(theme) index = list_of_themes.index(theme)
else: else:
index = 0 index = 0
self.themeSelect.setCurrentIndex(index) self.themeSelect.setCurrentIndex(index)
@ -703,14 +706,6 @@ class InterfaceSettings(CenteredWidget):
def closeEvent(self, event): def closeEvent(self, event):
settings = Settings.get_instance() settings = Settings.get_instance()
settings['theme'] = str(self.themeSelect.currentText()) settings['theme'] = str(self.themeSelect.currentText())
try:
theme = settings['theme']
app = QtWidgets.QApplication.instance()
with open(curr_directory() + settings.built_in_themes()[theme]) as fl:
style = fl.read()
app.setStyleSheet(style)
except IsADirectoryError:
app.setStyleSheet('') # for default style
settings['smileys'] = self.smileys.isChecked() settings['smileys'] = self.smileys.isChecked()
restart = False restart = False
if settings['mirror_mode'] != self.mirror_mode.isChecked(): if settings['mirror_mode'] != self.mirror_mode.isChecked():
@ -802,128 +797,6 @@ class AudioSettings(CenteredWidget):
settings.save() settings.save()
class DesktopAreaSelectionWindow(RubberBandWindow):
def mouseReleaseEvent(self, event):
if self.rubberband.isVisible():
self.rubberband.hide()
rect = self.rubberband.geometry()
width, height = rect.width(), rect.height()
if width >= 8 and height >= 8:
self.parent.save(rect.x(), rect.y(), width, height)
self.close()
class VideoSettings(CenteredWidget):
"""
Audio calls settings form
"""
def __init__(self):
super().__init__()
self.initUI()
self.retranslateUi()
self.center()
self.desktopAreaSelection = None
def initUI(self):
self.setObjectName("videoSettingsForm")
self.resize(400, 120)
self.setMinimumSize(QtCore.QSize(400, 120))
self.setMaximumSize(QtCore.QSize(400, 120))
self.in_label = QtWidgets.QLabel(self)
self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20))
settings = Settings.get_instance()
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setFamily(settings['font'])
self.in_label.setFont(font)
self.video_size = QtWidgets.QComboBox(self)
self.video_size.setGeometry(QtCore.QRect(25, 70, 350, 30))
self.input = QtWidgets.QComboBox(self)
self.input.setGeometry(QtCore.QRect(25, 30, 350, 30))
self.input.currentIndexChanged.connect(self.selectionChanged)
self.button = QtWidgets.QPushButton(self)
self.button.clicked.connect(self.button_clicked)
self.button.setGeometry(QtCore.QRect(25, 70, 350, 30))
import cv2
self.devices = [-1]
screen = QtWidgets.QApplication.primaryScreen()
size = screen.size()
self.frame_max_sizes = [(size.width(), size.height())]
desktop = QtWidgets.QApplication.translate("videoSettingsForm", "Desktop")
self.input.addItem(desktop)
for i in range(10):
v = cv2.VideoCapture(i)
if v.isOpened():
v.set(cv2.CAP_PROP_FRAME_WIDTH, 10000)
v.set(cv2.CAP_PROP_FRAME_HEIGHT, 10000)
width = int(v.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(v.get(cv2.CAP_PROP_FRAME_HEIGHT))
del v
self.devices.append(i)
self.frame_max_sizes.append((width, height))
self.input.addItem('Device #' + str(i))
try:
index = self.devices.index(settings.video['device'])
self.input.setCurrentIndex(index)
except:
print('Video devices error!')
def retranslateUi(self):
self.setWindowTitle(QtWidgets.QApplication.translate("videoSettingsForm", "Video settings"))
self.in_label.setText(QtWidgets.QApplication.translate("videoSettingsForm", "Device:"))
self.button.setText(QtWidgets.QApplication.translate("videoSettingsForm", "Select region"))
def button_clicked(self):
self.desktopAreaSelection = DesktopAreaSelectionWindow(self)
def closeEvent(self, event):
try:
settings = Settings.get_instance()
settings.video['device'] = self.devices[self.input.currentIndex()]
text = self.video_size.currentText()
settings.video['width'] = int(text.split(' ')[0])
settings.video['height'] = int(text.split(' ')[-1])
settings.save()
except Exception as ex:
print('Saving video settings error: ' + str(ex))
def save(self, x, y, width, height):
self.desktopAreaSelection = None
settings = Settings.get_instance()
settings.video['device'] = -1
settings.video['width'] = width
settings.video['height'] = height
settings.video['x'] = x
settings.video['y'] = y
settings.save()
def selectionChanged(self):
if self.input.currentIndex() == 0:
self.button.setVisible(True)
self.video_size.setVisible(False)
else:
self.button.setVisible(False)
self.video_size.setVisible(True)
width, height = self.frame_max_sizes[self.input.currentIndex()]
self.video_size.clear()
dims = [
(320, 240),
(640, 360),
(640, 480),
(720, 480),
(1280, 720),
(1920, 1080),
(2560, 1440)
]
for w, h in dims:
if w <= width and h <= height:
self.video_size.addItem(str(w) + ' * ' + str(h))
class PluginsSettings(CenteredWidget): class PluginsSettings(CenteredWidget):
""" """
Plugins settings form Plugins settings form

View File

@ -14,8 +14,6 @@ import avwidgets
import plugin_support import plugin_support
import basecontact import basecontact
import items_factory import items_factory
import cv2
import threading
class Profile(basecontact.BaseContact, Singleton): class Profile(basecontact.BaseContact, Singleton):
@ -38,7 +36,6 @@ class Profile(basecontact.BaseContact, Singleton):
self._tox = tox self._tox = tox
self._file_transfers = {} # dict of file transfers. key - tuple (friend_number, file_number) self._file_transfers = {} # dict of file transfers. key - tuple (friend_number, file_number)
self._call = calls.AV(tox.AV) # object with data about calls self._call = calls.AV(tox.AV) # object with data about calls
self._call_widgets = {} # dict of incoming call widgets
self._incoming_calls = set() self._incoming_calls = set()
self._load_history = True self._load_history = True
self._waiting_for_reconnection = False self._waiting_for_reconnection = False
@ -88,7 +85,6 @@ class Profile(basecontact.BaseContact, Singleton):
if status is not None: if status is not None:
self._tox.self_set_status(status) self._tox.self_set_status(status)
elif not self._waiting_for_reconnection: elif not self._waiting_for_reconnection:
self._waiting_for_reconnection = True
QtCore.QTimer.singleShot(50000, self.reconnect) QtCore.QTimer.singleShot(50000, self.reconnect)
def set_name(self, value): def set_name(self, value):
@ -667,7 +663,7 @@ class Profile(basecontact.BaseContact, Singleton):
dialog = dialog.format(name) dialog = dialog.format(name)
title = QtWidgets.QApplication.translate('MainWindow', title = QtWidgets.QApplication.translate('MainWindow',
'Set alias') 'Set alias')
text, ok = QtWidgets.QInputDialog.getText(None, text, ok = QtGui.QInputDialog.getText(None,
title, title,
dialog, dialog,
QtWidgets.QLineEdit.Normal, QtWidgets.QLineEdit.Normal,
@ -1230,9 +1226,10 @@ class Profile(basecontact.BaseContact, Singleton):
self._messages.scrollToBottom() self._messages.scrollToBottom()
else: else:
friend.actions = True friend.actions = True
self._call_widgets[friend_number] = avwidgets.IncomingCallWidget(friend_number, text, friend.name) # TODO: dict of widgets
self._call_widgets[friend_number].set_pixmap(friend.get_pixmap()) self._call_widget = avwidgets.IncomingCallWidget(friend_number, text, friend.name)
self._call_widgets[friend_number].show() self._call_widget.set_pixmap(friend.get_pixmap())
self._call_widget.show()
def accept_call(self, friend_number, audio, video): def accept_call(self, friend_number, audio, video):
""" """
@ -1242,7 +1239,8 @@ class Profile(basecontact.BaseContact, Singleton):
self._screen.active_call() self._screen.active_call()
if friend_number in self._incoming_calls: if friend_number in self._incoming_calls:
self._incoming_calls.remove(friend_number) self._incoming_calls.remove(friend_number)
del self._call_widgets[friend_number] if hasattr(self, '_call_widget'):
del self._call_widget
def stop_call(self, friend_number, by_friend): def stop_call(self, friend_number, by_friend):
""" """
@ -1256,9 +1254,8 @@ class Profile(basecontact.BaseContact, Singleton):
self._screen.call_finished() self._screen.call_finished()
self._call.finish_call(friend_number, by_friend) # finish or decline call self._call.finish_call(friend_number, by_friend) # finish or decline call
if hasattr(self, '_call_widget'): if hasattr(self, '_call_widget'):
self._call_widget[friend_number].close() self._call_widget.close()
del self._call_widget[friend_number] del self._call_widget
threading.Timer(2.0, lambda: cv2.destroyWindow(str(friend_number))).start()
friend = self.get_friend_by_number(friend_number) friend = self.get_friend_by_number(friend_number)
friend.append_message(InfoMessage(text, time.time())) friend.append_message(InfoMessage(text, time.time()))
if friend_number == self.get_active_number(): if friend_number == self.get_active_number():

View File

@ -1,22 +0,0 @@
import numpy as np
from PyQt5 import QtWidgets
class DesktopGrabber:
def __init__(self, x, y, width, height):
self._x = x
self._y = y
self._width = width
self._height = height
self._width -= width % 4
self._height -= height % 4
self._screen = QtWidgets.QApplication.primaryScreen()
def read(self):
pixmap = self._screen.grabWindow(0, self._x, self._y, self._width, self._height)
image = pixmap.toImage()
s = image.bits().asstring(self._width * self._height * 4)
arr = np.fromstring(s, dtype=np.uint8).reshape((self._height, self._width, 4))
return True, arr

View File

@ -47,7 +47,6 @@ class Settings(dict, Singleton):
self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1, self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1,
'output': p.get_default_output_device_info()['index'] if output_devices else -1, 'output': p.get_default_output_device_info()['index'] if output_devices else -1,
'enabled': input_devices and output_devices} 'enabled': input_devices and output_devices}
self.video = {'device': -1, 'width': 640, 'height': 480, 'x': 0, 'y': 0}
@staticmethod @staticmethod
def get_auto_profile(): def get_auto_profile():
@ -57,10 +56,7 @@ class Settings(dict, Singleton):
data = fl.read() data = fl.read()
auto = json.loads(data) auto = json.loads(data)
if 'path' in auto and 'name' in auto: if 'path' in auto and 'name' in auto:
path = str(auto['path']) return str(auto['path']), str(auto['name'])
name = str(auto['name'])
if os.path.isfile(append_slash(path) + name + '.tox'):
return path, name
return '', '' return '', ''
@staticmethod @staticmethod
@ -103,7 +99,7 @@ class Settings(dict, Singleton):
Default profile settings Default profile settings
""" """
return { return {
'theme': 'dark', 'theme': 'default',
'ipv6_enabled': True, 'ipv6_enabled': True,
'udp_enabled': True, 'udp_enabled': True,
'proxy_type': 0, 'proxy_type': 0,
@ -151,16 +147,8 @@ class Settings(dict, Singleton):
def supported_languages(): def supported_languages():
return { return {
'English': 'en_EN', 'English': 'en_EN',
'French': 'fr_FR',
'Russian': 'ru_RU', 'Russian': 'ru_RU',
'Ukrainian': 'uk_UA' 'French': 'fr_FR'
}
@staticmethod
def built_in_themes():
return {
'dark': '/styles/dark_style.qss',
'default': '/styles/style.qss'
} }
def upgrade(self): def upgrade(self):

File diff suppressed because it is too large Load Diff

View File

@ -41,9 +41,6 @@
<file>rc/radio_unchecked.png</file> <file>rc/radio_unchecked.png</file>
</qresource> </qresource>
<qresource prefix="qdarkstyle"> <qresource prefix="qdarkstyle">
<file>dark_style.qss</file>
</qresource>
<qresource prefix="defaultstyle">
<file>style.qss</file> <file>style.qss</file>
</qresource> </qresource>
</RCC> </RCC>

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from ctypes import c_char_p, Structure, c_bool, byref, c_int, c_size_t, POINTER, c_uint16, c_void_p, c_uint64 from ctypes import c_char_p, Structure, c_bool, byref, c_int, c_size_t, POINTER, c_uint16, c_void_p, c_uint64
from ctypes import create_string_buffer, ArgumentError, CFUNCTYPE, c_uint32, sizeof, c_uint8 from ctypes import create_string_buffer, ArgumentError, CFUNCTYPE, c_uint32, sizeof, c_uint8
from toxcore_enums_and_consts import * from toxcore_enums_and_consts import *

View File

@ -30,8 +30,7 @@ def tox_dns(email):
netman.setProxy(proxy) netman.setProxy(proxy)
for url in urls: for url in urls:
try: try:
request = QtNetwork.QNetworkRequest() request = QtNetwork.QNetworkRequest(url)
request.setUrl(QtCore.QUrl(url))
request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/json") request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/json")
reply = netman.post(request, bytes(json.dumps(data), 'utf-8')) reply = netman.post(request, bytes(json.dumps(data), 'utf-8'))

View File

@ -1,2 +1,2 @@
SOURCES = main.py profile.py menu.py list_items.py loginscreen.py mainscreen.py plugins/plugin_super_class.py callbacks.py widgets.py avwidgets.py mainscreen_widgets.py passwordscreen.py SOURCES = main.py profile.py menu.py list_items.py loginscreen.py mainscreen.py plugins/plugin_super_class.py callbacks.py widgets.py avwidgets.py mainscreen_widgets.py passwordscreen.py
TRANSLATIONS = translations/en_GB.ts translations/ru_RU.ts translations/fr_FR.ts translations/uk_UA.ts TRANSLATIONS = translations/en_GB.ts translations/ru_RU.ts translations/fr_FR.ts

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -57,9 +57,6 @@ def get_url(version):
def get_params(url, version): def get_params(url, version):
if is_from_sources(): if is_from_sources():
if platform.system() == 'Windows':
return ['python', 'toxygen_updater.py', url, version]
else:
return ['python3', 'toxygen_updater.py', url, version] return ['python3', 'toxygen_updater.py', url, version]
elif platform.system() == 'Windows': elif platform.system() == 'Windows':
return [util.curr_directory() + '/toxygen_updater.exe', url, version] return [util.curr_directory() + '/toxygen_updater.exe', url, version]
@ -90,8 +87,7 @@ def send_request(version):
netman.setProxy(proxy) netman.setProxy(proxy)
url = test_url(version) url = test_url(version)
try: try:
request = QtNetwork.QNetworkRequest() request = QtNetwork.QNetworkRequest(url)
request.setUrl(QtCore.QUrl(url))
reply = netman.get(request) reply = netman.get(request)
while not reply.isFinished(): while not reply.isFinished():
QtCore.QThread.msleep(1) QtCore.QThread.msleep(1)

View File

@ -4,32 +4,14 @@ import shutil
import sys import sys
import re import re
program_version = '0.2.8'
program_version = '0.3.1'
def cached(func):
saved_result = None
def wrapped_func():
nonlocal saved_result
if saved_result is None:
saved_result = func()
return saved_result
return wrapped_func
def log(data): def log(data):
try:
with open(curr_directory() + '/logs.log', 'a') as fl: with open(curr_directory() + '/logs.log', 'a') as fl:
fl.write(str(data) + '\n') fl.write(str(data) + '\n')
except:
pass
@cached
def curr_directory(): def curr_directory():
return os.path.dirname(os.path.realpath(__file__)) return os.path.dirname(os.path.realpath(__file__))
@ -64,8 +46,9 @@ def convert_time(t):
return '%02d:%02d' % (h, m) return '%02d:%02d' % (h, m)
@cached
def time_offset(): def time_offset():
if hasattr(time_offset, 'offset'):
return time_offset.offset
hours = int(time.strftime('%H')) hours = int(time.strftime('%H'))
minutes = int(time.strftime('%M')) minutes = int(time.strftime('%M'))
sec = int(time.time()) - time.timezone sec = int(time.time()) - time.timezone
@ -73,6 +56,7 @@ def time_offset():
h, m = divmod(m, 60) h, m = divmod(m, 60)
d, h = divmod(h, 24) d, h = divmod(h, 24)
result = hours * 60 + minutes - h * 60 - m result = hours * 60 + minutes - h * 60 - m
time_offset.offset = result
return result return result
@ -82,7 +66,6 @@ def append_slash(s):
return s return s
@cached
def is_64_bit(): def is_64_bit():
return sys.maxsize > 2 ** 32 return sys.maxsize > 2 ** 32

View File

@ -77,42 +77,6 @@ class RubberBand(QtWidgets.QRubberBand):
self.painter.end() self.painter.end()
class RubberBandWindow(QtWidgets.QWidget):
def __init__(self, parent):
super().__init__()
self.parent = parent
self.setMouseTracking(True)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.showFullScreen()
self.setWindowOpacity(0.5)
self.rubberband = RubberBand()
self.rubberband.setWindowFlags(self.rubberband.windowFlags() | QtCore.Qt.FramelessWindowHint)
self.rubberband.setAttribute(QtCore.Qt.WA_TranslucentBackground)
def mousePressEvent(self, event):
self.origin = event.pos()
self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
self.rubberband.show()
QtWidgets.QWidget.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
if self.rubberband.isVisible():
self.rubberband.setGeometry(QtCore.QRect(self.origin, event.pos()).normalized())
left = QtGui.QRegion(QtCore.QRect(0, 0, self.rubberband.x(), self.height()))
right = QtGui.QRegion(QtCore.QRect(self.rubberband.x() + self.rubberband.width(), 0, self.width(), self.height()))
top = QtGui.QRegion(0, 0, self.width(), self.rubberband.y())
bottom = QtGui.QRegion(0, self.rubberband.y() + self.rubberband.height(), self.width(), self.height())
self.setMask(left + right + top + bottom)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape:
self.rubberband.setHidden(True)
self.close()
else:
super().keyPressEvent(event)
def create_menu(menu): def create_menu(menu):
""" """
:return translated menu :return translated menu
@ -164,3 +128,4 @@ class MultilineEdit(CenteredWidget):
def button_click(self): def button_click(self):
self.save(self.edit.toPlainText()) self.save(self.edit.toPlainText())
self.close() self.close()