Consolidate docks
Update copyright Pondered the nature of protein powder
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
9
TODO
9
TODO
@@ -2,7 +2,8 @@ TODO
|
|||||||
General:
|
General:
|
||||||
✓ Internationalization
|
✓ Internationalization
|
||||||
✓ Application icon
|
✓ Application icon
|
||||||
✓ .desktop file
|
✓ .desktop file
|
||||||
|
Flatpak and maybe AppImage support
|
||||||
Options:
|
Options:
|
||||||
✓ Automatic library management
|
✓ Automatic library management
|
||||||
✓ Recursive file addition
|
✓ Recursive file addition
|
||||||
@@ -63,7 +64,7 @@ TODO
|
|||||||
✓ Track open bookmark windows so they can be closed quickly at exit
|
✓ Track open bookmark windows so they can be closed quickly at exit
|
||||||
Double page / column view
|
Double page / column view
|
||||||
✓ For comics
|
✓ For comics
|
||||||
Caching is current non fuctional
|
Caching is currently non fuctional
|
||||||
Annotations
|
Annotations
|
||||||
✓ Text
|
✓ Text
|
||||||
Annotation preview in listView
|
Annotation preview in listView
|
||||||
@@ -76,6 +77,7 @@ TODO
|
|||||||
✓ Homegrown solution please
|
✓ Homegrown solution please
|
||||||
✓ cbz, cbr support
|
✓ cbz, cbr support
|
||||||
✓ Keep font settings enabled but only for background color
|
✓ Keep font settings enabled but only for background color
|
||||||
|
✓ Double page view
|
||||||
✓ mobi, azw support
|
✓ mobi, azw support
|
||||||
Limit the extra files produced by KindleUnpack
|
Limit the extra files produced by KindleUnpack
|
||||||
Have them save to memory
|
Have them save to memory
|
||||||
@@ -90,6 +92,9 @@ TODO
|
|||||||
Colors aren't loaded properly for annotation previews
|
Colors aren't loaded properly for annotation previews
|
||||||
Cover page shouldn't be scolled midway
|
Cover page shouldn't be scolled midway
|
||||||
Last line in QTextBrowser should never be cut off
|
Last line in QTextBrowser should never be cut off
|
||||||
|
Annotation / bookmark docks shouldn't be separate
|
||||||
|
Cursor position is a little finicky when toggling fullscreen
|
||||||
|
Hide mousepointer more aggressively
|
||||||
|
|
||||||
Secondary:
|
Secondary:
|
||||||
Double page view for books
|
Double page view for books
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -78,7 +78,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.comic_profile = {}
|
self.comic_profile = {}
|
||||||
self.database_path = None
|
self.database_path = None
|
||||||
self.active_library_filters = []
|
self.active_library_filters = []
|
||||||
self.active_bookmark_docks = []
|
self.active_docks = []
|
||||||
|
|
||||||
# Initialize application
|
# Initialize application
|
||||||
Settings(self).read_settings() # This should populate all variables that need
|
Settings(self).read_settings() # This should populate all variables that need
|
||||||
@@ -171,9 +171,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.libraryToolBar.tableViewButton.trigger()
|
self.libraryToolBar.tableViewButton.trigger()
|
||||||
|
|
||||||
# Book toolbar
|
# Book toolbar
|
||||||
self.bookToolBar.annotationButton.triggered.connect(self.toggle_dock_widgets)
|
self.bookToolBar.annotationButton.triggered.connect(self.toggle_side_dock)
|
||||||
self.bookToolBar.addBookmarkButton.triggered.connect(self.add_bookmark)
|
self.bookToolBar.addBookmarkButton.triggered.connect(self.add_bookmark)
|
||||||
self.bookToolBar.bookmarkButton.triggered.connect(self.toggle_dock_widgets)
|
self.bookToolBar.bookmarkButton.triggered.connect(self.toggle_side_dock)
|
||||||
self.bookToolBar.distractionFreeButton.triggered.connect(self.toggle_distraction_free)
|
self.bookToolBar.distractionFreeButton.triggered.connect(self.toggle_distraction_free)
|
||||||
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
|
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
|
||||||
|
|
||||||
@@ -617,8 +617,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
# Hide bookmark and annotation widgets
|
# Hide bookmark and annotation widgets
|
||||||
for i in range(1, self.tabWidget.count()):
|
for i in range(1, self.tabWidget.count()):
|
||||||
self.tabWidget.widget(i).bookmarkDock.setVisible(False)
|
self.tabWidget.widget(i).sideDock.setVisible(False)
|
||||||
self.tabWidget.widget(i).annotationDock.setVisible(False)
|
|
||||||
|
|
||||||
if self.tabWidget.currentIndex() == 0:
|
if self.tabWidget.currentIndex() == 0:
|
||||||
|
|
||||||
@@ -685,9 +684,6 @@ 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()
|
||||||
|
|
||||||
self.bookToolBar.bookmarkButton.setChecked(False)
|
|
||||||
self.bookToolBar.annotationButton.setChecked(False)
|
|
||||||
|
|
||||||
def set_toc_position(self, event=None):
|
def set_toc_position(self, event=None):
|
||||||
current_tab = self.tabWidget.currentWidget()
|
current_tab = self.tabWidget.currentWidget()
|
||||||
|
|
||||||
@@ -705,13 +701,15 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
def set_fullscreen(self):
|
def set_fullscreen(self):
|
||||||
self.tabWidget.currentWidget().go_fullscreen()
|
self.tabWidget.currentWidget().go_fullscreen()
|
||||||
|
|
||||||
def toggle_dock_widgets(self):
|
def toggle_side_dock(self):
|
||||||
|
# Tab indices are fixed
|
||||||
|
# 0 = Annotations
|
||||||
|
# 1 = Bookmarks
|
||||||
sender = self.sender()
|
sender = self.sender()
|
||||||
|
|
||||||
if sender == self.bookToolBar.bookmarkButton:
|
|
||||||
self.tabWidget.currentWidget().toggle_bookmarks()
|
|
||||||
if sender == self.bookToolBar.annotationButton:
|
if sender == self.bookToolBar.annotationButton:
|
||||||
self.tabWidget.currentWidget().toggle_annotations()
|
self.tabWidget.currentWidget().toggle_side_dock(0)
|
||||||
|
if sender == self.bookToolBar.bookmarkButton:
|
||||||
|
self.tabWidget.currentWidget().toggle_side_dock(1)
|
||||||
|
|
||||||
def library_doubleclick(self, index):
|
def library_doubleclick(self, index):
|
||||||
sender = self.sender().objectName()
|
sender = self.sender().objectName()
|
||||||
@@ -986,7 +984,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.settingsDialog.hide()
|
self.settingsDialog.hide()
|
||||||
self.definitionDialog.hide()
|
self.definitionDialog.hide()
|
||||||
self.temp_dir.remove()
|
self.temp_dir.remove()
|
||||||
for this_dock in self.active_bookmark_docks:
|
for this_dock in self.active_docks:
|
||||||
try:
|
try:
|
||||||
this_dock.setVisible(False)
|
this_dock.setVisible(False)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -350,7 +350,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
self.image_pixmap.save(save_file[0])
|
self.image_pixmap.save(save_file[0])
|
||||||
|
|
||||||
if action == bookmarksToggleAction:
|
if action == bookmarksToggleAction:
|
||||||
self.parent.toggle_bookmarks()
|
self.parent.toggle_side_dock(1)
|
||||||
if action == dfToggleAction:
|
if action == dfToggleAction:
|
||||||
self.main_window.toggle_distraction_free()
|
self.main_window.toggle_distraction_free()
|
||||||
if action == fsToggleAction:
|
if action == fsToggleAction:
|
||||||
@@ -455,8 +455,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
if self.annotation_mode:
|
if self.annotation_mode:
|
||||||
self.annotation_mode = False
|
self.annotation_mode = False
|
||||||
self.viewport().setCursor(QtCore.Qt.ArrowCursor)
|
self.viewport().setCursor(QtCore.Qt.ArrowCursor)
|
||||||
self.parent.annotationDock.show()
|
self.parent.sideDock.show()
|
||||||
self.parent.annotationDock.setWindowOpacity(.95)
|
self.parent.sideDock.setWindowOpacity(.95)
|
||||||
|
|
||||||
self.current_annotation = None
|
self.current_annotation = None
|
||||||
self.parent.annotationListView.clearSelection()
|
self.parent.annotationListView.clearSelection()
|
||||||
@@ -464,7 +464,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
else:
|
else:
|
||||||
self.annotation_mode = True
|
self.annotation_mode = True
|
||||||
self.viewport().setCursor(QtCore.Qt.IBeamCursor)
|
self.viewport().setCursor(QtCore.Qt.IBeamCursor)
|
||||||
self.parent.annotationDock.hide()
|
self.parent.sideDock.hide()
|
||||||
|
|
||||||
selected_index = self.parent.annotationListView.currentIndex()
|
selected_index = self.parent.annotationListView.currentIndex()
|
||||||
self.current_annotation = self.parent.annotationModel.data(
|
self.current_annotation = self.parent.annotationModel.data(
|
||||||
@@ -616,7 +616,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
'delete', 'text', current_chapter, cursor_at_mouse.position())
|
'delete', 'text', current_chapter, cursor_at_mouse.position())
|
||||||
|
|
||||||
if action == bookmarksToggleAction:
|
if action == bookmarksToggleAction:
|
||||||
self.parent.toggle_bookmarks()
|
self.parent.toggle_side_dock(1)
|
||||||
|
|
||||||
if action == fsToggleAction:
|
if action == fsToggleAction:
|
||||||
self.parent.exit_fullscreen()
|
self.parent.exit_fullscreen()
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -74,11 +74,9 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
self.fontButton.triggered.connect(self.toggle_font_settings)
|
self.fontButton.triggered.connect(self.toggle_font_settings)
|
||||||
self.addSeparator()
|
self.addSeparator()
|
||||||
self.addAction(self.annotationButton)
|
self.addAction(self.annotationButton)
|
||||||
self.annotationButton.setCheckable(True)
|
|
||||||
self.addSeparator()
|
self.addSeparator()
|
||||||
self.addAction(self.addBookmarkButton)
|
self.addAction(self.addBookmarkButton)
|
||||||
self.addAction(self.bookmarkButton)
|
self.addAction(self.bookmarkButton)
|
||||||
self.bookmarkButton.setCheckable(True)
|
|
||||||
self.addSeparator()
|
self.addSeparator()
|
||||||
self.addAction(self.distractionFreeButton)
|
self.addAction(self.distractionFreeButton)
|
||||||
self.addAction(self.fullscreenButton)
|
self.addAction(self.fullscreenButton)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# This file is a part of Lector, a Qt based ebook reader
|
# This file is a part of Lector, a Qt based ebook reader
|
||||||
# Copyright (C) 2017-2018 BasioMeusPuga
|
# Copyright (C) 2017-2019 BasioMeusPuga
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
# TODO
|
# TODO
|
||||||
# Reading modes
|
# Reading modes
|
||||||
# Double page, Continuous etc
|
# Double page, Continuous etc
|
||||||
# Especially for comics
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
@@ -121,71 +120,61 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||||
self.contentView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
self.contentView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||||
|
|
||||||
# Create the annotations dock
|
# Create a common dock for annotations and bookmarks
|
||||||
self.annotationDock = PliantDockWidget(self.main_window, 'annotations', self.contentView)
|
# And add a vertical layout to it for requisite widgets
|
||||||
self.annotationDock.setWindowTitle(self._translate('Tab', 'Annotations'))
|
self.sideDock = PliantDockWidget(self.main_window, False, self.contentView)
|
||||||
self.annotationDock.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
|
self.sideDock.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
|
||||||
self.annotationDock.hide()
|
self.sideDock.setTitleBarWidget(QtWidgets.QWidget())
|
||||||
|
self.sideDockTabWidget = QtWidgets.QTabWidget()
|
||||||
|
self.sideDock.setWidget(self.sideDockTabWidget)
|
||||||
|
|
||||||
self.annotationListView = QtWidgets.QListView(self.annotationDock)
|
# Annotation list view and model
|
||||||
|
self.annotationListView = QtWidgets.QListView(self.sideDock)
|
||||||
self.annotationListView.setResizeMode(QtWidgets.QListWidget.Adjust)
|
self.annotationListView.setResizeMode(QtWidgets.QListWidget.Adjust)
|
||||||
self.annotationListView.setMaximumWidth(350)
|
self.annotationListView.setMaximumWidth(350)
|
||||||
self.annotationListView.doubleClicked.connect(self.contentView.toggle_annotation_mode)
|
self.annotationListView.doubleClicked.connect(self.contentView.toggle_annotation_mode)
|
||||||
self.annotationListView.setEditTriggers(QtWidgets.QListView.NoEditTriggers)
|
self.annotationListView.setEditTriggers(QtWidgets.QListView.NoEditTriggers)
|
||||||
self.annotationDock.setWidget(self.annotationListView)
|
self.sideDockTabWidget.addTab(self.annotationListView, 'Annotations')
|
||||||
|
|
||||||
self.annotationModel = QtGui.QStandardItemModel(self)
|
self.annotationModel = QtGui.QStandardItemModel(self)
|
||||||
self.generate_annotation_model()
|
self.generate_annotation_model()
|
||||||
|
|
||||||
# Create the annotation notes dock
|
# Bookmark tree view and model
|
||||||
self.annotationNoteDock = PliantDockWidget(self.main_window, 'notes', self.contentView)
|
self.bookmarkTreeView = QtWidgets.QTreeView(self.sideDock)
|
||||||
self.annotationNoteDock.setWindowTitle(self._translate('Tab', 'Note'))
|
|
||||||
self.annotationNoteDock.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
|
|
||||||
self.annotationNoteDock.hide()
|
|
||||||
|
|
||||||
self.annotationNoteEdit = QtWidgets.QTextEdit(self.annotationDock)
|
|
||||||
self.annotationNoteEdit.setMaximumSize(QtCore.QSize(250, 250))
|
|
||||||
self.annotationNoteEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
|
|
||||||
self.annotationNoteDock.setWidget(self.annotationNoteEdit)
|
|
||||||
|
|
||||||
# Create the dock widget for context specific display
|
|
||||||
self.bookmarkDock = PliantDockWidget(self.main_window, 'bookmarks', self.contentView)
|
|
||||||
|
|
||||||
title_string = self._translate('Tab', 'Bookmarks')
|
|
||||||
if self.main_window.settings['toc_with_bookmarks']:
|
|
||||||
title_string = self._translate('Tab', 'TOC + Bookmarks')
|
|
||||||
self.bookmarkDock.setWindowTitle(title_string)
|
|
||||||
|
|
||||||
self.bookmarkDock.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
|
|
||||||
self.bookmarkDock.hide()
|
|
||||||
|
|
||||||
self.bookmarkTreeView = QtWidgets.QTreeView(self.bookmarkDock)
|
|
||||||
self.bookmarkTreeView.setHeaderHidden(True)
|
self.bookmarkTreeView.setHeaderHidden(True)
|
||||||
self.bookmarkTreeView.setMaximumWidth(350)
|
self.bookmarkTreeView.setMaximumWidth(350)
|
||||||
self.bookmarkTreeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
self.bookmarkTreeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
self.bookmarkTreeView.customContextMenuRequested.connect(
|
self.bookmarkTreeView.customContextMenuRequested.connect(
|
||||||
self.generate_bookmark_context_menu)
|
self.generate_bookmark_context_menu)
|
||||||
self.bookmarkTreeView.clicked.connect(self.navigate_to_bookmark)
|
self.bookmarkTreeView.clicked.connect(self.navigate_to_bookmark)
|
||||||
self.bookmarkDock.setWidget(self.bookmarkTreeView)
|
self.sideDockTabWidget.addTab(self.bookmarkTreeView, 'Bookmarks')
|
||||||
|
|
||||||
self.bookmarkModel = QtGui.QStandardItemModel(self)
|
self.bookmarkModel = QtGui.QStandardItemModel(self)
|
||||||
self.bookmarkProxyModel = BookmarkProxyModel(self)
|
self.bookmarkProxyModel = BookmarkProxyModel(self)
|
||||||
self.generate_bookmark_model()
|
self.generate_bookmark_model()
|
||||||
|
|
||||||
|
# Create the annotation notes dock
|
||||||
|
self.annotationNoteDock = PliantDockWidget(self.main_window, True, self.contentView)
|
||||||
|
self.annotationNoteDock.setWindowTitle(self._translate('Tab', 'Note'))
|
||||||
|
self.annotationNoteDock.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
|
||||||
|
self.annotationNoteDock.hide()
|
||||||
|
|
||||||
|
self.annotationNoteEdit = QtWidgets.QTextEdit(self.annotationNoteDock)
|
||||||
|
self.annotationNoteEdit.setMaximumSize(QtCore.QSize(250, 250))
|
||||||
|
self.annotationNoteEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||||
|
self.annotationNoteDock.setWidget(self.annotationNoteEdit)
|
||||||
|
|
||||||
self.generate_keyboard_shortcuts()
|
self.generate_keyboard_shortcuts()
|
||||||
|
|
||||||
self.masterLayout.addWidget(self.contentView)
|
self.masterLayout.addWidget(self.contentView)
|
||||||
self.masterLayout.addWidget(self.annotationDock)
|
self.masterLayout.addWidget(self.sideDock)
|
||||||
self.masterLayout.addWidget(self.annotationNoteDock)
|
self.masterLayout.addWidget(self.annotationNoteDock)
|
||||||
self.masterLayout.addWidget(self.bookmarkDock)
|
|
||||||
|
|
||||||
# The following has to be after the docks are added to the layout
|
# The following has to be after the docks are added to the layout
|
||||||
self.annotationDock.setFloating(True)
|
self.sideDock.setFloating(True)
|
||||||
self.annotationDock.setWindowOpacity(.95)
|
self.sideDock.setWindowOpacity(.95)
|
||||||
self.annotationNoteDock.setFloating(True)
|
self.annotationNoteDock.setFloating(True)
|
||||||
self.annotationNoteDock.setWindowOpacity(.95)
|
self.annotationNoteDock.setWindowOpacity(.95)
|
||||||
self.bookmarkDock.setFloating(True)
|
|
||||||
self.bookmarkDock.setWindowOpacity(.95)
|
|
||||||
|
|
||||||
title = self.metadata['title']
|
title = self.metadata['title']
|
||||||
if self.main_window.settings['attenuate_titles'] and len(title) > 30:
|
if self.main_window.settings['attenuate_titles'] and len(title) > 30:
|
||||||
@@ -209,6 +198,18 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.contentView.setFocus()
|
self.contentView.setFocus()
|
||||||
|
|
||||||
|
def toggle_side_dock(self, tab_required=1):
|
||||||
|
if (self.sideDock.isVisible()
|
||||||
|
and self.sideDockTabWidget.currentIndex() == tab_required):
|
||||||
|
self.sideDock.hide()
|
||||||
|
elif not self.sideDock.isVisible():
|
||||||
|
self.sideDock.show()
|
||||||
|
|
||||||
|
if tab_required == 0:
|
||||||
|
self.sideDockTabWidget.setCurrentIndex(0)
|
||||||
|
else: # Takes care of the action menu as well
|
||||||
|
self.sideDockTabWidget.setCurrentIndex(1)
|
||||||
|
|
||||||
def update_last_accessed_time(self):
|
def update_last_accessed_time(self):
|
||||||
self.metadata['last_accessed'] = QtCore.QDateTime().currentDateTime()
|
self.metadata['last_accessed'] = QtCore.QDateTime().currentDateTime()
|
||||||
|
|
||||||
@@ -301,13 +302,13 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.ksToggleBookMarks = QtWidgets.QShortcut(
|
self.ksToggleBookMarks = QtWidgets.QShortcut(
|
||||||
QtGui.QKeySequence('Ctrl+B'), self.contentView)
|
QtGui.QKeySequence('Ctrl+B'), self.contentView)
|
||||||
self.ksToggleBookMarks.activated.connect(self.toggle_bookmarks)
|
self.ksToggleBookMarks.activated.connect(self.toggle_side_dock)
|
||||||
|
|
||||||
def go_fullscreen(self):
|
def go_fullscreen(self):
|
||||||
# To allow toggles to function
|
# To allow toggles to function
|
||||||
# properly after the fullscreening
|
# properly after the fullscreening
|
||||||
self.bookmarkDock.hide()
|
|
||||||
self.annotationDock.hide()
|
self.sideDock.hide()
|
||||||
self.annotationNoteDock.hide()
|
self.annotationNoteDock.hide()
|
||||||
|
|
||||||
if self.contentView.windowState() == QtCore.Qt.WindowFullScreen:
|
if self.contentView.windowState() == QtCore.Qt.WindowFullScreen:
|
||||||
@@ -328,11 +329,16 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.is_fullscreen = True
|
self.is_fullscreen = True
|
||||||
|
|
||||||
def exit_fullscreen(self):
|
def exit_fullscreen(self):
|
||||||
for i in (self.bookmarkDock, self.annotationDock, self.annotationNoteDock):
|
# Intercept escape presses
|
||||||
|
for i in (self.annotationNoteDock, self.sideDock):
|
||||||
if i.isVisible():
|
if i.isVisible():
|
||||||
i.setVisible(False)
|
i.setVisible(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Prevents cursor position change on escape presses
|
||||||
|
if self.main_window.isVisible():
|
||||||
|
return
|
||||||
|
|
||||||
if not self.are_we_doing_images_only:
|
if not self.are_we_doing_images_only:
|
||||||
self.contentView.record_position()
|
self.contentView.record_position()
|
||||||
|
|
||||||
@@ -424,12 +430,6 @@ class Tab(QtWidgets.QWidget):
|
|||||||
if old_position == new_position:
|
if old_position == new_position:
|
||||||
break
|
break
|
||||||
|
|
||||||
def toggle_annotations(self):
|
|
||||||
if self.annotationDock.isVisible():
|
|
||||||
self.annotationDock.hide()
|
|
||||||
else:
|
|
||||||
self.annotationDock.show()
|
|
||||||
|
|
||||||
def generate_annotation_model(self):
|
def generate_annotation_model(self):
|
||||||
saved_annotations = self.main_window.settings['annotations']
|
saved_annotations = self.main_window.settings['annotations']
|
||||||
|
|
||||||
@@ -451,12 +451,6 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.annotationListView.setModel(self.annotationModel)
|
self.annotationListView.setModel(self.annotationModel)
|
||||||
|
|
||||||
def toggle_bookmarks(self):
|
|
||||||
if self.bookmarkDock.isVisible():
|
|
||||||
self.bookmarkDock.hide()
|
|
||||||
else:
|
|
||||||
self.bookmarkDock.show()
|
|
||||||
|
|
||||||
def add_bookmark(self):
|
def add_bookmark(self):
|
||||||
identifier = uuid.uuid4().hex[:10]
|
identifier = uuid.uuid4().hex[:10]
|
||||||
description = self._translate('Tab', 'New bookmark')
|
description = self._translate('Tab', 'New bookmark')
|
||||||
@@ -472,7 +466,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
'cursor_position': cursor_position,
|
'cursor_position': cursor_position,
|
||||||
'description': description}
|
'description': description}
|
||||||
|
|
||||||
self.bookmarkDock.setVisible(True)
|
self.sideDock.setVisible(True)
|
||||||
self.add_bookmark_to_model(
|
self.add_bookmark_to_model(
|
||||||
description, chapter, cursor_position, identifier, True)
|
description, chapter, cursor_position, identifier, True)
|
||||||
|
|
||||||
@@ -484,7 +478,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
new_child = parent_item.child(parent_item.rowCount() - 1, 0)
|
new_child = parent_item.child(parent_item.rowCount() - 1, 0)
|
||||||
source_index = self.bookmarkModel.indexFromItem(new_child)
|
source_index = self.bookmarkModel.indexFromItem(new_child)
|
||||||
edit_index = self.bookmarkTreeView.model().mapFromSource(source_index)
|
edit_index = self.bookmarkTreeView.model().mapFromSource(source_index)
|
||||||
self.bookmarkDock.activateWindow()
|
self.sideDock.activateWindow()
|
||||||
self.bookmarkTreeView.setFocus()
|
self.bookmarkTreeView.setFocus()
|
||||||
self.bookmarkTreeView.setCurrentIndex(edit_index)
|
self.bookmarkTreeView.setCurrentIndex(edit_index)
|
||||||
self.bookmarkTreeView.edit(edit_index)
|
self.bookmarkTreeView.edit(edit_index)
|
||||||
@@ -632,10 +626,10 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
|
|
||||||
class PliantDockWidget(QtWidgets.QDockWidget):
|
class PliantDockWidget(QtWidgets.QDockWidget):
|
||||||
def __init__(self, main_window, intended_for, contentView, parent=None):
|
def __init__(self, main_window, notes_only, contentView, parent=None):
|
||||||
super(PliantDockWidget, self).__init__()
|
super(PliantDockWidget, self).__init__()
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
self.intended_for = intended_for
|
self.notes_only = notes_only
|
||||||
self.contentView = contentView
|
self.contentView = contentView
|
||||||
self.current_annotation = None
|
self.current_annotation = None
|
||||||
|
|
||||||
@@ -643,43 +637,30 @@ class PliantDockWidget(QtWidgets.QDockWidget):
|
|||||||
viewport_height = self.contentView.viewport().size().height()
|
viewport_height = self.contentView.viewport().size().height()
|
||||||
viewport_topRight = self.contentView.mapToGlobal(
|
viewport_topRight = self.contentView.mapToGlobal(
|
||||||
self.contentView.viewport().rect().topRight())
|
self.contentView.viewport().rect().topRight())
|
||||||
viewport_topLeft = self.contentView.mapToGlobal(
|
|
||||||
self.contentView.viewport().rect().topLeft())
|
|
||||||
|
|
||||||
desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
|
desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
|
||||||
dock_y = viewport_topRight.y() # + (viewport_height * .10)
|
dock_y = viewport_topRight.y()
|
||||||
dock_height = viewport_height * .999
|
dock_height = viewport_height * .999
|
||||||
|
|
||||||
if self.intended_for == 'bookmarks':
|
if self.notes_only:
|
||||||
dock_width = desktop_size.width() // 5.5
|
|
||||||
dock_x = viewport_topLeft.x()
|
|
||||||
self.main_window.bookToolBar.bookmarkButton.setChecked(True)
|
|
||||||
|
|
||||||
elif self.intended_for == 'annotations':
|
|
||||||
dock_width = desktop_size.width() // 5.5
|
|
||||||
dock_x = viewport_topRight.x() - dock_width + 1
|
|
||||||
self.main_window.bookToolBar.annotationButton.setChecked(True)
|
|
||||||
|
|
||||||
elif self.intended_for == 'notes':
|
|
||||||
dock_width = dock_height = desktop_size.width() // 5.5
|
dock_width = dock_height = desktop_size.width() // 5.5
|
||||||
dock_x = QtGui.QCursor.pos().x()
|
dock_x = QtGui.QCursor.pos().x()
|
||||||
dock_y = QtGui.QCursor.pos().y()
|
dock_y = QtGui.QCursor.pos().y()
|
||||||
|
else:
|
||||||
|
dock_width = desktop_size.width() // 5.5
|
||||||
|
dock_x = viewport_topRight.x() - dock_width + 1
|
||||||
|
|
||||||
self.main_window.active_bookmark_docks.append(self)
|
self.main_window.active_docks.append(self)
|
||||||
self.setGeometry(dock_x, dock_y, dock_width, dock_height)
|
self.setGeometry(dock_x, dock_y, dock_width, dock_height)
|
||||||
|
|
||||||
def hideEvent(self, event=None):
|
def hideEvent(self, event=None):
|
||||||
if self.intended_for == 'bookmarks':
|
if self.notes_only:
|
||||||
self.main_window.bookToolBar.bookmarkButton.setChecked(False)
|
|
||||||
elif self.intended_for == 'annotations':
|
|
||||||
self.main_window.bookToolBar.annotationButton.setChecked(False)
|
|
||||||
elif self.intended_for == 'notes':
|
|
||||||
annotationNoteEdit = self.findChild(QtWidgets.QTextEdit)
|
annotationNoteEdit = self.findChild(QtWidgets.QTextEdit)
|
||||||
if self.current_annotation:
|
if self.current_annotation:
|
||||||
self.current_annotation['note'] = annotationNoteEdit.toPlainText()
|
self.current_annotation['note'] = annotationNoteEdit.toPlainText()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.main_window.active_bookmark_docks.remove(self)
|
self.main_window.active_docks.remove(self)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user