From a340048c2b6b14c8390af65ec8ec96cf3d3a09a3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Nov 2010 09:39:21 -0700 Subject: [PATCH] Add a run welcome wizrd button to the preferences dialog --- src/calibre/gui2/actions/preferences.py | 4 +++- src/calibre/gui2/preferences/main.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/preferences.py b/src/calibre/gui2/actions/preferences.py index d9957bd70d..be536ca4e4 100644 --- a/src/calibre/gui2/actions/preferences.py +++ b/src/calibre/gui2/actions/preferences.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from PyQt4.Qt import QIcon, QMenu +from PyQt4.Qt import QIcon, QMenu, Qt from calibre.gui2.actions import InterfaceAction from calibre.gui2.preferences.main import Preferences @@ -41,5 +41,7 @@ class PreferencesAction(InterfaceAction): return d = Preferences(self.gui, initial_plugin=initial_plugin) d.show() + d.run_wizard_requested.connect(self.gui.run_wizard, + type=Qt.QueuedConnection) diff --git a/src/calibre/gui2/preferences/main.py b/src/calibre/gui2/preferences/main.py index c82ddcc022..fc01a33cf6 100644 --- a/src/calibre/gui2/preferences/main.py +++ b/src/calibre/gui2/preferences/main.py @@ -155,6 +155,8 @@ class Browser(QScrollArea): # {{{ class Preferences(QMainWindow): + run_wizard_requested = pyqtSignal() + def __init__(self, gui, initial_plugin=None): QMainWindow.__init__(self, gui) self.gui = gui @@ -195,6 +197,11 @@ class Preferences(QMainWindow): self.cw.setLayout(QVBoxLayout()) self.cw.layout().addWidget(self.stack) self.bb = QDialogButtonBox(QDialogButtonBox.Close) + self.wizard_button = self.bb.addButton(_('Run welcome wizard'), + self.bb.DestructiveRole) + self.wizard_button.setIcon(QIcon(I('wizard.png'))) + self.wizard_button.clicked.connect(self.run_wizard, + type=Qt.QueuedConnection) self.cw.layout().addWidget(self.bb) self.bb.rejected.connect(self.close, type=Qt.QueuedConnection) self.setCentralWidget(self.cw) @@ -240,6 +247,9 @@ class Preferences(QMainWindow): if plugin is not None: self.show_plugin(plugin) + def run_wizard(self): + self.close() + self.run_wizard_requested.emit() def show_plugin(self, plugin): self.showing_widget = plugin.create_widget(self.scroll_area)