From f1b1dce0507bfe927e14b46814584048bf51eee5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 8 May 2017 18:06:54 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/preferences/toolbar.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/preferences/toolbar.py b/src/calibre/gui2/preferences/toolbar.py index 35e206e663..691ae54b99 100644 --- a/src/calibre/gui2/preferences/toolbar.py +++ b/src/calibre/gui2/preferences/toolbar.py @@ -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():