Add resource file - Incorporates icons from the Papirus-Dark icon theme

More keyboard shortcuts
This commit is contained in:
BasioMeusPuga
2017-11-15 12:17:49 +05:30
parent a17a150a45
commit 945c5c0b49
8 changed files with 1276 additions and 18 deletions

View File

@@ -148,9 +148,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.lib_ref.create_proxymodel() self.lib_ref.create_proxymodel()
# Keyboard shortcuts # Keyboard shortcuts
self.exit_all = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Q'), self) self.ks_close_tab = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+W'), self)
self.exit_all.setContext(QtCore.Qt.ApplicationShortcut) self.ks_close_tab.setContext(QtCore.Qt.ApplicationShortcut)
self.exit_all.activated.connect(self.closeEvent) self.ks_close_tab.activated.connect(self.tab_close)
self.ks_exit_all = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Q'), self)
self.ks_exit_all.setContext(QtCore.Qt.ApplicationShortcut)
self.ks_exit_all.activated.connect(self.closeEvent)
# Open last... open books. # Open last... open books.
self.open_files(self.last_open_books) self.open_files(self.last_open_books)
@@ -266,7 +270,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.statusMessage.setText( self.statusMessage.setText(
current_author + ' - ' + current_title) current_author + ' - ' + current_title)
def tab_close(self, tab_index): def tab_close(self, tab_index=None):
if not tab_index:
tab_index = self.tabWidget.currentIndex()
if tab_index == 0:
return
tab_metadata = self.tabWidget.widget(tab_index).metadata tab_metadata = self.tabWidget.widget(tab_index).metadata
self.thread = BackGroundTabUpdate( self.thread = BackGroundTabUpdate(
@@ -353,7 +362,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1) self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
if not found_a_focusable_tab: if not found_a_focusable_tab:
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
def get_color(self): def get_color(self):
signal_sender = self.sender().objectName() signal_sender = self.sender().objectName()

View File

@@ -105,7 +105,10 @@ class Library:
# QtCore.Qt.DisplayRole is the same as item.setText() # QtCore.Qt.DisplayRole is the same as item.setText()
# The model is a single row and has no columns # The model is a single row and has no columns
img_pixmap = QtGui.QPixmap() img_pixmap = QtGui.QPixmap()
if cover:
img_pixmap.loadFromData(cover) img_pixmap.loadFromData(cover)
else:
img_pixmap.load(':/images/NotFound.png')
img_pixmap = img_pixmap.scaled(420, 600, QtCore.Qt.IgnoreAspectRatio) img_pixmap = img_pixmap.scaled(420, 600, QtCore.Qt.IgnoreAspectRatio)
item = QtGui.QStandardItem() item = QtGui.QStandardItem()
item.setToolTip(tooltip_string) item.setToolTip(tooltip_string)

1230
resources.py Normal file

File diff suppressed because it is too large Load Diff

6
resources/checkmark.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" version="1.1" viewBox="0 0 16 16">
<g transform="translate(0 -1036.4)">
<circle fill="#4caf50" cx="8" cy="1044.4" r="7"/>
<path fill="#fff" d="m11.535 1040.8-4.2422 4.2422-2.8281-2.8281-1.4141 1.4141 2.8281 2.8281 1.4141 1.4141 5.6563-5.6563-1.4141-1.4141z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 341 B

9
resources/error.svg Normal file
View File

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" version="1.1" viewBox="0 0 16 16">
<g transform="translate(0 -1036.4)">
<circle fill="#f44336" cx="8" cy="1044.4" r="7"/>
<g fill="#fff" transform="matrix(.70711 .70711 -.70711 .70711 740.82 300.23)">
<rect width="2" height="10" x="1043.4" y="-13" transform="rotate(90)"/>
<rect width="2" height="10" x="-9" y="-1049.4" transform="scale(-1)"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 438 B

7
resources/resources.qrc Normal file
View File

@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="images">
<file>NotFound.png</file>
<file>checkmark.svg</file>
<file>error.svg</file>
</qresource>
</RCC>

View File

@@ -114,11 +114,6 @@ class BookSorter:
# Different modes require different values # Different modes require different values
if self.mode == 'addition': if self.mode == 'addition':
cover_image = book_ref.get_cover_image() cover_image = book_ref.get_cover_image()
# TODO
if not cover_image:
with open('resources/NotFound.png', 'rb') as stand_in:
cover_image = stand_in.read()
self.all_books[file_md5] = { self.all_books[file_md5] = {
'title': title, 'title': title,
'author': author, 'author': author,

View File

@@ -1,12 +1,12 @@
#!usr/bin/env python3 #!usr/bin/env python3
import os import os
import shutil
from PyQt5 import QtWidgets, QtGui, QtCore from PyQt5 import QtWidgets, QtGui, QtCore
import pie_chart
import database
import sorter import sorter
import database
import pie_chart
import resources
class BookToolBar(QtWidgets.QToolBar): class BookToolBar(QtWidgets.QToolBar):
@@ -416,7 +416,6 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
# Color icon slightly red # Color icon slightly red
# if option.state & QtWidgets.QStyle.State_Selected: # if option.state & QtWidgets.QStyle.State_Selected:
# painter.fillRect(option.rect, QtGui.QColor().fromRgb(255, 0, 0, 20)) # painter.fillRect(option.rect, QtGui.QColor().fromRgb(255, 0, 0, 20))
# Also, painter.setOpacity(n)
option = option.__class__(option) option = option.__class__(option)
file_exists = index.data(QtCore.Qt.UserRole + 5) file_exists = index.data(QtCore.Qt.UserRole + 5)
@@ -426,7 +425,7 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
# Calculate progress on the basis of lines # Calculate progress on the basis of lines
if not file_exists: if not file_exists:
read_icon = QtGui.QIcon.fromTheme('vcs-conflicting').pixmap(36) read_icon = QtGui.QIcon(':/images/error.svg').pixmap(36)
painter.setOpacity(.7) painter.setOpacity(.7)
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
painter.setOpacity(1) painter.setOpacity(1)
@@ -443,7 +442,7 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
if current_chapter == total_chapters: if current_chapter == total_chapters:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
read_icon = QtGui.QIcon.fromTheme('vcs-normal').pixmap(36) read_icon = QtGui.QIcon(':/images/checkmark.svg').pixmap(36)
elif current_chapter == 1: elif current_chapter == 1:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
else: else: