From b349471c308f1c3055667ec12d9c33a6c444cf41 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 23 Apr 2018 21:24:12 -0700 Subject: [PATCH] Add empty ShareMode and ReceiveMode widgets, and show and hide them when switching modes --- onionshare_gui/onionshare_gui.py | 19 +++++++++++++++++++ onionshare_gui/receive_mode.py | 30 ++++++++++++++++++++++++++++++ onionshare_gui/share_mode.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 onionshare_gui/receive_mode.py create mode 100644 onionshare_gui/share_mode.py diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 25656c69..39b75449 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -27,6 +27,9 @@ from onionshare import strings, common from onionshare.common import Common, ShutdownTimer from onionshare.onion import * +from .share_mode import ShareMode +from .receive_mode import ReceiveMode + from .tor_connection_dialog import TorConnectionDialog from .settings_dialog import SettingsDialog from .file_selection import FileSelection @@ -115,6 +118,11 @@ class OnionShareGui(QtWidgets.QMainWindow): mode_switcher_layout.addWidget(self.share_mode_button) mode_switcher_layout.addWidget(self.receive_mode_button) mode_switcher_layout.addWidget(self.settings_button) + + # Share and receive mode widgets + self.receive_mode = ReceiveMode(self.common) + self.share_mode = ReceiveMode(self.common) + self.update_mode_switcher() # File selection @@ -240,6 +248,9 @@ class OnionShareGui(QtWidgets.QMainWindow): # Layouts contents_layout = QtWidgets.QVBoxLayout() contents_layout.setContentsMargins(10, 10, 10, 10) + contents_layout.addWidget(self.receive_mode) + contents_layout.addWidget(self.share_mode) + # TODO: move these into ShareMode contents_layout.addWidget(self.info_widget) contents_layout.addLayout(self.file_selection) contents_layout.addWidget(self.primary_action) @@ -283,10 +294,18 @@ class OnionShareGui(QtWidgets.QMainWindow): if self.mode == self.MODE_SHARE: self.share_mode_button.setStyleSheet(self.mode_switcher_selected_style) self.receive_mode_button.setStyleSheet(self.mode_switcher_unselected_style) + + self.share_mode.show() + self.receive_mode.hide() else: self.share_mode_button.setStyleSheet(self.mode_switcher_unselected_style) self.receive_mode_button.setStyleSheet(self.mode_switcher_selected_style) + self.share_mode.hide() + self.receive_mode.show() + + self.adjustSize(); + def share_mode_clicked(self): self.mode = self.MODE_SHARE self.update_mode_switcher() diff --git a/onionshare_gui/receive_mode.py b/onionshare_gui/receive_mode.py new file mode 100644 index 00000000..dd6f5eeb --- /dev/null +++ b/onionshare_gui/receive_mode.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +""" +OnionShare | https://onionshare.org/ + +Copyright (C) 2014-2018 Micah Lee + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" +from PyQt5 import QtCore, QtWidgets, QtGui + +from onionshare import strings + +class ReceiveMode(QtWidgets.QWidget): + """ + Parts of the main window UI for receiving files. + """ + def __init__(self, common): + super(ReceiveMode, self).__init__() + self.common = common diff --git a/onionshare_gui/share_mode.py b/onionshare_gui/share_mode.py new file mode 100644 index 00000000..81dd62d5 --- /dev/null +++ b/onionshare_gui/share_mode.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +""" +OnionShare | https://onionshare.org/ + +Copyright (C) 2014-2018 Micah Lee + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" +from PyQt5 import QtCore, QtWidgets, QtGui + +from onionshare import strings + +class ShareMode(QtWidgets.QWidget): + """ + Parts of the main window UI for sharing files. + """ + def __init__(self, common): + super(ShareMode, self).__init__() + self.common = common