mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 15:59:48 -05:00
Add a single tab, and fix several issues with moving all the tab code into its own object
This commit is contained in:
parent
c77db82e67
commit
6449e5183e
@ -17,7 +17,6 @@ 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/>.
|
||||
"""
|
||||
import queue
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings
|
||||
@ -27,6 +26,7 @@ from .tor_connection_dialog import TorConnectionDialog
|
||||
from .settings_dialog import SettingsDialog
|
||||
from .widgets import Alert
|
||||
from .update_checker import UpdateThread
|
||||
from .tab import Tab
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
@ -71,33 +71,41 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.system_tray.setContextMenu(menu)
|
||||
self.system_tray.show()
|
||||
|
||||
# Server status indicator on the status bar
|
||||
self.server_status_image_label = QtWidgets.QLabel()
|
||||
self.server_status_image_label.setFixedWidth(20)
|
||||
self.server_status_label = QtWidgets.QLabel("")
|
||||
self.server_status_label.setStyleSheet(
|
||||
self.common.gui.css["server_status_indicator_label"]
|
||||
)
|
||||
server_status_indicator_layout = QtWidgets.QHBoxLayout()
|
||||
server_status_indicator_layout.addWidget(self.server_status_image_label)
|
||||
server_status_indicator_layout.addWidget(self.server_status_label)
|
||||
self.server_status_indicator = QtWidgets.QWidget()
|
||||
self.server_status_indicator.setLayout(server_status_indicator_layout)
|
||||
|
||||
# Status bar
|
||||
self.status_bar = QtWidgets.QStatusBar()
|
||||
self.status_bar.setSizeGripEnabled(False)
|
||||
self.status_bar.setStyleSheet(self.common.gui.css["status_bar"])
|
||||
self.status_bar.addPermanentWidget(self.server_status_indicator)
|
||||
self.setStatusBar(self.status_bar)
|
||||
|
||||
# Placeholder label
|
||||
label = QtWidgets.QLabel("coming soon...")
|
||||
# Server status indicator on the status bar
|
||||
self.status_bar.server_status_image_label = QtWidgets.QLabel()
|
||||
self.status_bar.server_status_image_label.setFixedWidth(20)
|
||||
self.status_bar.server_status_label = QtWidgets.QLabel("")
|
||||
self.status_bar.server_status_label.setStyleSheet(
|
||||
self.common.gui.css["server_status_indicator_label"]
|
||||
)
|
||||
server_status_indicator_layout = QtWidgets.QHBoxLayout()
|
||||
server_status_indicator_layout.addWidget(
|
||||
self.status_bar.server_status_image_label
|
||||
)
|
||||
server_status_indicator_layout.addWidget(self.status_bar.server_status_label)
|
||||
self.status_bar.server_status_indicator = QtWidgets.QWidget()
|
||||
self.status_bar.server_status_indicator.setLayout(
|
||||
server_status_indicator_layout
|
||||
)
|
||||
self.status_bar.addPermanentWidget(self.status_bar.server_status_indicator)
|
||||
|
||||
# Tabs
|
||||
self.tabs = QtWidgets.QTabWidget()
|
||||
|
||||
# Start with one tab
|
||||
self.tab = Tab(self.common, self.system_tray, self.status_bar, filenames)
|
||||
self.tabs.addTab(self.tab, "Tab 1")
|
||||
|
||||
# Layout
|
||||
layout = QtWidgets.QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(label)
|
||||
# layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(self.tabs)
|
||||
|
||||
central_widget = QtWidgets.QWidget()
|
||||
central_widget.setLayout(layout)
|
||||
|
@ -25,9 +25,8 @@ from onionshare.common import AutoStopTimer
|
||||
from .history import IndividualFileHistoryItem
|
||||
|
||||
from ..server_status import ServerStatus
|
||||
from ..threads import OnionThread
|
||||
from ..threads import AutoStartTimer
|
||||
from ..widgets import Alert
|
||||
from ...threads import OnionThread, AutoStartTimer
|
||||
from ...widgets import Alert
|
||||
|
||||
|
||||
class Mode(QtWidgets.QWidget):
|
||||
|
@ -22,7 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings
|
||||
|
||||
from ..widgets import Alert, AddFileDialog
|
||||
from ...widgets import Alert, AddFileDialog
|
||||
|
||||
|
||||
class DropHereLabel(QtWidgets.QLabel):
|
||||
|
@ -24,7 +24,7 @@ from datetime import datetime
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings
|
||||
from ..widgets import Alert
|
||||
from ...widgets import Alert
|
||||
|
||||
|
||||
class HistoryItem(QtWidgets.QWidget):
|
||||
|
@ -29,7 +29,7 @@ from ..file_selection import FileSelection
|
||||
from .threads import CompressThread
|
||||
from .. import Mode
|
||||
from ..history import History, ToggleHistory, ShareHistoryItem
|
||||
from ...widgets import Alert
|
||||
from ....widgets import Alert
|
||||
|
||||
|
||||
class ShareMode(Mode):
|
||||
|
@ -31,7 +31,7 @@ from onionshare.web import Web
|
||||
from ..file_selection import FileSelection
|
||||
from .. import Mode
|
||||
from ..history import History, ToggleHistory
|
||||
from ...widgets import Alert
|
||||
from ....widgets import Alert
|
||||
|
||||
|
||||
class WebsiteMode(Mode):
|
||||
|
@ -23,7 +23,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings
|
||||
|
||||
from .widgets import Alert
|
||||
from ..widgets import Alert
|
||||
|
||||
|
||||
class ServerStatus(QtWidgets.QWidget):
|
||||
|
@ -17,6 +17,7 @@ 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/>.
|
||||
"""
|
||||
import queue
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings
|
||||
@ -73,7 +74,7 @@ class Tab(QtWidgets.QWidget):
|
||||
self.settings_button.setIcon(
|
||||
QtGui.QIcon(self.common.get_resource_path("images/settings.png"))
|
||||
)
|
||||
self.settings_button.clicked.connect(self.open_settings)
|
||||
# self.settings_button.clicked.connect(self.open_settings)
|
||||
self.settings_button.setStyleSheet(self.common.gui.css["settings_button"])
|
||||
mode_switcher_layout = QtWidgets.QHBoxLayout()
|
||||
mode_switcher_layout.setSpacing(0)
|
||||
@ -83,13 +84,13 @@ class Tab(QtWidgets.QWidget):
|
||||
mode_switcher_layout.addWidget(self.settings_button)
|
||||
|
||||
# Server status indicator icons
|
||||
self.server_status_image_stopped = QtGui.QImage(
|
||||
self.status_bar.server_status_image_stopped = QtGui.QImage(
|
||||
self.common.get_resource_path("images/server_stopped.png")
|
||||
)
|
||||
self.server_status_image_working = QtGui.QImage(
|
||||
self.status_bar.server_status_image_working = QtGui.QImage(
|
||||
self.common.get_resource_path("images/server_working.png")
|
||||
)
|
||||
self.server_status_image_started = QtGui.QImage(
|
||||
self.status_bar.server_status_image_started = QtGui.QImage(
|
||||
self.common.get_resource_path("images/server_started.png")
|
||||
)
|
||||
|
||||
@ -99,7 +100,7 @@ class Tab(QtWidgets.QWidget):
|
||||
self.common.gui.qtapp,
|
||||
self.app,
|
||||
self.status_bar,
|
||||
self.server_status_label,
|
||||
self.status_bar.server_status_label,
|
||||
self.system_tray,
|
||||
filenames,
|
||||
self.common.gui.local_only,
|
||||
@ -130,7 +131,7 @@ class Tab(QtWidgets.QWidget):
|
||||
self.common.gui.qtapp,
|
||||
self.app,
|
||||
self.status_bar,
|
||||
self.server_status_label,
|
||||
self.status_bar.server_status_label,
|
||||
self.system_tray,
|
||||
None,
|
||||
self.common.gui.local_only,
|
||||
@ -163,7 +164,7 @@ class Tab(QtWidgets.QWidget):
|
||||
self.common.gui.qtapp,
|
||||
self.app,
|
||||
self.status_bar,
|
||||
self.server_status_label,
|
||||
self.status_bar.server_status_label,
|
||||
self.system_tray,
|
||||
filenames,
|
||||
)
|
||||
@ -286,80 +287,80 @@ class Tab(QtWidgets.QWidget):
|
||||
if self.mode == self.common.gui.MODE_SHARE:
|
||||
# Share mode
|
||||
if self.share_mode.server_status.status == ServerStatus.STATUS_STOPPED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_stopped)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_stopped)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_stopped")
|
||||
)
|
||||
elif self.share_mode.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_working)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_working)
|
||||
)
|
||||
if self.share_mode.server_status.autostart_timer_datetime:
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_scheduled")
|
||||
)
|
||||
else:
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_working")
|
||||
)
|
||||
elif self.share_mode.server_status.status == ServerStatus.STATUS_STARTED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_started)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_started)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_started")
|
||||
)
|
||||
elif self.mode == self.common.gui.MODE_WEBSITE:
|
||||
# Website mode
|
||||
if self.website_mode.server_status.status == ServerStatus.STATUS_STOPPED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_stopped)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_stopped)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_stopped")
|
||||
)
|
||||
elif self.website_mode.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_working)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_working)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_working")
|
||||
)
|
||||
elif self.website_mode.server_status.status == ServerStatus.STATUS_STARTED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_started)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_started)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_share_started")
|
||||
)
|
||||
else:
|
||||
# Receive mode
|
||||
if self.receive_mode.server_status.status == ServerStatus.STATUS_STOPPED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_stopped)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_stopped)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_receive_stopped")
|
||||
)
|
||||
elif self.receive_mode.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_working)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_working)
|
||||
)
|
||||
if self.receive_mode.server_status.autostart_timer_datetime:
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_receive_scheduled")
|
||||
)
|
||||
else:
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_receive_working")
|
||||
)
|
||||
elif self.receive_mode.server_status.status == ServerStatus.STATUS_STARTED:
|
||||
self.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.server_status_image_started)
|
||||
self.status_bar.server_status_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(self.status_bar.server_status_image_started)
|
||||
)
|
||||
self.server_status_label.setText(
|
||||
self.status_bar.server_status_label.setText(
|
||||
strings._("gui_status_indicator_receive_started")
|
||||
)
|
||||
|
||||
@ -511,7 +512,7 @@ class Tab(QtWidgets.QWidget):
|
||||
self.website_mode_button.show()
|
||||
|
||||
# Disable settings menu action when server is active
|
||||
self.settings_action.setEnabled(not active)
|
||||
# self.settings_action.setEnabled(not active)
|
||||
|
||||
def clear_message(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user