2016-02-17 21:47:43 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-02-23 21:26:37 +01:00
|
|
|
from menu import *
|
2016-02-27 16:52:27 +01:00
|
|
|
from profile import *
|
2016-03-01 22:17:22 +01:00
|
|
|
from list_items import *
|
2016-02-17 21:47:43 +01:00
|
|
|
|
|
|
|
|
2016-03-05 13:44:52 +01:00
|
|
|
class MessageArea(QtGui.QPlainTextEdit):
|
|
|
|
|
|
|
|
def __init__(self, parent, form):
|
|
|
|
super(MessageArea, self).__init__(parent)
|
|
|
|
self.parent = form
|
|
|
|
|
|
|
|
def keyPressEvent(self, event):
|
|
|
|
if event.key() == QtCore.Qt.Key_Return:
|
|
|
|
self.parent.send_message()
|
|
|
|
else:
|
|
|
|
super(self.__class__, self).keyPressEvent(event)
|
|
|
|
|
|
|
|
|
2016-02-21 15:32:38 +01:00
|
|
|
class MainWindow(QtGui.QMainWindow):
|
2016-02-17 21:47:43 +01:00
|
|
|
|
2016-03-15 18:05:19 +01:00
|
|
|
def __init__(self, tox, reset):
|
2016-02-17 21:47:43 +01:00
|
|
|
super(MainWindow, self).__init__()
|
2016-03-15 18:05:19 +01:00
|
|
|
self.reset = reset
|
|
|
|
self.initUI(tox)
|
2016-02-17 21:47:43 +01:00
|
|
|
|
2016-02-21 15:32:38 +01:00
|
|
|
def setup_menu(self, MainWindow):
|
|
|
|
self.menubar = QtGui.QMenuBar(MainWindow)
|
|
|
|
self.menubar.setObjectName("menubar")
|
2016-02-24 18:26:12 +01:00
|
|
|
self.menubar.setNativeMenuBar(False)
|
|
|
|
self.menubar.setMinimumSize(self.width(), 25)
|
|
|
|
self.menubar.setMaximumSize(self.width(), 25)
|
|
|
|
self.menubar.setBaseSize(self.width(), 25)
|
2016-02-21 15:32:38 +01:00
|
|
|
self.menuProfile = QtGui.QMenu(self.menubar)
|
|
|
|
self.menuProfile.setObjectName("menuProfile")
|
|
|
|
self.menuSettings = QtGui.QMenu(self.menubar)
|
|
|
|
self.menuSettings.setObjectName("menuSettings")
|
|
|
|
self.menuAbout = QtGui.QMenu(self.menubar)
|
|
|
|
self.menuAbout.setObjectName("menuAbout")
|
|
|
|
self.actionAdd_friend = QtGui.QAction(MainWindow)
|
|
|
|
self.actionAdd_friend.setObjectName("actionAdd_friend")
|
|
|
|
self.actionProfile_settings = QtGui.QAction(MainWindow)
|
|
|
|
self.actionProfile_settings.setObjectName("actionProfile_settings")
|
|
|
|
self.actionPrivacy_settings = QtGui.QAction(MainWindow)
|
|
|
|
self.actionPrivacy_settings.setObjectName("actionPrivacy_settings")
|
|
|
|
self.actionInterface_settings = QtGui.QAction(MainWindow)
|
|
|
|
self.actionInterface_settings.setObjectName("actionInterface_settings")
|
|
|
|
self.actionNotifications = QtGui.QAction(MainWindow)
|
|
|
|
self.actionNotifications.setObjectName("actionNotifications")
|
|
|
|
self.actionNetwork = QtGui.QAction(MainWindow)
|
|
|
|
self.actionNetwork.setObjectName("actionNetwork")
|
|
|
|
self.actionAbout_program = QtGui.QAction(MainWindow)
|
|
|
|
self.actionAbout_program.setObjectName("actionAbout_program")
|
|
|
|
self.actionSettings = QtGui.QAction(MainWindow)
|
|
|
|
self.actionSettings.setObjectName("actionSettings")
|
|
|
|
self.menuProfile.addAction(self.actionAdd_friend)
|
|
|
|
self.menuProfile.addAction(self.actionSettings)
|
|
|
|
self.menuSettings.addAction(self.actionPrivacy_settings)
|
|
|
|
self.menuSettings.addAction(self.actionInterface_settings)
|
|
|
|
self.menuSettings.addAction(self.actionNotifications)
|
|
|
|
self.menuSettings.addAction(self.actionNetwork)
|
|
|
|
self.menuAbout.addAction(self.actionAbout_program)
|
|
|
|
self.menubar.addAction(self.menuProfile.menuAction())
|
|
|
|
self.menubar.addAction(self.menuSettings.menuAction())
|
|
|
|
self.menubar.addAction(self.menuAbout.menuAction())
|
|
|
|
|
2016-02-23 21:26:37 +01:00
|
|
|
self.actionAbout_program.triggered.connect(self.about_program)
|
|
|
|
self.actionNetwork.triggered.connect(self.network_settings)
|
|
|
|
self.actionAdd_friend.triggered.connect(self.add_contact)
|
|
|
|
self.actionSettings.triggered.connect(self.profile_settings)
|
|
|
|
self.actionPrivacy_settings.triggered.connect(self.privacy_settings)
|
|
|
|
self.actionInterface_settings.triggered.connect(self.interface_settings)
|
|
|
|
self.actionNotifications.triggered.connect(self.notification_settings)
|
|
|
|
|
2016-02-21 15:32:38 +01:00
|
|
|
self.menuProfile.setTitle(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.menuAbout.setTitle(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionAdd_friend.setText(QtGui.QApplication.translate("MainWindow", "Add contact", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionProfile_settings.setText(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionPrivacy_settings.setText(QtGui.QApplication.translate("MainWindow", "Privacy", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionInterface_settings.setText(QtGui.QApplication.translate("MainWindow", "Interface", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionNotifications.setText(QtGui.QApplication.translate("MainWindow", "Notifications", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionNetwork.setText(QtGui.QApplication.translate("MainWindow", "Network", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionAbout_program.setText(QtGui.QApplication.translate("MainWindow", "About program", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
self.actionSettings.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
|
|
|
|
2016-02-18 15:02:00 +01:00
|
|
|
def setup_right_bottom(self, Form):
|
|
|
|
Form.setObjectName("right_bottom")
|
2016-03-09 19:11:36 +01:00
|
|
|
Form.resize(650, 100)
|
2016-03-05 13:44:52 +01:00
|
|
|
self.messageEdit = MessageArea(Form, self)
|
2016-03-09 19:11:36 +01:00
|
|
|
self.messageEdit.setGeometry(QtCore.QRect(0, 10, 450, 110))
|
2016-02-18 15:02:00 +01:00
|
|
|
self.messageEdit.setObjectName("messageEdit")
|
|
|
|
self.screenshotButton = QtGui.QPushButton(Form)
|
2016-03-21 15:59:54 +01:00
|
|
|
self.screenshotButton.setGeometry(QtCore.QRect(460, 10, 90, 55))
|
2016-02-18 15:02:00 +01:00
|
|
|
self.screenshotButton.setObjectName("screenshotButton")
|
|
|
|
self.fileTransferButton = QtGui.QPushButton(Form)
|
2016-03-21 15:59:54 +01:00
|
|
|
self.fileTransferButton.setGeometry(QtCore.QRect(460, 65, 90, 55))
|
2016-02-18 15:02:00 +01:00
|
|
|
self.fileTransferButton.setObjectName("fileTransferButton")
|
|
|
|
self.sendMessageButton = QtGui.QPushButton(Form)
|
2016-03-09 19:11:36 +01:00
|
|
|
self.sendMessageButton.setGeometry(QtCore.QRect(550, 10, 60, 110))
|
2016-02-18 15:02:00 +01:00
|
|
|
self.sendMessageButton.setObjectName("sendMessageButton")
|
2016-02-25 21:40:00 +01:00
|
|
|
self.sendMessageButton.clicked.connect(self.send_message)
|
2016-03-22 18:32:29 +01:00
|
|
|
|
2016-03-21 15:23:34 +01:00
|
|
|
pixmap = QtGui.QPixmap(curr_directory() + '/images/send.png')
|
|
|
|
icon = QtGui.QIcon(pixmap)
|
|
|
|
self.sendMessageButton.setIcon(icon)
|
|
|
|
self.sendMessageButton.setIconSize(QtCore.QSize(50, 100))
|
|
|
|
pixmap = QtGui.QPixmap(curr_directory() + '/images/file.png')
|
|
|
|
icon = QtGui.QIcon(pixmap)
|
|
|
|
self.fileTransferButton.setIcon(icon)
|
|
|
|
self.fileTransferButton.setIconSize(QtCore.QSize(90, 40))
|
|
|
|
pixmap = QtGui.QPixmap(curr_directory() + '/images/screenshot.png')
|
|
|
|
icon = QtGui.QIcon(pixmap)
|
|
|
|
self.screenshotButton.setIcon(icon)
|
|
|
|
self.screenshotButton.setIconSize(QtCore.QSize(90, 40))
|
2016-03-22 18:32:29 +01:00
|
|
|
|
2016-03-16 20:59:15 +01:00
|
|
|
self.fileTransferButton.clicked.connect(self.send_file)
|
2016-03-22 13:17:46 +01:00
|
|
|
self.screenshotButton.clicked.connect(self.send_screenshot)
|
2016-02-18 15:02:00 +01:00
|
|
|
QtCore.QMetaObject.connectSlotsByName(Form)
|
|
|
|
|
2016-02-26 15:32:36 +01:00
|
|
|
def setup_left_bottom(self, Form):
|
2016-03-05 13:44:52 +01:00
|
|
|
Form.setObjectName("left_bottom")
|
2016-02-18 15:02:00 +01:00
|
|
|
Form.resize(500, 80)
|
|
|
|
self.online_contacts = QtGui.QCheckBox(Form)
|
|
|
|
self.online_contacts.setGeometry(QtCore.QRect(0, 20, 141, 22))
|
|
|
|
self.online_contacts.setObjectName("online_contacts")
|
2016-03-02 17:05:03 +01:00
|
|
|
self.online_contacts.clicked.connect(self.filtering)
|
2016-03-02 21:55:12 +01:00
|
|
|
self.contact_name = QtGui.QLineEdit(Form)
|
|
|
|
self.contact_name.setGeometry(QtCore.QRect(0, 40, 140, 28))
|
|
|
|
self.contact_name.setObjectName("contact_name")
|
|
|
|
self.contact_name.textChanged.connect(self.filtering)
|
2016-02-18 15:02:00 +01:00
|
|
|
self.online_contacts.setText(QtGui.QApplication.translate("Form", "Online contacts", None, QtGui.QApplication.UnicodeUTF8))
|
|
|
|
QtCore.QMetaObject.connectSlotsByName(Form)
|
|
|
|
|
2016-02-17 21:47:43 +01:00
|
|
|
def setup_left_top(self, Form):
|
2016-02-18 15:02:00 +01:00
|
|
|
Form.setObjectName("left_top")
|
2016-02-17 21:47:43 +01:00
|
|
|
Form.resize(500, 300)
|
2016-03-11 12:37:45 +01:00
|
|
|
Form.setCursor(QtCore.Qt.PointingHandCursor)
|
2016-02-17 21:47:43 +01:00
|
|
|
Form.setMinimumSize(QtCore.QSize(250, 100))
|
|
|
|
Form.setMaximumSize(QtCore.QSize(250, 100))
|
2016-02-25 21:40:00 +01:00
|
|
|
Form.setBaseSize(QtCore.QSize(250, 100))
|
2016-03-07 19:00:00 +01:00
|
|
|
self.avatar_label = Form.avatar_label = QtGui.QLabel(Form)
|
|
|
|
self.avatar_label.setGeometry(QtCore.QRect(10, 20, 64, 64))
|
|
|
|
self.avatar_label.setScaledContents(True)
|
2016-02-29 16:40:49 +01:00
|
|
|
self.name = Form.name = QtGui.QLabel(Form)
|
2016-03-11 12:37:45 +01:00
|
|
|
Form.name.setGeometry(QtCore.QRect(80, 30, 120, 25))
|
2016-02-17 21:47:43 +01:00
|
|
|
font = QtGui.QFont()
|
|
|
|
font.setFamily("Times New Roman")
|
2016-03-07 19:00:00 +01:00
|
|
|
font.setPointSize(14)
|
2016-02-17 21:47:43 +01:00
|
|
|
font.setBold(True)
|
2016-02-29 16:40:49 +01:00
|
|
|
Form.name.setFont(font)
|
|
|
|
Form.name.setObjectName("name")
|
|
|
|
self.status_message = Form.status_message = QtGui.QLabel(Form)
|
2016-03-08 19:53:11 +01:00
|
|
|
Form.status_message.setGeometry(QtCore.QRect(80, 60, 190, 20))
|
2016-03-07 19:00:00 +01:00
|
|
|
font.setPointSize(12)
|
2016-02-17 21:47:43 +01:00
|
|
|
font.setBold(False)
|
2016-02-29 16:40:49 +01:00
|
|
|
Form.status_message.setFont(font)
|
|
|
|
Form.status_message.setObjectName("status_message")
|
|
|
|
self.connection_status = Form.connection_status = StatusCircle(self)
|
|
|
|
Form.connection_status.setGeometry(QtCore.QRect(200, 34, 64, 64))
|
|
|
|
Form.connection_status.setMinimumSize(QtCore.QSize(32, 32))
|
|
|
|
Form.connection_status.setMaximumSize(QtCore.QSize(32, 32))
|
|
|
|
Form.connection_status.setBaseSize(QtCore.QSize(32, 32))
|
2016-03-11 12:37:45 +01:00
|
|
|
self.avatar_label.mouseReleaseEvent = self.profile_settings
|
|
|
|
self.status_message.mouseReleaseEvent = self.profile_settings
|
|
|
|
self.name.mouseReleaseEvent = self.profile_settings
|
|
|
|
self.connection_status.raise_()
|
2016-02-29 16:40:49 +01:00
|
|
|
Form.connection_status.setObjectName("connection_status")
|
2016-02-23 13:07:15 +01:00
|
|
|
|
2016-02-18 15:02:00 +01:00
|
|
|
def setup_right_top(self, Form):
|
|
|
|
Form.setObjectName("Form")
|
2016-03-08 19:53:11 +01:00
|
|
|
Form.resize(650, 300)
|
2016-03-07 19:00:00 +01:00
|
|
|
self.account_avatar = QtGui.QLabel(Form)
|
|
|
|
self.account_avatar.setGeometry(QtCore.QRect(10, 20, 64, 64))
|
|
|
|
self.account_avatar.setScaledContents(True)
|
2016-02-18 15:02:00 +01:00
|
|
|
self.account_name = QtGui.QLabel(Form)
|
2016-03-08 19:53:11 +01:00
|
|
|
self.account_name.setGeometry(QtCore.QRect(100, 30, 400, 25))
|
2016-02-18 15:02:00 +01:00
|
|
|
font = QtGui.QFont()
|
2016-03-07 19:00:00 +01:00
|
|
|
font.setFamily("Times New Roman")
|
|
|
|
font.setPointSize(14)
|
2016-02-18 15:02:00 +01:00
|
|
|
font.setBold(True)
|
|
|
|
self.account_name.setFont(font)
|
|
|
|
self.account_name.setObjectName("account_name")
|
|
|
|
self.account_status = QtGui.QLabel(Form)
|
2016-03-08 19:53:11 +01:00
|
|
|
self.account_status.setGeometry(QtCore.QRect(100, 50, 400, 25))
|
2016-03-07 19:00:00 +01:00
|
|
|
font.setPointSize(12)
|
2016-02-18 15:02:00 +01:00
|
|
|
font.setBold(False)
|
|
|
|
self.account_status.setFont(font)
|
|
|
|
self.account_status.setObjectName("account_status")
|
|
|
|
self.callButton = QtGui.QPushButton(Form)
|
2016-03-22 19:00:42 +01:00
|
|
|
self.callButton.setGeometry(QtCore.QRect(550, 30, 50, 50))
|
2016-02-18 15:02:00 +01:00
|
|
|
self.callButton.setObjectName("callButton")
|
2016-03-22 19:00:42 +01:00
|
|
|
pixmap = QtGui.QPixmap(curr_directory() + '/images/call.png')
|
|
|
|
icon = QtGui.QIcon(pixmap)
|
|
|
|
self.callButton.setIcon(icon)
|
|
|
|
self.callButton.setIconSize(QtCore.QSize(50, 50))
|
2016-02-18 15:02:00 +01:00
|
|
|
QtCore.QMetaObject.connectSlotsByName(Form)
|
2016-02-17 21:47:43 +01:00
|
|
|
|
2016-03-09 19:45:38 +01:00
|
|
|
def setup_left_center(self, widget):
|
2016-02-25 21:40:00 +01:00
|
|
|
self.friends_list = QtGui.QListWidget(widget)
|
2016-03-22 19:47:14 +01:00
|
|
|
self.friends_list.setGeometry(0, 0, 270, 250)
|
2016-02-25 21:40:00 +01:00
|
|
|
self.friends_list.clicked.connect(self.friend_click)
|
2016-03-10 21:04:43 +01:00
|
|
|
self.friends_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
|
|
|
self.friends_list.connect(self.friends_list, QtCore.SIGNAL("customContextMenuRequested(QPoint)"),
|
|
|
|
self.friend_right_click)
|
2016-02-25 21:40:00 +01:00
|
|
|
|
2016-02-26 19:54:15 +01:00
|
|
|
def setup_right_center(self, widget):
|
|
|
|
self.messages = QtGui.QListWidget(widget)
|
2016-03-08 19:53:11 +01:00
|
|
|
self.messages.setGeometry(0, 0, 600, 250)
|
2016-02-26 19:54:15 +01:00
|
|
|
|
2016-03-15 18:05:19 +01:00
|
|
|
def initUI(self, tox):
|
2016-03-22 20:03:28 +01:00
|
|
|
self.setMinimumSize(920, 520)
|
|
|
|
self.setMaximumSize(920, 520)
|
|
|
|
self.setGeometry(400, 400, 920, 520)
|
2016-02-25 21:40:00 +01:00
|
|
|
self.setWindowTitle('Toxygen')
|
2016-02-21 15:32:38 +01:00
|
|
|
main = QtGui.QWidget()
|
2016-02-17 21:47:43 +01:00
|
|
|
grid = QtGui.QGridLayout()
|
2016-02-18 15:02:00 +01:00
|
|
|
search = QtGui.QWidget()
|
2016-02-26 15:32:36 +01:00
|
|
|
self.setup_left_bottom(search)
|
|
|
|
grid.addWidget(search, 2, 0)
|
2016-02-17 21:47:43 +01:00
|
|
|
name = QtGui.QWidget()
|
|
|
|
self.setup_left_top(name)
|
|
|
|
grid.addWidget(name, 0, 0)
|
2016-02-26 19:54:15 +01:00
|
|
|
messages = QtGui.QWidget()
|
|
|
|
self.setup_right_center(messages)
|
|
|
|
grid.addWidget(messages, 1, 1)
|
2016-02-18 15:02:00 +01:00
|
|
|
info = QtGui.QWidget()
|
|
|
|
self.setup_right_top(info)
|
|
|
|
grid.addWidget(info, 0, 1)
|
2016-02-26 19:54:15 +01:00
|
|
|
message_buttons = QtGui.QWidget()
|
|
|
|
self.setup_right_bottom(message_buttons)
|
|
|
|
grid.addWidget(message_buttons, 2, 1)
|
2016-02-25 21:40:00 +01:00
|
|
|
main_list = QtGui.QWidget()
|
2016-03-09 19:45:38 +01:00
|
|
|
self.setup_left_center(main_list)
|
2016-02-26 15:32:36 +01:00
|
|
|
grid.addWidget(main_list, 1, 0)
|
2016-02-25 21:40:00 +01:00
|
|
|
grid.setColumnMinimumWidth(1, 500)
|
2016-03-22 19:47:14 +01:00
|
|
|
grid.setColumnMinimumWidth(0, 270)
|
2016-03-07 19:00:00 +01:00
|
|
|
grid.setRowMinimumHeight(1, 250)
|
2016-02-21 15:32:38 +01:00
|
|
|
main.setLayout(grid)
|
|
|
|
self.setCentralWidget(main)
|
2016-02-24 17:39:19 +01:00
|
|
|
self.setup_menu(self)
|
2016-03-09 19:11:36 +01:00
|
|
|
self.user_info = name
|
|
|
|
self.friend_info = info
|
2016-03-15 18:05:19 +01:00
|
|
|
self.profile = Profile(tox, self)
|
2016-02-17 21:47:43 +01:00
|
|
|
|
2016-03-12 21:18:13 +01:00
|
|
|
def closeEvent(self, *args, **kwargs):
|
2016-03-13 13:06:06 +01:00
|
|
|
self.profile.save_history()
|
2016-03-12 21:18:13 +01:00
|
|
|
|
2016-02-23 21:26:37 +01:00
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
# Functions which called when user click in menu
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def about_program(self):
|
|
|
|
import util
|
|
|
|
msgBox = QtGui.QMessageBox()
|
|
|
|
msgBox.setWindowTitle("About")
|
|
|
|
msgBox.setText("Toxygen is pythonic Tox client. Version: " + util.program_version)
|
|
|
|
msgBox.exec_()
|
|
|
|
|
|
|
|
def network_settings(self):
|
2016-03-15 18:05:19 +01:00
|
|
|
self.n_s = NetworkSettings(self.reset)
|
2016-02-23 21:26:37 +01:00
|
|
|
self.n_s.show()
|
|
|
|
|
|
|
|
def add_contact(self):
|
|
|
|
self.a_c = AddContact()
|
|
|
|
self.a_c.show()
|
|
|
|
|
2016-03-22 20:03:28 +01:00
|
|
|
def profile_settings(self):
|
2016-03-07 19:00:00 +01:00
|
|
|
self.p_s = ProfileSettings()
|
2016-02-23 21:26:37 +01:00
|
|
|
self.p_s.show()
|
|
|
|
|
|
|
|
def privacy_settings(self):
|
|
|
|
self.priv_s = PrivacySettings()
|
|
|
|
self.priv_s.show()
|
|
|
|
|
|
|
|
def notification_settings(self):
|
|
|
|
self.notif_s = NotificationsSettings()
|
|
|
|
self.notif_s.show()
|
|
|
|
|
|
|
|
def interface_settings(self):
|
|
|
|
self.int_s = InterfaceSettings()
|
|
|
|
self.int_s.show()
|
|
|
|
|
2016-03-13 13:06:06 +01:00
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
2016-03-16 20:59:15 +01:00
|
|
|
# Messages and file transfers
|
2016-03-13 13:06:06 +01:00
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
2016-02-25 21:40:00 +01:00
|
|
|
|
|
|
|
def send_message(self):
|
|
|
|
text = self.messageEdit.toPlainText()
|
2016-03-09 19:11:36 +01:00
|
|
|
self.profile.send_message(text)
|
2016-02-25 21:40:00 +01:00
|
|
|
|
2016-03-16 20:59:15 +01:00
|
|
|
def send_file(self):
|
|
|
|
if self.profile.is_active_online(): # active friend exists and online
|
|
|
|
name = QtGui.QFileDialog.getOpenFileName(self, 'Choose file')
|
2016-03-17 21:58:38 +01:00
|
|
|
if name[0]:
|
2016-03-17 21:49:27 +01:00
|
|
|
self.profile.send_file(name[0])
|
2016-03-16 20:59:15 +01:00
|
|
|
|
2016-03-22 13:17:46 +01:00
|
|
|
def send_screenshot(self):
|
|
|
|
# TODO: add screenshots support
|
|
|
|
if self.profile.is_active_online(): # active friend exists and online
|
|
|
|
pass
|
|
|
|
|
2016-03-13 13:06:06 +01:00
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
# Functions which called when user open context menu in friends list
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
2016-03-10 21:04:43 +01:00
|
|
|
|
|
|
|
def friend_right_click(self, pos):
|
|
|
|
item = self.friends_list.itemAt(pos)
|
2016-03-18 17:33:54 +01:00
|
|
|
num = self.friends_list.indexFromItem(item).row()
|
|
|
|
friend = Profile.get_instance().get_friend_by_number(num)
|
|
|
|
settings = Settings.get_instance()
|
|
|
|
allowed = friend.tox_id in settings['auto_accept_from_friends']
|
|
|
|
auto = 'Disallow auto accept' if allowed else 'Allow auto accept'
|
2016-03-10 21:04:43 +01:00
|
|
|
if item is not None:
|
|
|
|
self.listMenu = QtGui.QMenu()
|
|
|
|
set_alias_item = self.listMenu.addAction('Set alias')
|
|
|
|
clear_history_item = self.listMenu.addAction('Clear history')
|
|
|
|
copy_key_item = self.listMenu.addAction('Copy public key')
|
2016-03-18 17:33:54 +01:00
|
|
|
auto_accept_item = self.listMenu.addAction(auto)
|
2016-03-10 21:04:43 +01:00
|
|
|
remove_item = self.listMenu.addAction('Remove friend')
|
2016-03-18 17:33:54 +01:00
|
|
|
self.connect(set_alias_item, QtCore.SIGNAL("triggered()"), lambda: self.set_alias(num))
|
|
|
|
self.connect(remove_item, QtCore.SIGNAL("triggered()"), lambda: self.remove_friend(num))
|
|
|
|
self.connect(copy_key_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_friend_key(num))
|
|
|
|
self.connect(clear_history_item, QtCore.SIGNAL("triggered()"), lambda: self.clear_history(num))
|
|
|
|
self.connect(auto_accept_item, QtCore.SIGNAL("triggered()"), lambda: self.auto_accept(num, not allowed))
|
2016-03-10 21:04:43 +01:00
|
|
|
parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0))
|
|
|
|
self.listMenu.move(parent_position + pos)
|
|
|
|
self.listMenu.show()
|
|
|
|
|
2016-03-18 17:33:54 +01:00
|
|
|
def set_alias(self, num):
|
2016-03-10 21:04:43 +01:00
|
|
|
self.profile.set_alias(num)
|
|
|
|
|
2016-03-18 17:33:54 +01:00
|
|
|
def remove_friend(self, num):
|
2016-03-10 21:04:43 +01:00
|
|
|
self.profile.delete_friend(num)
|
|
|
|
|
2016-03-18 17:33:54 +01:00
|
|
|
def copy_friend_key(self, num):
|
2016-03-10 21:04:43 +01:00
|
|
|
tox_id = self.profile.friend_public_key(num)
|
|
|
|
clipboard = QtGui.QApplication.clipboard()
|
|
|
|
clipboard.setText(tox_id)
|
|
|
|
|
2016-03-18 17:33:54 +01:00
|
|
|
def clear_history(self, num):
|
2016-03-12 21:18:13 +01:00
|
|
|
self.profile.clear_history(num)
|
2016-03-10 21:04:43 +01:00
|
|
|
|
2016-03-18 17:33:54 +01:00
|
|
|
def auto_accept(self, num, value):
|
|
|
|
settings = Settings.get_instance()
|
|
|
|
tox_id = self.profile.friend_public_key(num)
|
|
|
|
if value:
|
|
|
|
settings['auto_accept_from_friends'].append(tox_id)
|
|
|
|
else:
|
|
|
|
index = settings['auto_accept_from_friends'].index(tox_id)
|
|
|
|
del settings['auto_accept_from_friends'][index]
|
|
|
|
settings.save()
|
|
|
|
|
2016-03-13 13:06:06 +01:00
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
# Functions which called when user click somewhere else
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
2016-02-25 21:40:00 +01:00
|
|
|
|
2016-02-28 22:33:35 +01:00
|
|
|
def friend_click(self, index):
|
|
|
|
num = index.row()
|
2016-03-09 19:11:36 +01:00
|
|
|
self.profile.set_active(num)
|
2016-03-02 17:05:03 +01:00
|
|
|
|
2016-03-07 19:00:00 +01:00
|
|
|
def mouseReleaseEvent(self, event):
|
|
|
|
x, y = event.x(), event.y()
|
|
|
|
pos = self.connection_status.pos()
|
|
|
|
if (pos.x() < x < pos.x() + 32) and (pos.y() < y < pos.y() + 32):
|
|
|
|
self.profile.change_status()
|
|
|
|
else:
|
|
|
|
super(self.__class__, self).mouseReleaseEvent(event)
|
|
|
|
|
2016-03-02 17:05:03 +01:00
|
|
|
def filtering(self):
|
2016-03-02 21:55:12 +01:00
|
|
|
self.profile.filtration(self.online_contacts.isChecked(), self.contact_name.text())
|
2016-03-05 13:44:52 +01:00
|
|
|
|
|
|
|
|