Add zoomin/zoomout commands.
This commit is contained in:
parent
dc179a65bb
commit
cf2133bb96
@ -376,6 +376,8 @@ class QuteBrowser(QApplication):
|
|||||||
'paste': browser.paste,
|
'paste': browser.paste,
|
||||||
'tabpaste': browser.tabpaste,
|
'tabpaste': browser.tabpaste,
|
||||||
'crash': self.crash,
|
'crash': self.crash,
|
||||||
|
'zoomin': browser.cur_zoom_in,
|
||||||
|
'zoomout': browser.cur_zoom_out,
|
||||||
}
|
}
|
||||||
|
|
||||||
handler = handlers[cmd]
|
handler = handlers[cmd]
|
||||||
|
@ -280,6 +280,22 @@ class TabPaste(Command):
|
|||||||
nargs = '?'
|
nargs = '?'
|
||||||
|
|
||||||
|
|
||||||
|
class ZoomIn(Command):
|
||||||
|
|
||||||
|
"""Zoom in in the current tab."""
|
||||||
|
|
||||||
|
nargs = 0
|
||||||
|
count = True
|
||||||
|
|
||||||
|
|
||||||
|
class ZoomOut(Command):
|
||||||
|
|
||||||
|
"""Zoom out in the current tab."""
|
||||||
|
|
||||||
|
nargs = 0
|
||||||
|
count = True
|
||||||
|
|
||||||
|
|
||||||
class Crash(Command):
|
class Crash(Command):
|
||||||
|
|
||||||
"""Simply raise an exception for debugging."""
|
"""Simply raise an exception for debugging."""
|
||||||
|
@ -110,6 +110,8 @@ pp = paste
|
|||||||
pP = paste sel
|
pP = paste sel
|
||||||
Pp = tabpaste
|
Pp = tabpaste
|
||||||
PP = tabpaste sel
|
PP = tabpaste sel
|
||||||
|
- = zoomout
|
||||||
|
+ = zoomin
|
||||||
@Ctrl-Q@ = quit
|
@Ctrl-Q@ = quit
|
||||||
@Ctrl-Shift-T@ = undo
|
@Ctrl-Shift-T@ = undo
|
||||||
@Ctrl-W@ = tabclose
|
@Ctrl-W@ = tabclose
|
||||||
|
@ -539,6 +539,26 @@ class TabbedBrowser(TabWidget):
|
|||||||
self.cur_temp_message.emit('Title yanked to {}'.format(
|
self.cur_temp_message.emit('Title yanked to {}'.format(
|
||||||
'primary selection' if sel else 'clipboard'))
|
'primary selection' if sel else 'clipboard'))
|
||||||
|
|
||||||
|
def cur_zoom_in(self, count=1):
|
||||||
|
"""Zoom in in the current tab.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
count: How many steps to take.
|
||||||
|
|
||||||
|
"""
|
||||||
|
tab = self.currentWidget()
|
||||||
|
tab.zoom(count)
|
||||||
|
|
||||||
|
def cur_zoom_out(self, count=1):
|
||||||
|
"""Zoom out in the current tab.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
count: How many steps to take.
|
||||||
|
|
||||||
|
"""
|
||||||
|
tab = self.currentWidget()
|
||||||
|
tab.zoom(-count)
|
||||||
|
|
||||||
def switch_prev(self, count=1):
|
def switch_prev(self, count=1):
|
||||||
"""Switch to the ([count]th) previous tab.
|
"""Switch to the ([count]th) previous tab.
|
||||||
|
|
||||||
@ -639,6 +659,7 @@ class BrowserTab(QWebView):
|
|||||||
Attributes:
|
Attributes:
|
||||||
page_: The QWebPage behind the view
|
page_: The QWebPage behind the view
|
||||||
signal_cache: The signal cache associated with the view.
|
signal_cache: The signal cache associated with the view.
|
||||||
|
_zoom: A NeighborList with the zoom levels.
|
||||||
_scroll_pos: The old scroll position.
|
_scroll_pos: The old scroll position.
|
||||||
_shutdown_callback: Callback to be called after shutdown.
|
_shutdown_callback: Callback to be called after shutdown.
|
||||||
_open_new_tab: Whether to open a new tab for the next action.
|
_open_new_tab: Whether to open a new tab for the next action.
|
||||||
@ -668,6 +689,10 @@ class BrowserTab(QWebView):
|
|||||||
self._shutdown_callback = None
|
self._shutdown_callback = None
|
||||||
self._open_new_tab = False
|
self._open_new_tab = False
|
||||||
self._destroyed = {}
|
self._destroyed = {}
|
||||||
|
self._zoom = NeighborList(
|
||||||
|
config.config.get('general', 'zoomlevels').split(','),
|
||||||
|
default=config.config.get('general', 'defaultzoom'),
|
||||||
|
mode=NeighborList.BLOCK)
|
||||||
self.page_ = BrowserPage(self)
|
self.page_ = BrowserPage(self)
|
||||||
self.setPage(self.page_)
|
self.setPage(self.page_)
|
||||||
self.signal_cache = SignalCache(uncached=['linkHovered'])
|
self.signal_cache = SignalCache(uncached=['linkHovered'])
|
||||||
@ -704,6 +729,20 @@ class BrowserTab(QWebView):
|
|||||||
else:
|
else:
|
||||||
return self.load(u)
|
return self.load(u)
|
||||||
|
|
||||||
|
def zoom(self, offset):
|
||||||
|
"""Increase/Decrease the zoom level.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
offset: The offset in the zoom level list.
|
||||||
|
|
||||||
|
Emit:
|
||||||
|
temp_message: Emitted with new zoom level.
|
||||||
|
|
||||||
|
"""
|
||||||
|
level = self._zoom.getitem(offset)
|
||||||
|
self.setZoomFactor(float(level) / 100)
|
||||||
|
self.temp_message.emit("Zoom level: {}%".format(level))
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def on_link_clicked(self, url):
|
def on_link_clicked(self, url):
|
||||||
"""Handle a link.
|
"""Handle a link.
|
||||||
|
Loading…
Reference in New Issue
Block a user