Skip to content

Commit 5427c27

Browse files
committed
Code quality
1 parent 7a81d76 commit 5427c27

3 files changed

Lines changed: 41 additions & 22 deletions

File tree

src/bitmessageqt/messagecompose.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
22
Message editor with a wheel zoom functionality
33
"""
4-
# pylint: disable=bad-continuation
54

6-
from PyQt4 import QtCore, QtGui
5+
from PyQt4 import QtCore, QtGui # pylint disable:import-error
76

87

98
class MessageCompose(QtGui.QTextEdit):
@@ -15,17 +14,22 @@ def __init__(self, parent=0):
1514

1615
def wheelEvent(self, event):
1716
"""Mouse wheel scroll event handler"""
18-
if (
19-
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
20-
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
17+
if (QtGui.QApplication.queryKeyboardModifiers()
18+
& QtCore.Qt.ControlModifier) == \
19+
QtCore.Qt.ControlModifier \
20+
and event.orientation() == QtCore.Qt.Vertical:
2121
if event.delta() > 0:
2222
self.zoomIn(1)
2323
else:
2424
self.zoomOut(1)
25-
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
26-
QtGui.QApplication.activeWindow().statusBar().showMessage(
27-
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(
28-
str(zoom)
25+
zoom = self.currentFont().pointSize() \
26+
* 100 \
27+
/ self.defaultFontPointSize
28+
QtGui.QApplication.activeWindow().statusBar(). \
29+
showMessage(
30+
QtGui.QApplication.translate("MainWindow",
31+
"Zoom level %1%").
32+
arg(str(zoom)
2933
)
3034
)
3135
else:

src/bitmessageqt/messageview.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ def wheelEvent(self, event):
5252
# super will actually automatically take care of zooming
5353
super(MessageView, self).wheelEvent(event)
5454
if (
55-
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
56-
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
57-
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
58-
QtGui.QApplication.activeWindow().statusBar().showMessage(_translate(
59-
"MainWindow", "Zoom level %1%").arg(str(zoom)))
55+
QtGui.QApplication.queryKeyboardModifiers()
56+
& QtCore.Qt.ControlModifier) == \
57+
QtCore.Qt.ControlModifier \
58+
and event.orientation() == QtCore.Qt.Vertical:
59+
zoom = self.currentFont().pointSize() \
60+
* 100 \
61+
/ self.defaultFontPointSize
62+
QtGui.QApplication.activeWindow().statusBar().\
63+
showMessage(_translate("MainWindow",
64+
"Zoom level %1%").\
65+
arg(str(zoom)))
6066

6167
def setWrappingWidth(self, width=None):
6268
"""Set word-wrapping width"""
@@ -114,17 +120,21 @@ def lazyRender(self):
114120
self.rendering = True
115121
position = self.verticalScrollBar().value()
116122
cursor = QtGui.QTextCursor(self.document())
117-
while self.outpos < len(self.out) and self.verticalScrollBar().value(
118-
) >= self.document().size().height() - 2 * self.size().height():
123+
while self.outpos < len(self.out) \
124+
and self.verticalScrollBar().value() \
125+
>= self.document().size().height() \
126+
- 2 * self.size().height():
119127
startpos = self.outpos
120128
self.outpos += 10240
121129
# find next end of tag
122130
if self.mode == MessageView.MODE_HTML:
123131
pos = self.out.find(">", self.outpos)
124132
if pos > self.outpos:
125133
self.outpos = pos + 1
126-
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
127-
cursor.insertHtml(QtCore.QString(self.out[startpos:self.outpos]))
134+
cursor.movePosition(QtGui.QTextCursor.End,
135+
QtGui.QTextCursor.MoveAnchor)
136+
cursor.insertHtml(
137+
QtCore.QString(self.out[startpos:self.outpos]))
128138
self.verticalScrollBar().setValue(position)
129139
self.rendering = False
130140

src/bitmessageqt/newchandialog.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
=================================
44
55
"""
6-
6+
# pylint: disable=import-error,relative-import,ungrouped-imports
77
from PyQt4 import QtCore, QtGui
88

99
import widgets
1010
from addresses import addBMIfNotPresent
1111
from addressvalidator import AddressValidator, PassPhraseValidator
1212
from queues import (
13-
addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue)
13+
addressGeneratorQueue,
14+
apiAddressGeneratorReturnQueue,
15+
UISignalQueue)
1416
from tr import _translate
1517
from utils import str_chan
1618

@@ -37,8 +39,11 @@ def __init__(self, parent=None):
3739
False))
3840

3941
self.timer = QtCore.QTimer()
40-
QtCore.QObject.connect( # pylint: disable=no-member
41-
self.timer, QtCore.SIGNAL("timeout()"), self.delayedUpdateStatus)
42+
# pylint: disable=no-member
43+
QtCore.QObject.connect(
44+
self.timer,
45+
QtCore.SIGNAL("timeout()"),
46+
self.delayedUpdateStatus)
4247
self.timer.start(500) # milliseconds
4348
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
4449
self.show()

0 commit comments

Comments
 (0)