From 0bb9bf649d0052703730fbd6e4391997f593a878 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 4 Feb 2018 21:18:41 -0800 Subject: [PATCH] Remove delete button, use delete X's instead --- install/onionshare.nsi | 2 ++ onionshare_gui/file_selection.py | 44 ++++++++++++------------------- share/images/file_delete.png | Bin 0 -> 182 bytes 3 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 share/images/file_delete.png diff --git a/install/onionshare.nsi b/install/onionshare.nsi index d83da6ad..e5f989bb 100644 --- a/install/onionshare.nsi +++ b/install/onionshare.nsi @@ -201,6 +201,7 @@ Section "install" File "${BINPATH}\share\html\index.html" SetOutPath "$INSTDIR\share\images" + File "${BINPATH}\share\images\file_delete.png" File "${BINPATH}\share\images\logo.png" File "${BINPATH}\share\images\logo_transparent.png" File "${BINPATH}\share\images\logo_grayscale.png" @@ -379,6 +380,7 @@ FunctionEnd Delete "$INSTDIR\share\html\404.html" Delete "$INSTDIR\share\html\denied.html" Delete "$INSTDIR\share\html\index.html" + Delete "$INSTDIR\share\images\file_delete.png" Delete "$INSTDIR\share\images\logo.png" Delete "$INSTDIR\share\images\logo_transparent.png" Delete "$INSTDIR\share\images\logo_grayscale.png" diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 5a371d3c..88576e8a 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -80,7 +80,7 @@ class FileList(QtWidgets.QListWidget): self.setIconSize(QtCore.QSize(32, 32)) self.setSortingEnabled(True) self.setMinimumHeight(200) - self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) + self.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) self.filenames = [] @@ -198,8 +198,21 @@ class FileList(QtWidgets.QListWidget): item.setToolTip(size) item.setIcon(icon) + # Item's delete button + def delete_item(): + itemrow = self.row(item) + self.filenames.pop(itemrow) + self.takeItem(itemrow) + self.files_updated.emit() + self.update() + + item_button = QtWidgets.QPushButton() + item_button.setDefault(False) + item_button.setFlat(True) + item_button.setIcon( QtGui.QIcon(common.get_resource_path('images/file_delete.png')) ) + item_button.clicked.connect(delete_item) + # Create an item widget to display on the item - item_button = QtWidgets.QPushButton('x') item_widget_layout = QtWidgets.QHBoxLayout() item_widget_layout.addStretch() item_widget_layout.addWidget(item_button) @@ -214,8 +227,7 @@ class FileList(QtWidgets.QListWidget): class FileSelection(QtWidgets.QVBoxLayout): """ - The list of files and folders in the GUI, as well as buttons to add and - delete the files and folders. + The list of files and folders in the GUI, as well as button to add files and folders. """ def __init__(self): super(FileSelection, self).__init__() @@ -229,11 +241,9 @@ class FileSelection(QtWidgets.QVBoxLayout): # buttons self.add_button = QtWidgets.QPushButton(strings._('gui_add', True)) self.add_button.clicked.connect(self.add) - self.delete_button = QtWidgets.QPushButton(strings._('gui_delete', True)) - self.delete_button.clicked.connect(self.delete) button_layout = QtWidgets.QHBoxLayout() + button_layout.addStretch() button_layout.addWidget(self.add_button) - button_layout.addWidget(self.delete_button) # add the widgets self.addWidget(self.file_list) @@ -248,17 +258,9 @@ class FileSelection(QtWidgets.QVBoxLayout): # all buttons should be disabled if the server is on if self.server_on: self.add_button.setEnabled(False) - self.delete_button.setEnabled(False) else: self.add_button.setEnabled(True) - # delete button should be disabled if item isn't selected - current_item = self.file_list.currentItem() - if not current_item: - self.delete_button.setEnabled(False) - else: - self.delete_button.setEnabled(True) - # update the file list self.file_list.update() @@ -273,18 +275,6 @@ class FileSelection(QtWidgets.QVBoxLayout): self.update() - def delete(self): - """ - Delete button clicked - """ - selected = self.file_list.selectedItems() - for item in selected: - itemrow = self.file_list.row(item) - self.file_list.filenames.pop(itemrow) - self.file_list.takeItem(itemrow) - self.file_list.files_updated.emit() - self.update() - def server_started(self): """ Gets called when the server starts. diff --git a/share/images/file_delete.png b/share/images/file_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..b9057df5d2f0590bb9bdbf6f4b7274cf094eb986 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv`=Osp(cYFe)ylz~Fdo-U3d5|@(`5)yu#KX9O+iP7AG zF_bx7=D?yC47(iJH)z;3oMuSrWUk0@4D4Ch(b>r3Fy*RCHfR6< literal 0 HcmV?d00001