Auto hide Tab-bar and Statusbar

This commit is contained in:
BasioMeusPuga
2018-03-29 02:50:01 +05:30
parent 406ca0485f
commit 0d015ad72e
4 changed files with 37 additions and 22 deletions

View File

@@ -87,7 +87,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.libraryFilterMenu = QtWidgets.QMenu()
self.statusMessage = QtWidgets.QLabel()
self.distractionFreeToggle = QtWidgets.QToolButton()
self.reloadLibrary = QtWidgets.QPushButton()
# Reference variables
self.alignment_dict = {
@@ -108,6 +107,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Initialize definition view dialog
self.definitionDialog = DefinitionsUI(self)
# Make the statusbar invisible by default
self.statusBar.setVisible(False)
# Statusbar widgets
self.statusMessage.setObjectName('statusMessage')
self.statusBar.addPermanentWidget(self.statusMessage)
@@ -119,15 +121,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.statusBar.addWidget(self.sorterProgress)
self.sorterProgress.setVisible(False)
# Statusbar + Toolbar Visibility
self.distractionFreeToggle.setIcon(self.QImageFactory.get_image('visibility'))
self.distractionFreeToggle.setObjectName('distractionFreeToggle')
self.distractionFreeToggle.setToolTip(
self._translate('Main_UI', 'Toggle distraction free mode (Ctrl + D)'))
self.distractionFreeToggle.setAutoRaise(True)
self.distractionFreeToggle.clicked.connect(self.toggle_distraction_free)
self.statusBar.addPermanentWidget(self.distractionFreeToggle)
# Application wide temporary directory
self.temp_dir = QtCore.QTemporaryDir()
@@ -162,6 +155,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodels)
self.libraryToolBar.sortingBox.activated.connect(self.lib_ref.update_proxymodels)
self.libraryToolBar.libraryFilterButton.setPopupMode(QtWidgets.QToolButton.InstantPopup)
self.libraryToolBar.searchBar.textChanged.connect(self.statusbar_visibility)
self.addToolBar(self.libraryToolBar)
if self.settings['current_view'] == 0:
@@ -172,6 +166,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Book toolbar
self.bookToolBar.addBookmarkButton.triggered.connect(self.add_bookmark)
self.bookToolBar.bookmarkButton.triggered.connect(self.toggle_dock_widget)
self.bookToolBar.distractionFreeButton.triggered.connect(self.toggle_distraction_free)
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
for count, i in enumerate(self.display_profiles):
@@ -242,6 +237,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.listView.customContextMenuRequested.connect(self.generate_library_context_menu)
self.listView.verticalScrollBar().valueChanged.connect(self.start_culling_timer)
self.listView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.listView.setStyleSheet(
"QListView {{background-color: {0}}}".format(
@@ -396,6 +392,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.reloadLibrary.setEnabled(False)
self.settings['last_open_path'] = os.path.dirname(opened_files[0][0])
self.statusBar.setVisible(True)
self.sorterProgress.setVisible(True)
self.statusMessage.setText(self._translate('Main_UI', 'Adding books...'))
self.thread = BackGroundBookAddition(
@@ -475,11 +472,14 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.settingsDialog.okButton.setEnabled(True)
self.settingsDialog.okButton.setToolTip(
self._translate('Main_UI', 'Save changes and start library scan'))
self.reloadLibrary.setEnabled(True)
self.libraryToolBar.reloadLibraryButton.setEnabled(True)
self.sorterProgress.setVisible(False)
self.sorterProgress.setValue(0)
if self.libraryToolBar.searchBar.text() == '':
self.statusBar.setVisible(False)
self.lib_ref.update_proxymodels()
self.lib_ref.generate_library_tags()
@@ -721,6 +721,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# TODO
# def dropEvent
def statusbar_visibility(self):
if self.sender() == self.libraryToolBar.searchBar:
if self.libraryToolBar.searchBar.text() == '':
self.statusBar.setVisible(False)
else:
self.statusBar.setVisible(True)
def show_settings(self):
if not self.settingsDialog.isVisible():
self.settingsDialog.show()
@@ -916,10 +923,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def toggle_distraction_free(self):
self.settings['show_bars'] = not self.settings['show_bars']
self.statusBar.setVisible(
not self.statusBar.isVisible())
self.tabWidget.tabBar().setVisible(
not self.tabWidget.tabBar().isVisible())
if self.tabWidget.count() > 1:
self.tabWidget.tabBar().setVisible(
self.settings['show_bars'])
current_tab = self.tabWidget.currentIndex()
if current_tab == 0:

View File

@@ -227,7 +227,7 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
# Disallow rechecking until the first check completes
self.okButton.setEnabled(False)
self.parent.reloadLibrary.setEnabled(False)
self.parent.libraryToolBar.reloadLibraryButton.setEnabled(False)
self.okButton.setToolTip(
self._translate('SettingsUI', 'Library scan in progress...'))
@@ -246,6 +246,7 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
return
# Hey, messaging is important, okay?
self.parent.statusBar.setVisible(True)
self.parent.sorterProgress.setVisible(True)
self.parent.statusMessage.setText(
self._translate('SettingsUI', 'Parsing files'))

View File

@@ -45,10 +45,6 @@ class BookToolBar(QtWidgets.QToolBar):
image_factory.get_image('gtk-select-font'),
self._translate('BookToolBar', 'View settings'),
self)
self.fullscreenButton = QtWidgets.QAction(
image_factory.get_image('view-fullscreen'),
self._translate('BookToolBar', 'Fullscreen (F11)'),
self)
self.addBookmarkButton = QtWidgets.QAction(
image_factory.get_image('bookmark-new'),
self._translate('BookToolBar', 'Add bookmark'),
@@ -58,6 +54,14 @@ class BookToolBar(QtWidgets.QToolBar):
self._translate('BookToolBar', 'Bookmarks (Ctrl + B)'),
self)
self.bookmarkButton.setObjectName('bookmarkButton')
self.distractionFreeButton = QtWidgets.QAction(
image_factory.get_image('visibility'),
self._translate('Main_BookToolBarUI', 'Toggle distraction free mode (Ctrl + D)'),
self)
self.fullscreenButton = QtWidgets.QAction(
image_factory.get_image('view-fullscreen'),
self._translate('BookToolBar', 'Fullscreen (F11)'),
self)
self.resetProfile = QtWidgets.QAction(
image_factory.get_image('reload'),
self._translate('BookToolBar', 'Reset profile'),
@@ -72,6 +76,7 @@ class BookToolBar(QtWidgets.QToolBar):
self.addAction(self.bookmarkButton)
self.bookmarkButton.setCheckable(True)
self.addSeparator()
self.addAction(self.distractionFreeButton)
self.addAction(self.fullscreenButton)
# Font modification
@@ -279,6 +284,7 @@ class BookToolBar(QtWidgets.QToolBar):
self.bookActions = [
self.addBookmarkButton,
self.bookmarkButton,
self.distractionFreeButton,
self.fullscreenButton,
self.tocBoxAction,
self.searchBarAction]

View File

@@ -158,8 +158,6 @@ class Tab(QtWidgets.QWidget):
title = self.metadata['title']
self.main_window.tabWidget.addTab(self, title)
# TODO
# Show cover image as tooltip text
this_tab_index = self.main_window.tabWidget.indexOf(self)
cover_icon = QtGui.QPixmap()
cover_icon.loadFromData(self.metadata['cover'])
@@ -171,6 +169,10 @@ class Tab(QtWidgets.QWidget):
self.mouse_hide_timer.setSingleShot(True)
self.mouse_hide_timer.timeout.connect(self.hide_mouse)
# Hide the tab bar in case distraction free mode is active
if not self.main_window.settings['show_bars']:
self.main_window.tabWidget.tabBar().setVisible(False)
self.contentView.setFocus()
def update_last_accessed_time(self):