mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-29 01:06:16 -05:00
Add empty ShareMode and ReceiveMode widgets, and show and hide them when switching modes
This commit is contained in:
parent
86fa0215d8
commit
b349471c30
@ -27,6 +27,9 @@ from onionshare import strings, common
|
|||||||
from onionshare.common import Common, ShutdownTimer
|
from onionshare.common import Common, ShutdownTimer
|
||||||
from onionshare.onion import *
|
from onionshare.onion import *
|
||||||
|
|
||||||
|
from .share_mode import ShareMode
|
||||||
|
from .receive_mode import ReceiveMode
|
||||||
|
|
||||||
from .tor_connection_dialog import TorConnectionDialog
|
from .tor_connection_dialog import TorConnectionDialog
|
||||||
from .settings_dialog import SettingsDialog
|
from .settings_dialog import SettingsDialog
|
||||||
from .file_selection import FileSelection
|
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.share_mode_button)
|
||||||
mode_switcher_layout.addWidget(self.receive_mode_button)
|
mode_switcher_layout.addWidget(self.receive_mode_button)
|
||||||
mode_switcher_layout.addWidget(self.settings_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()
|
self.update_mode_switcher()
|
||||||
|
|
||||||
# File selection
|
# File selection
|
||||||
@ -240,6 +248,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
# Layouts
|
# Layouts
|
||||||
contents_layout = QtWidgets.QVBoxLayout()
|
contents_layout = QtWidgets.QVBoxLayout()
|
||||||
contents_layout.setContentsMargins(10, 10, 10, 10)
|
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.addWidget(self.info_widget)
|
||||||
contents_layout.addLayout(self.file_selection)
|
contents_layout.addLayout(self.file_selection)
|
||||||
contents_layout.addWidget(self.primary_action)
|
contents_layout.addWidget(self.primary_action)
|
||||||
@ -283,10 +294,18 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
if self.mode == self.MODE_SHARE:
|
if self.mode == self.MODE_SHARE:
|
||||||
self.share_mode_button.setStyleSheet(self.mode_switcher_selected_style)
|
self.share_mode_button.setStyleSheet(self.mode_switcher_selected_style)
|
||||||
self.receive_mode_button.setStyleSheet(self.mode_switcher_unselected_style)
|
self.receive_mode_button.setStyleSheet(self.mode_switcher_unselected_style)
|
||||||
|
|
||||||
|
self.share_mode.show()
|
||||||
|
self.receive_mode.hide()
|
||||||
else:
|
else:
|
||||||
self.share_mode_button.setStyleSheet(self.mode_switcher_unselected_style)
|
self.share_mode_button.setStyleSheet(self.mode_switcher_unselected_style)
|
||||||
self.receive_mode_button.setStyleSheet(self.mode_switcher_selected_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):
|
def share_mode_clicked(self):
|
||||||
self.mode = self.MODE_SHARE
|
self.mode = self.MODE_SHARE
|
||||||
self.update_mode_switcher()
|
self.update_mode_switcher()
|
||||||
|
30
onionshare_gui/receive_mode.py
Normal file
30
onionshare_gui/receive_mode.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
OnionShare | https://onionshare.org/
|
||||||
|
|
||||||
|
Copyright (C) 2014-2018 Micah Lee <micah@micahflee.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
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
|
30
onionshare_gui/share_mode.py
Normal file
30
onionshare_gui/share_mode.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
OnionShare | https://onionshare.org/
|
||||||
|
|
||||||
|
Copyright (C) 2014-2018 Micah Lee <micah@micahflee.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user