Use multiple lines for quit messages
This commit is contained in:
parent
8a3aca63b0
commit
0305dedbfb
@ -1253,10 +1253,12 @@ class ConfirmQuit(List):
|
|||||||
if values == 'never':
|
if values == 'never':
|
||||||
return
|
return
|
||||||
# Never can't be set with other options
|
# 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!")
|
raise configexc.ValidationError(value, "List cannot contain never!")
|
||||||
# Always can't be set with other options
|
# 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,
|
raise configexc.ValidationError(value,
|
||||||
"List cannot contain always!")
|
"List cannot contain always!")
|
||||||
# Values have to be valid
|
# Values have to be valid
|
||||||
@ -1269,17 +1271,17 @@ class ConfirmQuit(List):
|
|||||||
" values!")
|
" values!")
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
combinations = []
|
permutations = []
|
||||||
# Generate combinations of the options that can be combined
|
# Generate combinations of the options that can be combined
|
||||||
for size in range(2, len(self.combinable_values) + 1):
|
for size in range(2, len(self.combinable_values) + 1):
|
||||||
combinations = combinations + list(
|
permutations = permutations + list(
|
||||||
itertools.combinations(self.combinable_values, size))
|
itertools.permutations(self.combinable_values, size))
|
||||||
out = []
|
out = []
|
||||||
# Add valid single values
|
# Add valid single values
|
||||||
for val in self.valid_values:
|
for val in self.valid_values:
|
||||||
out.append((val, self.valid_values.descriptions[val]))
|
out.append((val, self.valid_values.descriptions[val]))
|
||||||
# Add combinations to list of options
|
# Add combinations to list of options
|
||||||
for val in combinations:
|
for val in permutations:
|
||||||
desc = ''
|
desc = ''
|
||||||
val = ','.join(val)
|
val = ','.join(val)
|
||||||
out.append((val, desc))
|
out.append((val, desc))
|
||||||
|
@ -331,24 +331,22 @@ class MainWindow(QWidget):
|
|||||||
download_manager = objreg.get('download-manager', scope='window',
|
download_manager = objreg.get('download-manager', scope='window',
|
||||||
window=self.win_id)
|
window=self.win_id)
|
||||||
download_count = download_manager.rowCount()
|
download_count = download_manager.rowCount()
|
||||||
quit_text = []
|
quit_texts = []
|
||||||
# Close if set to never ask for confirmation (backward compatible)
|
# Close if set to never ask for confirmation (backward compatible)
|
||||||
if confirm_quit == 'never' or 'never' in confirm_quit:
|
if confirm_quit == 'never' or 'never' in confirm_quit:
|
||||||
pass
|
pass
|
||||||
# Ask if set to always ask before closing
|
|
||||||
if 'always' in confirm_quit:
|
|
||||||
quit_text.append("Close?")
|
|
||||||
# Ask if multiple-tabs are open
|
# Ask if multiple-tabs are open
|
||||||
if 'multiple-tabs' in confirm_quit and tab_count > 1:
|
if 'multiple-tabs' in confirm_quit and tab_count > 1:
|
||||||
quit_text.append("Close {} {}?".format(
|
quit_texts.append("{} {} open.".format(
|
||||||
tab_count, "tab" if tab_count == 1 else "tabs"))
|
tab_count, "tab is" if tab_count == 1 else "tabs are"))
|
||||||
# Ask if multiple downloads running
|
# Ask if multiple downloads running
|
||||||
if 'downloads' in confirm_quit and download_count > 0:
|
if 'downloads' in confirm_quit and download_count > 0:
|
||||||
quit_text.append("Close {} {}?".format(
|
quit_texts.append("{} {} running.".format(
|
||||||
tab_count, "download" if tab_count == 1 else "downloads"))
|
tab_count,
|
||||||
|
"download is" if tab_count == 1 else "downloads are"))
|
||||||
# Process all quit messages that user must confirm
|
# Process all quit messages that user must confirm
|
||||||
if len(quit_text) > 0:
|
if quit_texts or 'always' in confirm_quit:
|
||||||
for text in quit_text:
|
text = '\n'.join(['Really quit?'] + quit_texts)
|
||||||
confirmed = message.ask(self.win_id, text,
|
confirmed = message.ask(self.win_id, text,
|
||||||
usertypes.PromptMode.yesno,
|
usertypes.PromptMode.yesno,
|
||||||
default=True)
|
default=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user