mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Preferences->Ignored devices: Add a button to reset the list of devices that calibre is allowed to manage
This commit is contained in:
parent
a78bf9f21d
commit
acc6beaad8
@ -1,15 +1,16 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
||||||
|
# License: GPLv3 Copyright: 2012, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
import textwrap
|
||||||
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
from PyQt5.Qt import (QLabel, QVBoxLayout, QListWidget, QListWidgetItem, Qt,
|
from PyQt5.Qt import (
|
||||||
QIcon)
|
QIcon, QLabel, QListWidget, QListWidgetItem, QPushButton, Qt, QVBoxLayout
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.customize.ui import enable_plugin
|
from calibre.customize.ui import enable_plugin
|
||||||
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||||
from polyglot.builtins import iteritems, range
|
from polyglot.builtins import iteritems, range
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
self.gui = gui
|
self.gui = gui
|
||||||
self.l = l = QVBoxLayout()
|
self.l = l = QVBoxLayout()
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
|
self.confirms_reset = False
|
||||||
|
|
||||||
self.la = la = QLabel(_(
|
self.la = la = QLabel(_(
|
||||||
'The list of devices that you have asked calibre to ignore. '
|
'The list of devices that you have asked calibre to ignore. '
|
||||||
@ -46,11 +48,24 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
f.itemChanged.connect(self.changed_signal)
|
f.itemChanged.connect(self.changed_signal)
|
||||||
f.itemDoubleClicked.connect(self.toggle_item)
|
f.itemDoubleClicked.connect(self.toggle_item)
|
||||||
|
|
||||||
|
self.reset_confirmations_button = b = QPushButton(_('Reset allowed devices'))
|
||||||
|
b.setToolTip(textwrap.fill(_(
|
||||||
|
'This will erase the list of devices that calibre knows about'
|
||||||
|
' causing it to ask you for permission to manage them again,'
|
||||||
|
' the next time they connect')))
|
||||||
|
b.clicked.connect(self.reset_confirmations)
|
||||||
|
l.addWidget(b)
|
||||||
|
|
||||||
|
def reset_confirmations(self):
|
||||||
|
self.confirms_reset = True
|
||||||
|
self.changed_signal.emit()
|
||||||
|
|
||||||
def toggle_item(self, item):
|
def toggle_item(self, item):
|
||||||
item.setCheckState(Qt.Checked if item.checkState() == Qt.Unchecked else
|
item.setCheckState(Qt.Checked if item.checkState() == Qt.Unchecked else
|
||||||
Qt.Unchecked)
|
Qt.Unchecked)
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
|
self.confirms_reset = False
|
||||||
self.devices.blockSignals(True)
|
self.devices.blockSignals(True)
|
||||||
self.devices.clear()
|
self.devices.clear()
|
||||||
for dev in self.gui.device_manager.devices:
|
for dev in self.gui.device_manager.devices:
|
||||||
@ -94,11 +109,13 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
dev = e.data(Qt.UserRole)
|
dev = e.data(Qt.UserRole)
|
||||||
if e.checkState() == Qt.Unchecked:
|
if e.checkState() == Qt.Unchecked:
|
||||||
enable_plugin(dev)
|
enable_plugin(dev)
|
||||||
|
if self.confirms_reset:
|
||||||
|
gprefs['ask_to_manage_device'] = []
|
||||||
|
|
||||||
return True # Restart required
|
return True # Restart required
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from PyQt5.Qt import QApplication
|
from calibre.gui2 import Application
|
||||||
app = QApplication([])
|
app = Application([])
|
||||||
test_widget('Sharing', 'Ignored Devices')
|
test_widget('Sharing', 'Ignored Devices')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user