Tab reordering

This commit is contained in:
BasioMeusPuga
2019-01-17 21:53:04 +05:30
parent 5d35319164
commit 2185e9fcf7
3 changed files with 33 additions and 20 deletions

13
TODO
View File

@@ -31,6 +31,7 @@ TODO
✓ Allow editing of database data through the UI + for Bookmarks
✓ Include (action) icons with the applications
✓ Drag and drop support for the library
✓ Tab reordering
Set focus to newly added file
Reading:
✓ Drop down for TOC
@@ -68,7 +69,6 @@ TODO
Caching is currently non fuctional
Annotations
✓ Text
Annotation preview in listView
✓ Disable buttons for annotations, search in images
Adjust key navigation according to viewport dimensions
Redo context menu order
@@ -94,20 +94,15 @@ TODO
Clean up 'switch' page layout
Colors aren't loaded properly for annotation previews
Last line in QTextBrowser should never be cut off
Hide mousepointer more aggressively
Secondary:
Double page view for books
Graphical themes
Change focus rectangle dimensions
Tab reordering
Universal Ctrl + Tab
Allow tabs to detach and form their own windows
Goodreads API: Ratings, Read, Recommendations
Get ISBN using python-isbnlib
Pagination
Use embedded fonts + CSS
Scrolling: Smooth / By Line
Shift to logging instead of print statements
txt, doc, chm support
Include icons for filetype emblems
@@ -118,3 +113,9 @@ TODO
? Create emblem per filetype
In application notifications
Notification in case the filter is filtering out all files with no option in place
Need help with:
Double page view for books
Scrolling: Smooth / By Line
Annotation preview in listView
Pagination

View File

@@ -233,8 +233,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.tab_switch()
self.tabWidget.currentChanged.connect(self.tab_switch)
# Tab closing
# Tab Widget formatting
self.tabWidget.setTabsClosable(True)
self.tabWidget.setDocumentMode(True)
self.tabWidget.tabBarClicked.connect(self.tab_disallow_library_movement)
# Get list of available parsers
self.available_parsers = '*.' + ' *.'.join(sorter.available_parsers)
@@ -243,6 +245,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# The Library tab gets no button
self.tabWidget.tabBar().setTabButton(
0, QtWidgets.QTabBar.RightSide, None)
self.tabWidget.widget(0).is_library = True
self.tabWidget.tabCloseRequested.connect(self.tab_close)
self.tabWidget.setTabBarAutoHide(True)
@@ -607,6 +610,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def tab_switch(self):
try:
# Disallow library tab movement
# Does not need to be looped since the library
# tab can only ever go to position 1
if not self.tabWidget.widget(0).is_library:
self.tabWidget.tabBar().moveTab(1, 0)
if self.current_tab != 0:
self.tabWidget.widget(
self.current_tab).update_last_accessed_time()
@@ -692,6 +701,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.tabWidget.widget(tab_index).setParent(None)
gc.collect()
def tab_disallow_library_movement(self, tab_index):
# Makes the library tab immovable
if tab_index == 0:
self.tabWidget.setMovable(False)
else:
self.tabWidget.setMovable(True)
def set_toc_position(self, event=None):
current_tab = self.tabWidget.currentWidget()

View File

@@ -41,6 +41,7 @@ class Tab(QtWidgets.QWidget):
self.metadata = metadata # Save progress data into this dictionary
self.are_we_doing_images_only = self.metadata['images_only']
self.is_fullscreen = False
self.is_library = False
self.masterLayout = QtWidgets.QHBoxLayout(self)
self.masterLayout.setContentsMargins(0, 0, 0, 0)
@@ -534,23 +535,18 @@ class Tab(QtWidgets.QWidget):
def generate_annotation_model(self):
saved_annotations = self.main_window.settings['annotations']
if not saved_annotations:
return
def add_to_model(annotation):
item = QtGui.QStandardItem()
item.setText(annotation['name'])
item.setData(annotation, QtCore.Qt.UserRole)
self.annotationModel.appendRow(item)
# Prevent annotation mixup
# Create annotation model
# TODO
# Annotation previews will require creation of a
# QStyledItemDelegate
for i in saved_annotations:
if self.are_we_doing_images_only and i['applicable_to'] == 'images':
add_to_model(i)
elif not self.are_we_doing_images_only and i['applicable_to'] == 'text':
add_to_model(i)
item = QtGui.QStandardItem()
item.setText(i['name'])
item.setData(i, QtCore.Qt.UserRole)
self.annotationModel.appendRow(item)
self.annotationListView.setModel(self.annotationModel)
def add_bookmark(self, position=None):