Merge branch 'MazeChaZer-feature/remove-unused-tab'

This commit is contained in:
Florian Bruhin 2015-10-30 18:51:08 +01:00
commit c09ae4675c
2 changed files with 19 additions and 1 deletions

View File

@ -153,12 +153,12 @@ Contributors, sorted by the number of commits in descending order:
* ZDarian
* John ShaggyTwoDope Jenkins
* Peter Vilim
* Jonas Schürmann
* Jimmy
* Zach-Button
* rikn00
* Patric Schmitz
* Martin Zimmermann
* Jonas Schürmann
* Error 800
* Brian Jackson
* sbinix

View File

@ -301,6 +301,24 @@ class TabbedBrowser(tabwidget.TabWidget):
def undo(self):
"""Undo removing of a tab."""
# Remove unused tab which may be created after the last tab is closed
last_close = config.get('tabs', 'last-close')
if last_close in ['blank', 'startpage', 'default-page']:
only_one_tab_open = self.count() == 1
no_history = self.widget(0).history().count() == 1
urls = {
'blank': QUrl('about:blank'),
'startpage': QUrl(config.get('general', 'startpage')[0]),
'default-page': config.get('general', 'default-page'),
}
first_tab_url = self.widget(0).page().mainFrame().requestedUrl()
last_close_urlstr = urls[last_close].toString().rstrip('/')
first_tab_urlstr = first_tab_url.toString().rstrip('/')
last_close_url_used = first_tab_urlstr == last_close_urlstr
if only_one_tab_open and no_history and last_close_url_used:
self.removeTab(0)
url, history_data = self._undo_stack.pop()
newtab = self.tabopen(url, background=False)
qtutils.deserialize(history_data, newtab.history())