Browse Source

Add option to confirm item deletion

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
2be3ee426e
4 changed files with 33 additions and 19 deletions
  1. 1
      TODO
  2. 42
      youtube_dl_gui/mainframe.py
  3. 4
      youtube_dl_gui/optionsframe.py
  4. 5
      youtube_dl_gui/optionsmanager.py

1
TODO

@ -1,6 +1,5 @@
NEW_LAYOUT
==========
* Option to validate item deletion 'Are you sure?'
* Add '--recode-video' to Formats tab
* Show dialog with timer on shutdown
* Localization option: add country flags

42
youtube_dl_gui/mainframe.py

@ -499,28 +499,36 @@ class MainFrame(wx.Frame):
self._status_list.remove_row(self._download_list.index(ditem.object_id))
self._download_list.remove(ditem.object_id)
else:
while index >= 0:
object_id = self._status_list.GetItemData(index)
selected_download_item = self._download_list.get_item(object_id)
if self.opt_manager.options["confirm_deletion"]:
dlg = wx.MessageDialog(self, "Are you sure you want to remove selected items?", "Delete", wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal() == wx.ID_YES
dlg.Destroy()
else:
result = True
if selected_download_item.stage == "Active":
self._create_popup("Item is active, cannot remove", self.WARNING_LABEL, wx.OK | wx.ICON_EXCLAMATION)
else:
#if selected_download_item.stage == "Completed":
#dlg = wx.MessageDialog(self, "Do you want to remove the files associated with this item?", "Remove files", wx.YES_NO | wx.ICON_QUESTION)
if result:
while index >= 0:
object_id = self._status_list.GetItemData(index)
selected_download_item = self._download_list.get_item(object_id)
#result = dlg.ShowModal() == wx.ID_YES
#dlg.Destroy()
if selected_download_item.stage == "Active":
self._create_popup("Item is active, cannot remove", self.WARNING_LABEL, wx.OK | wx.ICON_EXCLAMATION)
else:
#if selected_download_item.stage == "Completed":
#dlg = wx.MessageDialog(self, "Do you want to remove the files associated with this item?", "Remove files", wx.YES_NO | wx.ICON_QUESTION)
#if result:
#for cur_file in selected_download_item.get_files():
#remove_file(cur_file)
#result = dlg.ShowModal() == wx.ID_YES
#dlg.Destroy()
self._status_list.remove_row(index)
self._download_list.remove(object_id)
index -= 1
#if result:
#for cur_file in selected_download_item.get_files():
#remove_file(cur_file)
index = self._status_list.get_next_selected(index)
self._status_list.remove_row(index)
self._download_list.remove(object_id)
index -= 1
index = self._status_list.get_next_selected(index)
self._update_pause_button(None)

4
youtube_dl_gui/optionsframe.py

@ -297,6 +297,7 @@ class GeneralTab(TabPanel):
self.more_opts_label = self.crt_statictext("More options")
self.confirm_exit_checkbox = self.crt_checkbox("Confirm on exit")
self.confirm_deletion_checkbox = self.crt_checkbox("Confirm item deletion")
self.show_completion_popup_checkbox = self.crt_checkbox("Inform me on download completion")
self.shutdown_checkbox = self.crt_checkbox("Shutdown on download completion", event_handler=self._on_shutdown)
@ -334,6 +335,7 @@ class GeneralTab(TabPanel):
vertical_sizer.Add(self.more_opts_label, flag=wx.TOP, border=5)
vertical_sizer.Add(self.confirm_exit_checkbox, flag=wx.ALL, border=5)
vertical_sizer.Add(self.confirm_deletion_checkbox, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
vertical_sizer.Add(self.show_completion_popup_checkbox, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
shutdown_sizer = wx.BoxSizer(wx.HORIZONTAL)
@ -412,6 +414,7 @@ class GeneralTab(TabPanel):
self.sudo_textctrl.SetValue(self.opt_manager.options["sudo_password"])
self.confirm_exit_checkbox.SetValue(self.opt_manager.options["confirm_exit"])
self.show_completion_popup_checkbox.SetValue(self.opt_manager.options["show_completion_popup"])
self.confirm_deletion_checkbox.SetValue(self.opt_manager.options["confirm_deletion"])
#REFACTOR Automatically call on the new methods
#save_options
@ -429,6 +432,7 @@ class GeneralTab(TabPanel):
self.opt_manager.options["sudo_password"] = self.sudo_textctrl.GetValue()
self.opt_manager.options["confirm_exit"] = self.confirm_exit_checkbox.GetValue()
self.opt_manager.options["show_completion_popup"] = self.show_completion_popup_checkbox.GetValue()
self.opt_manager.options["confirm_deletion"] = self.confirm_deletion_checkbox.GetValue()
class FormatsTab(TabPanel):

5
youtube_dl_gui/optionsmanager.py

@ -220,6 +220,8 @@ class OptionsManager(object):
show_completion_popup (boolean): When True youtube-dl-gui will create a popup
to inform the user for the download completion.
confirm_deletion (boolean): When True ask user before item removal.
"""
#TODO Remove old options & check options validation
self.options = {
@ -281,7 +283,8 @@ class OptionsManager(object):
'ignore_config': True,
'confirm_exit': True,
'native_hls': True,
'show_completion_popup': True
'show_completion_popup': True,
'confirm_deletion': True
}
def load_from_file(self):

Loading…
Cancel
Save