Browse Source

Implement confirm on exit option functionality

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
ebe96f3c9c
3 changed files with 18 additions and 4 deletions
  1. 12
      youtube_dl_gui/mainframe.py
  2. 5
      youtube_dl_gui/optionsframe.py
  3. 5
      youtube_dl_gui/optionsmanager.py

12
youtube_dl_gui/mainframe.py

@ -999,6 +999,18 @@ class MainFrame(wx.Frame):
processes are not running.
"""
if self.opt_manager.options["confirm_exit"]:
dlg = wx.MessageDialog(self, "Are you sure you want to exit?", "Exit", wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal() == wx.ID_YES
dlg.Destroy()
else:
result = True
if result:
self.close()
def close(self):
if self.download_manager is not None:
self.download_manager.stop_downloads()
self.download_manager.join()

5
youtube_dl_gui/optionsframe.py

@ -306,7 +306,6 @@ class GeneralTab(TabPanel):
self._set_layout()
self.confirm_exit_checkbox.Disable()
if os.name == "nt":
self.sudo_textctrl.Hide()
@ -401,8 +400,6 @@ class GeneralTab(TabPanel):
"""Event handler for the wx.EVT_CHECKBOX of the shutdown_checkbox."""
self.sudo_textctrl.Enable(self.shutdown_checkbox.GetValue())
#TODO Implement load-save for confirm_exit_checkbox widget
def load_options(self):
self.language_combobox.SetValue(self.LOCALE_NAMES[self.opt_manager.options["locale_name"]])
self.filename_format_combobox.SetValue(OUTPUT_FORMATS[self.opt_manager.options["output_format"]])
@ -410,6 +407,7 @@ class GeneralTab(TabPanel):
self.filename_ascii_checkbox.SetValue(self.opt_manager.options["restrict_filenames"])
self.shutdown_checkbox.SetValue(self.opt_manager.options["shutdown"])
self.sudo_textctrl.SetValue(self.opt_manager.options["sudo_password"])
self.confirm_exit_checkbox.SetValue(self.opt_manager.options["confirm_exit"])
#REFACTOR Automatically call on the new methods
#save_options
@ -425,6 +423,7 @@ class GeneralTab(TabPanel):
self.opt_manager.options["restrict_filenames"] = self.filename_ascii_checkbox.GetValue()
self.opt_manager.options["shutdown"] = self.shutdown_checkbox.GetValue()
self.opt_manager.options["sudo_password"] = self.sudo_textctrl.GetValue()
self.opt_manager.options["confirm_exit"] = self.confirm_exit_checkbox.GetValue()
class FormatsTab(TabPanel):

5
youtube_dl_gui/optionsmanager.py

@ -213,6 +213,8 @@ class OptionsManager(object):
ignore_config (boolean): When True will ignore youtube-dl config file options.
confirm_exit (boolean): When True create popup to confirm exiting youtube-dl-gui.
"""
#TODO Remove old options & check options validation
self.options = {
@ -271,7 +273,8 @@ class OptionsManager(object):
'selected_audio_formats': ['mp3', 'm4a', 'vorbis'],
'selected_format': '0',
'youtube_dl_debug': False,
'ignore_config': True
'ignore_config': True,
'confirm_exit': True
}
def load_from_file(self):

Loading…
Cancel
Save