Make delete books confirmation dialog show by default

This commit is contained in:
Kovid Goyal 2008-12-29 15:04:13 -08:00
parent fbba5f5db4
commit 808bb2155b
5 changed files with 136 additions and 17 deletions

View File

@ -186,7 +186,6 @@ class ConfigDialog(QDialog, Ui_Dialog):
single_format = config['save_to_disk_single_format']
self.single_format.setCurrentIndex(BOOK_EXTENSIONS.index(single_format))
self.cover_browse.setValue(config['cover_flow_queue_length'])
self.confirm_delete.setChecked(config['confirm_delete'])
from calibre.translations.compiled import translations
from calibre.translations import language_codes
from calibre.startup import get_lang
@ -393,7 +392,6 @@ class ConfigDialog(QDialog, Ui_Dialog):
config['column_map'] = cols
config['toolbar_icon_size'] = self.ICON_SIZES[self.toolbar_button_size.currentIndex()]
config['show_text_in_toolbar'] = bool(self.show_toolbar_text.isChecked())
config['confirm_delete'] = bool(self.confirm_delete.isChecked())
pattern = self.filename_pattern.commit()
prefs['filename_pattern'] = pattern
p = {0:'normal', 1:'high', 2:'low'}[self.priority.currentIndex()]

View File

@ -72,7 +72,7 @@
</sizepolicy>
</property>
<property name="currentIndex" >
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="page_3" >
<layout class="QVBoxLayout" name="verticalLayout" >
@ -127,17 +127,10 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="confirm_delete" >
<property name="text" >
<string>Ask for &amp;confirmation before deleting files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pdf_metadata" >
<property name="toolTip" >
<string>If you disable this setting, metadatas is guessed from the filename instead. This can be configured in the Advanced section.</string>
<string>If you disable this setting, metadata is guessed from the filename instead. This can be configured in the Advanced section.</string>
</property>
<property name="text" >
<string>Read &amp;metadata from files</string>

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
from calibre.gui2 import dynamic
from calibre.gui2.dialogs.confirm_delete_ui import Ui_Dialog
from PyQt4.Qt import QDialog, SIGNAL
def _config_name(name):
return name + '_again'
class Dialog(QDialog, Ui_Dialog):
def __init__(self, msg, name, parent):
QDialog.__init__(self, parent)
self.setupUi(self)
self.msg.setText(msg)
self.name = name
self.connect(self.again, SIGNAL('stateChanged(int)'), self.toggle)
def toggle(self, x):
dynamic[_config_name(self.name)] = self.again.isChecked()
def confirm(msg, name, parent=None):
if not dynamic.get(_config_name(name), True):
return True
d = Dialog(msg, name, parent)
return d.exec_() == d.Accepted

View File

@ -0,0 +1,100 @@
<ui version="4.0" >
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Are you sure?</string>
</property>
<property name="windowIcon" >
<iconset resource="../images.qrc" >
<normaloff>:/images/dialog_warning.svg</normaloff>:/images/dialog_warning.svg</iconset>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="pixmap" >
<pixmap resource="../images.qrc" >:/images/dialog_warning.svg</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="msg" >
<property name="text" >
<string>TextLabel</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="again" >
<property name="text" >
<string>&amp;Show this warning again</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc" />
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -49,6 +49,7 @@ from calibre.library.database2 import LibraryDatabase2, CoverCache
from calibre.parallel import JobKilled
from calibre.utils.filenames import ascii_filename
from calibre.gui2.widgets import WarningDialog
from calibre.gui2.dialogs.confirm_delete import confirm
class Main(MainWindow, Ui_MainWindow):
@ -758,13 +759,9 @@ class Main(MainWindow, Ui_MainWindow):
rows = view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
return
if config['confirm_delete']:
d = question_dialog(self, _('Confirm delete'),
_('Are you sure you want to delete these %d books?')%len(rows))
if d.exec_() != QMessageBox.Yes:
return
if self.stack.currentIndex() == 0:
if not confirm('<p>'+_('The selected books will be <b>permanently deleted</b> and the files removed from your computer. Are you sure?')+'</p>', 'library_delete_books', self):
return
view.model().delete_books(rows)
else:
view = self.memory_view if self.stack.currentIndex() == 1 else self.card_view