Mouse cursor hiding implemented for comics view, Tab focus fixed
This commit is contained in:
4
TODO
4
TODO
@@ -2,7 +2,7 @@ TODO
|
|||||||
Options:
|
Options:
|
||||||
Automatic library management
|
Automatic library management
|
||||||
✓ Recursive file addition
|
✓ Recursive file addition
|
||||||
Auto deletion
|
✓ Auto deletion
|
||||||
Add only one file type if multiple are present
|
Add only one file type if multiple are present
|
||||||
✓ Remember files
|
✓ Remember files
|
||||||
✓ Check files (hashes) upon restart
|
✓ Check files (hashes) upon restart
|
||||||
@@ -17,8 +17,8 @@ TODO
|
|||||||
✓ Shift focus to the tab that has the book open
|
✓ Shift focus to the tab that has the book open
|
||||||
✓ Tie file deletion and tab closing to model updates
|
✓ Tie file deletion and tab closing to model updates
|
||||||
✓ Create separate thread for parser - Show progress in main window
|
✓ Create separate thread for parser - Show progress in main window
|
||||||
|
✓ Memory management
|
||||||
? Create emblem per filetype
|
? Create emblem per filetype
|
||||||
Memory management
|
|
||||||
Table view
|
Table view
|
||||||
Ignore a / the / numbers for sorting purposes
|
Ignore a / the / numbers for sorting purposes
|
||||||
Put the path in the scope of the search
|
Put the path in the scope of the search
|
||||||
|
41
__main__.py
41
__main__.py
@@ -43,12 +43,11 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
# Empty variables that will be infested soon
|
# Empty variables that will be infested soon
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
self.last_open_tab = None
|
|
||||||
self.last_open_path = None
|
|
||||||
self.thread = None # Background Thread
|
self.thread = None # Background Thread
|
||||||
self.current_contentView = None # For fullscreening purposes
|
self.current_contentView = None # For fullscreening purposes
|
||||||
self.display_profiles = None
|
self.display_profiles = None
|
||||||
self.current_profile_index = None
|
self.current_profile_index = None
|
||||||
|
self.comic_profile = {}
|
||||||
self.database_path = None
|
self.database_path = None
|
||||||
self.library_filter_menu = None
|
self.library_filter_menu = None
|
||||||
|
|
||||||
@@ -176,7 +175,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.reloadLibrary.setObjectName('reloadLibrary')
|
self.reloadLibrary.setObjectName('reloadLibrary')
|
||||||
self.reloadLibrary.setAutoRaise(True)
|
self.reloadLibrary.setAutoRaise(True)
|
||||||
self.reloadLibrary.clicked.connect(self.settings_dialog.start_library_scan)
|
self.reloadLibrary.clicked.connect(self.settings_dialog.start_library_scan)
|
||||||
# self.reloadLibrary.clicked.connect(self.cull_covers) # TODO
|
|
||||||
|
|
||||||
self.tabWidget.tabBar().setTabButton(
|
self.tabWidget.tabBar().setTabButton(
|
||||||
0, QtWidgets.QTabBar.RightSide, self.reloadLibrary)
|
0, QtWidgets.QTabBar.RightSide, self.reloadLibrary)
|
||||||
@@ -233,7 +231,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
for i in range(self.lib_ref.proxy_model.rowCount()):
|
for i in range(self.lib_ref.proxy_model.rowCount()):
|
||||||
all_indexes.add(self.lib_ref.proxy_model.index(i, 0))
|
all_indexes.add(self.lib_ref.proxy_model.index(i, 0))
|
||||||
|
|
||||||
y_range = range(-20, self.listView.viewport().height(), 10)
|
y_range = list(range(0, self.listView.viewport().height(), 100))
|
||||||
|
y_range.extend((-20, self.listView.viewport().height() + 20))
|
||||||
x_range = range(0, self.listView.viewport().width(), 80)
|
x_range = range(0, self.listView.viewport().width(), 80)
|
||||||
|
|
||||||
visible_indexes = set()
|
visible_indexes = set()
|
||||||
@@ -279,7 +278,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
this_item.setData(True, QtCore.Qt.UserRole + 8)
|
this_item.setData(True, QtCore.Qt.UserRole + 8)
|
||||||
|
|
||||||
def start_culling_timer(self):
|
def start_culling_timer(self):
|
||||||
self.culling_timer.start(50)
|
self.culling_timer.start(30)
|
||||||
|
|
||||||
def test_function(self):
|
def test_function(self):
|
||||||
print('Caesar si viveret, ad remum dareris')
|
print('Caesar si viveret, ad remum dareris')
|
||||||
@@ -315,6 +314,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
layout_extra_space_per_image = space_left // num_images
|
layout_extra_space_per_image = space_left // num_images
|
||||||
self.listView.setGridSize(
|
self.listView.setGridSize(
|
||||||
QtCore.QSize(default_size + layout_extra_space_per_image, 250))
|
QtCore.QSize(default_size + layout_extra_space_per_image, 250))
|
||||||
|
self.start_culling_timer()
|
||||||
except ZeroDivisionError: # Initial resize is ignored
|
except ZeroDivisionError: # Initial resize is ignored
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
# from the libary in case of a database refresh
|
# from the libary in case of a database refresh
|
||||||
|
|
||||||
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
|
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
|
||||||
self, 'Open file', self.last_open_path,
|
self, 'Open file', self.settings['last_open_path'],
|
||||||
f'eBooks ({self.available_parsers})')
|
f'eBooks ({self.available_parsers})')
|
||||||
|
|
||||||
if not opened_files[0]:
|
if not opened_files[0]:
|
||||||
@@ -334,7 +334,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.settings_dialog.okButton.setEnabled(False)
|
self.settings_dialog.okButton.setEnabled(False)
|
||||||
self.reloadLibrary.setEnabled(False)
|
self.reloadLibrary.setEnabled(False)
|
||||||
|
|
||||||
self.last_open_path = os.path.dirname(opened_files[0][0])
|
self.settings['last_open_path'] = os.path.dirname(opened_files[0][0])
|
||||||
self.sorterProgress.setVisible(True)
|
self.sorterProgress.setVisible(True)
|
||||||
self.statusMessage.setText('Adding books...')
|
self.statusMessage.setText('Adding books...')
|
||||||
self.thread = BackGroundBookAddition(
|
self.thread = BackGroundBookAddition(
|
||||||
@@ -424,6 +424,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
if self.tabWidget.currentIndex() == 0:
|
if self.tabWidget.currentIndex() == 0:
|
||||||
|
|
||||||
self.resizeEvent()
|
self.resizeEvent()
|
||||||
|
self.start_culling_timer()
|
||||||
if self.settings['show_toolbars']:
|
if self.settings['show_toolbars']:
|
||||||
self.bookToolBar.hide()
|
self.bookToolBar.hide()
|
||||||
self.libraryToolBar.show()
|
self.libraryToolBar.show()
|
||||||
@@ -576,20 +577,26 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
True,
|
True,
|
||||||
self.temp_dir.path()).initiate_threads()
|
self.temp_dir.path()).initiate_threads()
|
||||||
|
|
||||||
found_a_focusable_tab = False
|
|
||||||
|
|
||||||
for i in contents:
|
for i in contents:
|
||||||
|
# New tabs are created here
|
||||||
|
# Initial position adjustment is carried out by the tab itself
|
||||||
file_data = contents[i]
|
file_data = contents[i]
|
||||||
Tab(file_data, self.tabWidget) # New tabs are created here
|
Tab(file_data, self.tabWidget)
|
||||||
# Initial position adjustment
|
|
||||||
# is carried out by the tab itself
|
|
||||||
if file_data['path'] == self.last_open_tab:
|
|
||||||
found_a_focusable_tab = True
|
|
||||||
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
|
|
||||||
|
|
||||||
if not found_a_focusable_tab:
|
if self.settings['last_open_tab'] == 'library':
|
||||||
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
|
self.tabWidget.setCurrentIndex(0)
|
||||||
|
self.listView.setFocus()
|
||||||
|
self.settings['last_open_tab'] = None
|
||||||
|
return
|
||||||
|
|
||||||
|
for i in range(1, self.tabWidget.count()):
|
||||||
|
this_path = self.tabWidget.widget(i).metadata['path']
|
||||||
|
if self.settings['last_open_tab'] == this_path:
|
||||||
|
self.tabWidget.setCurrentIndex(i)
|
||||||
|
self.settings['last_open_tab'] = None
|
||||||
|
return
|
||||||
|
|
||||||
|
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
|
||||||
self.format_contentView()
|
self.format_contentView()
|
||||||
|
|
||||||
def get_color(self):
|
def get_color(self):
|
||||||
|
@@ -52,7 +52,7 @@ class Settings:
|
|||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
self.settings.beginGroup('runtimeVariables')
|
self.settings.beginGroup('runtimeVariables')
|
||||||
self.parent.last_open_path = self.settings.value(
|
self.parent.settings['last_open_path'] = self.settings.value(
|
||||||
'lastOpenPath', os.path.expanduser('~'))
|
'lastOpenPath', os.path.expanduser('~'))
|
||||||
self.parent.database_path = self.settings.value(
|
self.parent.database_path = self.settings.value(
|
||||||
'databasePath',
|
'databasePath',
|
||||||
@@ -67,7 +67,7 @@ class Settings:
|
|||||||
|
|
||||||
self.settings.beginGroup('lastOpen')
|
self.settings.beginGroup('lastOpen')
|
||||||
self.parent.settings['last_open_books'] = self.settings.value('lastOpenBooks', [])
|
self.parent.settings['last_open_books'] = self.settings.value('lastOpenBooks', [])
|
||||||
self.parent.last_open_tab = self.settings.value('lastOpenTab', 'library')
|
self.parent.settings['last_open_tab'] = self.settings.value('lastOpenTab', 'library')
|
||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
self.settings.beginGroup('settingsWindow')
|
self.settings.beginGroup('settingsWindow')
|
||||||
@@ -107,7 +107,7 @@ class Settings:
|
|||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
self.settings.beginGroup('runtimeVariables')
|
self.settings.beginGroup('runtimeVariables')
|
||||||
self.settings.setValue('lastOpenPath', self.parent.last_open_path)
|
self.settings.setValue('lastOpenPath', self.parent.settings['last_open_path'])
|
||||||
self.settings.setValue('databasePath', self.parent.database_path)
|
self.settings.setValue('databasePath', self.parent.database_path)
|
||||||
|
|
||||||
current_profile1 = self.parent.bookToolBar.profileBox.itemData(
|
current_profile1 = self.parent.bookToolBar.profileBox.itemData(
|
||||||
|
31
widgets.py
31
widgets.py
@@ -408,10 +408,10 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.are_we_doing_images_only = self.metadata['images_only']
|
self.are_we_doing_images_only = self.metadata['images_only']
|
||||||
|
|
||||||
if self.are_we_doing_images_only: # Boolean
|
if self.are_we_doing_images_only: # Boolean
|
||||||
self.contentView = PliantQGraphicsView(self.window())
|
self.contentView = PliantQGraphicsView(self.window(), self)
|
||||||
self.contentView.loadImage(chapter_content)
|
self.contentView.loadImage(chapter_content)
|
||||||
else:
|
else:
|
||||||
self.contentView = PliantQTextBrowser(self.window())
|
self.contentView = PliantQTextBrowser(self.window(), self)
|
||||||
# print(dir(self.contentView.document())) ## TODO USE this for modifying formatting and searching
|
# print(dir(self.contentView.document())) ## TODO USE this for modifying formatting and searching
|
||||||
|
|
||||||
relative_path_root = os.path.join(
|
relative_path_root = os.path.join(
|
||||||
@@ -449,6 +449,11 @@ class Tab(QtWidgets.QWidget):
|
|||||||
title = self.metadata['title']
|
title = self.metadata['title']
|
||||||
self.parent.addTab(self, title)
|
self.parent.addTab(self, title)
|
||||||
|
|
||||||
|
# Hide mouse cursor timer
|
||||||
|
self.mouse_hide_timer = QtCore.QTimer()
|
||||||
|
self.mouse_hide_timer.setSingleShot(True)
|
||||||
|
self.mouse_hide_timer.timeout.connect(self.hide_mouse)
|
||||||
|
|
||||||
self.contentView.setFocus()
|
self.contentView.setFocus()
|
||||||
|
|
||||||
def generate_position(self):
|
def generate_position(self):
|
||||||
@@ -544,6 +549,9 @@ class Tab(QtWidgets.QWidget):
|
|||||||
else:
|
else:
|
||||||
self.dockWidget.show()
|
self.dockWidget.show()
|
||||||
|
|
||||||
|
def hide_mouse(self):
|
||||||
|
self.contentView.setCursor(QtCore.Qt.BlankCursor)
|
||||||
|
|
||||||
def sneaky_change(self):
|
def sneaky_change(self):
|
||||||
direction = -1
|
direction = -1
|
||||||
if self.sender().objectName() == 'nextChapter':
|
if self.sender().objectName() == 'nextChapter':
|
||||||
@@ -561,11 +569,13 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
def __init__(self, main_window, parent=None):
|
def __init__(self, main_window, parent=None):
|
||||||
super(PliantQGraphicsView, self).__init__(parent)
|
super(PliantQGraphicsView, self).__init__(parent)
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
|
self.parent = parent
|
||||||
self.image_pixmap = None
|
self.image_pixmap = None
|
||||||
self.ignore_wheel_event = False
|
self.ignore_wheel_event = False
|
||||||
self.ignore_wheel_event_number = 0
|
self.ignore_wheel_event_number = 0
|
||||||
self.common_functions = PliantWidgetsCommonFunctions(
|
self.common_functions = PliantWidgetsCommonFunctions(
|
||||||
self, self.main_window)
|
self, self.main_window)
|
||||||
|
self.setMouseTracking(True)
|
||||||
|
|
||||||
def loadImage(self, image_path):
|
def loadImage(self, image_path):
|
||||||
self.image_pixmap = QtGui.QPixmap()
|
self.image_pixmap = QtGui.QPixmap()
|
||||||
@@ -633,15 +643,21 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
scroll_increment = int((maximum - 0) / 2)
|
scroll_increment = int((maximum - 0) / 2)
|
||||||
self.verticalScrollBar().setValue(vertical + scroll_increment)
|
self.verticalScrollBar().setValue(vertical + scroll_increment)
|
||||||
|
|
||||||
|
def mouseMoveEvent(self, event):
|
||||||
|
self.setCursor(QtCore.Qt.ArrowCursor)
|
||||||
|
self.parent.mouse_hide_timer.start(3000)
|
||||||
|
|
||||||
|
|
||||||
class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
||||||
def __init__(self, main_window, parent=None):
|
def __init__(self, main_window, parent=None):
|
||||||
super(PliantQTextBrowser, self).__init__(parent)
|
super(PliantQTextBrowser, self).__init__(parent)
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
|
self.parent = parent
|
||||||
self.ignore_wheel_event = False
|
self.ignore_wheel_event = False
|
||||||
self.ignore_wheel_event_number = 0
|
self.ignore_wheel_event_number = 0
|
||||||
self.common_functions = PliantWidgetsCommonFunctions(
|
self.common_functions = PliantWidgetsCommonFunctions(
|
||||||
self, self.main_window)
|
self, self.main_window)
|
||||||
|
self.setMouseTracking(True)
|
||||||
|
|
||||||
def wheelEvent(self, event):
|
def wheelEvent(self, event):
|
||||||
self.common_functions.wheelEvent(event, False)
|
self.common_functions.wheelEvent(event, False)
|
||||||
@@ -659,6 +675,13 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
else:
|
else:
|
||||||
QtWidgets.QTextBrowser.keyPressEvent(self, event)
|
QtWidgets.QTextBrowser.keyPressEvent(self, event)
|
||||||
|
|
||||||
|
# def mouseMoveEvent(self, event):
|
||||||
|
# TODO
|
||||||
|
# This does not work as expected
|
||||||
|
# event.accept()
|
||||||
|
# self.setCursor(QtCore.Qt.ArrowCursor)
|
||||||
|
# self.parent.mouse_hide_timer.start(3000)
|
||||||
|
|
||||||
|
|
||||||
class PliantWidgetsCommonFunctions():
|
class PliantWidgetsCommonFunctions():
|
||||||
def __init__(self, parent_widget, main_window):
|
def __init__(self, parent_widget, main_window):
|
||||||
@@ -686,7 +709,7 @@ class PliantWidgetsCommonFunctions():
|
|||||||
elif vertical_pdelta < 0:
|
elif vertical_pdelta < 0:
|
||||||
moving_up = False
|
moving_up = False
|
||||||
|
|
||||||
if abs(vertical_pdelta) > 100: # Adjust sensitivity here
|
if abs(vertical_pdelta) > 80: # Adjust sensitivity here
|
||||||
# Implies that no scrollbar movement is possible
|
# Implies that no scrollbar movement is possible
|
||||||
if self.pw.verticalScrollBar().value() == self.pw.verticalScrollBar().maximum() == 0:
|
if self.pw.verticalScrollBar().value() == self.pw.verticalScrollBar().maximum() == 0:
|
||||||
if moving_up:
|
if moving_up:
|
||||||
@@ -721,7 +744,7 @@ class PliantWidgetsCommonFunctions():
|
|||||||
|
|
||||||
if not was_button_pressed:
|
if not was_button_pressed:
|
||||||
self.pw.ignore_wheel_event = True
|
self.pw.ignore_wheel_event = True
|
||||||
|
|
||||||
|
|
||||||
class LibraryDelegate(QtWidgets.QStyledItemDelegate):
|
class LibraryDelegate(QtWidgets.QStyledItemDelegate):
|
||||||
def __init__(self, temp_dir, parent=None):
|
def __init__(self, temp_dir, parent=None):
|
||||||
|
Reference in New Issue
Block a user