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 ✓ Allow editing of database data through the UI + for Bookmarks
✓ Include (action) icons with the applications ✓ Include (action) icons with the applications
✓ Drag and drop support for the library ✓ Drag and drop support for the library
✓ Tab reordering
Set focus to newly added file Set focus to newly added file
Reading: Reading:
✓ Drop down for TOC ✓ Drop down for TOC
@@ -68,7 +69,6 @@ TODO
Caching is currently non fuctional Caching is currently non fuctional
Annotations Annotations
✓ Text ✓ Text
Annotation preview in listView
✓ Disable buttons for annotations, search in images ✓ Disable buttons for annotations, search in images
Adjust key navigation according to viewport dimensions Adjust key navigation according to viewport dimensions
Redo context menu order Redo context menu order
@@ -94,20 +94,15 @@ TODO
Clean up 'switch' page layout Clean up 'switch' page layout
Colors aren't loaded properly for annotation previews Colors aren't loaded properly for annotation previews
Last line in QTextBrowser should never be cut off Last line in QTextBrowser should never be cut off
Hide mousepointer more aggressively
Secondary: Secondary:
Double page view for books
Graphical themes Graphical themes
Change focus rectangle dimensions Change focus rectangle dimensions
Tab reordering
Universal Ctrl + Tab Universal Ctrl + Tab
Allow tabs to detach and form their own windows Allow tabs to detach and form their own windows
Goodreads API: Ratings, Read, Recommendations Goodreads API: Ratings, Read, Recommendations
Get ISBN using python-isbnlib Get ISBN using python-isbnlib
Pagination
Use embedded fonts + CSS Use embedded fonts + CSS
Scrolling: Smooth / By Line
Shift to logging instead of print statements Shift to logging instead of print statements
txt, doc, chm support txt, doc, chm support
Include icons for filetype emblems Include icons for filetype emblems
@@ -118,3 +113,9 @@ TODO
? Create emblem per filetype ? Create emblem per filetype
In application notifications In application notifications
Notification in case the filter is filtering out all files with no option in place 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.tab_switch()
self.tabWidget.currentChanged.connect(self.tab_switch) self.tabWidget.currentChanged.connect(self.tab_switch)
# Tab closing # Tab Widget formatting
self.tabWidget.setTabsClosable(True) self.tabWidget.setTabsClosable(True)
self.tabWidget.setDocumentMode(True)
self.tabWidget.tabBarClicked.connect(self.tab_disallow_library_movement)
# Get list of available parsers # Get list of available parsers
self.available_parsers = '*.' + ' *.'.join(sorter.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 # The Library tab gets no button
self.tabWidget.tabBar().setTabButton( self.tabWidget.tabBar().setTabButton(
0, QtWidgets.QTabBar.RightSide, None) 0, QtWidgets.QTabBar.RightSide, None)
self.tabWidget.widget(0).is_library = True
self.tabWidget.tabCloseRequested.connect(self.tab_close) self.tabWidget.tabCloseRequested.connect(self.tab_close)
self.tabWidget.setTabBarAutoHide(True) self.tabWidget.setTabBarAutoHide(True)
@@ -607,6 +610,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def tab_switch(self): def tab_switch(self):
try: 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: if self.current_tab != 0:
self.tabWidget.widget( self.tabWidget.widget(
self.current_tab).update_last_accessed_time() 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) self.tabWidget.widget(tab_index).setParent(None)
gc.collect() 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): def set_toc_position(self, event=None):
current_tab = self.tabWidget.currentWidget() 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.metadata = metadata # Save progress data into this dictionary
self.are_we_doing_images_only = self.metadata['images_only'] self.are_we_doing_images_only = self.metadata['images_only']
self.is_fullscreen = False self.is_fullscreen = False
self.is_library = False
self.masterLayout = QtWidgets.QHBoxLayout(self) self.masterLayout = QtWidgets.QHBoxLayout(self)
self.masterLayout.setContentsMargins(0, 0, 0, 0) self.masterLayout.setContentsMargins(0, 0, 0, 0)
@@ -534,23 +535,18 @@ class Tab(QtWidgets.QWidget):
def generate_annotation_model(self): def generate_annotation_model(self):
saved_annotations = self.main_window.settings['annotations'] saved_annotations = self.main_window.settings['annotations']
if not saved_annotations: if not saved_annotations:
return return
def add_to_model(annotation): # Create annotation model
item = QtGui.QStandardItem() # TODO
item.setText(annotation['name']) # Annotation previews will require creation of a
item.setData(annotation, QtCore.Qt.UserRole) # QStyledItemDelegate
self.annotationModel.appendRow(item)
# Prevent annotation mixup
for i in saved_annotations: for i in saved_annotations:
if self.are_we_doing_images_only and i['applicable_to'] == 'images': item = QtGui.QStandardItem()
add_to_model(i) item.setText(i['name'])
elif not self.are_we_doing_images_only and i['applicable_to'] == 'text': item.setData(i, QtCore.Qt.UserRole)
add_to_model(i) self.annotationModel.appendRow(item)
self.annotationListView.setModel(self.annotationModel) self.annotationListView.setModel(self.annotationModel)
def add_bookmark(self, position=None): def add_bookmark(self, position=None):