Fixes #1922405 [Make the Create/edit a column icon rule window narrower](https://bugs.launchpad.net/calibre/+bug/1922405)
This commit is contained in:
Kovid Goyal 2021-04-03 18:28:13 +05:30
commit b4b2108546
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 48 additions and 17 deletions

View File

@ -224,7 +224,7 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="go_button"> <widget class="QToolButton" name="go_button">
<property name="text"> <property name="text">
<string>&amp;Go</string> <string>&amp;Go</string>
</property> </property>
@ -232,8 +232,8 @@ you the value as well as all the local variables&lt;/p&gt;</string>
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/sync-right.png</normaloff>:/images/sync-right.png</iconset> <normaloff>:/images/sync-right.png</normaloff>:/images/sync-right.png</iconset>
</property> </property>
<property name="styleSheet"> <property name="toolButtonStyle">
<string notr="true">padding: 5; padding-left: 1;</string> <set>Qt::ToolButtonTextBesideIcon</set>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>If 'Enable breakpoints' is checked then click this button to run your template</string> <string>If 'Enable breakpoints' is checked then click this button to run your template</string>
@ -286,12 +286,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="toggle_button"> <widget class="QToolButton" name="toggle_button">
<property name="text"> <property name="text">
<string>&amp;Toggle</string> <string>&amp;Toggle</string>
</property> </property>
<property name="styleSheet"> <property name="toolButtonStyle">
<string notr="true">padding: 5; padding-left: 1;</string> <set>Qt::ToolButtonTextBesideIcon</set>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
@ -316,12 +316,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="remove_all_button"> <widget class="QToolButton" name="remove_all_button">
<property name="text"> <property name="text">
<string>&amp;Remove all</string> <string>&amp;Remove all</string>
</property> </property>
<property name="styleSheet"> <property name="toolButtonStyle">
<string notr="true">padding: 5; padding-left: 1;</string> <set>Qt::ToolButtonTextBesideIcon</set>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
@ -333,12 +333,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="set_all_button"> <widget class="QToolButton" name="set_all_button">
<property name="text"> <property name="text">
<string>&amp;Set all</string> <string>&amp;Set all</string>
</property> </property>
<property name="styleSheet"> <property name="toolButtonStyle">
<string notr="true">padding: 5; padding-left: 1;</string> <set>Qt::ToolButtonTextBesideIcon</set>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">

View File

@ -12,7 +12,8 @@ from qt.core import (QWidget, QDialog, QLabel, QGridLayout, QComboBox, QSize,
QLineEdit, QIntValidator, QDoubleValidator, QFrame, Qt, QIcon, QHBoxLayout, QLineEdit, QIntValidator, QDoubleValidator, QFrame, Qt, QIcon, QHBoxLayout,
QScrollArea, QPushButton, QVBoxLayout, QDialogButtonBox, QToolButton, QItemSelectionModel, QScrollArea, QPushButton, QVBoxLayout, QDialogButtonBox, QToolButton, QItemSelectionModel,
QListView, QAbstractListModel, pyqtSignal, QSizePolicy, QSpacerItem, QPalette, QListView, QAbstractListModel, pyqtSignal, QSizePolicy, QSpacerItem, QPalette,
QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu, QAbstractItemView) QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu, QAbstractItemView,
QColor, QBrush, QPixmap, QPainter)
from calibre import prepare_string_for_xml, sanitize_file_name, as_unicode from calibre import prepare_string_for_xml, sanitize_file_name, as_unicode
from calibre.constants import config_dir from calibre.constants import config_dir
@ -21,7 +22,7 @@ from calibre.gui2 import (error_dialog, choose_files, pixmap_to_data, gprefs,
choose_save_file, open_local_file) choose_save_file, open_local_file)
from calibre.gui2.dialogs.template_dialog import TemplateDialog from calibre.gui2.dialogs.template_dialog import TemplateDialog
from calibre.gui2.metadata.single_download import RichTextDelegate from calibre.gui2.metadata.single_download import RichTextDelegate
from calibre.gui2.widgets2 import ColorButton from calibre.gui2.widgets2 import ColorButton, FlowLayout
from calibre.library.coloring import (Rule, conditionable_columns, from calibre.library.coloring import (Rule, conditionable_columns,
displayable_columns, rule_from_template, color_row_key) displayable_columns, rule_from_template, color_row_key)
from calibre.utils.localization import lang_map from calibre.utils.localization import lang_map
@ -895,6 +896,33 @@ class RulesView(QListView): # {{{
# }}} # }}}
class Separator(QWidget): # {{{
def __init__(self, parent, widget_for_height):
QWidget.__init__(self, parent)
self.bcol = QColor(QPalette.ColorRole.Text)
self.update_brush()
self.widget_for_height = widget_for_height
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.MinimumExpanding)
def update_brush(self):
self.brush = QBrush(self.bcol)
self.update()
def sizeHint(self):
return QSize(1, self.widget_for_height.height())
def paintEvent(self, ev):
painter = QPainter(self)
# Purely subjective: shorten the line a bit to look 'better'
r = ev.rect()
r.setTop(r.top() + 3)
r.setBottom(r.bottom() - 3)
painter.fillRect(r, self.brush)
painter.end()
# }}}
class EditRules(QWidget): # {{{ class EditRules(QWidget): # {{{
changed = pyqtSignal() changed = pyqtSignal()
@ -949,7 +977,7 @@ class EditRules(QWidget): # {{{
self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')), self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
_('Add ad&vanced rule'), self) _('Add ad&vanced rule'), self)
b.clicked.connect(self.add_advanced) b.clicked.connect(self.add_advanced)
self.hb = hb = QHBoxLayout() self.hb = hb = FlowLayout()
l.addLayout(hb, l.rowCount(), 0, 1, 2) l.addLayout(hb, l.rowCount(), 0, 1, 2)
hb.addWidget(b) hb.addWidget(b)
self.duplicate_rule_button = b = QPushButton(QIcon(I('edit-copy.png')), self.duplicate_rule_button = b = QPushButton(QIcon(I('edit-copy.png')),
@ -962,13 +990,16 @@ class EditRules(QWidget): # {{{
b.clicked.connect(self.convert_to_advanced) b.clicked.connect(self.convert_to_advanced)
b.setEnabled(False) b.setEnabled(False)
hb.addWidget(b) hb.addWidget(b)
hb.addStretch(10) sep = Separator(self, b)
hb.addWidget(sep)
self.open_icon_folder_button = b = QPushButton(QIcon(I('icon_choose.png')), self.open_icon_folder_button = b = QPushButton(QIcon(I('icon_choose.png')),
_('Open icon folder'), self) _('Open icon folder'), self)
connect_lambda(b.clicked, self, connect_lambda(b.clicked, self,
lambda _: open_local_file(os.path.join(config_dir, 'cc_icons'))) lambda _: open_local_file(os.path.join(config_dir, 'cc_icons')))
hb.addWidget(b) hb.addWidget(b)
hb.addStretch(10) sep = Separator(self, b)
hb.addWidget(sep)
self.export_button = b = QPushButton(_('E&xport'), self) self.export_button = b = QPushButton(_('E&xport'), self)
b.clicked.connect(self.export_rules) b.clicked.connect(self.export_rules)
b.setToolTip(_('Export these rules to a file')) b.setToolTip(_('Export these rules to a file'))