This commit is contained in:
ingvar1995 2016-06-15 21:02:59 +03:00
parent 183dfadc77
commit fe4af18196
3 changed files with 31 additions and 15 deletions

View file

@ -25,6 +25,7 @@ class MessageEdit(QtGui.QTextBrowser):
self.setAcceptRichText(True) self.setAcceptRichText(True)
self.setOpenLinks(False) self.setOpenLinks(False)
self.setSearchPaths([smileys.SmileyLoader.get_instance().get_smileys_path()]) self.setSearchPaths([smileys.SmileyLoader.get_instance().get_smileys_path()])
self.document().setDefaultStyleSheet('a { color: #306EFF; }')
self.setDecoratedText(text) self.setDecoratedText(text)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily("Times New Roman")
@ -87,7 +88,7 @@ class MessageEdit(QtGui.QTextBrowser):
arr = text.split('\n') arr = text.split('\n')
for i in range(len(arr)): # quotes for i in range(len(arr)): # quotes
if arr[i].startswith('>'): if arr[i].startswith('>'):
arr[i] = '<font color="green">' + arr[i][4:] + '</font>' arr[i] = '<font color="green"><b>' + arr[i][4:] + '</b></font>'
text = '<br>'.join(arr) text = '<br>'.join(arr)
text = smileys.SmileyLoader.get_instance().add_smileys_to_text(text, self) # smileys text = smileys.SmileyLoader.get_instance().add_smileys_to_text(text, self) # smileys
self.setHtml(text) self.setHtml(text)
@ -125,17 +126,17 @@ class MessageItem(QtGui.QWidget):
self.setFixedHeight(self.message.height()) self.setFixedHeight(self.message.height())
if message_type != TOX_MESSAGE_TYPE['NORMAL']: if message_type != TOX_MESSAGE_TYPE['NORMAL']:
self.name.setStyleSheet("QLabel { color: #4169E1; }") self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
self.name.setAlignment(QtCore.Qt.AlignCenter) self.message.setStyleSheet("QTextEdit { color: #5CB3FF; font: italic; font-size: 20px; }")
self.message.setStyleSheet("QTextEdit { color: #4169E1; }")
self.message.setAlignment(QtCore.Qt.AlignCenter) self.message.setAlignment(QtCore.Qt.AlignCenter)
self.time.setStyleSheet("QLabel { color: #4169E1; }") self.time.setStyleSheet("QLabel { color: #5CB3FF; }")
class ContactItem(QtGui.QWidget): class ContactItem(QtGui.QWidget):
""" """
Contact in friends list Contact in friends list
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.setBaseSize(QtCore.QSize(250, 70)) self.setBaseSize(QtCore.QSize(250, 70))
@ -143,7 +144,7 @@ class ContactItem(QtGui.QWidget):
self.avatar_label.setGeometry(QtCore.QRect(3, 3, 64, 64)) self.avatar_label.setGeometry(QtCore.QRect(3, 3, 64, 64))
self.avatar_label.setScaledContents(True) self.avatar_label.setScaledContents(True)
self.name = DataLabel(self) self.name = DataLabel(self)
self.name.setGeometry(QtCore.QRect(70, 10, 160, 25)) self.name.setGeometry(QtCore.QRect(75, 10, 160, 25))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily("Times New Roman")
font.setPointSize(12) font.setPointSize(12)
@ -151,7 +152,7 @@ class ContactItem(QtGui.QWidget):
self.name.setFont(font) self.name.setFont(font)
self.name.setObjectName("name") self.name.setObjectName("name")
self.status_message = DataLabel(self) self.status_message = DataLabel(self)
self.status_message.setGeometry(QtCore.QRect(70, 30, 180, 20)) self.status_message.setGeometry(QtCore.QRect(75, 30, 180, 20))
font.setPointSize(10) font.setPointSize(10)
font.setBold(False) font.setBold(False)
self.status_message.setFont(font) self.status_message.setFont(font)
@ -165,6 +166,7 @@ class StatusCircle(QtGui.QWidget):
""" """
Connection status Connection status
""" """
# TODO: rewrite
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)

View file

@ -9,7 +9,7 @@ import util
class MessageArea(QtGui.QPlainTextEdit): class MessageArea(QtGui.QPlainTextEdit):
"""User enters messages here""" """User types messages here"""
def __init__(self, parent, form): def __init__(self, parent, form):
super(MessageArea, self).__init__(parent) super(MessageArea, self).__init__(parent)
@ -122,6 +122,9 @@ class ScreenShotWindow(QtGui.QWidget):
class SmileyWindow(QtGui.QWidget): class SmileyWindow(QtGui.QWidget):
"""
Smiley selection window
"""
def __init__(self, parent): def __init__(self, parent):
super(SmileyWindow, self).__init__() super(SmileyWindow, self).__init__()
@ -129,7 +132,7 @@ class SmileyWindow(QtGui.QWidget):
inst = smileys.SmileyLoader.get_instance() inst = smileys.SmileyLoader.get_instance()
self.data = inst.get_smileys() self.data = inst.get_smileys()
count = len(self.data) count = len(self.data)
self.page_size = int(pow(count / 8, 0.5) + 1) * 8 self.page_size = int(pow(count / 8, 0.5) + 1) * 8 # smileys per page
if count % self.page_size == 0: if count % self.page_size == 0:
self.page_count = count / self.page_size self.page_count = count / self.page_size
else: else:
@ -137,7 +140,7 @@ class SmileyWindow(QtGui.QWidget):
self.page = 0 self.page = 0
self.radio = [] self.radio = []
self.parent = parent self.parent = parent
for i in range(self.page_count): for i in range(self.page_count): # buttons with smileys
elem = QtGui.QRadioButton(self) elem = QtGui.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 i=i: self.checked(i)) elem.clicked.connect(lambda i=i: self.checked(i))
@ -146,14 +149,14 @@ class SmileyWindow(QtGui.QWidget):
self.setMaximumSize(width, 200) self.setMaximumSize(width, 200)
self.setMinimumSize(width, 200) self.setMinimumSize(width, 200)
self.buttons = [] self.buttons = []
for i in range(self.page_size): for i in range(self.page_size): # pages - radio buttons
b = QtGui.QPushButton(self) b = QtGui.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 i=i: self.clicked(i)) b.clicked.connect(lambda i=i: self.clicked(i))
self.buttons.append(b) self.buttons.append(b)
self.checked(0) self.checked(0)
def checked(self, pos): def checked(self, pos): # new page opened
self.radio[self.page].setChecked(False) self.radio[self.page].setChecked(False)
self.radio[pos].setChecked(True) self.radio[pos].setChecked(True)
self.page = pos self.page = pos
@ -167,12 +170,15 @@ class SmileyWindow(QtGui.QWidget):
except: except:
self.buttons[i].setVisible(False) self.buttons[i].setVisible(False)
def clicked(self, pos): def clicked(self, pos): # smiley selected
pos += self.page * self.page_size pos += self.page * self.page_size
smiley = self.data[pos][0] smiley = self.data[pos][0]
self.parent.messageEdit.insertPlainText(smiley) self.parent.messageEdit.insertPlainText(smiley)
self.close() self.close()
def leaveEvent(self, event):
self.close()
class MenuButton(QtGui.QPushButton): class MenuButton(QtGui.QPushButton):
@ -268,11 +274,14 @@ class StickerItem(QtGui.QWidget):
self.path = fl self.path = fl
self.pixmap = QtGui.QPixmap() self.pixmap = QtGui.QPixmap()
self.pixmap.load(fl) self.pixmap.load(fl)
if self.pixmap.width() > 150:
self.pixmap = self.pixmap.scaled(150, 200, QtCore.Qt.KeepAspectRatio)
self.setFixedSize(150, self.pixmap.height()) self.setFixedSize(150, self.pixmap.height())
self._image_label.setPixmap(self.pixmap) self._image_label.setPixmap(self.pixmap)
class StickerWindow(QtGui.QWidget): class StickerWindow(QtGui.QWidget):
"""Sticker selection window"""
def __init__(self, parent): def __init__(self, parent):
super(StickerWindow, self).__init__() super(StickerWindow, self).__init__()
@ -296,4 +305,7 @@ class StickerWindow(QtGui.QWidget):
self.parent.profile.send_sticker(self.arr[num]) self.parent.profile.send_sticker(self.arr[num])
self.close() self.close()
def leaveEvent(self, event):
self.close()

View file

@ -444,6 +444,9 @@ class Profile(contact.Contact, Singleton):
data[3], data[3],
False) False)
elif message.get_type() == MESSAGE_TYPE['FILE_TRANSFER']: elif message.get_type() == MESSAGE_TYPE['FILE_TRANSFER']:
if message.get_status() is None:
self.create_unsent_file_item(message)
continue
item = self.create_file_transfer_item(message, False) item = self.create_file_transfer_item(message, False)
if message.get_status() >= 2: # active file transfer if message.get_status() >= 2: # active file transfer
ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())] ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())]
@ -973,8 +976,7 @@ class Profile(contact.Contact, Singleton):
self.get_friend_by_number(friend_number).update_transfer_data(file_number, self.get_friend_by_number(friend_number).update_transfer_data(file_number,
FILE_TRANSFER_MESSAGE_STATUS['FINISHED'], FILE_TRANSFER_MESSAGE_STATUS['FINISHED'],
inline) inline)
#self.update() self.update()
# TODO: fix
else: else:
self.get_friend_by_number(friend_number).update_transfer_data(file_number, self.get_friend_by_number(friend_number).update_transfer_data(file_number,
FILE_TRANSFER_MESSAGE_STATUS['FINISHED']) FILE_TRANSFER_MESSAGE_STATUS['FINISHED'])