mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 03:37:28 -03:00
Initial structuring of the enable quickstart screen
This commit is contained in:
parent
10147b6c6b
commit
e4f9f5f212
3 changed files with 131 additions and 14 deletions
|
@ -103,6 +103,7 @@ class Settings(object):
|
||||||
"socket_file_path": "/var/run/tor/control",
|
"socket_file_path": "/var/run/tor/control",
|
||||||
"auth_type": "no_auth",
|
"auth_type": "no_auth",
|
||||||
"auth_password": "",
|
"auth_password": "",
|
||||||
|
"auto_connect": False,
|
||||||
"use_autoupdate": True,
|
"use_autoupdate": True,
|
||||||
"autoupdate_timestamp": None,
|
"autoupdate_timestamp": None,
|
||||||
"no_bridges": True,
|
"no_bridges": True,
|
||||||
|
|
100
desktop/src/onionshare/auto_connect.py
Normal file
100
desktop/src/onionshare/auto_connect.py
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
OnionShare | https://onionshare.org/
|
||||||
|
|
||||||
|
Copyright (C) 2014-2021 Micah Lee, et al. <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 PySide2 import QtCore, QtWidgets, QtGui
|
||||||
|
|
||||||
|
from onionshare_cli.settings import Settings
|
||||||
|
|
||||||
|
from .gui_common import GuiCommon
|
||||||
|
|
||||||
|
|
||||||
|
class AutoConnect(QtWidgets.QWidget):
|
||||||
|
"""
|
||||||
|
GUI window that appears in the very beginning to ask user if
|
||||||
|
should auto connect.
|
||||||
|
"""
|
||||||
|
def __init__(self, common, parent=None):
|
||||||
|
super(AutoConnect, self).__init__(parent)
|
||||||
|
common.log("AutoConnect", "__init__")
|
||||||
|
|
||||||
|
# Was auto connected?
|
||||||
|
self.curr_settings = Settings(common)
|
||||||
|
self.curr_settings.load()
|
||||||
|
self.auto_connect_enabled = self.curr_settings.get("auto_connect")
|
||||||
|
|
||||||
|
if self.auto_connect_enabled:
|
||||||
|
self.parent().start_onionshare()
|
||||||
|
else:
|
||||||
|
# Onionshare logo
|
||||||
|
self.image_label = QtWidgets.QLabel()
|
||||||
|
self.image_label.setPixmap(
|
||||||
|
QtGui.QPixmap.fromImage(
|
||||||
|
QtGui.QImage(
|
||||||
|
GuiCommon.get_resource_path(
|
||||||
|
"images/{}_logo_text.png".format(common.gui.color_mode)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.image_label.setFixedSize(180, 40)
|
||||||
|
image_layout = QtWidgets.QVBoxLayout()
|
||||||
|
image_layout.addWidget(self.image_label)
|
||||||
|
self.image = QtWidgets.QWidget()
|
||||||
|
self.image.setLayout(image_layout)
|
||||||
|
|
||||||
|
# Description and checkbox
|
||||||
|
description_label = QtWidgets.QLabel("Some description about OnionShare and explain autoconnect stuff")
|
||||||
|
self.enable_autoconnect_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.enable_autoconnect_checkbox.clicked.connect(self.toggle_auto_connect)
|
||||||
|
self.enable_autoconnect_checkbox.setText(
|
||||||
|
"Enable automatically connecting to OnionShare"
|
||||||
|
)
|
||||||
|
|
||||||
|
# CTA buttons
|
||||||
|
self.connect_button = QtWidgets.QPushButton("Start OnionShare")
|
||||||
|
self.connect_button.setStyleSheet(
|
||||||
|
common.gui.css["server_status_button_stopped"]
|
||||||
|
)
|
||||||
|
self.configure_button = QtWidgets.QPushButton("Configure")
|
||||||
|
cta_layout = QtWidgets.QHBoxLayout()
|
||||||
|
cta_layout.addWidget(self.connect_button)
|
||||||
|
cta_layout.addWidget(self.configure_button)
|
||||||
|
cta_widget = QtWidgets.QWidget()
|
||||||
|
cta_widget.setLayout(cta_layout)
|
||||||
|
|
||||||
|
|
||||||
|
# Layout
|
||||||
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.layout.addStretch()
|
||||||
|
self.layout.addWidget(self.image)
|
||||||
|
self.layout.addWidget(description_label)
|
||||||
|
self.layout.addWidget(self.enable_autoconnect_checkbox)
|
||||||
|
self.layout.addStretch()
|
||||||
|
self.layout.addWidget(cta_widget)
|
||||||
|
self.layout.addStretch()
|
||||||
|
self.layout.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def toggle_auto_connect(self):
|
||||||
|
self.curr_settings.set(
|
||||||
|
"auto_connect", self.enable_autoconnect_checkbox.isChecked()
|
||||||
|
)
|
||||||
|
self.curr_settings.save()
|
|
@ -23,6 +23,7 @@ import time
|
||||||
from PySide2 import QtCore, QtWidgets, QtGui
|
from PySide2 import QtCore, QtWidgets, QtGui
|
||||||
|
|
||||||
from . import strings
|
from . import strings
|
||||||
|
from .auto_connect import AutoConnect
|
||||||
from .tor_connection_dialog import TorConnectionDialog
|
from .tor_connection_dialog import TorConnectionDialog
|
||||||
from .tor_settings_dialog import TorSettingsDialog
|
from .tor_settings_dialog import TorSettingsDialog
|
||||||
from .settings_dialog import SettingsDialog
|
from .settings_dialog import SettingsDialog
|
||||||
|
@ -157,21 +158,17 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
layout = QtWidgets.QVBoxLayout()
|
layout = QtWidgets.QVBoxLayout()
|
||||||
layout.addWidget(self.tabs)
|
layout.addWidget(self.tabs)
|
||||||
|
|
||||||
central_widget = QtWidgets.QWidget()
|
self.connected_central_widget = QtWidgets.QWidget()
|
||||||
central_widget.setLayout(layout)
|
self.connected_central_widget.setLayout(layout)
|
||||||
self.setCentralWidget(central_widget)
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
# Start the "Connecting to Tor" dialog, which calls onion.connect()
|
# Auto connect OnionShare?
|
||||||
tor_con = TorConnectionDialog(self.common)
|
auto_connect = AutoConnect(self.common, self)
|
||||||
tor_con.canceled.connect(self.tor_connection_canceled)
|
if not auto_connect.auto_connect_enabled:
|
||||||
tor_con.open_tor_settings.connect(self.tor_connection_open_tor_settings)
|
auto_connect.configure_button.clicked.connect(self.open_tor_settings)
|
||||||
if not self.common.gui.local_only:
|
auto_connect.connect_button.clicked.connect(self.start_onionshare)
|
||||||
tor_con.start()
|
self.setCentralWidget(auto_connect)
|
||||||
self.settings_have_changed()
|
self.show()
|
||||||
|
|
||||||
# After connecting to Tor, check for updates
|
|
||||||
self.check_for_updates()
|
|
||||||
|
|
||||||
# Create the close warning dialog -- the dialog widget needs to be in the constructor
|
# Create the close warning dialog -- the dialog widget needs to be in the constructor
|
||||||
# in order to test it
|
# in order to test it
|
||||||
|
@ -187,6 +184,25 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
)
|
)
|
||||||
self.close_dialog.setDefaultButton(self.close_dialog.reject_button)
|
self.close_dialog.setDefaultButton(self.close_dialog.reject_button)
|
||||||
|
|
||||||
|
def start_onionshare(self):
|
||||||
|
"""
|
||||||
|
Once the user clicks on connect in the initial screen, start tor connection
|
||||||
|
and show new tab screen
|
||||||
|
"""
|
||||||
|
self.setCentralWidget(self.connected_central_widget)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
# Start the "Connecting to Tor" dialog, which calls onion.connect()
|
||||||
|
tor_con = TorConnectionDialog(self.common)
|
||||||
|
tor_con.canceled.connect(self.tor_connection_canceled)
|
||||||
|
tor_con.open_tor_settings.connect(self.tor_connection_open_tor_settings)
|
||||||
|
if not self.common.gui.local_only:
|
||||||
|
tor_con.start()
|
||||||
|
self.settings_have_changed()
|
||||||
|
|
||||||
|
# After connecting to Tor, check for updates
|
||||||
|
self.check_for_updates()
|
||||||
|
|
||||||
def tor_connection_canceled(self):
|
def tor_connection_canceled(self):
|
||||||
"""
|
"""
|
||||||
If the user cancels before Tor finishes connecting, ask if they want to
|
If the user cancels before Tor finishes connecting, ask if they want to
|
||||||
|
|
Loading…
Reference in a new issue