mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
f974854eb1
commit
f1b1dce050
@ -11,8 +11,8 @@ from PyQt5.Qt import QAbstractListModel, Qt, QIcon, \
|
|||||||
QItemSelectionModel
|
QItemSelectionModel
|
||||||
|
|
||||||
from calibre.gui2.preferences.toolbar_ui import Ui_Form
|
from calibre.gui2.preferences.toolbar_ui import Ui_Form
|
||||||
from calibre.gui2 import gprefs, warning_dialog
|
from calibre.gui2 import gprefs, warning_dialog, error_dialog
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, AbortCommit
|
||||||
|
|
||||||
|
|
||||||
class FakeAction(object):
|
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_toolbar = self.models['toolbar-device'][1].has_action('Location Manager')
|
||||||
lm_in_menubar = self.models['menubar-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:
|
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:
|
if not lm_in_toolbar and not lm_in_menubar:
|
||||||
m = self.models['toolbar-device'][1]
|
error_dialog(self, _('Location Manager missing'), _(
|
||||||
m.add(['Location Manager'])
|
'The Location Manager must be in either the main toolbar or the menubar when a device is connected.'), show=True)
|
||||||
m.move(m.index(m.rowCount(None)-1), 5-m.rowCount(None))
|
raise AbortCommit()
|
||||||
|
|
||||||
# Save data.
|
# Save data.
|
||||||
for am, cm in self.models.values():
|
for am, cm in self.models.values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user