Auto adding: Option to auto add files of all types, not just ebooks

Auto adding: Option to add files of all types, not just ebooks. You can
now tell calibre to auto add all file types, instead of just known
ebooks via Preferences->Adding books->Automatic adding. Fixes #1252814 [[Enhancement] Automatic Add functionality for all file types](https://bugs.launchpad.net/calibre/+bug/1252814)
This commit is contained in:
Kovid Goyal 2013-11-20 09:46:21 +05:30
parent 220c918ab0
commit e22587dbc2
4 changed files with 72 additions and 47 deletions

View File

@ -102,6 +102,7 @@ defs['auto_add_path'] = None
defs['auto_add_check_for_duplicates'] = False
defs['blocked_auto_formats'] = []
defs['auto_add_auto_convert'] = True
defs['auto_add_everything'] = False
defs['ui_style'] = 'calibre' if iswindows or isosx else 'system'
defs['tag_browser_old_look'] = False
defs['book_list_tooltips'] = True

View File

@ -20,6 +20,14 @@ from calibre.gui2.dialogs.duplicates import DuplicatesQuestion
AUTO_ADDED = frozenset(BOOK_EXTENSIONS) - {'pdr', 'mbp', 'tan'}
class AllAllowed(object):
def __init__(self):
self.disallowed = frozenset(gprefs['blocked_auto_formats'])
def __contains__(self, x):
return x not in self.disallowed
class Worker(Thread):
def __init__(self, path, callback):
@ -29,7 +37,10 @@ class Worker(Thread):
self.wake_up = Event()
self.path, self.callback = path, callback
self.staging = set()
self.allowed = AUTO_ADDED - frozenset(gprefs['blocked_auto_formats'])
if gprefs['auto_add_everything']:
self.allowed = AllAllowed()
else:
self.allowed = AUTO_ADDED - frozenset(gprefs['blocked_auto_formats'])
def run(self):
self.tdir = PersistentTemporaryDirectory('_auto_adder')

View File

@ -38,6 +38,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('new_book_tags', prefs, setting=CommaSeparatedList)
r('mark_new_books', prefs)
r('auto_add_path', gprefs, restart_required=True)
r('auto_add_everything', gprefs, restart_required=True)
r('auto_add_check_for_duplicates', gprefs)
r('auto_add_auto_convert', gprefs)

View File

@ -173,6 +173,63 @@ Title match ignores leading indefinite articles ("the", "a",
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="5" column="0">
<widget class="QCheckBox" name="opt_auto_add_everything">
<property name="toolTip">
<string>By default, calibre will auto-add only known ebook files.
This option tells calibre to add all file types, except those
that have been explicitly ignored below.</string>
</property>
<property name="text">
<string>Auto add files of &amp;all types (not just ebooks)</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="opt_auto_add_path">
<property name="placeholderText">
<string>Folder to auto-add files from</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="auto_add_browse_button">
<property name="toolTip">
<string>Browse for folder</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/document_open.png</normaloff>:/images/document_open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="opt_auto_add_auto_convert">
<property name="text">
<string>Automatically &amp;convert added files to the current output format</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QGroupBox" name="groupBox">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -228,7 +285,7 @@ Title match ignores leading indefinite articles (&quot;the&quot;, &quot;a&quot;,
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -241,51 +298,6 @@ Title match ignores leading indefinite articles (&quot;the&quot;, &quot;a&quot;,
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="opt_auto_add_path">
<property name="placeholderText">
<string>Folder to auto-add files from</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="auto_add_browse_button">
<property name="toolTip">
<string>Browse for folder</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/document_open.png</normaloff>:/images/document_open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="opt_auto_add_auto_convert">
<property name="text">
<string>Automatically &amp;convert added files to the current output format</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>