Use multiple lines for quit messages

This commit is contained in:
Peter Vilim 2015-01-05 01:01:22 -06:00
parent 8a3aca63b0
commit 0305dedbfb
2 changed files with 25 additions and 25 deletions

View File

@ -1253,10 +1253,12 @@ class ConfirmQuit(List):
if values == 'never':
return
# Never can't be set with other options
elif 'never' in values and isinstance(values, list):
elif 'never' in values and isinstance(values,
list) and len(values) > 1:
raise configexc.ValidationError(value, "List cannot contain never!")
# Always can't be set with other options
elif 'always' in values and isinstance(values, list):
elif 'always' in values and isinstance(values,
list) and len(values) > 1:
raise configexc.ValidationError(value,
"List cannot contain always!")
# Values have to be valid
@ -1269,17 +1271,17 @@ class ConfirmQuit(List):
" values!")
def complete(self):
combinations = []
permutations = []
# Generate combinations of the options that can be combined
for size in range(2, len(self.combinable_values) + 1):
combinations = combinations + list(
itertools.combinations(self.combinable_values, size))
permutations = permutations + list(
itertools.permutations(self.combinable_values, size))
out = []
# Add valid single values
for val in self.valid_values:
out.append((val, self.valid_values.descriptions[val]))
# Add combinations to list of options
for val in combinations:
for val in permutations:
desc = ''
val = ','.join(val)
out.append((val, desc))

View File

@ -331,33 +331,31 @@ class MainWindow(QWidget):
download_manager = objreg.get('download-manager', scope='window',
window=self.win_id)
download_count = download_manager.rowCount()
quit_text = []
quit_texts = []
# Close if set to never ask for confirmation (backward compatible)
if confirm_quit == 'never' or 'never' in confirm_quit:
pass
# Ask if set to always ask before closing
if 'always' in confirm_quit:
quit_text.append("Close?")
# Ask if multiple-tabs are open
if 'multiple-tabs' in confirm_quit and tab_count > 1:
quit_text.append("Close {} {}?".format(
tab_count, "tab" if tab_count == 1 else "tabs"))
quit_texts.append("{} {} open.".format(
tab_count, "tab is" if tab_count == 1 else "tabs are"))
# Ask if multiple downloads running
if 'downloads' in confirm_quit and download_count > 0:
quit_text.append("Close {} {}?".format(
tab_count, "download" if tab_count == 1 else "downloads"))
quit_texts.append("{} {} running.".format(
tab_count,
"download is" if tab_count == 1 else "downloads are"))
# Process all quit messages that user must confirm
if len(quit_text) > 0:
for text in quit_text:
confirmed = message.ask(self.win_id, text,
usertypes.PromptMode.yesno,
default=True)
# Stop asking if the user cancels
if not confirmed:
log.destroy.debug("Cancelling losing of window {}".format(
self.win_id))
e.ignore()
return
if quit_texts or 'always' in confirm_quit:
text = '\n'.join(['Really quit?'] + quit_texts)
confirmed = message.ask(self.win_id, text,
usertypes.PromptMode.yesno,
default=True)
# Stop asking if the user cancels
if not confirmed:
log.destroy.debug("Cancelling losing of window {}".format(
self.win_id))
e.ignore()
return
e.accept()
objreg.get('app').geometry = bytes(self.saveGeometry())
log.destroy.debug("Closing window {}".format(self.win_id))