notifications added, some fixes
This commit is contained in:
parent
568609dfcb
commit
35cf74eff8
@ -1,5 +1,5 @@
|
|||||||
from PySide import QtCore
|
from PySide import QtCore
|
||||||
from toxcore_enums_and_consts import TOX_USER_CONNECTION_STATUS, TOX_CONNECTION
|
from notifications import *
|
||||||
# TODO: add all callbacks (replace test callbacks and use wrappers)
|
# TODO: add all callbacks (replace test callbacks and use wrappers)
|
||||||
|
|
||||||
|
|
||||||
@ -33,10 +33,6 @@ def repaint_widget(widget):
|
|||||||
def self_connection_status(st, tox_link):
|
def self_connection_status(st, tox_link):
|
||||||
def wrapped(tox, connection, user_data):
|
def wrapped(tox, connection, user_data):
|
||||||
print 'Connection status: ', str(connection)
|
print 'Connection status: ', str(connection)
|
||||||
if connection == TOX_CONNECTION['NONE']:
|
|
||||||
st.status = TOX_USER_CONNECTION_STATUS['OFFLINE']
|
|
||||||
else:
|
|
||||||
st.status = int(tox_link.self_get_status())
|
|
||||||
invoke_in_main_thread(repaint_widget(st))
|
invoke_in_main_thread(repaint_widget(st))
|
||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
@ -47,6 +43,7 @@ def friend_status(a, b, c, d):
|
|||||||
|
|
||||||
def friend_message(a, b, c, d, e, f):
|
def friend_message(a, b, c, d, e, f):
|
||||||
print 'Message: ', d.decode('utf8')
|
print 'Message: ', d.decode('utf8')
|
||||||
|
tray_notification('Message', d.decode('utf8'))
|
||||||
|
|
||||||
|
|
||||||
def init_callbacks(tox, window):
|
def init_callbacks(tox, window):
|
||||||
|
@ -11,32 +11,29 @@ class StatusCircle(QtGui.QWidget):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtGui.QWidget.__init__(self, parent)
|
QtGui.QWidget.__init__(self, parent)
|
||||||
self.setGeometry(0, 0, 32, 32)
|
self.setGeometry(0, 0, 32, 32)
|
||||||
self.status = TOX_USER_CONNECTION_STATUS['OFFLINE']
|
|
||||||
self.tox = parent.tox
|
self.tox = parent.tox
|
||||||
|
|
||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
if self.status != TOX_USER_CONNECTION_STATUS['OFFLINE']:
|
pass
|
||||||
self.status += 1
|
|
||||||
self.status %= TOX_USER_CONNECTION_STATUS['OFFLINE']
|
|
||||||
self.tox.self_set_status(self.status)
|
|
||||||
self.repaint()
|
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
paint = QtGui.QPainter()
|
paint = QtGui.QPainter()
|
||||||
paint.begin(self)
|
paint.begin(self)
|
||||||
paint.setRenderHint(QtGui.QPainter.Antialiasing)
|
paint.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||||
paint.setBrush(QtCore.Qt.white)
|
#paint.setBrush(QtCore.Qt.white)
|
||||||
paint.drawRect(event.rect())
|
#paint.drawRect(event.rect())
|
||||||
k = 16
|
k = 16
|
||||||
rad_x = rad_y = 10
|
rad_x = rad_y = 10
|
||||||
if self.status == TOX_USER_CONNECTION_STATUS['OFFLINE']:
|
if not self.tox.self_get_connection_status():
|
||||||
color = QtCore.Qt.black
|
color = QtCore.Qt.black
|
||||||
elif self.status == TOX_USER_CONNECTION_STATUS['ONLINE']:
|
else:
|
||||||
color = QtCore.Qt.green
|
status = self.tox.self_get_status()
|
||||||
elif self.status == TOX_USER_CONNECTION_STATUS['AWAY']:
|
if status == TOX_USER_STATUS['NONE']:
|
||||||
color = QtCore.Qt.yellow
|
color = QtCore.Qt.green
|
||||||
else: # self.status == TOX_USER_CONNECTION_STATUS['BUSY']:
|
elif status == TOX_USER_STATUS['AWAY']:
|
||||||
color = QtCore.Qt.red
|
color = QtCore.Qt.yellow
|
||||||
|
else: # self.status == TOX_USER_STATUS['BUSY']:
|
||||||
|
color = QtCore.Qt.red
|
||||||
|
|
||||||
paint.setPen(color)
|
paint.setPen(color)
|
||||||
center = QtCore.QPoint(k, k)
|
center = QtCore.QPoint(k, k)
|
||||||
|
10
src/notifications.py
Normal file
10
src/notifications.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from PySide import QtGui, QtCore
|
||||||
|
# TODO: add sound notifications
|
||||||
|
|
||||||
|
|
||||||
|
def tray_notification(title, text):
|
||||||
|
if QtGui.QSystemTrayIcon.isSystemTrayAvailable():
|
||||||
|
tray = QtGui.QSystemTrayIcon()
|
||||||
|
tray.setContextMenu(QtGui.QMenu())
|
||||||
|
tray.show()
|
||||||
|
tray.showMessage(title, text)
|
@ -199,15 +199,3 @@ TOX_MAX_MESSAGE_LENGTH = 1372
|
|||||||
TOX_MAX_NAME_LENGTH = 128
|
TOX_MAX_NAME_LENGTH = 128
|
||||||
|
|
||||||
TOX_MAX_STATUS_MESSAGE_LENGTH = 1007
|
TOX_MAX_STATUS_MESSAGE_LENGTH = 1007
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
|
||||||
# Other enums
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
TOX_USER_CONNECTION_STATUS = {
|
|
||||||
'ONLINE': 0,
|
|
||||||
'AWAY': 1,
|
|
||||||
'BUSY': 2,
|
|
||||||
'OFFLINE': 3
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user