def __init__(self, parent): QWidget.__init__(self, parent) self._layout = l = QHBoxLayout() self.setLayout(self._layout) self._layout.setContentsMargins(0, 5, 0, 0) x = QToolButton(self) x.setText(_('Vi&rtual Library')) x.setIcon(QIcon(I('lt.png'))) x.setObjectName("virtual_library") x.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) l.addWidget(x) parent.virtual_library = x x = QToolButton(self) x.setIcon(QIcon(I('minus.png'))) x.setObjectName('clear_vl') l.addWidget(x) x.setVisible(False) x.setToolTip(_('Close the Virtual Library')) parent.clear_vl = x x = QLabel(self) x.setObjectName("search_count") l.addWidget(x) parent.search_count = x x.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) parent.advanced_search_button = x = QToolButton(self) parent.advanced_search_toggle_action = ac = QAction(parent) parent.addAction(ac) parent.keyboard.register_shortcut('advanced search toggle', _('Advanced search'), default_keys=("Shift+Ctrl+F", ), action=ac) ac.triggered.connect(x.click) x.setIcon(QIcon(I('search.png'))) l.addWidget(x) x.setToolTip(_("Advanced search")) x = parent.search = SearchBox2(self) x.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) x.setObjectName("search") x.setToolTip( _("<p>Search the list of books by title, author, publisher, " "tags, comments, etc.<br><br>Words separated by spaces are ANDed" )) x.setMinimumContentsLength(10) l.addWidget(x) self.search_button = QToolButton() self.search_button.setToolButtonStyle(Qt.ToolButtonTextOnly) self.search_button.setText(_('&Go!')) l.addWidget(self.search_button) self.search_button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.search_button.clicked.connect(parent.do_search_button) self.search_button.setToolTip( _('Do Quick Search (you can also press the Enter key)')) x = parent.clear_button = QToolButton(self) x.setIcon(QIcon(I('clear_left.png'))) x.setObjectName("clear_button") l.addWidget(x) x.setToolTip(_("Reset Quick Search")) x = parent.highlight_only_button = QToolButton(self) x.setIcon(QIcon(I('arrow-down.png'))) l.addWidget(x) x = parent.saved_search = SavedSearchBox(self) x.setMaximumSize(QSize(150, 16777215)) x.setMinimumContentsLength(10) x.setObjectName("saved_search") l.addWidget(x) x = parent.copy_search_button = QToolButton(self) x.setIcon(QIcon(I("search_copy_saved.png"))) x.setObjectName("copy_search_button") l.addWidget(x) x.setToolTip(_("Copy current search text (instead of search name)")) x = parent.save_search_button = RightClickButton(self) x.setIcon(QIcon(I("search_add_saved.png"))) x.setObjectName("save_search_button") l.addWidget(x)
def __init__(self, parent): QFrame.__init__(self, parent) self.setFrameStyle(QFrame.Shape.NoFrame) self.setObjectName('search_bar') self._layout = l = QHBoxLayout(self) l.setContentsMargins(0, 4, 0, 4) x = parent.virtual_library = QToolButton(self) x.setCursor(Qt.CursorShape.PointingHandCursor) x.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) x.setText(_('Virtual library')) x.setAutoRaise(True) x.setIcon(QIcon(I('vl.png'))) x.setObjectName("virtual_library") x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) l.addWidget(x) x = QToolButton(self) x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) x.setAutoRaise(True) x.setIcon(QIcon(I('minus.png'))) x.setObjectName('clear_vl') l.addWidget(x) x.setVisible(False) x.setToolTip(_('Close the Virtual library')) parent.clear_vl = x self.vl_sep = QFrame(self) self.vl_sep.setFrameStyle(QFrame.Shape.VLine | QFrame.Shadow.Sunken) l.addWidget(self.vl_sep) parent.sort_sep = QFrame(self) parent.sort_sep.setFrameStyle(QFrame.Shape.VLine | QFrame.Shadow.Sunken) parent.sort_sep.setVisible(False) parent.sort_button = self.sort_button = sb = QToolButton(self) sb.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) sb.setToolTip(_('Change how the displayed books are sorted')) sb.setCursor(Qt.CursorShape.PointingHandCursor) sb.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) sb.setAutoRaise(True) sb.setText(_('Sort')) sb.setIcon(QIcon(I('sort.png'))) sb.setMenu(QMenu(sb)) sb.menu().aboutToShow.connect(self.populate_sort_menu) sb.setVisible(False) l.addWidget(sb) l.addWidget(parent.sort_sep) x = parent.search = SearchBox2(self, as_url=search_as_url) x.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) x.setObjectName("search") x.setToolTip(_("<p>Search the list of books by title, author, publisher, " "tags, comments, etc.<br><br>Words separated by spaces are ANDed")) x.setMinimumContentsLength(10) l.addWidget(x) parent.advanced_search_toggle_action = ac = parent.search.add_action('gear.png', QLineEdit.ActionPosition.LeadingPosition) parent.addAction(ac) ac.setToolTip(_('Advanced search')) parent.keyboard.register_shortcut('advanced search toggle', _('Advanced search'), default_keys=("Shift+Ctrl+F",), action=ac) self.search_button = QToolButton() self.search_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly) self.search_button.setIcon(QIcon(I('search.png'))) self.search_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) self.search_button.setText(_('Search')) self.search_button.setAutoRaise(True) self.search_button.setCursor(Qt.CursorShape.PointingHandCursor) l.addWidget(self.search_button) self.search_button.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) self.search_button.clicked.connect(parent.do_search_button) self.search_button.setToolTip( _('Do quick search (you can also press the Enter key)')) x = parent.highlight_only_button = QToolButton(self) x.setAutoRaise(True) x.setText(_('Highlight')) x.setCursor(Qt.CursorShape.PointingHandCursor) x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) x.setIcon(QIcon(I('arrow-down.png'))) l.addWidget(x) x = parent.saved_search = SavedSearchBox(self) x.setMaximumSize(QSize(150, 16777215)) x.setMinimumContentsLength(10) x.setObjectName("saved_search") l.addWidget(x) x.setVisible(tweaks['show_saved_search_box']) x = parent.copy_search_button = QToolButton(self) x.setAutoRaise(True) x.setCursor(Qt.CursorShape.PointingHandCursor) x.setIcon(QIcon(I("search_copy_saved.png"))) x.setObjectName("copy_search_button") l.addWidget(x) x.setToolTip(_("Copy current search text (instead of search name)")) x.setVisible(tweaks['show_saved_search_box']) x = parent.save_search_button = RightClickButton(self) x.setAutoRaise(True) x.setCursor(Qt.CursorShape.PointingHandCursor) x.setIcon(QIcon(I("search_add_saved.png"))) x.setObjectName("save_search_button") l.addWidget(x) x.setVisible(tweaks['show_saved_search_box']) x = parent.add_saved_search_button = RightClickButton(self) x.setToolTip(_( 'Use an existing Saved search or create a new one' )) x.setText(_('Saved search')) x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) x.setCursor(Qt.CursorShape.PointingHandCursor) x.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) x.setAutoRaise(True) x.setIcon(QIcon(I("bookmarks.png"))) l.addWidget(x) x.setVisible(not tweaks['show_saved_search_box'])