Add gui for website sharing and listing

This commit is contained in:
hiro 2019-04-19 16:52:43 +02:00
parent 2d43588a3b
commit 391c82f2a6
9 changed files with 426 additions and 10 deletions

View file

@ -39,6 +39,7 @@ class ServerStatus(QtWidgets.QWidget):
MODE_SHARE = 'share'
MODE_RECEIVE = 'receive'
MODE_WEBSITE = 'website'
STATUS_STOPPED = 0
STATUS_WORKING = 1
@ -159,7 +160,7 @@ class ServerStatus(QtWidgets.QWidget):
"""
self.mode = share_mode
if self.mode == ServerStatus.MODE_SHARE:
if (self.mode == ServerStatus.MODE_SHARE) or (self.mode == ServerStatus.MODE_WEBSITE):
self.file_selection = file_selection
self.update()
@ -207,6 +208,8 @@ class ServerStatus(QtWidgets.QWidget):
if self.mode == ServerStatus.MODE_SHARE:
self.url_description.setText(strings._('gui_share_url_description').format(info_image))
elif self.mode == ServerStatus.MODE_WEBSITE:
self.url_description.setText(strings._('gui_share_url_description').format(info_image))
else:
self.url_description.setText(strings._('gui_receive_url_description').format(info_image))
@ -258,6 +261,8 @@ class ServerStatus(QtWidgets.QWidget):
# Button
if self.mode == ServerStatus.MODE_SHARE and self.file_selection.get_num_files() == 0:
self.server_button.hide()
elif self.mode == ServerStatus.MODE_WEBSITE and self.file_selection.get_num_files() == 0:
self.server_button.hide()
else:
self.server_button.show()
@ -266,6 +271,8 @@ class ServerStatus(QtWidgets.QWidget):
self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setText(strings._('gui_share_start_server'))
elif self.mode == ServerStatus.MODE_WEBSITE:
self.server_button.setText(strings._('gui_share_start_server'))
else:
self.server_button.setText(strings._('gui_receive_start_server'))
self.server_button.setToolTip('')
@ -278,13 +285,27 @@ class ServerStatus(QtWidgets.QWidget):
self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setText(strings._('gui_share_stop_server'))
if self.mode == ServerStatus.MODE_WEBSITE:
self.server_button.setText(strings._('gui_share_stop_server'))
else:
self.server_button.setText(strings._('gui_receive_stop_server'))
<<<<<<< HEAD
if self.common.settings.get('autostart_timer'):
self.autostart_timer_container.hide()
if self.common.settings.get('autostop_timer'):
self.autostop_timer_container.hide()
self.server_button.setToolTip(strings._('gui_stop_server_autostop_timer_tooltip').format(self.autostop_timer_widget.dateTime().toString("h:mm AP, MMMM dd, yyyy")))
=======
if self.common.settings.get('shutdown_timeout'):
self.shutdown_timeout_container.hide()
if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setToolTip(strings._('gui_share_stop_server_shutdown_timeout_tooltip').format(self.timeout))
if self.mode == ServerStatus.MODE_WEBSITE:
self.server_button.setToolTip(strings._('gui_share_stop_server_shutdown_timeout_tooltip').format(self.timeout))
else:
self.server_button.setToolTip(strings._('gui_receive_stop_server_shutdown_timeout_tooltip').format(self.timeout))
>>>>>>> Add gui for website sharing and listing
elif self.status == self.STATUS_WORKING:
self.server_button.setStyleSheet(self.common.css['server_status_button_working'])
self.server_button.setEnabled(True)
@ -411,6 +432,8 @@ class ServerStatus(QtWidgets.QWidget):
"""
if self.common.settings.get('public_mode'):
url = 'http://{0:s}'.format(self.app.onion_host)
elif self.mode == ServerStatus.MODE_WEBSITE:
url = 'http://onionshare:{0:s}@{1:s}'.format(self.web.slug, self.app.onion_host)
else:
url = 'http://{0:s}/{1:s}'.format(self.app.onion_host, self.web.slug)
return url