]>
jfr.im git - irc/weechat/qweechat.git/blob - src/qweechat/chat.py
2 # -*- coding: utf-8 -*-
4 # Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
6 # This file is part of QWeeChat, a Qt remote GUI for WeeChat.
8 # QWeeChat is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # QWeeChat is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
28 QtCore
= qt_compat
.import_module('QtCore')
29 QtGui
= qt_compat
.import_module('QtGui')
32 class ChatTextEdit(QtGui
.QTextEdit
):
35 def __init__(self
, *args
):
36 apply(QtGui
.QTextEdit
.__init
__, (self
,) + args
)
38 self
.setFocusPolicy(QtCore
.Qt
.NoFocus
)
39 self
.setFontFamily('monospace')
41 def display(self
, time
, prefix
, text
, color
=None):
42 oldcolor
= self
.textColor()
44 d
= datetime
.datetime
.now()
46 d
= datetime
.datetime
.fromtimestamp(float(time
))
47 self
.setTextColor(QtGui
.QColor('#999999'))
48 self
.insertPlainText(d
.strftime('%H:%M '))
49 self
.setTextColor(oldcolor
)
51 self
.insertPlainText(str(prefix
).decode('utf-8') + ' ')
53 self
.setTextColor(QtGui
.QColor(color
))
54 self
.insertPlainText(str(text
).decode('utf-8'))
56 self
.insertPlainText('\n')
58 self
.setTextColor(oldcolor
)
61 def scroll_bottom(self
):
62 bar
= self
.verticalScrollBar()
63 bar
.setValue(bar
.maximum())