A little further into finalizing Profile setting
This commit is contained in:
56
__main__.py
56
__main__.py
@@ -28,10 +28,10 @@
|
|||||||
✓ Override the keypress event of the textedit
|
✓ Override the keypress event of the textedit
|
||||||
✓ Use format* icons for toolbar buttons
|
✓ Use format* icons for toolbar buttons
|
||||||
✓ Implement book view settings with a(nother) toolbar
|
✓ Implement book view settings with a(nother) toolbar
|
||||||
? Substitute textedit for another widget
|
✓ Substitute textedit for another widget
|
||||||
|
Theming
|
||||||
All ebooks should first be added to the database and then returned as HTML
|
All ebooks should first be added to the database and then returned as HTML
|
||||||
Pagination
|
Pagination
|
||||||
Theming
|
|
||||||
Set context menu for definitions and the like
|
Set context menu for definitions and the like
|
||||||
Keep fontsize and margins consistent - Let page increase in length
|
Keep fontsize and margins consistent - Let page increase in length
|
||||||
Filetypes:
|
Filetypes:
|
||||||
@@ -97,13 +97,19 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar = BookToolBar(self)
|
self.bookToolBar = BookToolBar(self)
|
||||||
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
|
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
|
||||||
|
|
||||||
self.bookToolBar.fontBox.activated.connect(self.modify_font)
|
self.bookToolBar.fontBox.currentFontChanged.connect(self.modify_font)
|
||||||
self.bookToolBar.fontSizeUp.triggered.connect(self.modify_font)
|
self.bookToolBar.fontSizeUp.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.fontSizeDown.triggered.connect(self.modify_font)
|
self.bookToolBar.fontSizeDown.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.lineSpacingUp.triggered.connect(self.modify_font)
|
self.bookToolBar.lineSpacingUp.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.lineSpacingDown.triggered.connect(self.modify_font)
|
self.bookToolBar.lineSpacingDown.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.paddingUp.triggered.connect(self.modify_font)
|
self.bookToolBar.paddingUp.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.paddingDown.triggered.connect(self.modify_font)
|
self.bookToolBar.paddingDown.triggered.connect(self.modify_font)
|
||||||
|
for count, i in enumerate(self.display_profiles):
|
||||||
|
self.bookToolBar.profileBox.setItemData(count, i, QtCore.Qt.UserRole)
|
||||||
|
self.bookToolBar.profileBox.currentIndexChanged.connect(self.change_display_profile)
|
||||||
|
self.current_profile = self.bookToolBar.profileBox.itemData(
|
||||||
|
self.current_profile_index, QtCore.Qt.UserRole)
|
||||||
|
self.bookToolBar.profileBox.setCurrentIndex(self.current_profile_index)
|
||||||
|
|
||||||
self.bookToolBar.colorBoxFG.clicked.connect(self.get_color)
|
self.bookToolBar.colorBoxFG.clicked.connect(self.get_color)
|
||||||
self.bookToolBar.colorBoxBG.clicked.connect(self.get_color)
|
self.bookToolBar.colorBoxBG.clicked.connect(self.get_color)
|
||||||
@@ -114,8 +120,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.tab_switch()
|
self.tab_switch()
|
||||||
self.tabWidget.currentChanged.connect(self.tab_switch)
|
self.tabWidget.currentChanged.connect(self.tab_switch)
|
||||||
|
|
||||||
# New tabs and their contents
|
# For fullscreening purposes
|
||||||
self.current_tab = None
|
|
||||||
self.current_contentView = None
|
self.current_contentView = None
|
||||||
|
|
||||||
# Tab closing
|
# Tab closing
|
||||||
@@ -141,12 +146,14 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
# TODO
|
# TODO
|
||||||
# Get display profiles from settings
|
# Get display profiles from settings
|
||||||
# Current using a default
|
# Current using a default
|
||||||
self.current_profile = {
|
# self.bookToolBar.profileBox.setItemData(1, 'asdadasd', QtCore.Qt.UserRole)
|
||||||
'foreground': 'grey',
|
# self.current_profile = {
|
||||||
'background': 'black',
|
# 'font': 'Noto Sans',
|
||||||
'padding': 100,
|
# 'foreground': 'grey',
|
||||||
'font_size': 22,
|
# 'background': 'black',
|
||||||
'line_spacing': 1.5}
|
# 'padding': 100,
|
||||||
|
# 'font_size': 22,
|
||||||
|
# 'line_spacing': 1.5}
|
||||||
|
|
||||||
def resizeEvent(self, event=None):
|
def resizeEvent(self, event=None):
|
||||||
if event:
|
if event:
|
||||||
@@ -269,6 +276,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.tocBox.setCurrentIndex(current_position)
|
self.bookToolBar.tocBox.setCurrentIndex(current_position)
|
||||||
self.bookToolBar.tocBox.blockSignals(False)
|
self.bookToolBar.tocBox.blockSignals(False)
|
||||||
|
|
||||||
|
self.format_contentView()
|
||||||
|
|
||||||
self.statusMessage.setText(
|
self.statusMessage.setText(
|
||||||
current_author + ' - ' + current_title)
|
current_author + ' - ' + current_title)
|
||||||
|
|
||||||
@@ -353,7 +362,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
signal_sender = self.sender().objectName()
|
signal_sender = self.sender().objectName()
|
||||||
|
|
||||||
if signal_sender == 'fontBox':
|
if signal_sender == 'fontBox':
|
||||||
pass
|
self.current_profile['font'] = self.bookToolBar.fontBox.currentFont().family()
|
||||||
|
|
||||||
if signal_sender == 'fontSizeUp':
|
if signal_sender == 'fontSizeUp':
|
||||||
self.current_profile['font_size'] += 1
|
self.current_profile['font_size'] += 1
|
||||||
@@ -376,7 +385,14 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
# TODO
|
# TODO
|
||||||
# Implement line spacing
|
# Implement line spacing
|
||||||
# Implement font changing
|
# Implement font changing
|
||||||
|
# See what happens if a font isn't installed
|
||||||
|
|
||||||
|
# print(self.bookToolBar.profileBox.itemData(1, QtCore.Qt.UserRole))
|
||||||
|
# print(self.current_profile)
|
||||||
|
# current_profile = self.bookToolBar.profileBox.itemData()
|
||||||
|
|
||||||
|
|
||||||
|
font = self.current_profile['font']
|
||||||
foreground = self.current_profile['foreground']
|
foreground = self.current_profile['foreground']
|
||||||
background = self.current_profile['background']
|
background = self.current_profile['background']
|
||||||
padding = self.current_profile['padding']
|
padding = self.current_profile['padding']
|
||||||
@@ -387,8 +403,20 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
current_contentView = current_tab_widget.findChildren(QtWidgets.QTextBrowser)[0]
|
current_contentView = current_tab_widget.findChildren(QtWidgets.QTextBrowser)[0]
|
||||||
|
|
||||||
current_contentView.setStyleSheet(
|
current_contentView.setStyleSheet(
|
||||||
"QTextEdit {{font-size: {0}px; padding-left: {1}; padding-right: {1}; color: {2}; background-color: {3}}}".format(
|
"QTextEdit {{font-family: {0}; font-size: {1}px; padding-left: {2}; padding-right: {2}; color: {3}; background-color: {4}}}".format(
|
||||||
font_size, padding, foreground, background))
|
font, font_size, padding, foreground, background))
|
||||||
|
|
||||||
|
def change_display_profile(self):
|
||||||
|
profile_index = self.bookToolBar.profileBox.currentIndex()
|
||||||
|
|
||||||
|
self.bookToolBar.profileBox.setItemData()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.current_profile = self.bookToolBar.profileBox.itemData(
|
||||||
|
profile_index, QtCore.Qt.UserRole)
|
||||||
|
self.format_contentView()
|
||||||
|
|
||||||
|
|
||||||
def closeEvent(self, event=None):
|
def closeEvent(self, event=None):
|
||||||
# All tabs must be iterated upon here
|
# All tabs must be iterated upon here
|
||||||
|
@@ -58,5 +58,5 @@ class ParseCBZ:
|
|||||||
# TODO
|
# TODO
|
||||||
# Image resizing, formatting
|
# Image resizing, formatting
|
||||||
# Cleanup after exit
|
# Cleanup after exit
|
||||||
contents[page_name] = "<img src='%s'/>" % image_path
|
contents[page_name] = "<img src='%s' align='middle'/>" % image_path
|
||||||
return contents, tmp_dir
|
return contents, tmp_dir
|
||||||
|
@@ -126,6 +126,30 @@ class Settings:
|
|||||||
self.parent_window = parent
|
self.parent_window = parent
|
||||||
self.settings = QtCore.QSettings('Lector', 'Lector')
|
self.settings = QtCore.QSettings('Lector', 'Lector')
|
||||||
|
|
||||||
|
self.default_profile1 = {
|
||||||
|
'font': 'Noto Sans',
|
||||||
|
'foreground': '#000000',
|
||||||
|
'background': '#d8d8d8',
|
||||||
|
'padding': 140,
|
||||||
|
'font_size': 20,
|
||||||
|
'line_spacing': 1.5}
|
||||||
|
|
||||||
|
self.default_profile2 = {
|
||||||
|
'font': 'Roboto',
|
||||||
|
'foreground': '#c2c2c2',
|
||||||
|
'background': '#161616',
|
||||||
|
'padding': 140,
|
||||||
|
'font_size': 20,
|
||||||
|
'line_spacing': 1.5}
|
||||||
|
|
||||||
|
self.default_profile3 = {
|
||||||
|
'font': 'Roboto',
|
||||||
|
'foreground': '#657b83',
|
||||||
|
'background': '#002b36',
|
||||||
|
'padding': 140,
|
||||||
|
'font_size': 20,
|
||||||
|
'line_spacing': 1.5}
|
||||||
|
|
||||||
def read_settings(self):
|
def read_settings(self):
|
||||||
self.settings.beginGroup('mainWindow')
|
self.settings.beginGroup('mainWindow')
|
||||||
self.parent_window.resize(self.settings.value(
|
self.parent_window.resize(self.settings.value(
|
||||||
@@ -142,6 +166,14 @@ class Settings:
|
|||||||
self.parent_window.database_path = self.settings.value(
|
self.parent_window.database_path = self.settings.value(
|
||||||
'databasePath',
|
'databasePath',
|
||||||
QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation))
|
QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation))
|
||||||
|
self.parent_window.display_profiles = self.settings.value(
|
||||||
|
'displayProfiles', [
|
||||||
|
self.default_profile1,
|
||||||
|
self.default_profile2,
|
||||||
|
self.default_profile3])
|
||||||
|
self.parent_window.current_profile_index = self.settings.value(
|
||||||
|
'currentProfileIndex', 0)
|
||||||
|
|
||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
def save_settings(self):
|
def save_settings(self):
|
||||||
|
@@ -65,6 +65,7 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
self.lineSpacingDown.setObjectName('lineSpacingDown')
|
self.lineSpacingDown.setObjectName('lineSpacingDown')
|
||||||
|
|
||||||
self.fontBox = QtWidgets.QFontComboBox()
|
self.fontBox = QtWidgets.QFontComboBox()
|
||||||
|
self.fontBox.setFontFilters(QtWidgets.QFontComboBox.ScalableFonts)
|
||||||
self.fontBox.setObjectName('fontBox')
|
self.fontBox.setObjectName('fontBox')
|
||||||
|
|
||||||
self.colorBoxFG = FixedPushButton(self)
|
self.colorBoxFG = FixedPushButton(self)
|
||||||
@@ -77,6 +78,7 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
# TODO
|
# TODO
|
||||||
# Get color profiles from settings
|
# Get color profiles from settings
|
||||||
# Generate default profiles
|
# Generate default profiles
|
||||||
|
# Maybe a default button
|
||||||
profiles = ['Profile 1', 'Profile 2', 'Profile 3']
|
profiles = ['Profile 1', 'Profile 2', 'Profile 3']
|
||||||
self.profileBox = QtWidgets.QComboBox(self)
|
self.profileBox = QtWidgets.QComboBox(self)
|
||||||
self.profileBox.addItems(profiles)
|
self.profileBox.addItems(profiles)
|
||||||
@@ -288,8 +290,8 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
self.contentView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
self.gridLayout.addWidget(self.contentView, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.contentView, 0, 0, 1, 1)
|
||||||
self.parent.addTab(self, title)
|
self.parent.addTab(self, title)
|
||||||
self.contentView.setStyleSheet(
|
# self.contentView.setStyleSheet(
|
||||||
"QTextEdit {font-size:20px; padding-left:100; padding-right:100; background-color:black}")
|
# "QTextEdit {font-size:20px; padding-left:100; padding-right:100; background-color:black}")
|
||||||
|
|
||||||
|
|
||||||
class LibraryDelegate(QtWidgets.QStyledItemDelegate):
|
class LibraryDelegate(QtWidgets.QStyledItemDelegate):
|
||||||
|
Reference in New Issue
Block a user