Message editor updates

- Does not allow changing fonts (it's ignored once it's sent anyway),
fixes #167
- Allows zooming, fixes #163
This commit is contained in:
mailchuck 2016-01-22 19:16:47 +01:00
parent 00e90bd38f
commit d7a52893ea
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
3 changed files with 29 additions and 4 deletions

View File

@ -2275,7 +2275,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.lineEditTo.setText('')
self.ui.lineEditSubject.setText('')
self.ui.textEditMessage.setText('')
self.ui.textEditMessage.reset()
if self.replyFromTab is not None:
self.ui.tabWidget.setCurrentIndex(self.replyFromTab)
self.replyFromTab = None
@ -2325,7 +2325,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0)
self.ui.lineEditSubjectBroadcast.setText('')
self.ui.textEditMessageBroadcast.setText('')
self.ui.textEditMessageBroadcast.reset()
self.ui.tabWidget.setCurrentIndex(1)
self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0)
self.statusBar().showMessage(_translate(

View File

@ -9,6 +9,7 @@
from PyQt4 import QtCore, QtGui
from messageview import MessageView
from messagecompose import MessageCompose
import settingsmixin
try:
@ -232,7 +233,7 @@ class Ui_MainWindow(object):
self.gridLayout_2_Widget = QtGui.QWidget()
self.gridLayout_2_Widget.setLayout(self.gridLayout_2)
self.verticalSplitter_5.addWidget(self.gridLayout_2_Widget)
self.textEditMessage = QtGui.QTextEdit(self.sendDirect)
self.textEditMessage = MessageCompose(self.sendDirect)
self.textEditMessage.setObjectName(_fromUtf8("textEditMessage"))
self.verticalSplitter_5.addWidget(self.textEditMessage)
self.verticalSplitter_5.setStretchFactor(0, 0)
@ -268,7 +269,7 @@ class Ui_MainWindow(object):
self.gridLayout_5_Widget = QtGui.QWidget()
self.gridLayout_5_Widget.setLayout(self.gridLayout_5)
self.verticalSplitter_6.addWidget(self.gridLayout_5_Widget)
self.textEditMessageBroadcast = QtGui.QTextEdit(self.sendBroadcast)
self.textEditMessageBroadcast = MessageCompose(self.sendBroadcast)
self.textEditMessageBroadcast.setObjectName(_fromUtf8("textEditMessageBroadcast"))
self.verticalSplitter_6.addWidget(self.textEditMessageBroadcast)
self.verticalSplitter_6.setStretchFactor(0, 0)

View File

@ -0,0 +1,24 @@
from PyQt4 import QtCore, QtGui
class MessageCompose(QtGui.QTextEdit):
def __init__(self, parent = 0):
super(MessageCompose, self).__init__(parent)
self.setAcceptRichText(False) # we'll deal with this later when we have a new message format
self.defaultFontPointSize = self.currentFont().pointSize()
def wheelEvent(self, event):
if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
numDegrees = event.delta() / 8
numSteps = numDegrees / 15
zoomDiff = numSteps + self.currentFont().pointSize() - self.defaultFontPointSize
if numSteps > 0:
self.zoomIn(numSteps)
else:
self.zoomOut(-numSteps)
QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1").arg(str(zoomDiff)))
# super will actually automatically take care of zooming
super(MessageCompose, self).wheelEvent(event)
def reset(self):
self.setText('')