mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-14 08:49:47 -05:00
Allow changing downloads_dir from SettingsDialog
This commit is contained in:
parent
a017af0748
commit
dd7d97dbbb
@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
"""
|
"""
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import os, sys, platform, argparse
|
import os, sys, platform, argparse
|
||||||
from .alert import Alert
|
from .widgets import Alert
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
|
|
||||||
from onionshare import strings
|
from onionshare import strings
|
||||||
|
@ -27,7 +27,7 @@ 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 .alert import Alert
|
from .widgets import Alert
|
||||||
from .update_checker import UpdateThread
|
from .update_checker import UpdateThread
|
||||||
|
|
||||||
class OnionShareGui(QtWidgets.QMainWindow):
|
class OnionShareGui(QtWidgets.QMainWindow):
|
||||||
|
@ -24,7 +24,7 @@ from onionshare import strings, common
|
|||||||
from onionshare.settings import Settings
|
from onionshare.settings import Settings
|
||||||
from onionshare.onion import *
|
from onionshare.onion import *
|
||||||
|
|
||||||
from .alert import Alert
|
from .widgets import Alert
|
||||||
from .update_checker import *
|
from .update_checker import *
|
||||||
from .tor_connection_dialog import TorConnectionDialog
|
from .tor_connection_dialog import TorConnectionDialog
|
||||||
|
|
||||||
@ -77,6 +77,23 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label", True))
|
sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label", True))
|
||||||
sharing_group.setLayout(sharing_group_layout)
|
sharing_group.setLayout(sharing_group_layout)
|
||||||
|
|
||||||
|
# Downloads dir
|
||||||
|
downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label', True));
|
||||||
|
self.downloads_dir_lineedit = QtWidgets.QLineEdit()
|
||||||
|
self.downloads_dir_lineedit.setReadOnly(True)
|
||||||
|
downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button', True))
|
||||||
|
downloads_button.clicked.connect(self.downloads_button_clicked)
|
||||||
|
downloads_layout = QtWidgets.QHBoxLayout()
|
||||||
|
downloads_layout.addWidget(downloads_label)
|
||||||
|
downloads_layout.addWidget(self.downloads_dir_lineedit)
|
||||||
|
downloads_layout.addWidget(downloads_button)
|
||||||
|
|
||||||
|
# Receiving options layout
|
||||||
|
receiving_group_layout = QtWidgets.QVBoxLayout()
|
||||||
|
receiving_group_layout.addLayout(downloads_layout)
|
||||||
|
receiving_group = QtWidgets.QGroupBox(strings._("gui_settings_receiving_label", True))
|
||||||
|
receiving_group.setLayout(receiving_group_layout)
|
||||||
|
|
||||||
# Stealth options
|
# Stealth options
|
||||||
|
|
||||||
# Stealth
|
# Stealth
|
||||||
@ -349,6 +366,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
# Layout
|
# Layout
|
||||||
left_col_layout = QtWidgets.QVBoxLayout()
|
left_col_layout = QtWidgets.QVBoxLayout()
|
||||||
left_col_layout.addWidget(sharing_group)
|
left_col_layout.addWidget(sharing_group)
|
||||||
|
left_col_layout.addWidget(receiving_group)
|
||||||
left_col_layout.addWidget(stealth_group)
|
left_col_layout.addWidget(stealth_group)
|
||||||
left_col_layout.addWidget(autoupdate_group)
|
left_col_layout.addWidget(autoupdate_group)
|
||||||
left_col_layout.addStretch()
|
left_col_layout.addStretch()
|
||||||
@ -392,6 +410,9 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
else:
|
else:
|
||||||
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
|
|
||||||
|
downloads_dir = self.old_settings.get('downloads_dir')
|
||||||
|
self.downloads_dir_lineedit.setText(downloads_dir)
|
||||||
|
|
||||||
use_stealth = self.old_settings.get('use_stealth')
|
use_stealth = self.old_settings.get('use_stealth')
|
||||||
if use_stealth:
|
if use_stealth:
|
||||||
self.stealth_checkbox.setCheckState(QtCore.Qt.Checked)
|
self.stealth_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||||
@ -575,6 +596,18 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
clipboard = self.qtapp.clipboard()
|
clipboard = self.qtapp.clipboard()
|
||||||
clipboard.setText(self.old_settings.get('hidservauth_string'))
|
clipboard.setText(self.old_settings.get('hidservauth_string'))
|
||||||
|
|
||||||
|
def downloads_button_clicked(self):
|
||||||
|
"""
|
||||||
|
Browse for a new downloads directory
|
||||||
|
"""
|
||||||
|
downloads_dir = self.downloads_dir_lineedit.text()
|
||||||
|
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self,
|
||||||
|
strings._('gui_settings_downloads_label', True), downloads_dir)
|
||||||
|
|
||||||
|
if selected_dir:
|
||||||
|
self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir))
|
||||||
|
self.downloads_dir_lineedit.setText(selected_dir)
|
||||||
|
|
||||||
def test_tor_clicked(self):
|
def test_tor_clicked(self):
|
||||||
"""
|
"""
|
||||||
Test Tor Settings button clicked. With the given settings, see if we can
|
Test Tor Settings button clicked. With the given settings, see if we can
|
||||||
@ -760,6 +793,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
settings.set('slug', '')
|
settings.set('slug', '')
|
||||||
# Also unset the HidServAuth if we are removing our reusable private key
|
# Also unset the HidServAuth if we are removing our reusable private key
|
||||||
settings.set('hidservauth_string', '')
|
settings.set('hidservauth_string', '')
|
||||||
|
settings.set('downloads_dir', self.downloads_dir_lineedit.text())
|
||||||
settings.set('use_stealth', self.stealth_checkbox.isChecked())
|
settings.set('use_stealth', self.stealth_checkbox.isChecked())
|
||||||
# Always unset the HidServAuth if Stealth mode is unset
|
# Always unset the HidServAuth if Stealth mode is unset
|
||||||
if not self.stealth_checkbox.isChecked():
|
if not self.stealth_checkbox.isChecked():
|
||||||
|
@ -30,7 +30,7 @@ from .file_selection import FileSelection
|
|||||||
from .server_status import ServerStatus
|
from .server_status import ServerStatus
|
||||||
from .downloads import Downloads
|
from .downloads import Downloads
|
||||||
from ..onion_thread import OnionThread
|
from ..onion_thread import OnionThread
|
||||||
from ..alert import Alert
|
from ..widgets import Alert
|
||||||
|
|
||||||
|
|
||||||
class ShareMode(QtWidgets.QWidget):
|
class ShareMode(QtWidgets.QWidget):
|
||||||
|
@ -22,7 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
|||||||
|
|
||||||
from onionshare import strings
|
from onionshare import strings
|
||||||
|
|
||||||
from ..alert import Alert
|
from ..widgets import Alert, AddFileDialog
|
||||||
|
|
||||||
class DropHereLabel(QtWidgets.QLabel):
|
class DropHereLabel(QtWidgets.QLabel):
|
||||||
"""
|
"""
|
||||||
@ -340,7 +340,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
"""
|
"""
|
||||||
Add button clicked.
|
Add button clicked.
|
||||||
"""
|
"""
|
||||||
file_dialog = FileDialog(caption=strings._('gui_choose_items', True))
|
file_dialog = AddFileDialog(self.common, caption=strings._('gui_choose_items', True))
|
||||||
if file_dialog.exec_() == QtWidgets.QDialog.Accepted:
|
if file_dialog.exec_() == QtWidgets.QDialog.Accepted:
|
||||||
for filename in file_dialog.selectedFiles():
|
for filename in file_dialog.selectedFiles():
|
||||||
self.file_list.add_file(filename)
|
self.file_list.add_file(filename)
|
||||||
@ -388,22 +388,3 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
Set the Qt app focus on the file selection box.
|
Set the Qt app focus on the file selection box.
|
||||||
"""
|
"""
|
||||||
self.file_list.setFocus()
|
self.file_list.setFocus()
|
||||||
|
|
||||||
class FileDialog(QtWidgets.QFileDialog):
|
|
||||||
"""
|
|
||||||
Overridden version of QFileDialog which allows us to select
|
|
||||||
folders as well as, or instead of, files.
|
|
||||||
"""
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
QtWidgets.QFileDialog.__init__(self, *args, **kwargs)
|
|
||||||
self.setOption(self.DontUseNativeDialog, True)
|
|
||||||
self.setOption(self.ReadOnly, True)
|
|
||||||
self.setOption(self.ShowDirsOnly, False)
|
|
||||||
self.setFileMode(self.ExistingFiles)
|
|
||||||
tree_view = self.findChild(QtWidgets.QTreeView)
|
|
||||||
tree_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
|
||||||
list_view = self.findChild(QtWidgets.QListView, "listView")
|
|
||||||
list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
|
||||||
|
|
||||||
def accept(self):
|
|
||||||
QtWidgets.QDialog.accept(self)
|
|
||||||
|
@ -22,7 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
|||||||
|
|
||||||
from onionshare import strings
|
from onionshare import strings
|
||||||
|
|
||||||
from ..alert import Alert
|
from ..widgets import Alert
|
||||||
|
|
||||||
class ServerStatus(QtWidgets.QWidget):
|
class ServerStatus(QtWidgets.QWidget):
|
||||||
"""
|
"""
|
||||||
|
@ -22,7 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
|||||||
from onionshare import strings
|
from onionshare import strings
|
||||||
from onionshare.onion import *
|
from onionshare.onion import *
|
||||||
|
|
||||||
from .alert import Alert
|
from .widgets import Alert
|
||||||
|
|
||||||
class TorConnectionDialog(QtWidgets.QProgressDialog):
|
class TorConnectionDialog(QtWidgets.QProgressDialog):
|
||||||
"""
|
"""
|
||||||
|
@ -38,3 +38,28 @@ class Alert(QtWidgets.QMessageBox):
|
|||||||
|
|
||||||
if autostart:
|
if autostart:
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
class AddFileDialog(QtWidgets.QFileDialog):
|
||||||
|
"""
|
||||||
|
Overridden version of QFileDialog which allows us to select folders as well
|
||||||
|
as, or instead of, files. For adding files/folders to share.
|
||||||
|
"""
|
||||||
|
def __init__(self, common, *args, **kwargs):
|
||||||
|
QtWidgets.QFileDialog.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
self.common = common
|
||||||
|
self.common.log('AddFileDialog', '__init__')
|
||||||
|
|
||||||
|
self.setOption(self.DontUseNativeDialog, True)
|
||||||
|
self.setOption(self.ReadOnly, True)
|
||||||
|
self.setOption(self.ShowDirsOnly, False)
|
||||||
|
self.setFileMode(self.ExistingFiles)
|
||||||
|
tree_view = self.findChild(QtWidgets.QTreeView)
|
||||||
|
tree_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||||
|
list_view = self.findChild(QtWidgets.QListView, "listView")
|
||||||
|
list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
self.common.log('AddFileDialog', 'accept')
|
||||||
|
QtWidgets.QDialog.accept(self)
|
@ -164,5 +164,8 @@
|
|||||||
"receive_mode_warning": "Warning: Some files can hack your computer if you open them! Only open files from people you trust, or if you know what you're doing.",
|
"receive_mode_warning": "Warning: Some files can hack your computer if you open them! Only open files from people you trust, or if you know what you're doing.",
|
||||||
"receive_mode_received_file": "Received file: {}",
|
"receive_mode_received_file": "Received file: {}",
|
||||||
"gui_mode_share_button": "Share Files",
|
"gui_mode_share_button": "Share Files",
|
||||||
"gui_mode_receive_button": "Receive Files"
|
"gui_mode_receive_button": "Receive Files",
|
||||||
|
"gui_settings_receiving_label": "Receiving options",
|
||||||
|
"gui_settings_downloads_label": "Save files to",
|
||||||
|
"gui_settings_downloads_button": "Browse"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user