mirror mode
This commit is contained in:
parent
3ed4e8f511
commit
9bf072e122
@ -1,6 +1,6 @@
|
||||
from toxcore_enums_and_consts import TOX_FILE_KIND, TOX_FILE_CONTROL
|
||||
from os.path import basename, getsize, exists
|
||||
from os import remove, rename
|
||||
from os.path import basename, getsize, exists, dirname
|
||||
from os import remove, rename, chdir
|
||||
from time import time, sleep
|
||||
from tox import Tox
|
||||
import settings
|
||||
@ -161,6 +161,18 @@ class SendFromBuffer(FileTransfer):
|
||||
self.state = TOX_FILE_TRANSFER_STATE['FINISHED']
|
||||
self._state_changed.signal.emit(self.state, 1)
|
||||
|
||||
|
||||
class SendFromFileBuffer(SendTransfer):
|
||||
|
||||
def __init__(self, *args):
|
||||
super(SendFromFileBuffer, self).__init__(*args)
|
||||
|
||||
def send_chunk(self, position, size):
|
||||
super(SendFromFileBuffer, self).send_chunk(position, size)
|
||||
if not size:
|
||||
chdir(dirname(self._path))
|
||||
remove(self._path)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Receive file
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
@ -268,6 +280,7 @@ class ReceiveAvatar(ReceiveTransfer):
|
||||
if self.state:
|
||||
avatar_path = self._path[:-4]
|
||||
if exists(avatar_path):
|
||||
chdir(dirname(avatar_path))
|
||||
remove(avatar_path)
|
||||
rename(self._path, avatar_path)
|
||||
|
||||
|
@ -65,7 +65,6 @@ class MessageArea(QtGui.QPlainTextEdit):
|
||||
|
||||
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
# TODO: add mirror mode
|
||||
|
||||
def __init__(self, tox, reset, tray):
|
||||
super(MainWindow, self).__init__()
|
||||
@ -189,15 +188,15 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.sendMessageButton.setGeometry(QtCore.QRect(565, 3, 60, 55))
|
||||
self.sendMessageButton.setObjectName("sendMessageButton")
|
||||
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/send.png')
|
||||
pixmap = QtGui.QPixmap('send.png')
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.sendMessageButton.setIcon(icon)
|
||||
self.sendMessageButton.setIconSize(QtCore.QSize(45, 60))
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/file.png')
|
||||
pixmap = QtGui.QPixmap('file.png')
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.fileTransferButton.setIcon(icon)
|
||||
self.fileTransferButton.setIconSize(QtCore.QSize(40, 40))
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/screenshot.png')
|
||||
pixmap = QtGui.QPixmap('screenshot.png')
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.screenshotButton.setIcon(icon)
|
||||
self.screenshotButton.setIconSize(QtCore.QSize(40, 60))
|
||||
@ -296,7 +295,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.typing = QtGui.QLabel(Form)
|
||||
self.typing.setGeometry(QtCore.QRect(500, 40, 50, 30))
|
||||
pixmap = QtGui.QPixmap(QtCore.QSize(50, 30))
|
||||
pixmap.load(curr_directory() + '/images/typing.png')
|
||||
pixmap.load('typing.png')
|
||||
self.typing.setScaledContents(False)
|
||||
self.typing.setPixmap(pixmap.scaled(50, 30, QtCore.Qt.KeepAspectRatio))
|
||||
self.typing.setVisible(False)
|
||||
@ -335,25 +334,41 @@ class MainWindow(QtGui.QMainWindow):
|
||||
main = QtGui.QWidget()
|
||||
grid = QtGui.QGridLayout()
|
||||
search = QtGui.QWidget()
|
||||
name = QtGui.QWidget()
|
||||
info = QtGui.QWidget()
|
||||
main_list = QtGui.QWidget()
|
||||
messages = QtGui.QWidget()
|
||||
message_buttons = QtGui.QWidget()
|
||||
if not Settings.get_instance()['mirror_mode']:
|
||||
self.setup_left_center_menu(search)
|
||||
grid.addWidget(search, 1, 0)
|
||||
name = QtGui.QWidget()
|
||||
self.setup_left_top(name)
|
||||
grid.addWidget(name, 0, 0)
|
||||
messages = QtGui.QWidget()
|
||||
self.setup_right_center(messages)
|
||||
grid.addWidget(messages, 1, 1, 2, 1)
|
||||
info = QtGui.QWidget()
|
||||
self.setup_right_top(info)
|
||||
grid.addWidget(info, 0, 1)
|
||||
message_buttons = QtGui.QWidget()
|
||||
self.setup_right_bottom(message_buttons)
|
||||
grid.addWidget(message_buttons, 3, 1)
|
||||
main_list = QtGui.QWidget()
|
||||
self.setup_left_center(main_list)
|
||||
grid.addWidget(main_list, 2, 0, 2, 1)
|
||||
grid.setColumnMinimumWidth(1, 500)
|
||||
grid.setColumnMinimumWidth(0, 270)
|
||||
else:
|
||||
self.setup_left_center_menu(search)
|
||||
grid.addWidget(search, 1, 1)
|
||||
self.setup_left_top(name)
|
||||
grid.addWidget(name, 0, 1)
|
||||
self.setup_right_center(messages)
|
||||
grid.addWidget(messages, 1, 0, 2, 1)
|
||||
self.setup_right_top(info)
|
||||
grid.addWidget(info, 0, 0)
|
||||
self.setup_right_bottom(message_buttons)
|
||||
grid.addWidget(message_buttons, 3, 0)
|
||||
self.setup_left_center(main_list)
|
||||
grid.addWidget(main_list, 2, 1, 2, 1)
|
||||
grid.setColumnMinimumWidth(0, 500)
|
||||
grid.setColumnMinimumWidth(1, 270)
|
||||
grid.setRowMinimumHeight(0, 82)
|
||||
grid.setRowMinimumHeight(1, 25)
|
||||
grid.setRowMinimumHeight(2, 410)
|
||||
@ -377,6 +392,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
def resizeEvent(self, *args, **kwargs):
|
||||
self.messages.setGeometry(0, 0, self.width() - 300, self.height() - 172)
|
||||
self.friends_list.setGeometry(0, 0, 270, self.height() - 140)
|
||||
|
||||
self.videocallButton.setGeometry(QtCore.QRect(self.width() - 350, 20, 50, 50))
|
||||
self.callButton.setGeometry(QtCore.QRect(self.width() - 410, 20, 50, 50))
|
||||
self.typing.setGeometry(QtCore.QRect(self.width() - 470, 30, 50, 30))
|
||||
@ -475,11 +491,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def update_call_state(self, fl):
|
||||
# TODO: do smth with video call button
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(fl))
|
||||
os.chdir(curr_directory() + '/images/')
|
||||
pixmap = QtGui.QPixmap('{}.png'.format(fl))
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.callButton.setIcon(icon)
|
||||
self.callButton.setIconSize(QtCore.QSize(50, 50))
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/videocall.png')
|
||||
pixmap = QtGui.QPixmap('videocall.png')
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.videocallButton.setIcon(icon)
|
||||
self.videocallButton.setIconSize(QtCore.QSize(35, 35))
|
||||
|
Loading…
Reference in New Issue
Block a user