This commit is contained in:
BasioMeusPuga
2017-11-13 17:16:40 +05:30
parent 65c1f61660
commit bffa747662
2 changed files with 24 additions and 7 deletions

View File

@@ -32,6 +32,7 @@
✓ Theming ✓ Theming
✓ Keep fontsize and margins consistent - Let page increase in length ✓ Keep fontsize and margins consistent - Let page increase in length
✓ Fullscreening ✓ Fullscreening
Record progress
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
Set context menu for definitions and the like Set context menu for definitions and the like
@@ -132,6 +133,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# ListView # ListView
# self.listView.setSpacing(0) # self.listView.setSpacing(0)
self.listView.setGridSize(QtCore.QSize(175, 240)) self.listView.setGridSize(QtCore.QSize(175, 240))
self.listView.setMouseTracking(True)
self.listView.verticalScrollBar().setSingleStep(7) self.listView.verticalScrollBar().setSingleStep(7)
self.listView.doubleClicked.connect(self.list_doubleclick) self.listView.doubleClicked.connect(self.list_doubleclick)
self.listView.setItemDelegate(LibraryDelegate()) self.listView.setItemDelegate(LibraryDelegate())
@@ -277,6 +279,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
current_tab = self.tabWidget.widget(self.tabWidget.currentIndex()) current_tab = self.tabWidget.widget(self.tabWidget.currentIndex())
required_content = current_tab.metadata['content'][chapter_name] required_content = current_tab.metadata['content'][chapter_name]
current_tab.contentView.verticalScrollBar().setValue(0)
current_tab.contentView.setHtml(required_content) current_tab.contentView.setHtml(required_content)
def set_fullscreen(self): def set_fullscreen(self):
@@ -291,6 +294,11 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
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)
state = self.listView.model().data(index, QtCore.Qt.UserRole + 5)
if state == 'deleted':
return
metadata = self.listView.model().data(index, QtCore.Qt.UserRole + 3) metadata = self.listView.model().data(index, QtCore.Qt.UserRole + 3)
# Shift focus to the tab that has the book open (if there is one) # Shift focus to the tab that has the book open (if there is one)

View File

@@ -305,19 +305,28 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
super(LibraryDelegate, self).__init__(parent) super(LibraryDelegate, self).__init__(parent)
def paint(self, painter, option, index): def paint(self, painter, option, index):
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) # This is a hint for the future
# Color icon slightly red
# if option.state & QtWidgets.QStyle.State_Selected:
# painter.fillRect(option.rect, QtGui.QColor().fromRgb(255, 0, 0, 20))
option = option.__class__(option) option = option.__class__(option)
state = index.data(QtCore.Qt.UserRole + 5) state = index.data(QtCore.Qt.UserRole + 5)
if state: if state:
if state == 'deleted': if state == 'deleted':
painter.setOpacity(.5)
read_icon = QtGui.QIcon.fromTheme('vcs-conflicting').pixmap(36) read_icon = QtGui.QIcon.fromTheme('vcs-conflicting').pixmap(36)
painter.setOpacity(.5)
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
painter.setOpacity(1)
if state == 'completed': if state == 'completed':
read_icon = QtGui.QIcon.fromTheme('vcs-normal').pixmap(36) read_icon = QtGui.QIcon.fromTheme('vcs-normal').pixmap(36)
if state == 'inprogress': if state == 'inprogress':
read_icon = QtGui.QIcon.fromTheme('vcs-locally-modified').pixmap(36) read_icon = QtGui.QIcon.fromTheme('vcs-locally-modified').pixmap(36)
else:
return
x_draw = option.rect.bottomRight().x() - 30 x_draw = option.rect.bottomRight().x() - 30
y_draw = option.rect.bottomRight().y() - 35 y_draw = option.rect.bottomRight().y() - 35
painter.drawPixmap(x_draw, y_draw, read_icon) painter.drawPixmap(x_draw, y_draw, read_icon)
else:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)