More intelligent auto hiding of toolbar text

This commit is contained in:
Kovid Goyal 2010-07-20 15:24:36 -06:00
parent 39797be6fe
commit c93189037c
2 changed files with 11 additions and 6 deletions

View File

@ -243,6 +243,7 @@ class ToolBar(QToolBar): # {{{
donate.setAutoRaise(True)
donate.setCursor(Qt.PointingHandCursor)
self.build_bar()
self.preferred_width = self.sizeHint().width()
def contextMenuEvent(self, *args):
pass
@ -295,11 +296,13 @@ class ToolBar(QToolBar): # {{{
a.setText(text)
def resizeEvent(self, ev):
style = Qt.ToolButtonTextUnderIcon
if self.size().width() < 1260:
style = Qt.ToolButtonIconOnly
self.setToolButtonStyle(style)
QToolBar.resizeEvent(self, ev)
style = Qt.ToolButtonTextUnderIcon
if self.preferred_width > self.width()+35:
style = Qt.ToolButtonIconOnly
self.setToolButtonStyle(style)
def database_changed(self, db):
pass
@ -309,7 +312,7 @@ class ToolBar(QToolBar): # {{{
class Action(QAction):
pass
class ShareConnMenu(QMenu):
class ShareConnMenu(QMenu): # {{{
connect_to_folder = pyqtSignal()
connect_to_itunes = pyqtSignal()
@ -363,6 +366,8 @@ class ShareConnMenu(QMenu):
def setup_email(self, *args):
self.config_email.emit()
# }}}
class MainWindowMixin(object):
def __init__(self, db):

View File

@ -84,7 +84,7 @@ class SearchBox2(QComboBox):
self.prev_search = ''
self.timer = QTimer()
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.timer_event, Qt.QueuedConnection)
self.timer.timeout.connect(self.timer_event, type=Qt.QueuedConnection)
self.setInsertPolicy(self.NoInsert)
self.setMaxCount(self.MAX_COUNT)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)