Merge branch 'single_add_button' of https://github.com/mig5/onionshare into mig5-single_add_button

This commit is contained in:
Micah Lee 2017-05-30 12:21:03 -07:00
commit c039ccd184
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
11 changed files with 51 additions and 85 deletions

View File

@ -171,15 +171,12 @@ class FileSelection(QtWidgets.QVBoxLayout):
self.file_list.files_dropped.connect(self.update) self.file_list.files_dropped.connect(self.update)
# buttons # buttons
self.add_files_button = QtWidgets.QPushButton(strings._('gui_add_files', True)) self.add_button = QtWidgets.QPushButton(strings._('gui_add', True))
self.add_files_button.clicked.connect(self.add_files) self.add_button.clicked.connect(self.add)
self.add_dir_button = QtWidgets.QPushButton(strings._('gui_add_folder', True))
self.add_dir_button.clicked.connect(self.add_dir)
self.delete_button = QtWidgets.QPushButton(strings._('gui_delete', True)) self.delete_button = QtWidgets.QPushButton(strings._('gui_delete', True))
self.delete_button.clicked.connect(self.delete_file) self.delete_button.clicked.connect(self.delete)
button_layout = QtWidgets.QHBoxLayout() button_layout = QtWidgets.QHBoxLayout()
button_layout.addWidget(self.add_files_button) button_layout.addWidget(self.add_button)
button_layout.addWidget(self.add_dir_button)
button_layout.addWidget(self.delete_button) button_layout.addWidget(self.delete_button)
# add the widgets # add the widgets
@ -194,12 +191,10 @@ class FileSelection(QtWidgets.QVBoxLayout):
""" """
# all buttons should be disabled if the server is on # all buttons should be disabled if the server is on
if self.server_on: if self.server_on:
self.add_files_button.setEnabled(False) self.add_button.setEnabled(False)
self.add_dir_button.setEnabled(False)
self.delete_button.setEnabled(False) self.delete_button.setEnabled(False)
else: else:
self.add_files_button.setEnabled(True) self.add_button.setEnabled(True)
self.add_dir_button.setEnabled(True)
# delete button should be disabled if item isn't selected # delete button should be disabled if item isn't selected
current_item = self.file_list.currentItem() current_item = self.file_list.currentItem()
@ -211,46 +206,18 @@ class FileSelection(QtWidgets.QVBoxLayout):
# update the file list # update the file list
self.file_list.update() self.file_list.update()
def add_files(self): def add(self):
""" """
Add files button clicked. Add button clicked.
""" """
file_dialog = QtWidgets.QFileDialog(caption=strings._('gui_choose_files', True)) file_dialog = FileDialog(caption=strings._('gui_choose_items', True))
file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
file_dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
file_dialog.setOption(QtWidgets.QFileDialog.ReadOnly, True)
tree_view = file_dialog.findChild(QtWidgets.QTreeView)
tree_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
list_view = file_dialog.findChild(QtWidgets.QListView, "listView")
list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
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)
self.update() self.update()
def add_dir(self): def delete(self):
"""
Add folder button clicked.
"""
file_dialog = QtWidgets.QFileDialog(caption=strings._('gui_choose_folder', True))
file_dialog.setFileMode(QtWidgets.QFileDialog.Directory)
file_dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
file_dialog.setOption(QtWidgets.QFileDialog.ReadOnly, True)
file_dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
tree_view = file_dialog.findChild(QtWidgets.QTreeView)
tree_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
list_view = file_dialog.findChild(QtWidgets.QListView, "listView")
list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
if file_dialog.exec_() == QtWidgets.QDialog.Accepted:
for filename in file_dialog.selectedFiles():
self.file_list.add_file(filename)
self.update()
def delete_file(self):
""" """
Delete button clicked Delete button clicked
""" """
@ -288,3 +255,22 @@ 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)

View File

@ -22,11 +22,9 @@
"help_debug": "Zaznamenat chyby na disk", "help_debug": "Zaznamenat chyby na disk",
"help_filename": "Seznam souborů a složek ke sdílení", "help_filename": "Seznam souborů a složek ke sdílení",
"gui_drag_and_drop": "Táhni a pusť\nsoubory sem", "gui_drag_and_drop": "Táhni a pusť\nsoubory sem",
"gui_add_files": "Přidat soubory", "gui_add": "Přidat",
"gui_add_folder": "Přidat složku",
"gui_delete": "Smazat", "gui_delete": "Smazat",
"gui_choose_files": "Vybrat soubory", "gui_choose_items": "Vybrat",
"gui_choose_folder": "vybrat složku",
"gui_start_server": "Spustit sdílení", "gui_start_server": "Spustit sdílení",
"gui_stop_server": "Zastavit sdílení", "gui_stop_server": "Zastavit sdílení",
"gui_copy_url": "Kopírovat URL", "gui_copy_url": "Kopírovat URL",

View File

@ -22,11 +22,9 @@
"help_debug": "Fehler auf Festplatte schreiben", "help_debug": "Fehler auf Festplatte schreiben",
"help_filename": "Liste der zu teilenden Dateien oder Verzeichnisse", "help_filename": "Liste der zu teilenden Dateien oder Verzeichnisse",
"gui_drag_and_drop": "Drag & drop\nDateien hier", "gui_drag_and_drop": "Drag & drop\nDateien hier",
"gui_add_files": "Dateien hinzufügen", "gui_add": "Hinzufügen",
"gui_add_folder": "Verzeichnis hinzufügen",
"gui_delete": "Löschen", "gui_delete": "Löschen",
"gui_choose_files": "Dateien auswählen", "gui_choose_items": "Auswählen",
"gui_choose_folder": "Verzeichnis auswählen",
"gui_start_server": "Server starten", "gui_start_server": "Server starten",
"gui_stop_server": "Server anhalten", "gui_stop_server": "Server anhalten",
"gui_copy_url": "URL kopieren", "gui_copy_url": "URL kopieren",

View File

@ -30,11 +30,9 @@
"help_debug": "Log application errors to stdout, and log web errors to disk", "help_debug": "Log application errors to stdout, and log web errors to disk",
"help_filename": "List of files or folders to share", "help_filename": "List of files or folders to share",
"gui_drag_and_drop": "Drag and drop\nfiles here", "gui_drag_and_drop": "Drag and drop\nfiles here",
"gui_add_files": "Add Files", "gui_add": "Add",
"gui_add_folder": "Add Folders",
"gui_delete": "Delete", "gui_delete": "Delete",
"gui_choose_files": "Choose files", "gui_choose_items": "Choose",
"gui_choose_folder": "Choose folders",
"gui_start_server": "Start Sharing", "gui_start_server": "Start Sharing",
"gui_stop_server": "Stop Sharing", "gui_stop_server": "Stop Sharing",
"gui_copy_url": "Copy URL", "gui_copy_url": "Copy URL",

View File

@ -22,11 +22,9 @@
"help_debug": "Protokoli erarojn sur disko", "help_debug": "Protokoli erarojn sur disko",
"help_filename": "Listo de dosieroj aŭ dosierujoj por kundividi", "help_filename": "Listo de dosieroj aŭ dosierujoj por kundividi",
"gui_drag_and_drop": "Ŝovu kaj metu\nla dosierojn ĉi tien", "gui_drag_and_drop": "Ŝovu kaj metu\nla dosierojn ĉi tien",
"gui_add_files": "Aldoni dosierojn", "gui_add": "Aldoni",
"gui_add_folder": "Aldoni dosierujon",
"gui_delete": "Forviŝi", "gui_delete": "Forviŝi",
"gui_choose_files": "Elekti dosierojn", "gui_choose_items": "Elekti",
"gui_choose_folder": "Elekti dosierujon",
"gui_start_server": "Komenci kundividon", "gui_start_server": "Komenci kundividon",
"gui_stop_server": "Ĉesigi kundividon", "gui_stop_server": "Ĉesigi kundividon",
"gui_copy_url": "Kopii URL", "gui_copy_url": "Kopii URL",

View File

@ -21,11 +21,9 @@
"help_debug": "Guardar registro de errores en el disco", "help_debug": "Guardar registro de errores en el disco",
"help_filename": "Lista de archivos o carpetas para compartir", "help_filename": "Lista de archivos o carpetas para compartir",
"gui_drag_and_drop": "Arrastre\narchivos aquí", "gui_drag_and_drop": "Arrastre\narchivos aquí",
"gui_add_files": "Añadir Archivos", "gui_add": "Añadir",
"gui_add_folder": "Añadir Carpeta",
"gui_delete": "Eliminar", "gui_delete": "Eliminar",
"gui_choose_files": "Elegir archivos", "gui_choose_items": "Elegir",
"gui_choose_folder": "Elegir carpeta",
"gui_start_server": "Encender el Servidor", "gui_start_server": "Encender el Servidor",
"gui_stop_server": "Detener el Servidor", "gui_stop_server": "Detener el Servidor",
"gui_copy_url": "Copiar URL", "gui_copy_url": "Copiar URL",

View File

@ -23,11 +23,9 @@
"help_debug": "Tallentaa virheet levylle", "help_debug": "Tallentaa virheet levylle",
"help_filename": "Luettele jaettavat tiedostot tai kansiot", "help_filename": "Luettele jaettavat tiedostot tai kansiot",
"gui_drag_and_drop": "Vedä ja pudota\ntiedostot tänne", "gui_drag_and_drop": "Vedä ja pudota\ntiedostot tänne",
"gui_add_files": "Lisää tiedostoja", "gui_add": "Lisää",
"gui_add_folder": "Lisää kansio",
"gui_delete": "Poista", "gui_delete": "Poista",
"gui_choose_files": "Valitse tiedostoja", "gui_choose_items": "Valitse",
"gui_choose_folder": "Valitse kansio",
"gui_start_server": "Käynnistä palvelin", "gui_start_server": "Käynnistä palvelin",
"gui_stop_server": "Pysäytä palvelin", "gui_stop_server": "Pysäytä palvelin",
"gui_copy_url": "Kopioi URL-osoite", "gui_copy_url": "Kopioi URL-osoite",

View File

@ -20,11 +20,9 @@
"help_debug": "Enregistrer les erreurs sur le disque", "help_debug": "Enregistrer les erreurs sur le disque",
"help_filename": "Liste des fichiers ou dossiers à partager", "help_filename": "Liste des fichiers ou dossiers à partager",
"gui_drag_and_drop": "Glissez déposez\nles fichiers ici", "gui_drag_and_drop": "Glissez déposez\nles fichiers ici",
"gui_add_files": "Ajouter des fichiers", "gui_add": "Ajouter",
"gui_add_folder": "Ajouter des dossiers",
"gui_delete": "Supprimer", "gui_delete": "Supprimer",
"gui_choose_files": "Sélectionnez des fichiers", "gui_choose_items": "Sélectionnez",
"gui_choose_folder": "Sélectionnez des dossiers",
"gui_start_server": "Démarrer le serveur", "gui_start_server": "Démarrer le serveur",
"gui_stop_server": "Arrêter le serveur", "gui_stop_server": "Arrêter le serveur",
"gui_copy_url": "Copier URL", "gui_copy_url": "Copier URL",

View File

@ -23,11 +23,9 @@
"help_debug": "Registra gli errori sul disco", "help_debug": "Registra gli errori sul disco",
"help_filename": "Lista dei file o cartelle da condividere", "help_filename": "Lista dei file o cartelle da condividere",
"gui_drag_and_drop": "Prendi e rilascia\ni file qui sopra", "gui_drag_and_drop": "Prendi e rilascia\ni file qui sopra",
"gui_add_files": "Aggiungi il Files", "gui_add": "Aggiungi",
"gui_add_folder": "Aggiungi la Cartella",
"gui_delete": "Cancella", "gui_delete": "Cancella",
"gui_choose_files": "Scegli il file", "gui_choose_items": "Scegli",
"gui_choose_folder": "Scegli la cartella",
"gui_start_server": "Inizia la condivisione", "gui_start_server": "Inizia la condivisione",
"gui_stop_server": "Ferma la condivisione", "gui_stop_server": "Ferma la condivisione",
"gui_copy_url": "Copia lo URL", "gui_copy_url": "Copia lo URL",

View File

@ -22,11 +22,9 @@
"help_debug": "Log fouten naar harde schijf", "help_debug": "Log fouten naar harde schijf",
"help_filename": "Lijst van bestanden of mappen om te delen", "help_filename": "Lijst van bestanden of mappen om te delen",
"gui_drag_and_drop": "Sleep en zet\nbestanden hier neer", "gui_drag_and_drop": "Sleep en zet\nbestanden hier neer",
"gui_add_files": "Bestanden toevoegen", "gui_add": "Toevoegen",
"gui_add_folder": "Map toevoegen",
"gui_delete": "Verwijder", "gui_delete": "Verwijder",
"gui_choose_files": "Kies bestanden", "gui_choose_items": "Kies",
"gui_choose_folder": "Kies map",
"gui_start_server": "Start server", "gui_start_server": "Start server",
"gui_stop_server": "Stop server", "gui_stop_server": "Stop server",
"gui_copy_url": "Kopieer URL", "gui_copy_url": "Kopieer URL",

View File

@ -23,11 +23,9 @@
"help_debug": "Hata kayıtlarını diske kaydet", "help_debug": "Hata kayıtlarını diske kaydet",
"help_filename": "Paylaşmak için dosya ve klasörler listesi", "help_filename": "Paylaşmak için dosya ve klasörler listesi",
"gui_drag_and_drop": "Dosyaları buraya\n Sürükle ve Bırak", "gui_drag_and_drop": "Dosyaları buraya\n Sürükle ve Bırak",
"gui_add_files": "Dosyalar Ekle", "gui_add": "Ekle",
"gui_add_folder": "Klasör Ekle",
"gui_delete": "Sil", "gui_delete": "Sil",
"gui_choose_files": "Dosyalar Seç", "gui_choose_items": "Seç",
"gui_choose_folder": "Klasör Seç",
"gui_start_server": "Paylaşımı Başlat", "gui_start_server": "Paylaşımı Başlat",
"gui_stop_server": "Paylaşımı Durdur", "gui_stop_server": "Paylaşımı Durdur",
"gui_copy_url": "URL Kopyala", "gui_copy_url": "URL Kopyala",