Preferences dialog: Dont show close button in sub panels. Disallow further preference editing after modifying custom columns. Fix gui re-init code not running after dialg closed

This commit is contained in:
Kovid Goyal 2010-09-07 13:12:23 -06:00
parent 705a6e7d9d
commit de298693ee
5 changed files with 48 additions and 27 deletions

View File

@ -42,15 +42,4 @@ class PreferencesAction(InterfaceAction):
d = Preferences(self.gui, initial_plugin=initial_plugin)
d.show()
if d.committed:
self.gui.must_restart_before_config = d.must_restart
self.gui.tags_view.set_new_model() # in case columns changed
self.gui.tags_view.recount()
self.gui.create_device_menu()
self.gui.set_device_menu_items_state(bool(self.gui.device_connected))
self.gui.tool_bar.build_bar()
self.gui.build_context_menus()
self.gui.tool_bar.apply_settings()

View File

@ -36,6 +36,10 @@ class ConfigWidgetInterface(object):
restore_defaults_desc = _('Restore settings to default values. '
'You have to click Apply to actually save the default settings.')
#: If True the Preferences dialog will not allow the user to set any more
#: preferences. Only has effect if :meth:`commit` returns True.
restart_critical = False
def genesis(self, gui):
'''
Called once before the widget is displayed, should perform any
@ -218,6 +222,7 @@ class ConfigWidgetBase(QWidget, ConfigWidgetInterface):
changed_signal = pyqtSignal()
supports_restoring_to_defaults = True
restart_critical = False
def __init__(self, parent=None):
QWidget.__init__(self, parent)

View File

@ -16,6 +16,8 @@ from calibre.gui2 import error_dialog, question_dialog, ALL_COLUMNS
class ConfigWidget(ConfigWidgetBase, Ui_Form):
restart_critical = True
def genesis(self, gui):
self.gui = gui
db = self.gui.library_view.model().db

View File

@ -264,6 +264,7 @@ class Preferences(QMainWindow):
self.bar_title.show_plugin(plugin)
self.setWindowIcon(QIcon(plugin.icon))
self.bar.setVisible(True)
self.bb.setVisible(False)
def hide_plugin(self):
@ -273,6 +274,7 @@ class Preferences(QMainWindow):
self.bar.setVisible(False)
self.stack.setCurrentIndex(0)
self.setWindowIcon(QIcon(I('config.png')))
self.bb.setVisible(True)
def esc(self, *args):
if self.stack.currentIndex() == 1:
@ -285,15 +287,24 @@ class Preferences(QMainWindow):
must_restart = self.showing_widget.commit()
except AbortCommit:
return
rc = self.showing_widget.restart_critical
self.committed = True
if must_restart:
self.must_restart = True
warning_dialog(self, _('Restart needed'),
_('Some of the changes you made require a restart.'
' Please restart calibre as soon as possible.'),
show=True, show_copy_button=False)
msg = _('Some of the changes you made require a restart.'
' Please restart calibre as soon as possible.')
if rc:
msg = _('The changes you have made require calibre be '
'restarted immediately. You will not be allowed '
'set any more preferences, until you restart.')
warning_dialog(self, _('Restart needed'), msg, show=True,
show_copy_button=False)
self.showing_widget.refresh_gui(self.gui)
self.hide_plugin()
if must_restart and rc:
self.close()
def cancel(self, *args):
@ -305,6 +316,16 @@ class Preferences(QMainWindow):
def closeEvent(self, *args):
gprefs.set('preferences_window_geometry',
bytearray(self.saveGeometry()))
if self.committed:
self.gui.must_restart_before_config = self.must_restart
self.gui.tags_view.set_new_model() # in case columns changed
self.gui.tags_view.recount()
self.gui.create_device_menu()
self.gui.set_device_menu_items_state(bool(self.gui.device_connected))
self.gui.tool_bar.build_bar()
self.gui.build_context_menus()
self.gui.tool_bar.apply_settings()
return QMainWindow.closeEvent(self, *args)
if __name__ == '__main__':

View File

@ -5,8 +5,8 @@
msgid ""
msgstr ""
"Project-Id-Version: calibre 0.7.17\n"
"POT-Creation-Date: 2010-09-07 12:36+MDT\n"
"PO-Revision-Date: 2010-09-07 12:36+MDT\n"
"POT-Creation-Date: 2010-09-07 13:11+MDT\n"
"PO-Revision-Date: 2010-09-07 13:11+MDT\n"
"Last-Translator: Automatically generated\n"
"Language-Team: LANGUAGE\n"
"MIME-Version: 1.0\n"
@ -178,7 +178,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/actions/preferences.py:22
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:187
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:251
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:272
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:273
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:206
msgid "Preferences"
msgstr ""
@ -2888,7 +2888,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/actions/choose_library.py:186
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/confirm_delete_ui.py:53
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:100
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:102
msgid "Are you sure?"
msgstr ""
@ -7073,15 +7073,15 @@ msgstr ""
msgid "Use internal &viewer for:"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:94
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:96
msgid "You must select a column to delete it"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:99
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:101
msgid "The selected column is not a custom column"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:101
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/columns.py:103
msgid "Do you really want to delete column %s and all its data?"
msgstr ""
@ -7429,13 +7429,17 @@ msgstr ""
msgid "Restoring to defaults not supported for"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:291
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/server.py:120
msgid "Restart needed"
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:294
msgid "Some of the changes you made require a restart. Please restart calibre as soon as possible."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:292
msgid "Some of the changes you made require a restart. Please restart calibre as soon as possible."
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:297
msgid "The changes you have made require calibre be restarted immediately. You will not be allowed set any more preferences, until you restart."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:302
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/server.py:120
msgid "Restart needed"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/preferences/misc.py:49