Fix #1857923 [[Enhancement] Remeber last paths in automatic adding](https://bugs.launchpad.net/calibre/+bug/1857923)

This commit is contained in:
Kovid Goyal 2019-12-31 08:08:02 +05:30
parent f24fbd5312
commit bf83df219c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 18 additions and 6 deletions

View File

@ -63,9 +63,6 @@
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="opt_debug_pipeline">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>

View File

@ -15,6 +15,7 @@ from PyQt5.Qt import (QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox, QApplica
from calibre.customize.ui import preferences_plugins
from calibre.utils.config import ConfigProxy
from calibre.gui2.complete2 import EditWithComplete
from calibre.gui2.widgets import HistoryLineEdit
from polyglot.builtins import unicode_type, string_or_bytes
@ -109,9 +110,11 @@ class Setting(object):
elif isinstance(self.gui_obj, QAbstractSpinBox):
self.datatype = 'number'
self.gui_obj.valueChanged.connect(self.changed)
elif isinstance(self.gui_obj, QLineEdit):
elif isinstance(self.gui_obj, (QLineEdit, HistoryLineEdit)):
self.datatype = 'string'
self.gui_obj.textChanged.connect(self.changed)
if isinstance(self.gui_obj, HistoryLineEdit):
self.gui_obj.initialize('preferences_setting_' + self.name)
elif isinstance(self.gui_obj, QComboBox):
self.datatype = 'choice'
self.gui_obj.editTextChanged.connect(self.changed)

View File

@ -93,6 +93,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
_('Choose a folder'))
if path:
self.opt_auto_add_path.setText(path)
self.opt_auto_add_path.save_history()
def initialize(self):
ConfigWidgetBase.initialize(self)

View File

@ -17,7 +17,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -313,10 +313,13 @@ that have been explicitly ignored below.</string>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="opt_auto_add_path">
<widget class="HistoryLineEdit" name="opt_auto_add_path">
<property name="placeholderText">
<string>Folder to automatically add files from</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -436,6 +439,13 @@ that have been explicitly ignored below.</string>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>calibre/gui2/widgets.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>
</resources>

View File

@ -669,6 +669,7 @@ class HistoryLineEdit(QComboBox): # {{{
self.setInsertPolicy(self.NoInsert)
self.setMaxCount(10)
self.setClearButtonEnabled = self.lineEdit().setClearButtonEnabled
self.textChanged = self.editTextChanged
def setPlaceholderText(self, txt):
return self.lineEdit().setPlaceholderText(txt)