Comic view modes, Fulscreen keys
This commit is contained in:
133
__main__.py
133
__main__.py
@@ -90,6 +90,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.thread = None # Background Thread
|
self.thread = None # Background Thread
|
||||||
self.viewModel = None
|
self.viewModel = None
|
||||||
self.current_contentView = None # For fullscreening purposes
|
self.current_contentView = None # For fullscreening purposes
|
||||||
|
self.display_profiles = None
|
||||||
|
self.current_profile_index = None
|
||||||
|
# self.comic_profile = None
|
||||||
|
|
||||||
# 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
|
||||||
@@ -136,6 +139,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.paddingDown.triggered.connect(self.modify_font)
|
self.bookToolBar.paddingDown.triggered.connect(self.modify_font)
|
||||||
self.bookToolBar.resetProfile.triggered.connect(self.reset_profile)
|
self.bookToolBar.resetProfile.triggered.connect(self.reset_profile)
|
||||||
|
|
||||||
|
self.bookToolBar.zoomIn.triggered.connect(self.modify_comic_view)
|
||||||
|
self.bookToolBar.zoomOut.triggered.connect(self.modify_comic_view)
|
||||||
|
self.bookToolBar.fitWidth.triggered.connect(self.modify_comic_view)
|
||||||
|
self.bookToolBar.bestFit.triggered.connect(self.modify_comic_view)
|
||||||
|
self.bookToolBar.originalSize.triggered.connect(self.modify_comic_view)
|
||||||
|
self.bookToolBar.comicBGColor.clicked.connect(self.get_color)
|
||||||
|
|
||||||
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)
|
||||||
self.bookToolBar.tocBox.currentIndexChanged.connect(self.set_toc_position)
|
self.bookToolBar.tocBox.currentIndexChanged.connect(self.set_toc_position)
|
||||||
@@ -336,13 +346,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
def set_fullscreen(self):
|
def set_fullscreen(self):
|
||||||
current_tab = self.tabWidget.currentIndex()
|
current_tab = self.tabWidget.currentIndex()
|
||||||
current_tab_widget = self.tabWidget.widget(current_tab)
|
current_tab_widget = self.tabWidget.widget(current_tab)
|
||||||
self.current_contentView = current_tab_widget.findChildren(
|
current_tab_widget.go_fullscreen()
|
||||||
(QtWidgets.QTextBrowser, QtWidgets.QGraphicsView))[0]
|
|
||||||
|
|
||||||
self.current_contentView.setWindowFlags(QtCore.Qt.Window)
|
|
||||||
self.current_contentView.setWindowState(QtCore.Qt.WindowFullScreen)
|
|
||||||
self.current_contentView.show()
|
|
||||||
self.hide()
|
|
||||||
|
|
||||||
def list_doubleclick(self, myindex):
|
def list_doubleclick(self, myindex):
|
||||||
index = self.listView.model().index(myindex.row(), 0)
|
index = self.listView.model().index(myindex.row(), 0)
|
||||||
@@ -366,8 +370,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
if not file_paths:
|
if not file_paths:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print('Attempting to open: ' + ', '.join(file_paths))
|
||||||
|
|
||||||
contents = sorter.BookSorter(
|
contents = sorter.BookSorter(
|
||||||
file_paths, 'reading', self.database_path, self.temp_dir.path()).initiate_threads()
|
file_paths,
|
||||||
|
'reading',
|
||||||
|
self.database_path,
|
||||||
|
self.temp_dir.path()).initiate_threads()
|
||||||
|
|
||||||
found_a_focusable_tab = False
|
found_a_focusable_tab = False
|
||||||
|
|
||||||
@@ -405,6 +414,11 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.colorBoxBG.setStyleSheet(
|
self.bookToolBar.colorBoxBG.setStyleSheet(
|
||||||
'background-color: %s' % color_name)
|
'background-color: %s' % color_name)
|
||||||
current_profile['background'] = color_name
|
current_profile['background'] = color_name
|
||||||
|
|
||||||
|
elif signal_sender == 'comicBGColor':
|
||||||
|
self.bookToolBar.comicBGColor.setStyleSheet(
|
||||||
|
'background-color: %s' % color_name)
|
||||||
|
self.comic_profile['background'] = new_color
|
||||||
|
|
||||||
self.bookToolBar.profileBox.setItemData(
|
self.bookToolBar.profileBox.setItemData(
|
||||||
profile_index, current_profile, QtCore.Qt.UserRole)
|
profile_index, current_profile, QtCore.Qt.UserRole)
|
||||||
@@ -441,41 +455,90 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
profile_index, current_profile, QtCore.Qt.UserRole)
|
profile_index, current_profile, QtCore.Qt.UserRole)
|
||||||
self.format_contentView()
|
self.format_contentView()
|
||||||
|
|
||||||
|
def modify_comic_view(self):
|
||||||
|
signal_sender = self.sender().objectName()
|
||||||
|
current_tab = self.tabWidget.widget(self.tabWidget.currentIndex())
|
||||||
|
|
||||||
|
self.bookToolBar.fitWidth.setChecked(False)
|
||||||
|
self.bookToolBar.bestFit.setChecked(False)
|
||||||
|
self.bookToolBar.originalSize.setChecked(False)
|
||||||
|
|
||||||
|
if signal_sender == 'zoomOut':
|
||||||
|
self.comic_profile['zoom_mode'] = 'manualZoom'
|
||||||
|
self.comic_profile['padding'] += 50
|
||||||
|
if self.comic_profile['padding'] * 2 > current_tab.contentView.viewport().width():
|
||||||
|
self.comic_profile['padding'] -= 50
|
||||||
|
|
||||||
|
if signal_sender == 'zoomIn':
|
||||||
|
self.comic_profile['zoom_mode'] = 'manualZoom'
|
||||||
|
self.comic_profile['padding'] -= 50
|
||||||
|
if self.comic_profile['padding'] < 0:
|
||||||
|
self.comic_profile['padding'] = 0
|
||||||
|
|
||||||
|
if signal_sender == 'fitWidth':
|
||||||
|
self.comic_profile['zoom_mode'] = 'fitWidth'
|
||||||
|
self.comic_profile['padding'] = 0
|
||||||
|
self.bookToolBar.fitWidth.setChecked(True)
|
||||||
|
|
||||||
|
if signal_sender == 'bestFit':
|
||||||
|
self.comic_profile['zoom_mode'] = 'bestFit'
|
||||||
|
self.bookToolBar.bestFit.setChecked(True)
|
||||||
|
|
||||||
|
if signal_sender == 'originalSize':
|
||||||
|
self.comic_profile['zoom_mode'] = 'originalSize'
|
||||||
|
self.bookToolBar.originalSize.setChecked(True)
|
||||||
|
|
||||||
|
self.format_contentView()
|
||||||
|
|
||||||
|
|
||||||
def format_contentView(self):
|
def format_contentView(self):
|
||||||
# TODO
|
# TODO
|
||||||
# Implement line spacing
|
# Implement line spacing
|
||||||
# See what happens if a font isn't installed
|
# See what happens if a font isn't installed
|
||||||
|
|
||||||
profile_index = self.bookToolBar.profileBox.currentIndex()
|
current_tab = self.tabWidget.widget(self.tabWidget.currentIndex())
|
||||||
current_profile = self.bookToolBar.profileBox.itemData(
|
|
||||||
profile_index, QtCore.Qt.UserRole)
|
|
||||||
|
|
||||||
font = current_profile['font']
|
try:
|
||||||
foreground = current_profile['foreground']
|
current_metadata = current_tab.metadata
|
||||||
background = current_profile['background']
|
except AttributeError:
|
||||||
padding = current_profile['padding']
|
|
||||||
font_size = current_profile['font_size']
|
|
||||||
|
|
||||||
# Change toolbar widgets to match new settings
|
|
||||||
self.bookToolBar.fontBox.blockSignals(True)
|
|
||||||
self.bookToolBar.fontSizeBox.blockSignals(True)
|
|
||||||
self.bookToolBar.fontBox.setCurrentText(font)
|
|
||||||
self.bookToolBar.fontSizeBox.setCurrentText(str(font_size))
|
|
||||||
self.bookToolBar.fontBox.blockSignals(False)
|
|
||||||
self.bookToolBar.fontSizeBox.blockSignals(False)
|
|
||||||
|
|
||||||
self.bookToolBar.colorBoxFG.setStyleSheet(
|
|
||||||
'background-color: %s' % foreground)
|
|
||||||
self.bookToolBar.colorBoxBG.setStyleSheet(
|
|
||||||
'background-color: %s' % background)
|
|
||||||
|
|
||||||
# Do not run when only the library tab is open
|
|
||||||
if self.tabWidget.count() == 1:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Change contentView to match new settings
|
if current_metadata['images_only']:
|
||||||
current_tab = self.tabWidget.widget(self.tabWidget.currentIndex())
|
background = self.comic_profile['background']
|
||||||
current_tab.format_view(font, font_size, foreground, background, padding)
|
padding = self.comic_profile['padding']
|
||||||
|
|
||||||
|
self.bookToolBar.comicBGColor.setStyleSheet(
|
||||||
|
'background-color: %s' % background.name())
|
||||||
|
|
||||||
|
current_tab.format_view(
|
||||||
|
None, None, None, background, padding)
|
||||||
|
|
||||||
|
else:
|
||||||
|
profile_index = self.bookToolBar.profileBox.currentIndex()
|
||||||
|
current_profile = self.bookToolBar.profileBox.itemData(
|
||||||
|
profile_index, QtCore.Qt.UserRole)
|
||||||
|
|
||||||
|
font = current_profile['font']
|
||||||
|
foreground = current_profile['foreground']
|
||||||
|
background = current_profile['background']
|
||||||
|
padding = current_profile['padding']
|
||||||
|
font_size = current_profile['font_size']
|
||||||
|
|
||||||
|
# Change toolbar widgets to match new settings
|
||||||
|
self.bookToolBar.fontBox.blockSignals(True)
|
||||||
|
self.bookToolBar.fontSizeBox.blockSignals(True)
|
||||||
|
self.bookToolBar.fontBox.setCurrentText(font)
|
||||||
|
self.bookToolBar.fontSizeBox.setCurrentText(str(font_size))
|
||||||
|
self.bookToolBar.fontBox.blockSignals(False)
|
||||||
|
self.bookToolBar.fontSizeBox.blockSignals(False)
|
||||||
|
|
||||||
|
self.bookToolBar.colorBoxFG.setStyleSheet(
|
||||||
|
'background-color: %s' % foreground)
|
||||||
|
self.bookToolBar.colorBoxBG.setStyleSheet(
|
||||||
|
'background-color: %s' % background)
|
||||||
|
|
||||||
|
current_tab.format_view(
|
||||||
|
font, font_size, foreground, background, padding)
|
||||||
|
|
||||||
def reset_profile(self):
|
def reset_profile(self):
|
||||||
current_profile_index = self.bookToolBar.profileBox.currentIndex()
|
current_profile_index = self.bookToolBar.profileBox.currentIndex()
|
||||||
|
@@ -73,8 +73,9 @@ class ParseCBR:
|
|||||||
for i in os.walk(extract_path):
|
for i in os.walk(extract_path):
|
||||||
if i[2]: # Implies files were found
|
if i[2]: # Implies files were found
|
||||||
image_dir = i[0]
|
image_dir = i[0]
|
||||||
found_images = i[2]
|
add_path_to_file = [
|
||||||
break
|
os.path.join(image_dir, j) for j in i[2]]
|
||||||
|
found_images.extend(add_path_to_file)
|
||||||
|
|
||||||
if not found_images:
|
if not found_images:
|
||||||
print('Found nothing in ' + self.filename)
|
print('Found nothing in ' + self.filename)
|
||||||
@@ -84,7 +85,7 @@ class ParseCBR:
|
|||||||
|
|
||||||
for count, i in enumerate(found_images):
|
for count, i in enumerate(found_images):
|
||||||
page_name = 'Page ' + str(count + 1)
|
page_name = 'Page ' + str(count + 1)
|
||||||
image_path = os.path.join(extract_path, image_dir, i)
|
image_path = os.path.join(extract_path, i)
|
||||||
|
|
||||||
contents[page_name] = image_path
|
contents[page_name] = image_path
|
||||||
|
|
||||||
|
@@ -76,8 +76,9 @@ class ParseCBZ:
|
|||||||
for i in os.walk(extract_path):
|
for i in os.walk(extract_path):
|
||||||
if i[2]: # Implies files were found
|
if i[2]: # Implies files were found
|
||||||
image_dir = i[0]
|
image_dir = i[0]
|
||||||
found_images = i[2]
|
add_path_to_file = [
|
||||||
break
|
os.path.join(image_dir, j) for j in i[2]]
|
||||||
|
found_images.extend(add_path_to_file)
|
||||||
|
|
||||||
if not found_images:
|
if not found_images:
|
||||||
print('Found nothing in ' + self.filename)
|
print('Found nothing in ' + self.filename)
|
||||||
@@ -87,7 +88,7 @@ class ParseCBZ:
|
|||||||
|
|
||||||
for count, i in enumerate(found_images):
|
for count, i in enumerate(found_images):
|
||||||
page_name = 'Page ' + str(count + 1)
|
page_name = 'Page ' + str(count + 1)
|
||||||
image_path = os.path.join(extract_path, image_dir, i)
|
image_path = os.path.join(extract_path, i)
|
||||||
|
|
||||||
contents[page_name] = image_path
|
contents[page_name] = image_path
|
||||||
|
|
||||||
|
10
settings.py
10
settings.py
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore, QtGui
|
||||||
|
|
||||||
|
|
||||||
class Settings:
|
class Settings:
|
||||||
@@ -36,6 +36,11 @@ class Settings:
|
|||||||
self.default_profiles = [
|
self.default_profiles = [
|
||||||
default_profile1, default_profile2, default_profile3]
|
default_profile1, default_profile2, default_profile3]
|
||||||
|
|
||||||
|
self.default_comic_profile = {
|
||||||
|
'padding': 100, # pixel padding on either size
|
||||||
|
'background': QtGui.QColor().fromRgb(0, 0, 0),
|
||||||
|
'zoom_mode': 'bestFit'}
|
||||||
|
|
||||||
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(
|
||||||
@@ -56,6 +61,8 @@ class Settings:
|
|||||||
'displayProfiles', self.default_profiles)
|
'displayProfiles', self.default_profiles)
|
||||||
self.parent_window.current_profile_index = int(self.settings.value(
|
self.parent_window.current_profile_index = int(self.settings.value(
|
||||||
'currentProfileIndex', 0))
|
'currentProfileIndex', 0))
|
||||||
|
self.parent_window.comic_profile = self.settings.value(
|
||||||
|
'comicProfile', self.default_comic_profile)
|
||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
self.settings.beginGroup('lastOpen')
|
self.settings.beginGroup('lastOpen')
|
||||||
@@ -86,6 +93,7 @@ class Settings:
|
|||||||
current_profile2,
|
current_profile2,
|
||||||
current_profile3])
|
current_profile3])
|
||||||
self.settings.setValue('currentProfileIndex', current_profile_index)
|
self.settings.setValue('currentProfileIndex', current_profile_index)
|
||||||
|
self.settings.setValue('comicProfile', self.parent_window.comic_profile)
|
||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
|
||||||
current_tab_index = self.parent_window.tabWidget.currentIndex()
|
current_tab_index = self.parent_window.tabWidget.currentIndex()
|
||||||
|
75
widgets.py
75
widgets.py
@@ -127,26 +127,31 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
self.zoomIn = QtWidgets.QAction(
|
self.zoomIn = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('zoom-in'),
|
QtGui.QIcon.fromTheme('zoom-in'),
|
||||||
'Zoom in', self)
|
'Zoom in', self)
|
||||||
|
self.zoomIn.setObjectName('zoomIn')
|
||||||
self.zoomOut = QtWidgets.QAction(
|
self.zoomOut = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('zoom-out'),
|
QtGui.QIcon.fromTheme('zoom-out'),
|
||||||
'Zoom Out', self)
|
'Zoom Out', self)
|
||||||
|
self.zoomOut.setObjectName('zoomOut')
|
||||||
|
|
||||||
self.fitWidth = QtWidgets.QAction(
|
self.fitWidth = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('zoom-fit-width'),
|
QtGui.QIcon.fromTheme('zoom-fit-width'),
|
||||||
'Fit Width', self)
|
'Fit Width', self)
|
||||||
|
self.fitWidth.setObjectName('fitWidth')
|
||||||
self.fitWidth.setCheckable(True)
|
self.fitWidth.setCheckable(True)
|
||||||
self.bestFit = QtWidgets.QAction(
|
self.bestFit = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('zoom-fit-best'),
|
QtGui.QIcon.fromTheme('zoom-fit-best'),
|
||||||
'Best Fit', self)
|
'Best Fit', self)
|
||||||
|
self.bestFit.setObjectName('bestFit')
|
||||||
self.bestFit.setCheckable(True)
|
self.bestFit.setCheckable(True)
|
||||||
self.originalSize = QtWidgets.QAction(
|
self.originalSize = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('zoom-original'),
|
QtGui.QIcon.fromTheme('zoom-original'),
|
||||||
'Original size', self)
|
'Original size', self)
|
||||||
|
self.originalSize.setObjectName('originalSize')
|
||||||
self.originalSize.setCheckable(True)
|
self.originalSize.setCheckable(True)
|
||||||
|
|
||||||
self.comicColorBG = FixedPushButton(self)
|
self.comicBGColor = FixedPushButton(self)
|
||||||
self.comicColorBG.setToolTip('Background color')
|
self.comicBGColor.setToolTip('Background color')
|
||||||
self.comicColorBG.setObjectName('comicColorBG')
|
self.comicBGColor.setObjectName('comicBGColor')
|
||||||
|
|
||||||
self.comicSeparator1 = self.addSeparator()
|
self.comicSeparator1 = self.addSeparator()
|
||||||
self.addAction(self.zoomIn)
|
self.addAction(self.zoomIn)
|
||||||
@@ -155,7 +160,7 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
self.addAction(self.bestFit)
|
self.addAction(self.bestFit)
|
||||||
self.addAction(self.originalSize)
|
self.addAction(self.originalSize)
|
||||||
self.comicSeparator2 = self.addSeparator()
|
self.comicSeparator2 = self.addSeparator()
|
||||||
self.comicBGColorAction = self.addWidget(self.comicColorBG)
|
self.comicBGColorAction = self.addWidget(self.comicBGColor)
|
||||||
|
|
||||||
self.comicActions = [
|
self.comicActions = [
|
||||||
self.comicBGColorAction,
|
self.comicBGColorAction,
|
||||||
@@ -211,6 +216,10 @@ class BookToolBar(QtWidgets.QToolBar):
|
|||||||
def customize_view_on(self):
|
def customize_view_on(self):
|
||||||
if self.parent().tabWidget.widget(
|
if self.parent().tabWidget.widget(
|
||||||
self.parent().tabWidget.currentIndex()).metadata['images_only']:
|
self.parent().tabWidget.currentIndex()).metadata['images_only']:
|
||||||
|
|
||||||
|
# The following might seem redundant,
|
||||||
|
# but it's necessary for tab switching
|
||||||
|
|
||||||
for i in self.comicActions:
|
for i in self.comicActions:
|
||||||
i.setVisible(True)
|
i.setVisible(True)
|
||||||
|
|
||||||
@@ -354,7 +363,6 @@ class Tab(QtWidgets.QWidget):
|
|||||||
if self.are_we_doing_images_only: # Boolean
|
if self.are_we_doing_images_only: # Boolean
|
||||||
self.contentView = PliantQGraphicsView(self.window())
|
self.contentView = PliantQGraphicsView(self.window())
|
||||||
self.contentView.loadImage(chapter_content)
|
self.contentView.loadImage(chapter_content)
|
||||||
self.setStyleSheet("background-color: black;")
|
|
||||||
else:
|
else:
|
||||||
self.contentView = PliantQTextBrowser(self.window())
|
self.contentView = PliantQTextBrowser(self.window())
|
||||||
|
|
||||||
@@ -408,7 +416,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.go_fs = QtWidgets.QShortcut(
|
self.go_fs = QtWidgets.QShortcut(
|
||||||
QtGui.QKeySequence('F11'), self.contentView)
|
QtGui.QKeySequence('F11'), self.contentView)
|
||||||
self.go_fs.activated.connect(self.window().set_fullscreen)
|
self.go_fs.activated.connect(self.go_fullscreen)
|
||||||
|
|
||||||
self.exit_fs = QtWidgets.QShortcut(
|
self.exit_fs = QtWidgets.QShortcut(
|
||||||
QtGui.QKeySequence('Escape'), self.contentView)
|
QtGui.QKeySequence('Escape'), self.contentView)
|
||||||
@@ -419,6 +427,16 @@ class Tab(QtWidgets.QWidget):
|
|||||||
# QtGui.QKeySequence('Ctrl+Q'), self.contentView)
|
# QtGui.QKeySequence('Ctrl+Q'), self.contentView)
|
||||||
# self.exit_all.activated.connect(self.sneaky_exit)
|
# self.exit_all.activated.connect(self.sneaky_exit)
|
||||||
|
|
||||||
|
def go_fullscreen(self):
|
||||||
|
if self.contentView.windowState() == QtCore.Qt.WindowFullScreen:
|
||||||
|
self.exit_fullscreen()
|
||||||
|
return
|
||||||
|
|
||||||
|
self.contentView.setWindowFlags(QtCore.Qt.Window)
|
||||||
|
self.contentView.setWindowState(QtCore.Qt.WindowFullScreen)
|
||||||
|
self.contentView.show()
|
||||||
|
self.window().hide()
|
||||||
|
|
||||||
def exit_fullscreen(self):
|
def exit_fullscreen(self):
|
||||||
self.window().show()
|
self.window().show()
|
||||||
self.contentView.setWindowFlags(QtCore.Qt.Widget)
|
self.contentView.setWindowFlags(QtCore.Qt.Widget)
|
||||||
@@ -436,12 +454,17 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.setHtml(required_content)
|
self.contentView.setHtml(required_content)
|
||||||
|
|
||||||
def format_view(self, font, font_size, foreground, background, padding):
|
def format_view(self, font, font_size, foreground, background, padding):
|
||||||
self.contentView.setViewportMargins(padding, 0, padding, 0)
|
|
||||||
|
|
||||||
if self.are_we_doing_images_only:
|
if self.are_we_doing_images_only:
|
||||||
self.contentView.setBackgroundBrush(
|
# Tab color does not need to be set separately in case
|
||||||
QtGui.QBrush(QtCore.Qt.black, QtCore.Qt.SolidPattern))
|
# no padding is set for the viewport of a QGraphicsView
|
||||||
|
# and image resizing in done in the pixmap
|
||||||
|
my_qbrush = QtGui.QBrush(QtCore.Qt.SolidPattern)
|
||||||
|
my_qbrush.setColor(background)
|
||||||
|
self.contentView.setBackgroundBrush(my_qbrush)
|
||||||
|
self.contentView.resizeEvent()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
self.contentView.setViewportMargins(padding, 0, padding, 0)
|
||||||
self.contentView.setStyleSheet(
|
self.contentView.setStyleSheet(
|
||||||
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
|
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
|
||||||
font, font_size, foreground, background))
|
font, font_size, foreground, background))
|
||||||
@@ -478,19 +501,30 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
if not self.image_pixmap:
|
if not self.image_pixmap:
|
||||||
return
|
return
|
||||||
|
|
||||||
profile_index = self.main_window.bookToolBar.profileBox.currentIndex()
|
zoom_mode = self.main_window.comic_profile['zoom_mode']
|
||||||
current_profile = self.main_window.bookToolBar.profileBox.itemData(
|
padding = self.main_window.comic_profile['padding']
|
||||||
profile_index, QtCore.Qt.UserRole)
|
|
||||||
padding = current_profile['padding']
|
|
||||||
|
|
||||||
available_width = self.viewport().width() - 2 * padding
|
if zoom_mode == 'fitWidth':
|
||||||
|
available_width = self.viewport().width()
|
||||||
if self.image_pixmap.width() > available_width:
|
|
||||||
image_pixmap = self.image_pixmap.scaledToWidth(
|
image_pixmap = self.image_pixmap.scaledToWidth(
|
||||||
available_width, QtCore.Qt.SmoothTransformation)
|
available_width, QtCore.Qt.SmoothTransformation)
|
||||||
else:
|
|
||||||
|
elif zoom_mode == 'originalSize':
|
||||||
image_pixmap = self.image_pixmap
|
image_pixmap = self.image_pixmap
|
||||||
|
|
||||||
|
elif zoom_mode == 'bestFit':
|
||||||
|
available_width = self.viewport().width()
|
||||||
|
available_height = self.viewport().height()
|
||||||
|
|
||||||
|
image_pixmap = self.image_pixmap.scaled(
|
||||||
|
available_width, available_height,
|
||||||
|
QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
||||||
|
|
||||||
|
elif zoom_mode == 'manualZoom':
|
||||||
|
available_width = self.viewport().width() - 2 * padding
|
||||||
|
image_pixmap = self.image_pixmap.scaledToWidth(
|
||||||
|
available_width, QtCore.Qt.SmoothTransformation)
|
||||||
|
|
||||||
graphics_scene = QtWidgets.QGraphicsScene()
|
graphics_scene = QtWidgets.QGraphicsScene()
|
||||||
graphics_scene.addPixmap(image_pixmap)
|
graphics_scene.addPixmap(image_pixmap)
|
||||||
|
|
||||||
@@ -689,7 +723,10 @@ class BackGroundBookAddition(QtCore.QThread):
|
|||||||
self.database_path = database_path
|
self.database_path = database_path
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
books = sorter.BookSorter(self.file_list, 'addition', self.database_path)
|
books = sorter.BookSorter(
|
||||||
|
self.file_list,
|
||||||
|
'addition',
|
||||||
|
self.database_path)
|
||||||
parsed_books = books.initiate_threads()
|
parsed_books = books.initiate_threads()
|
||||||
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
||||||
self.parent_window.lib_ref.generate_model('addition', parsed_books)
|
self.parent_window.lib_ref.generate_model('addition', parsed_books)
|
||||||
|
Reference in New Issue
Block a user