Fix #1929300 [[Enhancement] Add a Clear button to clear the tab Advanced search of the Advanced search window](https://bugs.launchpad.net/calibre/+bug/1929300)

This commit is contained in:
Kovid Goyal 2021-05-23 08:03:29 +05:30
parent bf9248ddea
commit ef11d26921
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 106 additions and 44 deletions

View File

@ -30,6 +30,7 @@ class AdvSearchBuilderDialog(QDialog, Ui_Dialog):
self.tab_2_button_box.accepted.connect(self.accept)
self.tab_2_button_box.rejected.connect(self.reject)
self.clear_button.clicked.connect(self.clear_button_pushed)
self.advanced_clear_button.clicked.connect(self.clear_advanced)
self.adv_search_used = False
self.mc = ''
@ -56,6 +57,12 @@ class AdvSearchBuilderDialog(QDialog, Ui_Dialog):
self.download_combo.setCurrentIndex(0)
self.affiliate_combo.setCurrentIndex(0)
def clear_advanced(self):
self.all.setText('')
self.phrase.setText('')
self.any.setText('')
self.none.setText('')
def tokens(self, raw):
phrases = re.findall(r'\s*".*?"\s*', raw)
for f in phrases:

View File

@ -56,8 +56,8 @@
<attribute name="title">
<string>A&amp;dvanced search</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Find entries that have...</string>
@ -117,7 +117,7 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>But don't show entries that have...</string>
@ -159,15 +159,52 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="advanced_clear_button">
<property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<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>
</item>
</layout>
</widget>

View File

@ -24,6 +24,7 @@ class AdvSearchBuilderDialog(QDialog, Ui_Dialog):
self.tab_2_button_box.accepted.connect(self.accept)
self.tab_2_button_box.rejected.connect(self.reject)
self.clear_button.clicked.connect(self.clear_button_pushed)
self.advanced_clear_button.clicked.connect(self.clear_advanced)
self.adv_search_used = False
self.mc = ''
@ -46,6 +47,12 @@ class AdvSearchBuilderDialog(QDialog, Ui_Dialog):
self.author_box.setText('')
self.format_box.setText('')
def clear_advanced(self):
self.all.setText('')
self.phrase.setText('')
self.any.setText('')
self.none.setText('')
def tokens(self, raw):
phrases = re.findall(r'\s*".*?"\s*', raw)
for f in phrases:

View File

@ -14,7 +14,7 @@
<string>Advanced search</string>
</property>
<property name="windowIcon">
<iconset>
<iconset resource="../../../../../../resources/images.qrc">
<normaloff>:/images/search.png</normaloff>:/images/search.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -47,7 +47,7 @@
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" rowspan="2" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
@ -56,8 +56,8 @@
<attribute name="title">
<string>A&amp;dvanced search</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Find entries that have...</string>
@ -117,10 +117,10 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>But don&apos;t show entries that have...</string>
<string>But don't show entries that have...</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -149,7 +149,7 @@
</size>
</property>
<property name="text">
<string>See the &lt;a href=&quot;https://manual.calibre-ebook.com/gui.html#the-search-interface&quot;&gt;User Manual&lt;/a&gt; for more help</string>
<string>See the &lt;a href=&quot;https://manual.calibre-ebook.com/gui.html#the-search-interface&quot;&gt;User Manual&lt;/a&gt; for more help</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@ -159,7 +159,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -172,15 +172,39 @@
</property>
</spacer>
</item>
<item row="3" 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 class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="advanced_clear_button">
<property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<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>
</item>
</layout>
</widget>
@ -274,19 +298,6 @@
</widget>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_3">
<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>
<customwidgets>
@ -311,7 +322,7 @@
<tabstop>matchkind</tabstop>
</tabstops>
<resources>
<include location="../../../../resources/images.qrc"/>
<include location="../../../../../../resources/images.qrc"/>
</resources>
<connections>
<connection>
@ -321,8 +332,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>259</x>
<y>451</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@ -337,8 +348,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>327</x>
<y>451</y>
</hint>
<hint type="destinationlabel">
<x>286</x>