Complete annotation editor
Annotation saving and loading
This commit is contained in:
		
							
								
								
									
										248
									
								
								lector/annotations.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										248
									
								
								lector/annotations.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,248 @@ | ||||
| #!/usr/bin/env python3 | ||||
|  | ||||
| # This file is a part of Lector, a Qt based ebook reader | ||||
| # Copyright (C) 2017-2018 BasioMeusPuga | ||||
|  | ||||
| # 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 | ||||
| # the Free Software Foundation, either version 3 of the License, or | ||||
| # (at your option) any later version. | ||||
|  | ||||
| # This program is distributed in the hope that it will be useful, | ||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  | ||||
| from PyQt5 import QtWidgets, QtCore, QtGui | ||||
|  | ||||
| from lector.resources import annotationswindow | ||||
|  | ||||
|  | ||||
| class AnnotationsUI(QtWidgets.QDialog, annotationswindow.Ui_Dialog): | ||||
|     def __init__(self, parent=None): | ||||
|         super(AnnotationsUI, self).__init__() | ||||
|         self.setupUi(self) | ||||
|  | ||||
|         self.parent = parent | ||||
|         self._translate = QtCore.QCoreApplication.translate | ||||
|  | ||||
|         # Current annotation | ||||
|         self.modelIndex = None  # The index of the annotations list model in the parent dialog | ||||
|         self.current_annotation = {} | ||||
|  | ||||
|         # Populate annotation type | ||||
|         textmarkup_string = self._translate('AnnotationsUI', 'Text markup') | ||||
|         all_types = [textmarkup_string] | ||||
|         for i in all_types: | ||||
|             self.typeBox.addItem(i) | ||||
|  | ||||
|         # Init defaults | ||||
|         self.default_stylesheet = self.foregroundCheck.styleSheet() | ||||
|         self.foregroundColor = QtGui.QColor.fromRgb(0, 0, 0) | ||||
|         self.underlineColor = QtGui.QColor.fromRgb(255, 0, 0) | ||||
|         self.highlightColor = QtGui.QColor.fromRgb(66, 209, 56) | ||||
|         self.underline_styles = { | ||||
|             'Solid': QtGui.QTextCharFormat.SingleUnderline, | ||||
|             'Dashes': QtGui.QTextCharFormat.DashUnderline, | ||||
|             'Dots': QtGui.QTextCharFormat.DotLine, | ||||
|             'Wavy': QtGui.QTextCharFormat.WaveUnderline} | ||||
|  | ||||
|         # Push buttons | ||||
|         self.foregroundColorButton.clicked.connect(self.modify_annotation) | ||||
|         self.highlightColorButton.clicked.connect(self.modify_annotation) | ||||
|         self.underlineColorButton.clicked.connect(self.modify_annotation) | ||||
|  | ||||
|         self.okButton.clicked.connect(self.ok_pressed) | ||||
|         self.cancelButton.clicked.connect(self.hide) | ||||
|  | ||||
|         # Underline combo box | ||||
|         underline_items = ['Solid', 'Dashes', 'Dots', 'Wavy'] | ||||
|         self.underlineType.addItems(underline_items) | ||||
|         self.underlineType.currentIndexChanged.connect(self.modify_annotation) | ||||
|  | ||||
|         # Text markup related checkboxes | ||||
|         self.foregroundCheck.clicked.connect(self.modify_annotation) | ||||
|         self.highlightCheck.clicked.connect(self.modify_annotation) | ||||
|         self.boldCheck.clicked.connect(self.modify_annotation) | ||||
|         self.italicCheck.clicked.connect(self.modify_annotation) | ||||
|         self.underlineCheck.clicked.connect(self.modify_annotation) | ||||
|  | ||||
|     def show_dialog(self, mode, index=None): | ||||
|         if mode == 'edit' or mode == 'preview': | ||||
|             self.modelIndex = index | ||||
|             this_annotation = self.parent.annotationModel.data( | ||||
|                 index, QtCore.Qt.UserRole) | ||||
|  | ||||
|             annotation_name = this_annotation['name'] | ||||
|             self.nameEdit.setText(annotation_name) | ||||
|  | ||||
|             annotation_components = this_annotation['components'] | ||||
|  | ||||
|             if 'foregroundColor' in annotation_components: | ||||
|                 self.foregroundCheck.setChecked(True) | ||||
|                 self.set_button_background_color( | ||||
|                     self.foregroundColorButton, annotation_components['foregroundColor']) | ||||
|             else: | ||||
|                 self.foregroundCheck.setChecked(False) | ||||
|  | ||||
|             if 'highlightColor' in annotation_components: | ||||
|                 self.highlightCheck.setChecked(True) | ||||
|                 self.set_button_background_color( | ||||
|                     self.highlightColorButton, annotation_components['highlightColor']) | ||||
|             else: | ||||
|                 self.highlightCheck.setChecked(False) | ||||
|  | ||||
|             if 'bold' in annotation_components: | ||||
|                 self.boldCheck.setChecked(True) | ||||
|             else: | ||||
|                 self.boldCheck.setChecked(False) | ||||
|  | ||||
|             if 'italic' in annotation_components: | ||||
|                 self.italicCheck.setChecked(True) | ||||
|             else: | ||||
|                 self.italicCheck.setChecked(False) | ||||
|  | ||||
|             if 'underline' in annotation_components: | ||||
|                 self.underlineCheck.setChecked(True) | ||||
|                 underline_params = annotation_components['underline'] | ||||
|                 self.underlineType.setCurrentText(underline_params[0]) | ||||
|                 self.set_button_background_color( | ||||
|                     self.underlineColorButton, underline_params[1]) | ||||
|             else: | ||||
|                 self.underlineCheck.setChecked(False) | ||||
|  | ||||
|         elif mode == 'add': | ||||
|             new_annotation_string = self._translate('AnnotationsUI', 'New annotation') | ||||
|             self.nameEdit.setText(new_annotation_string) | ||||
|  | ||||
|             all_checkboxes = ( | ||||
|                 self.foregroundCheck, self.highlightCheck, | ||||
|                 self.boldCheck, self.italicCheck, self.underlineCheck) | ||||
|             for i in all_checkboxes: | ||||
|                 i.setChecked(False) | ||||
|  | ||||
|             self.modelIndex = None | ||||
|             self.set_button_background_color( | ||||
|                 self.foregroundColorButton, self.foregroundColor) | ||||
|             self.set_button_background_color( | ||||
|                 self.highlightColorButton, self.highlightColor) | ||||
|             self.set_button_background_color( | ||||
|                 self.underlineColorButton, self.underlineColor) | ||||
|  | ||||
|         self.update_preview() | ||||
|         if mode != 'preview': | ||||
|             self.show() | ||||
|  | ||||
|     def set_button_background_color(self, button, color): | ||||
|         button.setStyleSheet( | ||||
|             "QPushButton {{background-color: {0}}}".format(color.name())) | ||||
|  | ||||
|     def update_preview(self): | ||||
|         cursor = self.parent.previewView.textCursor() | ||||
|         cursor.setPosition(0) | ||||
|         cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.KeepAnchor) | ||||
|  | ||||
|         # TODO | ||||
|         # Other kinds of text markup | ||||
|         previewCharFormat = QtGui.QTextCharFormat() | ||||
|  | ||||
|         if self.foregroundCheck.isChecked(): | ||||
|             previewCharFormat.setForeground(self.foregroundColor) | ||||
|  | ||||
|         highlight = QtCore.Qt.transparent | ||||
|         if self.highlightCheck.isChecked(): | ||||
|             highlight = self.highlightColor | ||||
|         previewCharFormat.setBackground(highlight) | ||||
|  | ||||
|         font_weight = QtGui.QFont.Normal | ||||
|         if self.boldCheck.isChecked(): | ||||
|             font_weight = QtGui.QFont.Bold | ||||
|         previewCharFormat.setFontWeight(font_weight) | ||||
|  | ||||
|         if self.italicCheck.isChecked(): | ||||
|             previewCharFormat.setFontItalic(True) | ||||
|  | ||||
|         if self.underlineCheck.isChecked(): | ||||
|             previewCharFormat.setFontUnderline(True) | ||||
|             previewCharFormat.setUnderlineColor(self.underlineColor) | ||||
|             previewCharFormat.setUnderlineStyle( | ||||
|                 self.underline_styles[self.underlineType.currentText()]) | ||||
|  | ||||
|         previewCharFormat.setFontStyleStrategy( | ||||
|             QtGui.QFont.PreferAntialias) | ||||
|  | ||||
|         cursor.setCharFormat(previewCharFormat) | ||||
|         cursor.clearSelection() | ||||
|         self.parent.previewView.setTextCursor(cursor) | ||||
|  | ||||
|     def modify_annotation(self): | ||||
|         sender = self.sender() | ||||
|         if isinstance(sender, QtWidgets.QCheckBox): | ||||
|             if not sender.isChecked(): | ||||
|                 self.update_preview() | ||||
|                 return | ||||
|  | ||||
|         if sender == self.foregroundColorButton: | ||||
|             new_color = self.get_color(self.foregroundColor) | ||||
|             self.set_button_background_color(self.foregroundColorButton, new_color) | ||||
|             self.foregroundColor = new_color | ||||
|  | ||||
|         if sender == self.highlightColorButton: | ||||
|             new_color = self.get_color(self.highlightColor) | ||||
|             self.set_button_background_color(self.highlightColorButton, new_color) | ||||
|             self.highlightColor = new_color | ||||
|  | ||||
|         if sender == self.underlineColorButton: | ||||
|             new_color = self.get_color(self.underlineColor) | ||||
|             self.set_button_background_color(self.underlineColorButton, new_color) | ||||
|             self.underlineColor = new_color | ||||
|  | ||||
|         self.update_preview() | ||||
|  | ||||
|     def get_color(self, current_color): | ||||
|         color_dialog = QtWidgets.QColorDialog() | ||||
|         new_color = color_dialog.getColor(current_color) | ||||
|         if new_color.isValid():  # Returned in case cancel is pressed | ||||
|             return new_color | ||||
|         else: | ||||
|             return current_color | ||||
|  | ||||
|     def ok_pressed(self): | ||||
|         annotation_name = self.nameEdit.text() | ||||
|         if annotation_name == '': | ||||
|             self.nameEdit.setText('Why do you like bugs? WHY?') | ||||
|             return | ||||
|  | ||||
|         annotation_components = {} | ||||
|         if self.foregroundCheck.isChecked(): | ||||
|             annotation_components['foregroundColor'] = self.foregroundColor | ||||
|         if self.highlightCheck.isChecked(): | ||||
|             annotation_components['highlightColor'] = self.highlightColor | ||||
|         if self.boldCheck.isChecked(): | ||||
|             annotation_components['bold'] = True | ||||
|         if self.italicCheck.isChecked(): | ||||
|             annotation_components['italic'] = True | ||||
|         if self.underlineCheck.isChecked(): | ||||
|             annotation_components['underline'] = ( | ||||
|                 self.underlineType.currentText(), self.underlineColor) | ||||
|  | ||||
|         self.current_annotation = { | ||||
|             'name': annotation_name, | ||||
|             'type': 'text_markup', | ||||
|             'components': annotation_components} | ||||
|  | ||||
|         if self.modelIndex: | ||||
|             self.parent.annotationModel.setData( | ||||
|                 self.modelIndex, annotation_name, QtCore.Qt.DisplayRole) | ||||
|             self.parent.annotationModel.setData( | ||||
|                 self.modelIndex, self.current_annotation, QtCore.Qt.UserRole) | ||||
|         else:  # New annotation | ||||
|             new_annotation_item = QtGui.QStandardItem() | ||||
|             new_annotation_item.setText(annotation_name) | ||||
|             new_annotation_item.setData(self.current_annotation, QtCore.Qt.UserRole) | ||||
|             self.parent.annotationModel.appendRow(new_annotation_item) | ||||
|  | ||||
|         self.hide() | ||||
							
								
								
									
										146
									
								
								lector/resources/annotationswindow.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								lector/resources/annotationswindow.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,146 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| # Form implementation generated from reading ui file 'raw/annotations.ui' | ||||
| # | ||||
| # Created by: PyQt5 UI code generator 5.10.1 | ||||
| # | ||||
| # WARNING! All changes made in this file will be lost! | ||||
|  | ||||
| from PyQt5 import QtCore, QtGui, QtWidgets | ||||
|  | ||||
| class Ui_Dialog(object): | ||||
|     def setupUi(self, Dialog): | ||||
|         Dialog.setObjectName("Dialog") | ||||
|         Dialog.resize(306, 387) | ||||
|         self.gridLayout = QtWidgets.QGridLayout(Dialog) | ||||
|         self.gridLayout.setObjectName("gridLayout") | ||||
|         self.verticalLayout = QtWidgets.QVBoxLayout() | ||||
|         self.verticalLayout.setObjectName("verticalLayout") | ||||
|         self.horizontalLayout_2 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_2.setObjectName("horizontalLayout_2") | ||||
|         self.nameEdit = QtWidgets.QLineEdit(Dialog) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.nameEdit.sizePolicy().hasHeightForWidth()) | ||||
|         self.nameEdit.setSizePolicy(sizePolicy) | ||||
|         self.nameEdit.setObjectName("nameEdit") | ||||
|         self.horizontalLayout_2.addWidget(self.nameEdit) | ||||
|         self.verticalLayout.addLayout(self.horizontalLayout_2) | ||||
|         self.horizontalLayout = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout.setObjectName("horizontalLayout") | ||||
|         self.typeLabel = QtWidgets.QLabel(Dialog) | ||||
|         self.typeLabel.setObjectName("typeLabel") | ||||
|         self.horizontalLayout.addWidget(self.typeLabel) | ||||
|         self.typeBox = QtWidgets.QComboBox(Dialog) | ||||
|         self.typeBox.setObjectName("typeBox") | ||||
|         self.horizontalLayout.addWidget(self.typeBox) | ||||
|         self.verticalLayout.addLayout(self.horizontalLayout) | ||||
|         self.stackedWidget = QtWidgets.QStackedWidget(Dialog) | ||||
|         self.stackedWidget.setObjectName("stackedWidget") | ||||
|         self.page = QtWidgets.QWidget() | ||||
|         self.page.setObjectName("page") | ||||
|         self.gridLayout_2 = QtWidgets.QGridLayout(self.page) | ||||
|         self.gridLayout_2.setObjectName("gridLayout_2") | ||||
|         self.verticalLayout_12 = QtWidgets.QVBoxLayout() | ||||
|         self.verticalLayout_12.setObjectName("verticalLayout_12") | ||||
|         self.horizontalLayout_15 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_15.setObjectName("horizontalLayout_15") | ||||
|         self.foregroundCheck = QtWidgets.QCheckBox(self.page) | ||||
|         self.foregroundCheck.setObjectName("foregroundCheck") | ||||
|         self.horizontalLayout_15.addWidget(self.foregroundCheck) | ||||
|         self.foregroundColorButton = QtWidgets.QPushButton(self.page) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.foregroundColorButton.sizePolicy().hasHeightForWidth()) | ||||
|         self.foregroundColorButton.setSizePolicy(sizePolicy) | ||||
|         self.foregroundColorButton.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.foregroundColorButton.setMaximumSize(QtCore.QSize(45, 40)) | ||||
|         self.foregroundColorButton.setText("") | ||||
|         self.foregroundColorButton.setObjectName("foregroundColorButton") | ||||
|         self.horizontalLayout_15.addWidget(self.foregroundColorButton) | ||||
|         self.verticalLayout_12.addLayout(self.horizontalLayout_15) | ||||
|         self.horizontalLayout_16 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_16.setObjectName("horizontalLayout_16") | ||||
|         self.highlightCheck = QtWidgets.QCheckBox(self.page) | ||||
|         self.highlightCheck.setObjectName("highlightCheck") | ||||
|         self.horizontalLayout_16.addWidget(self.highlightCheck) | ||||
|         self.highlightColorButton = QtWidgets.QPushButton(self.page) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.highlightColorButton.sizePolicy().hasHeightForWidth()) | ||||
|         self.highlightColorButton.setSizePolicy(sizePolicy) | ||||
|         self.highlightColorButton.setMinimumSize(QtCore.QSize(30, 24)) | ||||
|         self.highlightColorButton.setMaximumSize(QtCore.QSize(45, 40)) | ||||
|         self.highlightColorButton.setText("") | ||||
|         self.highlightColorButton.setObjectName("highlightColorButton") | ||||
|         self.horizontalLayout_16.addWidget(self.highlightColorButton) | ||||
|         self.verticalLayout_12.addLayout(self.horizontalLayout_16) | ||||
|         self.horizontalLayout_17 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_17.setObjectName("horizontalLayout_17") | ||||
|         self.boldCheck = QtWidgets.QCheckBox(self.page) | ||||
|         self.boldCheck.setObjectName("boldCheck") | ||||
|         self.horizontalLayout_17.addWidget(self.boldCheck) | ||||
|         self.verticalLayout_12.addLayout(self.horizontalLayout_17) | ||||
|         self.horizontalLayout_18 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_18.setObjectName("horizontalLayout_18") | ||||
|         self.italicCheck = QtWidgets.QCheckBox(self.page) | ||||
|         self.italicCheck.setObjectName("italicCheck") | ||||
|         self.horizontalLayout_18.addWidget(self.italicCheck) | ||||
|         self.verticalLayout_12.addLayout(self.horizontalLayout_18) | ||||
|         self.horizontalLayout_19 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_19.setObjectName("horizontalLayout_19") | ||||
|         self.underlineCheck = QtWidgets.QCheckBox(self.page) | ||||
|         self.underlineCheck.setObjectName("underlineCheck") | ||||
|         self.horizontalLayout_19.addWidget(self.underlineCheck) | ||||
|         self.underlineType = QtWidgets.QComboBox(self.page) | ||||
|         self.underlineType.setObjectName("underlineType") | ||||
|         self.horizontalLayout_19.addWidget(self.underlineType) | ||||
|         self.underlineColorButton = QtWidgets.QPushButton(self.page) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.underlineColorButton.sizePolicy().hasHeightForWidth()) | ||||
|         self.underlineColorButton.setSizePolicy(sizePolicy) | ||||
|         self.underlineColorButton.setMinimumSize(QtCore.QSize(45, 24)) | ||||
|         self.underlineColorButton.setMaximumSize(QtCore.QSize(45, 40)) | ||||
|         self.underlineColorButton.setText("") | ||||
|         self.underlineColorButton.setObjectName("underlineColorButton") | ||||
|         self.horizontalLayout_19.addWidget(self.underlineColorButton) | ||||
|         self.verticalLayout_12.addLayout(self.horizontalLayout_19) | ||||
|         self.gridLayout_2.addLayout(self.verticalLayout_12, 0, 0, 1, 1) | ||||
|         self.stackedWidget.addWidget(self.page) | ||||
|         self.verticalLayout.addWidget(self.stackedWidget) | ||||
|         self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) | ||||
|         self.horizontalLayout_3 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_3.setObjectName("horizontalLayout_3") | ||||
|         spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | ||||
|         self.horizontalLayout_3.addItem(spacerItem) | ||||
|         self.okButton = QtWidgets.QPushButton(Dialog) | ||||
|         self.okButton.setObjectName("okButton") | ||||
|         self.horizontalLayout_3.addWidget(self.okButton) | ||||
|         self.cancelButton = QtWidgets.QPushButton(Dialog) | ||||
|         self.cancelButton.setObjectName("cancelButton") | ||||
|         self.horizontalLayout_3.addWidget(self.cancelButton) | ||||
|         spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | ||||
|         self.horizontalLayout_3.addItem(spacerItem1) | ||||
|         self.gridLayout.addLayout(self.horizontalLayout_3, 1, 0, 1, 1) | ||||
|  | ||||
|         self.retranslateUi(Dialog) | ||||
|         QtCore.QMetaObject.connectSlotsByName(Dialog) | ||||
|  | ||||
|     def retranslateUi(self, Dialog): | ||||
|         _translate = QtCore.QCoreApplication.translate | ||||
|         Dialog.setWindowTitle(_translate("Dialog", "Annotation Editor")) | ||||
|         self.nameEdit.setPlaceholderText(_translate("Dialog", "Annotation Name")) | ||||
|         self.typeLabel.setText(_translate("Dialog", "Type")) | ||||
|         self.foregroundCheck.setText(_translate("Dialog", "Foreground")) | ||||
|         self.highlightCheck.setText(_translate("Dialog", "Highlight")) | ||||
|         self.boldCheck.setText(_translate("Dialog", "Bold")) | ||||
|         self.italicCheck.setText(_translate("Dialog", "Italic")) | ||||
|         self.underlineCheck.setText(_translate("Dialog", "Underline")) | ||||
|         self.okButton.setText(_translate("Dialog", "OK")) | ||||
|         self.cancelButton.setText(_translate("Dialog", "Cancel")) | ||||
|  | ||||
							
								
								
									
										8
									
								
								lector/resources/raw/DarkIcons/arrow-down.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lector/resources/raw/DarkIcons/arrow-down.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"> | ||||
|  <defs> | ||||
|   <style id="current-color-scheme" type="text/css"> | ||||
|    .ColorScheme-Text { color:#5c616c; } .ColorScheme-Highlight { color:#5294e2; } | ||||
|   </style> | ||||
|  </defs> | ||||
|  <path style="fill:currentColor" class="ColorScheme-Text" d="M 3 6 L 8 11 L 13 6 L 3 6 z" transform="translate(3 3)"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 372 B | 
							
								
								
									
										8
									
								
								lector/resources/raw/DarkIcons/arrow-up.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lector/resources/raw/DarkIcons/arrow-up.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"> | ||||
|  <defs> | ||||
|   <style id="current-color-scheme" type="text/css"> | ||||
|    .ColorScheme-Text { color:#5c616c; } .ColorScheme-Highlight { color:#5294e2; } | ||||
|   </style> | ||||
|  </defs> | ||||
|  <path style="fill:currentColor" class="ColorScheme-Text" d="M 8 5 L 3 10 L 13 10 L 8 5 z" transform="translate(3 3)"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 373 B | 
							
								
								
									
										8
									
								
								lector/resources/raw/LightIcons/arrow-down.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lector/resources/raw/LightIcons/arrow-down.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"> | ||||
|  <defs> | ||||
|   <style id="current-color-scheme" type="text/css"> | ||||
|    .ColorScheme-Text { color:#d3dae3; } .ColorScheme-Highlight { color:#5294e2; } | ||||
|   </style> | ||||
|  </defs> | ||||
|  <path style="fill:currentColor" class="ColorScheme-Text" d="M 3 6 L 8 11 L 13 6 L 3 6 z" transform="translate(3 3)"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 372 B | 
							
								
								
									
										8
									
								
								lector/resources/raw/LightIcons/arrow-up.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lector/resources/raw/LightIcons/arrow-up.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"> | ||||
|  <defs> | ||||
|   <style id="current-color-scheme" type="text/css"> | ||||
|    .ColorScheme-Text { color:#d3dae3; } .ColorScheme-Highlight { color:#5294e2; } | ||||
|   </style> | ||||
|  </defs> | ||||
|  <path style="fill:currentColor" class="ColorScheme-Text" d="M 8 5 L 3 10 L 13 10 L 8 5 z" transform="translate(3 3)"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 373 B | 
							
								
								
									
										245
									
								
								lector/resources/raw/annotations.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										245
									
								
								lector/resources/raw/annotations.ui
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,245 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>Dialog</class> | ||||
|  <widget class="QDialog" name="Dialog"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>306</width> | ||||
|     <height>387</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>Annotation Editor</string> | ||||
|   </property> | ||||
|   <layout class="QGridLayout" name="gridLayout"> | ||||
|    <item row="0" column="0"> | ||||
|     <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|      <item> | ||||
|       <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||||
|        <item> | ||||
|         <widget class="QLineEdit" name="nameEdit"> | ||||
|          <property name="sizePolicy"> | ||||
|           <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|            <horstretch>0</horstretch> | ||||
|            <verstretch>0</verstretch> | ||||
|           </sizepolicy> | ||||
|          </property> | ||||
|          <property name="placeholderText"> | ||||
|           <string>Annotation Name</string> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|       </layout> | ||||
|      </item> | ||||
|      <item> | ||||
|       <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
|        <item> | ||||
|         <widget class="QLabel" name="typeLabel"> | ||||
|          <property name="text"> | ||||
|           <string>Type</string> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QComboBox" name="typeBox"/> | ||||
|        </item> | ||||
|       </layout> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QStackedWidget" name="stackedWidget"> | ||||
|        <widget class="QWidget" name="page"> | ||||
|         <layout class="QGridLayout" name="gridLayout_2"> | ||||
|          <item row="0" column="0"> | ||||
|           <layout class="QVBoxLayout" name="verticalLayout_12"> | ||||
|            <item> | ||||
|             <layout class="QHBoxLayout" name="horizontalLayout_15"> | ||||
|              <item> | ||||
|               <widget class="QCheckBox" name="foregroundCheck"> | ||||
|                <property name="text"> | ||||
|                 <string>Foreground</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QPushButton" name="foregroundColorButton"> | ||||
|                <property name="sizePolicy"> | ||||
|                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||||
|                  <horstretch>0</horstretch> | ||||
|                  <verstretch>0</verstretch> | ||||
|                 </sizepolicy> | ||||
|                </property> | ||||
|                <property name="minimumSize"> | ||||
|                 <size> | ||||
|                  <width>30</width> | ||||
|                  <height>0</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="maximumSize"> | ||||
|                 <size> | ||||
|                  <width>45</width> | ||||
|                  <height>40</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string/> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </item> | ||||
|            <item> | ||||
|             <layout class="QHBoxLayout" name="horizontalLayout_16"> | ||||
|              <item> | ||||
|               <widget class="QCheckBox" name="highlightCheck"> | ||||
|                <property name="text"> | ||||
|                 <string>Highlight</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QPushButton" name="highlightColorButton"> | ||||
|                <property name="sizePolicy"> | ||||
|                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||||
|                  <horstretch>0</horstretch> | ||||
|                  <verstretch>0</verstretch> | ||||
|                 </sizepolicy> | ||||
|                </property> | ||||
|                <property name="minimumSize"> | ||||
|                 <size> | ||||
|                  <width>30</width> | ||||
|                  <height>24</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="maximumSize"> | ||||
|                 <size> | ||||
|                  <width>45</width> | ||||
|                  <height>40</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string/> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </item> | ||||
|            <item> | ||||
|             <layout class="QHBoxLayout" name="horizontalLayout_17"> | ||||
|              <item> | ||||
|               <widget class="QCheckBox" name="boldCheck"> | ||||
|                <property name="text"> | ||||
|                 <string>Bold</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </item> | ||||
|            <item> | ||||
|             <layout class="QHBoxLayout" name="horizontalLayout_18"> | ||||
|              <item> | ||||
|               <widget class="QCheckBox" name="italicCheck"> | ||||
|                <property name="text"> | ||||
|                 <string>Italic</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </item> | ||||
|            <item> | ||||
|             <layout class="QHBoxLayout" name="horizontalLayout_19"> | ||||
|              <item> | ||||
|               <widget class="QCheckBox" name="underlineCheck"> | ||||
|                <property name="text"> | ||||
|                 <string>Underline</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QComboBox" name="underlineType"/> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QPushButton" name="underlineColorButton"> | ||||
|                <property name="sizePolicy"> | ||||
|                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||||
|                  <horstretch>0</horstretch> | ||||
|                  <verstretch>0</verstretch> | ||||
|                 </sizepolicy> | ||||
|                </property> | ||||
|                <property name="minimumSize"> | ||||
|                 <size> | ||||
|                  <width>45</width> | ||||
|                  <height>24</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="maximumSize"> | ||||
|                 <size> | ||||
|                  <width>45</width> | ||||
|                  <height>40</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string/> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </item> | ||||
|           </layout> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </widget> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="1" column="0"> | ||||
|     <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||||
|      <item> | ||||
|       <spacer name="horizontalSpacer"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Horizontal</enum> | ||||
|        </property> | ||||
|        <property name="sizeHint" stdset="0"> | ||||
|         <size> | ||||
|          <width>40</width> | ||||
|          <height>20</height> | ||||
|         </size> | ||||
|        </property> | ||||
|       </spacer> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QPushButton" name="okButton"> | ||||
|        <property name="text"> | ||||
|         <string>OK</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QPushButton" name="cancelButton"> | ||||
|        <property name="text"> | ||||
|         <string>Cancel</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <spacer name="horizontalSpacer_2"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Horizontal</enum> | ||||
|        </property> | ||||
|        <property name="sizeHint" stdset="0"> | ||||
|         <size> | ||||
|          <width>40</width> | ||||
|          <height>20</height> | ||||
|         </size> | ||||
|        </property> | ||||
|       </spacer> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <resources/> | ||||
|  <connections/> | ||||
| </ui> | ||||
| @@ -1,5 +1,9 @@ | ||||
| <RCC> | ||||
|   <qresource prefix="images"> | ||||
|     <file>DarkIcons/arrow-down.svg</file> | ||||
|     <file>DarkIcons/arrow-up.svg</file> | ||||
|     <file>LightIcons/arrow-down.svg</file> | ||||
|     <file>LightIcons/arrow-up.svg</file> | ||||
|     <file>Lector.png</file> | ||||
|     <file>DarkIcons/tableofcontents.svg</file> | ||||
|     <file>LightIcons/tableofcontents.svg</file> | ||||
|   | ||||
| @@ -22,6 +22,9 @@ | ||||
|        <verstretch>0</verstretch> | ||||
|       </sizepolicy> | ||||
|      </property> | ||||
|      <property name="editTriggers"> | ||||
|       <set>QAbstractItemView::NoEditTriggers</set> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="0" column="1"> | ||||
| @@ -339,8 +342,11 @@ Reopen book to see changes</string> | ||||
|                        <height>16777215</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="toolTip"> | ||||
|                       <string>New</string> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string>+</string> | ||||
|                       <string/> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
| @@ -364,8 +370,39 @@ Reopen book to see changes</string> | ||||
|                        <height>16777215</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="toolTip"> | ||||
|                       <string>Delete</string> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string>-</string> | ||||
|                       <string/> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QPushButton" name="editAnnotation"> | ||||
|                      <property name="sizePolicy"> | ||||
|                       <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||||
|                        <horstretch>0</horstretch> | ||||
|                        <verstretch>0</verstretch> | ||||
|                       </sizepolicy> | ||||
|                      </property> | ||||
|                      <property name="minimumSize"> | ||||
|                       <size> | ||||
|                        <width>30</width> | ||||
|                        <height>0</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="maximumSize"> | ||||
|                       <size> | ||||
|                        <width>45</width> | ||||
|                        <height>16777215</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="toolTip"> | ||||
|                       <string>Edit</string> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string/> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
| @@ -389,8 +426,11 @@ Reopen book to see changes</string> | ||||
|                        <height>16777215</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="toolTip"> | ||||
|                       <string>Move Up</string> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string>⬆</string> | ||||
|                       <string/> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
| @@ -414,8 +454,11 @@ Reopen book to see changes</string> | ||||
|                        <height>16777215</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                      <property name="toolTip"> | ||||
|                       <string>Move Down</string> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string>⬇</string> | ||||
|                       <string/> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
| @@ -435,72 +478,17 @@ Reopen book to see changes</string> | ||||
|                   </layout> | ||||
|                  </item> | ||||
|                  <item> | ||||
|                   <widget class="QListView" name="annotationsList"/> | ||||
|                  </item> | ||||
|                  <item> | ||||
|                   <layout class="QVBoxLayout" name="verticalLayout_8"> | ||||
|                    <item> | ||||
|                     <spacer name="verticalSpacer_5"> | ||||
|                      <property name="orientation"> | ||||
|                       <enum>Qt::Vertical</enum> | ||||
|                      </property> | ||||
|                      <property name="sizeHint" stdset="0"> | ||||
|                       <size> | ||||
|                        <width>20</width> | ||||
|                        <height>40</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                     </spacer> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QCheckBox" name="foregroundCheck"> | ||||
|                      <property name="text"> | ||||
|                       <string>Foreground</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QCheckBox" name="highlightCheck"> | ||||
|                      <property name="text"> | ||||
|                       <string>Highlight</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QCheckBox" name="boldCheck"> | ||||
|                      <property name="text"> | ||||
|                       <string>Bold</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QCheckBox" name="italicCheck"> | ||||
|                      <property name="text"> | ||||
|                       <string>Italic</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QCheckBox" name="underlineCheck"> | ||||
|                      <property name="text"> | ||||
|                       <string>Underline</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <spacer name="verticalSpacer_4"> | ||||
|                      <property name="orientation"> | ||||
|                       <enum>Qt::Vertical</enum> | ||||
|                      </property> | ||||
|                      <property name="sizeHint" stdset="0"> | ||||
|                       <size> | ||||
|                        <width>20</width> | ||||
|                        <height>40</height> | ||||
|                       </size> | ||||
|                      </property> | ||||
|                     </spacer> | ||||
|                    </item> | ||||
|                   </layout> | ||||
|                   <widget class="QListView" name="annotationsList"> | ||||
|                    <property name="editTriggers"> | ||||
|                     <set>QAbstractItemView::NoEditTriggers</set> | ||||
|                    </property> | ||||
|                    <property name="showDropIndicator" stdset="0"> | ||||
|                     <bool>false</bool> | ||||
|                    </property> | ||||
|                    <property name="defaultDropAction"> | ||||
|                     <enum>Qt::IgnoreAction</enum> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                 </layout> | ||||
|                </item> | ||||
| @@ -522,6 +510,9 @@ Reopen book to see changes</string> | ||||
|                    <height>100</height> | ||||
|                   </size> | ||||
|                  </property> | ||||
|                  <property name="focusPolicy"> | ||||
|                   <enum>Qt::NoFocus</enum> | ||||
|                  </property> | ||||
|                 </widget> | ||||
|                </item> | ||||
|               </layout> | ||||
| @@ -530,7 +521,7 @@ Reopen book to see changes</string> | ||||
|            </widget> | ||||
|            <widget class="QWidget" name="imageTab"> | ||||
|             <attribute name="title"> | ||||
|              <string>Comic/PDF</string> | ||||
|              <string>Image</string> | ||||
|             </attribute> | ||||
|            </widget> | ||||
|           </widget> | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -20,6 +20,7 @@ class Ui_Dialog(object): | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.listView.sizePolicy().hasHeightForWidth()) | ||||
|         self.listView.setSizePolicy(sizePolicy) | ||||
|         self.listView.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) | ||||
|         self.listView.setObjectName("listView") | ||||
|         self.gridLayout.addWidget(self.listView, 0, 0, 1, 1) | ||||
|         self.verticalLayout_4 = QtWidgets.QVBoxLayout() | ||||
| @@ -191,6 +192,7 @@ class Ui_Dialog(object): | ||||
|         self.newAnnotation.setSizePolicy(sizePolicy) | ||||
|         self.newAnnotation.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.newAnnotation.setMaximumSize(QtCore.QSize(45, 16777215)) | ||||
|         self.newAnnotation.setText("") | ||||
|         self.newAnnotation.setObjectName("newAnnotation") | ||||
|         self.verticalLayout_6.addWidget(self.newAnnotation) | ||||
|         self.deleteAnnotation = QtWidgets.QPushButton(self.textTab) | ||||
| @@ -201,8 +203,20 @@ class Ui_Dialog(object): | ||||
|         self.deleteAnnotation.setSizePolicy(sizePolicy) | ||||
|         self.deleteAnnotation.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.deleteAnnotation.setMaximumSize(QtCore.QSize(45, 16777215)) | ||||
|         self.deleteAnnotation.setText("") | ||||
|         self.deleteAnnotation.setObjectName("deleteAnnotation") | ||||
|         self.verticalLayout_6.addWidget(self.deleteAnnotation) | ||||
|         self.editAnnotation = QtWidgets.QPushButton(self.textTab) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
|         sizePolicy.setVerticalStretch(0) | ||||
|         sizePolicy.setHeightForWidth(self.editAnnotation.sizePolicy().hasHeightForWidth()) | ||||
|         self.editAnnotation.setSizePolicy(sizePolicy) | ||||
|         self.editAnnotation.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.editAnnotation.setMaximumSize(QtCore.QSize(45, 16777215)) | ||||
|         self.editAnnotation.setText("") | ||||
|         self.editAnnotation.setObjectName("editAnnotation") | ||||
|         self.verticalLayout_6.addWidget(self.editAnnotation) | ||||
|         self.moveUp = QtWidgets.QPushButton(self.textTab) | ||||
|         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | ||||
|         sizePolicy.setHorizontalStretch(0) | ||||
| @@ -211,6 +225,7 @@ class Ui_Dialog(object): | ||||
|         self.moveUp.setSizePolicy(sizePolicy) | ||||
|         self.moveUp.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.moveUp.setMaximumSize(QtCore.QSize(45, 16777215)) | ||||
|         self.moveUp.setText("") | ||||
|         self.moveUp.setObjectName("moveUp") | ||||
|         self.verticalLayout_6.addWidget(self.moveUp) | ||||
|         self.moveDown = QtWidgets.QPushButton(self.textTab) | ||||
| @@ -221,36 +236,18 @@ class Ui_Dialog(object): | ||||
|         self.moveDown.setSizePolicy(sizePolicy) | ||||
|         self.moveDown.setMinimumSize(QtCore.QSize(30, 0)) | ||||
|         self.moveDown.setMaximumSize(QtCore.QSize(45, 16777215)) | ||||
|         self.moveDown.setText("") | ||||
|         self.moveDown.setObjectName("moveDown") | ||||
|         self.verticalLayout_6.addWidget(self.moveDown) | ||||
|         spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) | ||||
|         self.verticalLayout_6.addItem(spacerItem2) | ||||
|         self.horizontalLayout_11.addLayout(self.verticalLayout_6) | ||||
|         self.annotationsList = QtWidgets.QListView(self.textTab) | ||||
|         self.annotationsList.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) | ||||
|         self.annotationsList.setProperty("showDropIndicator", False) | ||||
|         self.annotationsList.setDefaultDropAction(QtCore.Qt.IgnoreAction) | ||||
|         self.annotationsList.setObjectName("annotationsList") | ||||
|         self.horizontalLayout_11.addWidget(self.annotationsList) | ||||
|         self.verticalLayout_8 = QtWidgets.QVBoxLayout() | ||||
|         self.verticalLayout_8.setObjectName("verticalLayout_8") | ||||
|         spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) | ||||
|         self.verticalLayout_8.addItem(spacerItem3) | ||||
|         self.foregroundCheck = QtWidgets.QCheckBox(self.textTab) | ||||
|         self.foregroundCheck.setObjectName("foregroundCheck") | ||||
|         self.verticalLayout_8.addWidget(self.foregroundCheck) | ||||
|         self.highlightCheck = QtWidgets.QCheckBox(self.textTab) | ||||
|         self.highlightCheck.setObjectName("highlightCheck") | ||||
|         self.verticalLayout_8.addWidget(self.highlightCheck) | ||||
|         self.boldCheck = QtWidgets.QCheckBox(self.textTab) | ||||
|         self.boldCheck.setObjectName("boldCheck") | ||||
|         self.verticalLayout_8.addWidget(self.boldCheck) | ||||
|         self.italicCheck = QtWidgets.QCheckBox(self.textTab) | ||||
|         self.italicCheck.setObjectName("italicCheck") | ||||
|         self.verticalLayout_8.addWidget(self.italicCheck) | ||||
|         self.underlineCheck = QtWidgets.QCheckBox(self.textTab) | ||||
|         self.underlineCheck.setObjectName("underlineCheck") | ||||
|         self.verticalLayout_8.addWidget(self.underlineCheck) | ||||
|         spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) | ||||
|         self.verticalLayout_8.addItem(spacerItem4) | ||||
|         self.horizontalLayout_11.addLayout(self.verticalLayout_8) | ||||
|         self.verticalLayout_5.addLayout(self.horizontalLayout_11) | ||||
|         self.gridLayout_8.addLayout(self.verticalLayout_5, 0, 0, 1, 1) | ||||
|         self.horizontalLayout_2 = QtWidgets.QHBoxLayout() | ||||
| @@ -262,6 +259,7 @@ class Ui_Dialog(object): | ||||
|         sizePolicy.setHeightForWidth(self.previewView.sizePolicy().hasHeightForWidth()) | ||||
|         self.previewView.setSizePolicy(sizePolicy) | ||||
|         self.previewView.setMaximumSize(QtCore.QSize(16777215, 100)) | ||||
|         self.previewView.setFocusPolicy(QtCore.Qt.NoFocus) | ||||
|         self.previewView.setObjectName("previewView") | ||||
|         self.horizontalLayout_2.addWidget(self.previewView) | ||||
|         self.gridLayout_8.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) | ||||
| @@ -284,8 +282,8 @@ class Ui_Dialog(object): | ||||
|         self.verticalLayout_4.addWidget(self.stackedWidget) | ||||
|         self.horizontalLayout_10 = QtWidgets.QHBoxLayout() | ||||
|         self.horizontalLayout_10.setObjectName("horizontalLayout_10") | ||||
|         spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | ||||
|         self.horizontalLayout_10.addItem(spacerItem5) | ||||
|         spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | ||||
|         self.horizontalLayout_10.addItem(spacerItem3) | ||||
|         self.okButton = QtWidgets.QPushButton(Dialog) | ||||
|         self.okButton.setObjectName("okButton") | ||||
|         self.horizontalLayout_10.addWidget(self.okButton) | ||||
| @@ -324,17 +322,13 @@ class Ui_Dialog(object): | ||||
|         self.cachingEnabled.setText(_translate("Dialog", "Cache comic / pdf pages")) | ||||
|         self.languageLabel.setText(_translate("Dialog", "Dictionary language")) | ||||
|         self.scrollSpeedLabel.setText(_translate("Dialog", "Scroll speed")) | ||||
|         self.newAnnotation.setText(_translate("Dialog", "+")) | ||||
|         self.deleteAnnotation.setText(_translate("Dialog", "-")) | ||||
|         self.moveUp.setText(_translate("Dialog", "⬆")) | ||||
|         self.moveDown.setText(_translate("Dialog", "⬇")) | ||||
|         self.foregroundCheck.setText(_translate("Dialog", "Foreground")) | ||||
|         self.highlightCheck.setText(_translate("Dialog", "Highlight")) | ||||
|         self.boldCheck.setText(_translate("Dialog", "Bold")) | ||||
|         self.italicCheck.setText(_translate("Dialog", "Italic")) | ||||
|         self.underlineCheck.setText(_translate("Dialog", "Underline")) | ||||
|         self.newAnnotation.setToolTip(_translate("Dialog", "New")) | ||||
|         self.deleteAnnotation.setToolTip(_translate("Dialog", "Delete")) | ||||
|         self.editAnnotation.setToolTip(_translate("Dialog", "Edit")) | ||||
|         self.moveUp.setToolTip(_translate("Dialog", "Move Up")) | ||||
|         self.moveDown.setToolTip(_translate("Dialog", "Move Down")) | ||||
|         self.tabWidget.setTabText(self.tabWidget.indexOf(self.textTab), _translate("Dialog", "Text")) | ||||
|         self.tabWidget.setTabText(self.tabWidget.indexOf(self.imageTab), _translate("Dialog", "Comic/PDF")) | ||||
|         self.tabWidget.setTabText(self.tabWidget.indexOf(self.imageTab), _translate("Dialog", "Image")) | ||||
|         self.okButton.setText(_translate("Dialog", "Scan Library")) | ||||
|         self.cancelButton.setText(_translate("Dialog", "Close")) | ||||
|  | ||||
|   | ||||
| @@ -113,6 +113,13 @@ class Settings: | ||||
|             'dialogBackground', QtGui.QColor().fromRgb(0, 0, 0)) | ||||
|         self.settings.endGroup() | ||||
|  | ||||
|         self.settings.beginGroup('annotations') | ||||
|         self.parent.settings['annotations'] = self.settings.value( | ||||
|             'annotationList', list()) | ||||
|         if self.parent.settings['annotations'] is None: | ||||
|             self.parent.settings['annotations'] = list() | ||||
|         self.settings.endGroup() | ||||
|  | ||||
|     def save_settings(self): | ||||
|         print('Saving settings...') | ||||
|         current_settings = self.parent.settings | ||||
| @@ -183,3 +190,7 @@ class Settings: | ||||
|         self.settings.beginGroup('dialogSettings') | ||||
|         self.settings.setValue('dialogBackground', current_settings['dialog_background']) | ||||
|         self.settings.endGroup() | ||||
|  | ||||
|         self.settings.beginGroup('annotations') | ||||
|         self.settings.setValue('annotationList', current_settings['annotations']) | ||||
|         self.settings.endGroup() | ||||
|   | ||||
| @@ -26,9 +26,11 @@ import pathlib | ||||
| from PyQt5 import QtWidgets, QtCore, QtGui | ||||
|  | ||||
| from lector import database | ||||
| from lector.annotations import AnnotationsUI | ||||
| from lector.models import MostExcellentFileSystemModel | ||||
| from lector.threaded import BackGroundBookSearch, BackGroundBookAddition | ||||
| from lector.resources import settingswindow | ||||
| from lector.settings import Settings | ||||
|  | ||||
|  | ||||
| class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
| @@ -40,6 +42,10 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
|  | ||||
|         self.parent = parent | ||||
|         self.database_path = self.parent.database_path | ||||
|         self.image_factory = self.parent.QImageFactory | ||||
|  | ||||
|         # The annotation dialog will use the settings dialog as its parent | ||||
|         self.annotationsDialog = AnnotationsUI(self) | ||||
|  | ||||
|         self.resize(self.parent.settings['settings_dialog_size']) | ||||
|         self.move(self.parent.settings['settings_dialog_position']) | ||||
| @@ -121,22 +127,33 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
|         self.listView.setModel(self.listModel) | ||||
|         self.listView.clicked.connect(self.page_switch) | ||||
|  | ||||
|         # Annotation related buttons | ||||
|         # Icon names | ||||
|         self.newAnnotation.setIcon(self.image_factory.get_image('add')) | ||||
|         self.deleteAnnotation.setIcon(self.image_factory.get_image('remove')) | ||||
|         self.editAnnotation.setIcon(self.image_factory.get_image('edit-rename')) | ||||
|         self.moveUp.setIcon(self.image_factory.get_image('arrow-up')) | ||||
|         self.moveDown.setIcon(self.image_factory.get_image('arrow-down')) | ||||
|  | ||||
|         # Icon sizes | ||||
|         self.newAnnotation.setIconSize(QtCore.QSize(24, 24)) | ||||
|         self.deleteAnnotation.setIconSize(QtCore.QSize(24, 24)) | ||||
|         self.editAnnotation.setIconSize(QtCore.QSize(24, 24)) | ||||
|         self.moveUp.setIconSize(QtCore.QSize(24, 24)) | ||||
|         self.moveDown.setIconSize(QtCore.QSize(24, 24)) | ||||
|  | ||||
|         self.annotationsList.clicked.connect(self.load_annotation) | ||||
|         self.annotationsList.doubleClicked.connect(self.editAnnotation.click) | ||||
|         self.newAnnotation.clicked.connect(self.add_annotation) | ||||
|         self.deleteAnnotation.clicked.connect(self.delete_annotation) | ||||
|         self.editAnnotation.clicked.connect(self.load_annotation) | ||||
|         self.moveUp.clicked.connect(self.move_annotation) | ||||
|         self.moveDown.clicked.connect(self.move_annotation) | ||||
|  | ||||
|         # Generate annotation settings | ||||
|         self.annotations_list = [] | ||||
|         self.annotationModel = QtGui.QStandardItemModel() | ||||
|         self.generate_annotations() | ||||
|  | ||||
|         # Init colors | ||||
|         self.default_stylesheet = self.foregroundCheck.styleSheet() | ||||
|         self.foreground = QtGui.QColor.fromRgb(0, 0, 0) | ||||
|         self.highlight = QtGui.QColor.fromRgb(255, 255, 255) | ||||
|  | ||||
|         # Connect annotation related checkboxes | ||||
|         self.foregroundCheck.clicked.connect(self.format_checkboxes) | ||||
|         self.highlightCheck.clicked.connect(self.format_checkboxes) | ||||
|         self.boldCheck.clicked.connect(self.format_checkboxes) | ||||
|         self.italicCheck.clicked.connect(self.format_checkboxes) | ||||
|         self.underlineCheck.clicked.connect(self.format_checkboxes) | ||||
|  | ||||
|         # Generate the filesystem treeView | ||||
|         self.generate_tree() | ||||
|  | ||||
| @@ -297,6 +314,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
|  | ||||
|     def no_more_settings(self): | ||||
|         self.parent.libraryToolBar.settingsButton.setChecked(False) | ||||
|         self.gather_annotations() | ||||
|         Settings(self.parent).save_settings() | ||||
|         self.resizeEvent() | ||||
|  | ||||
|     def resizeEvent(self, event=None): | ||||
| @@ -344,20 +363,21 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
|             self.parent.cover_functions.load_all_covers() | ||||
|  | ||||
|     def generate_annotations(self): | ||||
|         annotations_model = QtGui.QStandardItemModel() | ||||
|         items_list = ['Sample annotation'] | ||||
|  | ||||
|         for i in items_list: | ||||
|             # TODO | ||||
|             # Set annotation types to user roles | ||||
|         saved_annotations = self.parent.settings['annotations'] | ||||
|  | ||||
|         for i in saved_annotations: | ||||
|             item = QtGui.QStandardItem() | ||||
|             item.setText(i) | ||||
|             annotations_model.appendRow(item) | ||||
|             item.setText(i['name']) | ||||
|             item.setData(i, QtCore.Qt.UserRole) | ||||
|             self.annotationModel.appendRow(item) | ||||
|  | ||||
|         self.annotationsList.setModel(annotations_model) | ||||
|         self.annotationsList.setModel(self.annotationModel) | ||||
|  | ||||
|     def format_preview(self): | ||||
|         # Needed to clear the preview of annotation ickiness | ||||
|         cursor = QtGui.QTextCursor() | ||||
|         self.previewView.setTextCursor(cursor) | ||||
|  | ||||
|         self.previewView.setText('Vidistine nuper imagines moventes bonas?') | ||||
|         profile_index = self.parent.bookToolBar.profileBox.currentIndex() | ||||
|         current_profile = self.parent.bookToolBar.profileBox.itemData( | ||||
| @@ -387,76 +407,54 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): | ||||
|             if old_position == new_position: | ||||
|                 break | ||||
|  | ||||
|     def update_preview(self): | ||||
|         cursor = self.previewView.textCursor() | ||||
|         cursor.setPosition(0) | ||||
|         cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.KeepAnchor) | ||||
|     def add_annotation(self): | ||||
|         self.annotationsDialog.show_dialog('add') | ||||
|  | ||||
|         # TODO | ||||
|         # Other kinds of text markup | ||||
|         previewCharFormat = QtGui.QTextCharFormat() | ||||
|  | ||||
|         if self.foregroundCheck.isChecked(): | ||||
|             previewCharFormat.setForeground(self.foreground) | ||||
|  | ||||
|         highlight = QtCore.Qt.transparent | ||||
|         if self.highlightCheck.isChecked(): | ||||
|             highlight = self.highlight | ||||
|         previewCharFormat.setBackground(highlight) | ||||
|  | ||||
|         font_weight = QtGui.QFont.Normal | ||||
|         if self.boldCheck.isChecked(): | ||||
|             font_weight = QtGui.QFont.Bold | ||||
|         previewCharFormat.setFontWeight(font_weight) | ||||
|  | ||||
|         font_italic = False | ||||
|         if self.italicCheck.isChecked(): | ||||
|             font_italic = True | ||||
|         previewCharFormat.setFontItalic(font_italic) | ||||
|  | ||||
|         font_underline = False | ||||
|         if self.underlineCheck.isChecked(): | ||||
|             font_underline = True | ||||
|         previewCharFormat.setFontUnderline(font_underline) | ||||
|  | ||||
|         previewCharFormat.setFontStyleStrategy( | ||||
|             QtGui.QFont.PreferAntialias) | ||||
|  | ||||
|         cursor.setCharFormat(previewCharFormat) | ||||
|         cursor.clearSelection() | ||||
|         self.previewView.setTextCursor(cursor) | ||||
|  | ||||
|     def format_checkboxes(self): | ||||
|         sender = self.sender() | ||||
|         if not sender.isChecked(): | ||||
|             sender.setStyleSheet(self.default_stylesheet) | ||||
|             self.update_preview() | ||||
|     def delete_annotation(self): | ||||
|         selected_index = self.annotationsList.currentIndex() | ||||
|         if not selected_index.isValid(): | ||||
|             return | ||||
|  | ||||
|         if sender == self.foregroundCheck: | ||||
|             new_color = self.get_color(self.foreground) | ||||
|             self.foregroundCheck.setStyleSheet( | ||||
|                 "QCheckBox {{color: {0}; border: none;}}".format(new_color.name())) | ||||
|             self.foreground = new_color | ||||
|         self.annotationModel.removeRow( | ||||
|             self.annotationsList.currentIndex().row()) | ||||
|         self.format_preview() | ||||
|         self.annotationsList.clearSelection() | ||||
|  | ||||
|         if sender == self.highlightCheck: | ||||
|             new_color = self.get_color(self.highlight) | ||||
|             self.highlightCheck.setStyleSheet( | ||||
|                 "QCheckBox {{background-color: {0}}}".format(new_color.name())) | ||||
|             self.highlight = new_color | ||||
|     def load_annotation(self): | ||||
|         selected_index = self.annotationsList.currentIndex() | ||||
|         if not selected_index.isValid(): | ||||
|             return | ||||
|  | ||||
|         # TODO | ||||
|         # See if QCheckboxes support this | ||||
|         if sender == self.boldCheck: | ||||
|             self.boldCheck.setStyleSheet( | ||||
|                 "QCheckBox {{font-weight: bold;}}") | ||||
|         if self.sender() == self.annotationsList: | ||||
|             self.annotationsDialog.show_dialog('preview', selected_index) | ||||
|  | ||||
|         self.update_preview() | ||||
|         elif self.sender() == self.editAnnotation: | ||||
|             self.annotationsDialog.show_dialog('edit', selected_index) | ||||
|  | ||||
|     def get_color(self, current_color): | ||||
|         color_dialog = QtWidgets.QColorDialog() | ||||
|         new_color = color_dialog.getColor(current_color) | ||||
|         if new_color.isValid():  # Returned in case cancel is pressed | ||||
|             return new_color | ||||
|         else: | ||||
|             return current_color | ||||
|     def move_annotation(self): | ||||
|         current_row = self.annotationsList.currentIndex().row() | ||||
|  | ||||
|         if self.sender() == self.moveUp: | ||||
|             new_row = current_row - 1 | ||||
|             if new_row < 0: | ||||
|                 return | ||||
|  | ||||
|         elif self.sender() == self.moveDown: | ||||
|             new_row = current_row + 1 | ||||
|             if new_row == self.annotationModel.rowCount(): | ||||
|                 return | ||||
|  | ||||
|         row_out = self.annotationModel.takeRow(current_row) | ||||
|         self.annotationModel.insertRow(new_row, row_out) | ||||
|         new_index = self.annotationModel.index(new_row, 0) | ||||
|  | ||||
|         self.annotationsList.setCurrentIndex(new_index) | ||||
|  | ||||
|     def gather_annotations(self): | ||||
|         annotations_out = [] | ||||
|         for i in range(self.annotationModel.rowCount()): | ||||
|             annotation_item = self.annotationModel.item(i, 0) | ||||
|             annotation_data = annotation_item.data(QtCore.Qt.UserRole) | ||||
|             annotations_out.append(annotation_data) | ||||
|  | ||||
|         self.parent.settings['annotations'] = annotations_out | ||||
|   | ||||
		Reference in New Issue
	
	Block a user