diff --git a/src/calibre/gui2/dialogs/smartdevice.py b/src/calibre/gui2/dialogs/smartdevice.py index b83db2bd18..1a8829323b 100644 --- a/src/calibre/gui2/dialogs/smartdevice.py +++ b/src/calibre/gui2/dialogs/smartdevice.py @@ -53,11 +53,13 @@ class SmartdeviceDialog(QDialog, Ui_Dialog): if pw: self.password_box.setText(pw) - use_fixed_port = self.device_manager.get_option('smartdevice', 'use_fixed_port') - port_number = self.device_manager.get_option('smartdevice', 'port_number') - self.fixed_port.setText(port_number) - self.use_fixed_port.setChecked(use_fixed_port); - if not use_fixed_port: + self.orig_fixed_port = self.device_manager.get_option('smartdevice', + 'use_fixed_port') + self.orig_port_number = self.device_manager.get_option('smartdevice', + 'port_number') + self.fixed_port.setText(self.orig_port_number) + self.use_fixed_port.setChecked(self.orig_fixed_port); + if not self.orig_fixed_port: self.fixed_port.setEnabled(False); if pw: @@ -85,8 +87,13 @@ class SmartdeviceDialog(QDialog, Ui_Dialog): message = self.device_manager.start_plugin('smartdevice') if not self.device_manager.is_running('smartdevice'): - error_dialog(self, _('Problem starting smartdevice'), - _('The snart device driver did not start. It said "%s"')%message, show=True) + error_dialog(self, _('Problem starting the wireless device'), + _('The wireless device driver did not start. It said "%s"')%message, + show=True) + self.device_manager.set_option('smartdevice', 'use_fixed_port', + self.orig_fixed_port) + self.device_manager.set_option('smartdevice', 'port_number', + self.orig_port_number) else: QDialog.accept(self) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 67415bee9e..2271c82c4f 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -339,14 +339,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ if config['autolaunch_server']: self.start_content_server() - smartdevice_action = self.iactions['Connect Share'] - smartdevice_action.check_smartdevice_menus() - if self.device_manager.get_option('smartdevice', 'autostart'): - try: - self.device_manager.start_plugin('smartdevice') - except: - pass - smartdevice_action.set_smartdevice_action_state() self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection) @@ -381,9 +373,29 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ 'the file: %s
The ' 'log will be displayed automatically.')%self.gui_debug, show=True) + self.iactions['Connect Share'].check_smartdevice_menus() + QTimer.singleShot(1, self.start_smartdevice) + def esc(self, *args): self.clear_button.click() + def start_smartdevice(self): + message = None + if self.device_manager.get_option('smartdevice', 'autostart'): + try: + message = self.device_manager.start_plugin('smartdevice') + except: + message = 'start smartdevice unknown exception' + prints(message) + import traceback + traceback.print_exc() + if message: + if not self.device_manager.is_running('Wireless Devices'): + error_dialog(self, _('Problem starting the wireless device'), + _('The wireless device driver did not start. ' + 'It said "%s"')%message, show=True) + self.iactions['Connect Share'].set_smartdevice_action_state() + def start_content_server(self, check_started=True): from calibre.library.server.main import start_threaded_server from calibre.library.server import server_config