Commit 35729ede authored by Dan Pascu's avatar Dan Pascu

Added LocationBar widget

parent e26e9238
# Copyright (c) 2010 AG Projects. See LICENSE for details.
#
__all__ = ['LineEdit', 'ValidatingLineEdit', 'SearchBox']
__all__ = ['LineEdit', 'ValidatingLineEdit', 'SearchBox', 'LocationBar']
import re
......@@ -275,3 +275,27 @@ class SearchBox(LineEdit):
self.clear_button.setVisible(not text.isEmpty())
class LocationBar(LineEdit):
locationCleared = pyqtSignal()
def __init__(self, parent=None):
LineEdit.__init__(self, parent=parent)
self.clear_button = ClearButton(self)
self.addTailWidget(self.clear_button)
option = QStyleOptionFrameV2()
self.initStyleOption(option)
frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, self)
widgets_height = self.clear_button.minimumHeight()
self.setMinimumHeight(widgets_height + 2 + 2*frame_width)
self.clear_button.hide()
self.clear_button.clicked.connect(self._SH_ClearButtonClicked)
self.textChanged.connect(self._SH_TextChanged)
def _SH_ClearButtonClicked(self):
self.clear()
self.locationCleared.emit()
def _SH_TextChanged(self, text):
self.clear_button.setVisible(not text.isEmpty())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment