Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

183.folder remove ux #190

Merged
merged 7 commits into from Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion gridsync/gui/main_window.py
Expand Up @@ -428,7 +428,7 @@ def keyPressEvent(self, event):
view = self.current_view()
selected = (view.selectedIndexes() if view else None)
if selected:
view.confirm_remove(view.get_selected_folders())
view.confirm_stop_syncing(view.get_selected_folders())
if key == Qt.Key_Escape:
view = self.current_view()
selected = (view.selectedIndexes() if view else None)
Expand Down
47 changes: 29 additions & 18 deletions gridsync/gui/view.py
Expand Up @@ -301,40 +301,49 @@ def remove_folder(self, folder_name, unlink=False):
if unlink:
yield self.unlink_folder(folder_name)

def confirm_remove(self, folders):
def confirm_stop_syncing(self, folders):
msgbox = QMessageBox(self)
msgbox.setIcon(QMessageBox.Question)
humanized_folders = humanized_list(folders, "folders")
msgbox.setWindowTitle("Remove {}?".format(humanized_folders))
msgbox.setWindowTitle("Stop syncing {}?".format(humanized_folders))
if len(folders) == 1:
msgbox.setText(
'Are you sure you wish to remove the "{}" folder?'.format(
folders[0]))
'Are you sure you wish to stop syncing the "{}" folder?'
.format(folders[0])
)
msgbox.setInformativeText(
"This folder will remain on your computer but it will no "
"longer synchronize automatically with {}.".format(
self.gateway.name)
)
checkbox = QCheckBox(
"Allow this folder to be restored later with my Recovery Key")
"Keep a backup copy of this folder on {}".format(
self.gateway.name))
else:
msgbox.setText(
"Are you sure you wish to remove {}?".format(humanized_folders)
"Are you sure you wish to stop syncing {}?".format(
humanized_folders)
)
checkbox = QCheckBox(
"Allow these folders to be restored later with my Recovery Key"
msgbox.setInformativeText(
"These folders will remain on your computer but they will no "
"longer synchronize automatically with {}.".format(
self.gateway.name)
)
msgbox.setInformativeText(
"Removed folders will remain on your computer but {} will no "
"longer synchronize their contents with {}.".format(
APP_NAME, self.gateway.name))
checkbox.setCheckState(Qt.Checked)
checkbox = QCheckBox(
"Keep backup copies of these folders on {}".format(
self.gateway.name))
checkbox.setCheckState(Qt.Unchecked)
msgbox.setCheckBox(checkbox)
msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msgbox.setDefaultButton(QMessageBox.Yes)
if msgbox.exec_() == QMessageBox.Yes:
tasks = []
if checkbox.checkState() == Qt.Unchecked:
if checkbox.checkState() == Qt.Checked:
for folder in folders:
tasks.append(self.remove_folder(folder, unlink=True))
tasks.append(self.remove_folder(folder, unlink=False))
else:
for folder in folders:
tasks.append(self.remove_folder(folder, unlink=False))
tasks.append(self.remove_folder(folder, unlink=True))
d = DeferredList(tasks)
d.addCallback(self.maybe_rescan_rootcap)
d.addCallback(self.maybe_restart_gateway)
Expand Down Expand Up @@ -415,7 +424,8 @@ def on_right_click(self, position):
lambda: self.open_invite_sender_dialog(selected))
share_menu.addAction(invite_action)

remove_action = QAction(QIcon(resource('close.png')), "Remove...")
remove_action = QAction(
QIcon(resource('close.png')), "Remove from Recovery Key...")
menu.addAction(open_action)
menu.addMenu(share_menu)
menu.addSeparator()
Expand All @@ -431,8 +441,9 @@ def on_right_click(self, position):
share_menu.setEnabled(False)
share_menu.setTitle(
"Sync with device (disabled; no admin access)")
remove_action.setText('Stop syncing...')
remove_action.triggered.connect(
lambda: self.confirm_remove(selected))
lambda: self.confirm_stop_syncing(selected))
menu.exec_(self.viewport().mapToGlobal(position))

@inlineCallbacks
Expand Down