Preferences->Toolbars: Show an error message when the user tries to remove either the Preferences or Location Manager buttons instead of just silently adding them back. Fixes #1689022 [main toolbar device connected massage fails](https://bugs.launchpad.net/calibre/+bug/1689022)

This commit is contained in:
Kovid Goyal 2017-05-08 18:06:54 +05:30
parent f974854eb1
commit f1b1dce050
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -11,8 +11,8 @@ from PyQt5.Qt import QAbstractListModel, Qt, QIcon, \
QItemSelectionModel
from calibre.gui2.preferences.toolbar_ui import Ui_Form
from calibre.gui2 import gprefs, warning_dialog
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2 import gprefs, warning_dialog, error_dialog
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, AbortCommit
class FakeAction(object):
@ -335,11 +335,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
lm_in_toolbar = self.models['toolbar-device'][1].has_action('Location Manager')
lm_in_menubar = self.models['menubar-device'][1].has_action('Location Manager')
if not pref_in_toolbar and not pref_in_menubar:
self.models['menubar'][1].add(['Preferences'])
error_dialog(self, _('Preferences missing'), _(
'The Preferences action must be in either the main toolbar or the menubar.'), show=True)
raise AbortCommit()
if not lm_in_toolbar and not lm_in_menubar:
m = self.models['toolbar-device'][1]
m.add(['Location Manager'])
m.move(m.index(m.rowCount(None)-1), 5-m.rowCount(None))
error_dialog(self, _('Location Manager missing'), _(
'The Location Manager must be in either the main toolbar or the menubar when a device is connected.'), show=True)
raise AbortCommit()
# Save data.
for am, cm in self.models.values():