Show the IP address the content server is listening on in Preferences->Sharing over the net. Fixes #1717641 [Show Content server IP address in Main window](https://bugs.launchpad.net/calibre/+bug/1717641)

This commit is contained in:
Kovid Goyal 2017-09-19 14:41:22 +05:30
parent 312e6388c1
commit 3535bb6f0c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 21 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class ShareConnMenu(QMenu): # {{{
config_email = pyqtSignal()
toggle_server = pyqtSignal()
control_smartdevice = pyqtSignal()
server_state_changed_signal = pyqtSignal(object, object)
dont_add_to = frozenset(['context-menu-device'])
DEVICE_MSGS = [_('Start wireless device connection'),
@ -32,6 +33,7 @@ class ShareConnMenu(QMenu): # {{{
def __init__(self, parent=None):
QMenu.__init__(self, parent)
self.ip_text = ''
mitem = self.addAction(QIcon(I('devices/folder.png')), _('Connect to folder'))
mitem.setEnabled(True)
mitem.triggered.connect(lambda x : self.connect_to_folder.emit())
@ -84,7 +86,11 @@ class ShareConnMenu(QMenu): # {{{
ip=listen_on, port=opts.port)
except Exception:
ip_text = ' [%s]'%listen_on
self.ip_text = ip_text
self.server_state_changed_signal.emit(running, ip_text)
text = _('Stop Content server') + ip_text
else:
self.ip_text = ''
self.toggle_server_action.setText(text)
def hide_smartdevice_menus(self):

View File

@ -31,6 +31,7 @@ from calibre.srv.users import (
)
from calibre.utils.icu import primary_sort_key
# Advanced {{{
@ -240,8 +241,20 @@ class MainTab(QWidget): # {{{
if name == 'show_logs':
h.addStretch(10)
h.addWidget(b)
self.ip_info = QLabel(self)
self.update_ip_info()
from calibre.gui2.ui import get_gui
get_gui().iactions['Connect Share'].share_conn_menu.server_state_changed_signal.connect(self.update_ip_info)
l.addSpacing(10)
l.addWidget(self.ip_info)
l.addStretch(10)
def update_ip_info(self):
from calibre.gui2.ui import get_gui
t = get_gui().iactions['Connect Share'].share_conn_menu.ip_text
t = t.strip().strip('[]')
self.ip_info.setText(_('Content server listening at: %s') % t)
def genesis(self):
opts = server_config()
self.opt_auth.setChecked(opts.auth)
@ -273,6 +286,8 @@ class MainTab(QWidget): # {{{
from calibre.gui2.ui import get_gui
gui = get_gui()
is_running = gui.content_server is not None and gui.content_server.is_running
self.ip_info.setVisible(is_running)
self.update_ip_info()
self.start_server_button.setEnabled(not is_running)
self.stop_server_button.setEnabled(is_running)
self.test_server_button.setEnabled(is_running)