From 7f5b6fc3495bd9b3165ec8f5fbb73bca5f0e1795 Mon Sep 17 00:00:00 2001 From: BasioMeusPuga Date: Wed, 21 Mar 2018 21:19:28 +0530 Subject: [PATCH] Multiple UI improvements --- lector/__main__.py | 14 +++++-- lector/settings.py | 4 +- lector/settingsdialog.py | 5 ++- lector/widgets.py | 14 ++++++- resources/raw/settings.ui | 81 ++++++++++++++++++++++--------------- resources/settingswindow.py | 55 ++++++++++++++----------- 6 files changed, 109 insertions(+), 64 deletions(-) diff --git a/lector/__main__.py b/lector/__main__.py index 27eb191..5cafb64 100755 --- a/lector/__main__.py +++ b/lector/__main__.py @@ -50,6 +50,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): super(MainUI, self).__init__() self.setupUi(self) + # Central Widget - Make borders disappear + self.centralWidget().layout().setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + # Initialize translation function self._translate = QtCore.QCoreApplication.translate @@ -78,7 +82,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): self.libraryFilterMenu = QtWidgets.QMenu() self.statusMessage = QtWidgets.QLabel() self.distractionFreeToggle = QtWidgets.QToolButton() - self.reloadLibrary = QtWidgets.QToolButton() + # self.reloadLibrary = QtWidgets.QToolButton() + self.reloadLibrary = QtWidgets.QPushButton() # Create the database in case it doesn't exist database.DatabaseInit(self.database_path) @@ -200,10 +205,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): print('Available parsers: ' + self.available_parsers) # The library refresh button on the Library tab + self.reloadLibrary.setFlat(True) self.reloadLibrary.setIcon(self.QImageFactory.get_image('reload')) self.reloadLibrary.setObjectName('reloadLibrary') self.reloadLibrary.setToolTip(self._translate('Main_UI', 'Scan library')) - self.reloadLibrary.setAutoRaise(True) self.reloadLibrary.clicked.connect(self.settingsDialog.start_library_scan) self.tabWidget.tabBar().setTabButton( @@ -434,7 +439,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): # First, calculate the number of images per row i = self.listView.viewport().width() / default_size rem = i - int(i) - if rem >= .11875 and rem <= .9999: + if rem >= .21875 and rem <= .9999: num_images = int(i) else: num_images = int(i) - 1 @@ -1171,7 +1176,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): else: self.libraryFilterMenu.actions()[-1].setChecked(True) - # print(self.active_library_filters) self.lib_ref.update_proxymodels() def toggle_distraction_free(self): @@ -1190,6 +1194,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): self.bookToolBar.setVisible( not self.bookToolBar.isVisible()) + self.start_culling_timer() + def closeEvent(self, event=None): if event: event.ignore() diff --git a/lector/settings.py b/lector/settings.py index 0be9abc..9600fa2 100644 --- a/lector/settings.py +++ b/lector/settings.py @@ -101,7 +101,8 @@ class Settings: 'dictionaryLanguage', 'en') self.parent.settings['caching_enabled'] = literal_eval(self.settings.value( 'cachingEnabled', 'True').capitalize()) - + self.parent.settings['hide_scrollbars'] = literal_eval(self.settings.value( + 'hideScrollBars', 'False').capitalize()) self.settings.endGroup() self.settings.beginGroup('dialogSettings') @@ -171,6 +172,7 @@ class Settings: self.settings.setValue('performCulling', current_settings['perform_culling']) self.settings.setValue('dictionaryLanguage', current_settings['dictionary_language']) self.settings.setValue('cachingEnabled', current_settings['caching_enabled']) + self.settings.setValue('hideScrollBars', current_settings['hide_scrollbars']) self.settings.endGroup() self.settings.beginGroup('dialogSettings') diff --git a/lector/settingsdialog.py b/lector/settingsdialog.py index baa9fbd..f701527 100644 --- a/lector/settingsdialog.py +++ b/lector/settingsdialog.py @@ -91,6 +91,7 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): self.fileRemember.setChecked(self.parent.settings['remember_files']) self.performCulling.setChecked(self.parent.settings['perform_culling']) self.cachingEnabled.setChecked(self.parent.settings['caching_enabled']) + self.hideScrollBars.setChecked(self.parent.settings['hide_scrollbars']) self.autoTags.clicked.connect(self.manage_checkboxes) self.coverShadows.clicked.connect(self.manage_checkboxes) @@ -98,6 +99,7 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): self.fileRemember.clicked.connect(self.manage_checkboxes) self.performCulling.clicked.connect(self.manage_checkboxes) self.cachingEnabled.clicked.connect(self.manage_checkboxes) + self.hideScrollBars.clicked.connect(self.manage_checkboxes) # Generate the filesystem treeView self.generate_tree() @@ -284,7 +286,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): 'refreshLibrary': 'scan_library', 'fileRemember': 'remember_files', 'performCulling': 'perform_culling', - 'cachingEnabled': 'caching_enabled',} + 'cachingEnabled': 'caching_enabled', + 'hideScrollBars': 'hide_scrollbars'} self.parent.settings[sender_dict[sender]] = not self.parent.settings[sender_dict[sender]] diff --git a/lector/widgets.py b/lector/widgets.py index 22fbf03..8b71b49 100644 --- a/lector/widgets.py +++ b/lector/widgets.py @@ -51,6 +51,7 @@ class Tab(QtWidgets.QWidget): self.main_window = self.window() self.masterLayout = QtWidgets.QHBoxLayout(self) + self.masterLayout.setContentsMargins(0, 0, 0, 0) self.horzLayout = QtWidgets.QSplitter(self) self.horzLayout.setOrientation(QtCore.Qt.Horizontal) self.masterLayout.addWidget(self.horzLayout) @@ -111,8 +112,13 @@ class Tab(QtWidgets.QWidget): self.contentView.setFrameShape(QtWidgets.QFrame.NoFrame) self.contentView.setObjectName('contentView') self.contentView.verticalScrollBar().setSingleStep(7) - self.contentView.setHorizontalScrollBarPolicy( - QtCore.Qt.ScrollBarAsNeeded) + + if self.main_window.settings['hide_scrollbars']: + self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.contentView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + else: + self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + self.contentView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) # See bookmark availability if not self.metadata['bookmarks']: @@ -296,6 +302,10 @@ class Tab(QtWidgets.QWidget): # Hide the view modification buttons in case they're visible self.main_window.bookToolBar.customize_view_off() + # Exit distraction free mode too + if not self.main_window.settings['show_bars']: + self.main_window.toggle_distraction_free() + def change_chapter_tocBox(self): chapter_number = self.main_window.bookToolBar.tocBox.currentIndex() required_content = self.metadata['content'][chapter_number][1] diff --git a/resources/raw/settings.ui b/resources/raw/settings.ui index 0b05ed6..f03b912 100644 --- a/resources/raw/settings.ui +++ b/resources/raw/settings.ui @@ -63,35 +63,15 @@ - + + + Enabling reduces startup time and memory usage + - Generate tags from files + Load covers only when needed - - - - - - - 0 - 0 - - - - Dictionary: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - @@ -106,12 +86,9 @@ - - - Enabling reduces startup time and memory usage - + - Load covers only when needed + Generate tags from files @@ -125,12 +102,50 @@ + + + + + + + + + + + 0 + 0 + + + + Dictionary: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + Horizontal scrolling with Alt + Scroll +Reopen book to see changes + + + Hide scrollbars when reading + + + - Restart to see changes + Restart application to see changes Icon theme: @@ -140,7 +155,7 @@ - Restart to see changes + Restart application to see changes Dar&k @@ -150,7 +165,7 @@ - Restart to see changes + Restart application to see changes &Light diff --git a/resources/settingswindow.py b/resources/settingswindow.py index 9830ac3..8ccd2fc 100644 --- a/resources/settingswindow.py +++ b/resources/settingswindow.py @@ -43,9 +43,25 @@ class Ui_Dialog(object): self.fileRemember = QtWidgets.QCheckBox(self.groupBox) self.fileRemember.setObjectName("fileRemember") self.horizontalLayout_4.addWidget(self.fileRemember) + self.performCulling = QtWidgets.QCheckBox(self.groupBox) + self.performCulling.setObjectName("performCulling") + self.horizontalLayout_4.addWidget(self.performCulling) + self.verticalLayout.addLayout(self.horizontalLayout_4) + self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.coverShadows = QtWidgets.QCheckBox(self.groupBox) + self.coverShadows.setObjectName("coverShadows") + self.horizontalLayout.addWidget(self.coverShadows) self.autoTags = QtWidgets.QCheckBox(self.groupBox) self.autoTags.setObjectName("autoTags") - self.horizontalLayout_4.addWidget(self.autoTags) + self.horizontalLayout.addWidget(self.autoTags) + self.cachingEnabled = QtWidgets.QCheckBox(self.groupBox) + self.cachingEnabled.setObjectName("cachingEnabled") + self.horizontalLayout.addWidget(self.cachingEnabled) + self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1) + self.horizontalLayout_6 = QtWidgets.QHBoxLayout() + self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.languageLabel = QtWidgets.QLabel(self.groupBox) @@ -60,20 +76,10 @@ class Ui_Dialog(object): self.languageBox = QtWidgets.QComboBox(self.groupBox) self.languageBox.setObjectName("languageBox") self.horizontalLayout_3.addWidget(self.languageBox) - self.horizontalLayout_4.addLayout(self.horizontalLayout_3) - self.verticalLayout.addLayout(self.horizontalLayout_4) - self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.coverShadows = QtWidgets.QCheckBox(self.groupBox) - self.coverShadows.setObjectName("coverShadows") - self.horizontalLayout.addWidget(self.coverShadows) - self.performCulling = QtWidgets.QCheckBox(self.groupBox) - self.performCulling.setObjectName("performCulling") - self.horizontalLayout.addWidget(self.performCulling) - self.cachingEnabled = QtWidgets.QCheckBox(self.groupBox) - self.cachingEnabled.setObjectName("cachingEnabled") - self.horizontalLayout.addWidget(self.cachingEnabled) + self.horizontalLayout_6.addLayout(self.horizontalLayout_3) + self.hideScrollBars = QtWidgets.QCheckBox(self.groupBox) + self.hideScrollBars.setObjectName("hideScrollBars") + self.horizontalLayout_6.addWidget(self.hideScrollBars) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.label = QtWidgets.QLabel(self.groupBox) @@ -85,8 +91,8 @@ class Ui_Dialog(object): self.lightIconsRadio = QtWidgets.QRadioButton(self.groupBox) self.lightIconsRadio.setObjectName("lightIconsRadio") self.horizontalLayout_5.addWidget(self.lightIconsRadio) - self.horizontalLayout.addLayout(self.horizontalLayout_5) - self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1) + self.horizontalLayout_6.addLayout(self.horizontalLayout_5) + self.gridLayout.addLayout(self.horizontalLayout_6, 2, 0, 1, 1) self.verticalLayout_2.addWidget(self.groupBox) self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 0, 1, 1) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() @@ -113,18 +119,21 @@ class Ui_Dialog(object): self.groupBox.setTitle(_translate("Dialog", "Switches")) self.refreshLibrary.setText(_translate("Dialog", "Startup: Refresh library")) self.fileRemember.setText(_translate("Dialog", "Remember open files")) - self.autoTags.setText(_translate("Dialog", "Generate tags from files")) - self.languageLabel.setText(_translate("Dialog", "Dictionary:")) - self.coverShadows.setText(_translate("Dialog", "Cover shadows")) self.performCulling.setToolTip(_translate("Dialog", "Enabling reduces startup time and memory usage")) self.performCulling.setText(_translate("Dialog", "Load covers only when needed")) + self.coverShadows.setText(_translate("Dialog", "Cover shadows")) + self.autoTags.setText(_translate("Dialog", "Generate tags from files")) self.cachingEnabled.setToolTip(_translate("Dialog", "Greatly reduces page transition time at the cost of more memory")) self.cachingEnabled.setText(_translate("Dialog", "Cache comic / pdf pages")) - self.label.setToolTip(_translate("Dialog", "Restart to see changes")) + self.languageLabel.setText(_translate("Dialog", "Dictionary:")) + self.hideScrollBars.setToolTip(_translate("Dialog", "Horizontal scrolling with Alt + Scroll\n" +"Reopen book to see changes")) + self.hideScrollBars.setText(_translate("Dialog", "Hide scrollbars when reading")) + self.label.setToolTip(_translate("Dialog", "Restart application to see changes")) self.label.setText(_translate("Dialog", "Icon theme: ")) - self.darkIconsRadio.setToolTip(_translate("Dialog", "Restart to see changes")) + self.darkIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes")) self.darkIconsRadio.setText(_translate("Dialog", "Dar&k")) - self.lightIconsRadio.setToolTip(_translate("Dialog", "Restart to see changes")) + self.lightIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes")) self.lightIconsRadio.setText(_translate("Dialog", "&Light")) self.okButton.setText(_translate("Dialog", "Scan Library")) self.cancelButton.setText(_translate("Dialog", "Close"))