Implement image color inversion
This commit is contained in:
@@ -203,10 +203,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
|
||||
self.bookToolBar.doublePageButton.triggered.connect(self.change_page_view)
|
||||
self.bookToolBar.mangaModeButton.triggered.connect(self.change_page_view)
|
||||
self.bookToolBar.invertButton.triggered.connect(self.change_page_view)
|
||||
if self.settings['double_page_mode']:
|
||||
self.bookToolBar.doublePageButton.setChecked(True)
|
||||
if self.settings['manga_mode']:
|
||||
self.bookToolBar.mangaModeButton.setChecked(True)
|
||||
if self.settings['invert_colors']:
|
||||
self.bookToolBar.invertButton.setChecked(True)
|
||||
|
||||
for count, i in enumerate(self.display_profiles):
|
||||
self.bookToolBar.profileBox.setItemData(count, i, QtCore.Qt.UserRole)
|
||||
@@ -765,7 +768,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
def change_page_view(self, key_pressed=False):
|
||||
# Set zoom mode to best fit to
|
||||
# make the transition less jarring
|
||||
self.comic_profile['zoom_mode'] = 'bestFit'
|
||||
# if the sender isn't the invert colors button
|
||||
if self.sender() != self.bookToolBar.invertButton:
|
||||
self.comic_profile['zoom_mode'] = 'bestFit'
|
||||
|
||||
# Toggle Double page mode / manga mode on keypress
|
||||
if key_pressed == QtCore.Qt.Key_D:
|
||||
@@ -779,6 +784,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
# current state of each of the toolbar buttons
|
||||
self.settings['double_page_mode'] = self.bookToolBar.doublePageButton.isChecked()
|
||||
self.settings['manga_mode'] = self.bookToolBar.mangaModeButton.isChecked()
|
||||
self.settings['invert_colors'] = self.bookToolBar.invertButton.isChecked()
|
||||
|
||||
# Switch page to whatever index is selected in the tocBox
|
||||
current_tab = self.tabWidget.currentWidget()
|
||||
|
@@ -175,6 +175,14 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
||||
else:
|
||||
return_pixmap = load_page(current_page)
|
||||
|
||||
if self.main_window.settings['invert_colors']:
|
||||
qImg = return_pixmap.toImage()
|
||||
qImg.invertPixels()
|
||||
if qImg: # Will return None if conversion doesn't work
|
||||
return_pixmap = QtGui.QPixmap().fromImage(qImg)
|
||||
else:
|
||||
logger.error('Color inversion failed: ' + current_page)
|
||||
|
||||
self.image_pixmap = return_pixmap
|
||||
self.resizeEvent()
|
||||
|
||||
|
@@ -89,6 +89,7 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
|
||||
except Exception as e:
|
||||
this_error = f'API access error'
|
||||
logger.exception(this_error + f' {type(e).__name__} Arguments: {e.args}')
|
||||
self.parent.display_error_notification(None)
|
||||
return None
|
||||
|
||||
def find_definition(self, word):
|
||||
|
8
lector/resources/raw/DarkIcons/invert.svg
Normal file
8
lector/resources/raw/DarkIcons/invert.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:#444444; } .ColorScheme-Highlight { color:#5294e2; }
|
||||
</style>
|
||||
</defs>
|
||||
<path style="fill:currentColor" class="ColorScheme-Text" d="M 2 1 L 2 15 L 9 15 L 9 13 A 5 5 0 0 1 4 8 A 5 5 0 0 1 9 3 L 9 1 L 2 1 z M 9 3 L 9 13 C 11.7614 13 14 10.7614 14 8 C 14 5.2386 11.7614 3 9 3 z" transform="translate(3 3)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 487 B |
8
lector/resources/raw/LightIcons/invert.svg
Normal file
8
lector/resources/raw/LightIcons/invert.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:#dfdfdf; } .ColorScheme-Highlight { color:#5294e2; }
|
||||
</style>
|
||||
</defs>
|
||||
<path style="fill:currentColor" class="ColorScheme-Text" d="M 2 1 L 2 15 L 9 15 L 9 13 A 5 5 0 0 1 4 8 A 5 5 0 0 1 9 3 L 9 1 L 2 1 z M 9 3 L 9 13 C 11.7614 13 14 10.7614 14 8 C 14 5.2386 11.7614 3 9 3 z" transform="translate(3 3)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 487 B |
@@ -1,5 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="images">
|
||||
<file>DarkIcons/invert.svg</file>
|
||||
<file>LightIcons/invert.svg</file>
|
||||
<file>DarkIcons/manga-mode.svg</file>
|
||||
<file>LightIcons/manga-mode.svg</file>
|
||||
<file>DarkIcons/search-word.svg</file>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -134,6 +134,8 @@ class Settings:
|
||||
'doublePageMode', 'False').capitalize())
|
||||
self.parent.settings['manga_mode'] = literal_eval(self.settings.value(
|
||||
'mangaMode', 'False').capitalize())
|
||||
self.parent.settings['invert_colors'] = literal_eval(self.settings.value(
|
||||
'invertColors', 'False').capitalize())
|
||||
self.settings.endGroup()
|
||||
|
||||
self.settings.beginGroup('dialogSettings')
|
||||
@@ -216,8 +218,9 @@ class Settings:
|
||||
self.settings.setValue('autoCover', str(current_settings['auto_cover']))
|
||||
self.settings.setValue('scrollSpeed', current_settings['scroll_speed'])
|
||||
self.settings.setValue('considerReadAt', current_settings['consider_read_at'])
|
||||
self.settings.setValue('mangaMode', str(current_settings['manga_mode']))
|
||||
self.settings.setValue('doublePageMode', str(current_settings['double_page_mode']))
|
||||
self.settings.setValue('mangaMode', str(current_settings['manga_mode']))
|
||||
self.settings.setValue('invertColors', str(current_settings['invert_colors']))
|
||||
self.settings.setValue('smallIncrement', current_settings['small_increment'])
|
||||
self.settings.setValue('largeIncrement', current_settings['large_increment'])
|
||||
self.settings.endGroup()
|
||||
|
@@ -227,6 +227,13 @@ class BookToolBar(QtWidgets.QToolBar):
|
||||
self.mangaModeButton.setObjectName('mangaModeButton')
|
||||
self.mangaModeButton.setCheckable(True)
|
||||
|
||||
self.invertButton = QtWidgets.QAction(
|
||||
image_factory.get_image('invert'),
|
||||
self._translate('BookToolBar', 'Invert page colors'),
|
||||
self)
|
||||
self.invertButton.setObjectName('mangaModeButton')
|
||||
self.invertButton.setCheckable(True)
|
||||
|
||||
self.zoomIn = QtWidgets.QAction(
|
||||
image_factory.get_image('zoom-in'),
|
||||
self._translate('BookToolBar', 'Zoom in (+)'),
|
||||
@@ -264,6 +271,7 @@ class BookToolBar(QtWidgets.QToolBar):
|
||||
self.comicSeparator1 = self.addSeparator()
|
||||
self.addAction(self.doublePageButton)
|
||||
self.addAction(self.mangaModeButton)
|
||||
self.addAction(self.invertButton)
|
||||
self.comicSeparator2 = self.addSeparator()
|
||||
self.addAction(self.zoomIn)
|
||||
self.addAction(self.zoomOut)
|
||||
@@ -276,6 +284,7 @@ class BookToolBar(QtWidgets.QToolBar):
|
||||
self.comicActions = [
|
||||
self.doublePageButton,
|
||||
self.mangaModeButton,
|
||||
self.invertButton,
|
||||
self.comicBGColorAction,
|
||||
self.zoomIn,
|
||||
self.zoomOut,
|
||||
|
Reference in New Issue
Block a user