Add a run welcome wizrd button to the preferences dialog

This commit is contained in:
Kovid Goyal 2010-11-20 09:39:21 -07:00
parent 256a54c63c
commit a340048c2b
2 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,7 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__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)

View File

@ -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)