From c93189037cb73777bddda0f2a67b6e09d47af9b5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 20 Jul 2010 15:24:36 -0600 Subject: [PATCH] More intelligent auto hiding of toolbar text --- src/calibre/gui2/layout.py | 15 ++++++++++----- src/calibre/gui2/search_box.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index b0ddf5eb0d..7249d47122 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -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): diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 5c4a76b207..cb6791bb3b 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -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)