mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-28 02:23:58 +00:00
Add a clear button to the search line edit
This commit is contained in:
@@ -36,7 +36,7 @@ from picard.ui.options.dialog import OptionsDialog
|
||||
from picard.ui.infodialog import FileInfoDialog, AlbumInfoDialog
|
||||
from picard.ui.infostatus import InfoStatus
|
||||
from picard.ui.passworddialog import PasswordDialog
|
||||
from picard.ui.util import find_starting_directory
|
||||
from picard.ui.util import find_starting_directory, ButtonLineEdit
|
||||
from picard.util import icontheme, webbrowser2, throttle, thread
|
||||
from picard.util.cdrom import discid, get_cdrom_drives
|
||||
from picard.plugin import ExtensionPoint
|
||||
@@ -598,7 +598,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.search_combo.addItem(_(u"Artist"), "artist")
|
||||
self.search_combo.addItem(_(u"Track"), "track")
|
||||
hbox.addWidget(self.search_combo, 0)
|
||||
self.search_edit = QtGui.QLineEdit(search_panel)
|
||||
self.search_edit = ButtonLineEdit(search_panel)
|
||||
self.search_edit.returnPressed.connect(self.search)
|
||||
hbox.addWidget(self.search_edit, 0)
|
||||
self.search_button = QtGui.QToolButton(search_panel)
|
||||
|
||||
@@ -63,3 +63,28 @@ def find_starting_directory():
|
||||
else:
|
||||
path = config.persist["current_directory"] or QtCore.QDir.homePath()
|
||||
return find_existing_path(unicode(path))
|
||||
|
||||
|
||||
class ButtonLineEdit(QtGui.QLineEdit):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QLineEdit.__init__(self, parent)
|
||||
|
||||
self.clear_button = QtGui.QToolButton(self)
|
||||
self.clear_button.setVisible(False)
|
||||
self.clear_button.setCursor(QtCore.Qt.PointingHandCursor)
|
||||
self.clear_button.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.clear_button.setIcon(QtGui.QIcon.fromTheme("edit-clear"))
|
||||
self.clear_button.setStyleSheet(
|
||||
"QToolButton { background: transparent; border: none;} QToolButton QWidget { color: black;}")
|
||||
layout = QtGui.QHBoxLayout(self)
|
||||
layout.addWidget(self.clear_button, 0, QtCore.Qt.AlignRight)
|
||||
|
||||
layout.setSpacing(0)
|
||||
layout.setMargin(5)
|
||||
self.clear_button.setToolTip(_("Clear entry"))
|
||||
self.clear_button.clicked.connect(self.clear)
|
||||
self.textChanged.connect(self._update_clear_button)
|
||||
|
||||
def _update_clear_button(self, text):
|
||||
self.clear_button.setVisible(text != "")
|
||||
|
||||
Reference in New Issue
Block a user