action messages fix
This commit is contained in:
parent
7bdc506ff2
commit
24d27f9f47
1 changed files with 10 additions and 7 deletions
|
@ -13,7 +13,7 @@ import smileys
|
||||||
|
|
||||||
class MessageEdit(QtGui.QTextBrowser):
|
class MessageEdit(QtGui.QTextBrowser):
|
||||||
|
|
||||||
def __init__(self, text, width, parent=None):
|
def __init__(self, text, width, message_type, parent=None):
|
||||||
super(MessageEdit, self).__init__(parent)
|
super(MessageEdit, self).__init__(parent)
|
||||||
self.urls = {}
|
self.urls = {}
|
||||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
|
@ -25,13 +25,17 @@ class MessageEdit(QtGui.QTextBrowser):
|
||||||
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.document().setDefaultStyleSheet('a { color: #306EFF; }')
|
||||||
self.setDecoratedText(text)
|
text = self.decoratedText(text)
|
||||||
|
if message_type == TOX_MESSAGE_TYPE['ACTION']:
|
||||||
|
self.setHtml('<p style="color: #5CB3FF; font: italic; font-size: 20px;" >' + text + '</p>')
|
||||||
|
else:
|
||||||
|
self.setHtml(text)
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setFamily("Times New Roman")
|
font.setFamily("Times New Roman")
|
||||||
font.setPixelSize(14)
|
font.setPixelSize(14)
|
||||||
font.setBold(False)
|
font.setBold(False)
|
||||||
self.setFont(font)
|
self.setFont(font)
|
||||||
self.setFixedHeight(self.document().size().height())
|
self.resize(width, self.document().size().height())
|
||||||
self.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse | QtCore.Qt.LinksAccessibleByMouse)
|
self.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse | QtCore.Qt.LinksAccessibleByMouse)
|
||||||
self.anchorClicked.connect(self.on_anchor_clicked)
|
self.anchorClicked.connect(self.on_anchor_clicked)
|
||||||
|
|
||||||
|
@ -64,7 +68,7 @@ class MessageEdit(QtGui.QTextBrowser):
|
||||||
movie.currentPixmap())
|
movie.currentPixmap())
|
||||||
self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth())
|
self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth())
|
||||||
|
|
||||||
def setDecoratedText(self, text):
|
def decoratedText(self, text):
|
||||||
text = cgi.escape(text) # replace < and >
|
text = cgi.escape(text) # replace < and >
|
||||||
exp = QtCore.QRegExp(
|
exp = QtCore.QRegExp(
|
||||||
'('
|
'('
|
||||||
|
@ -90,7 +94,7 @@ class MessageEdit(QtGui.QTextBrowser):
|
||||||
arr[i] = '<font color="green"><b>' + arr[i][4:] + '</b></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)
|
return text
|
||||||
|
|
||||||
|
|
||||||
class MessageItem(QtGui.QWidget):
|
class MessageItem(QtGui.QWidget):
|
||||||
|
@ -125,10 +129,9 @@ class MessageItem(QtGui.QWidget):
|
||||||
else:
|
else:
|
||||||
self.time.setText(time)
|
self.time.setText(time)
|
||||||
|
|
||||||
self.message = MessageEdit(text, parent.width() - 150, self)
|
self.message = MessageEdit(text, parent.width() - 150, message_type, self)
|
||||||
if message_type != TOX_MESSAGE_TYPE['NORMAL']:
|
if message_type != TOX_MESSAGE_TYPE['NORMAL']:
|
||||||
self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
|
self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
|
||||||
self.message.setStyleSheet("QTextEdit { color: #5CB3FF; font: italic; font-size: 20px; }")
|
|
||||||
self.message.setAlignment(QtCore.Qt.AlignCenter)
|
self.message.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.time.setStyleSheet("QLabel { color: #5CB3FF; }")
|
self.time.setStyleSheet("QLabel { color: #5CB3FF; }")
|
||||||
self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 150, self.message.height()))
|
self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 150, self.message.height()))
|
||||||
|
|
Loading…
Reference in a new issue