Skip to content

Commit

Permalink
Fixed zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
mnunberg committed Oct 14, 2010
1 parent 1ac3474 commit 0a77ca2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 41 deletions.
36 changes: 30 additions & 6 deletions py/gui/chatwindow.py
Expand Up @@ -177,16 +177,40 @@ def __init__(self, client, parent=None, type=IM, acct_obj=None, target=None,
self.chat_text = _ChatText(self.widgets.convtext)

self.zoom_variations = 0
def decrement_zoom(): self.zoom_variations -= 1
def increment_zoom(): self.zoom_variations += 1
def log_zoom(in_fn):
def fn(*args, **kwargs):
#log_debug(self.zoom_variations)
in_fn(*args, **kwargs)
return fn
@log_zoom
def convtext_zoomIn(range=1):
self.zoom_variations += range
w.convtext.__class__.zoomIn(w.convtext, range)
@log_zoom
def convtext_zoomOut(range=1):
self.zoom_variations -= range
w.convtext.__class__.zoomOut(w.convtext, range)

@log_zoom
def reset_zoom():
if self.zoom_variations == 0: return
elif self.zoom_variations > 0: self.widgets.convtext.zoomOut(self.zoom_variations)
elif self.zoom_variations < 0: self.widgets.convtext.zoomIn(abs(self.zoom_variations))
elif self.zoom_variations > 0: w.convtext.__class__.zoomOut(w.convtext, self.zoom_variations)
elif self.zoom_variations < 0: w.convtext.__class__.zoomIn(w.convtext, abs(self.zoom_variations))
self.zoom_variations = 0
signal_connect(w.zoom_in, SIGNAL("clicked()"), increment_zoom)
signal_connect(w.zoom_out, SIGNAL("clicked()"), decrement_zoom)
@log_zoom
def _wheelEvent(event):
if not event.modifiers() & Qt.CTRL:
w.convtext.__class__.wheelEvent(w.convtext, event)
return
if event.delta() > 0:
#zoom in
convtext_zoomIn()
else:
convtext_zoomOut()
w.convtext.wheelEvent = _wheelEvent
signal_connect(w.zoom_orig, SIGNAL("clicked()"), reset_zoom)
signal_connect(w.zoom_in, SIGNAL("clicked()"), convtext_zoomIn)
signal_connect(w.zoom_out, SIGNAL("clicked()"), convtext_zoomOut)

################################################################################
############################# INPUT WIDGET METHODS #############################
Expand Down
4 changes: 1 addition & 3 deletions py/gui/chatwindow_auto.py
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'chatwindow_auto.ui'
#
# Created: Wed Oct 13 22:05:18 2010
# Created: Thu Oct 14 00:04:30 2010
# by: PyQt4 UI code generator 4.7.3
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -439,8 +439,6 @@ def setupUi(self, w_chatwindow):
QtCore.QObject.connect(self.italic, QtCore.SIGNAL("toggled(bool)"), self.input.setFontItalic)
QtCore.QObject.connect(self.underline, QtCore.SIGNAL("toggled(bool)"), self.input.setFontUnderline)
QtCore.QObject.connect(self.actionShow_Topic, QtCore.SIGNAL("toggled(bool)"), self.chat_topic.setVisible)
QtCore.QObject.connect(self.zoom_in, QtCore.SIGNAL("clicked()"), self.convtext.zoomIn)
QtCore.QObject.connect(self.zoom_out, QtCore.SIGNAL("clicked()"), self.convtext.zoomOut)
QtCore.QMetaObject.connectSlotsByName(w_chatwindow)

def retranslateUi(self, w_chatwindow):
Expand Down
32 changes: 0 additions & 32 deletions py/gui/chatwindow_auto.ui
Expand Up @@ -1164,37 +1164,5 @@ padding:0px;
</hint>
</hints>
</connection>
<connection>
<sender>zoom_in</sender>
<signal>clicked()</signal>
<receiver>convtext</receiver>
<slot>zoomIn()</slot>
<hints>
<hint type="sourcelabel">
<x>377</x>
<y>450</y>
</hint>
<hint type="destinationlabel">
<x>189</x>
<y>246</y>
</hint>
</hints>
</connection>
<connection>
<sender>zoom_out</sender>
<signal>clicked()</signal>
<receiver>convtext</receiver>
<slot>zoomOut()</slot>
<hints>
<hint type="sourcelabel">
<x>407</x>
<y>450</y>
</hint>
<hint type="destinationlabel">
<x>189</x>
<y>246</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 0a77ca2

Please sign in to comment.