Change library background color

This commit is contained in:
BasioMeusPuga
2018-03-02 12:47:51 +05:30
parent f30ed2b0d7
commit 11ab2db5ea
3 changed files with 39 additions and 15 deletions

11
TODO
View File

@@ -20,12 +20,11 @@ TODO
✓ Memory management
✓ Mass tagging
✓ Add capability to sort by new
Table view
Ignore a / the / numbers for sorting purposes
Information dialog widget
Table view
Context menu: Cache, Read, Edit database, delete, Mark read/unread
Set focus to newly added file
Information dialog widget
Allow editing of database data through the UI + for Bookmarks
Set focus to newly added file
Reading:
✓ Drop down for TOC
✓ Override the keypress event of the textedit
@@ -42,6 +41,7 @@ TODO
✓ Line spacing
✓ Record progress
✓ Text alignment
Background color
Bookmarks
✓ Creation
✓ Navigation
@@ -82,4 +82,5 @@ TODO
txt, doc, chm, djvu, fb2 support
Include icons for filetype emblems
Drag and drop support for the library
Leave comic images on disk in case tab isn't closed and files are remembered
Leave comic images on disk in case tab isn't closed and files are remembered
Ignore a / the / numbers for sorting purposes

View File

@@ -84,6 +84,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.statusBar.addWidget(self.sorterProgress)
self.sorterProgress.setVisible(False)
# Statusbar - Toolbar Visibility
self.toolbarToggle.setIcon(QtGui.QIcon.fromTheme('visibility'))
self.toolbarToggle.setObjectName('toolbarToggle')
self.toolbarToggle.setToolTip('Toggle toolbar')
@@ -91,6 +92,15 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.toolbarToggle.clicked.connect(self.toggle_toolbars)
self.statusBar.addPermanentWidget(self.toolbarToggle)
# Statusbar - Library background
self.libraryBackground = QtWidgets.QToolButton()
self.libraryBackground.setIcon(QtGui.QIcon.fromTheme('color-management'))
self.libraryBackground.setObjectName('libraryBackground')
self.libraryBackground.setToolTip('Change library background color')
self.libraryBackground.setAutoRaise(True)
self.libraryBackground.clicked.connect(self.get_color)
self.statusBar.addPermanentWidget(self.libraryBackground)
# THIS IS TEMPORARY
self.guiTest = QtWidgets.QToolButton()
self.guiTest.setIcon(QtGui.QIcon.fromTheme('mail-thread-watch'))
@@ -211,6 +221,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.listView.setItemDelegate(LibraryDelegate(self.temp_dir.path(), self))
self.listView.verticalScrollBar().valueChanged.connect(self.start_culling_timer)
self.listView.setStyleSheet(
"QListView {{background-color: {0}}}".format(
self.settings['listview_background'].name()))
# TableView
self.tableView.doubleClicked.connect(self.library_doubleclick)
self.tableView.horizontalHeader().setSectionResizeMode(
@@ -367,7 +381,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
print('Caesar si viveret, ad remum dareris')
self.metadata_dialog.show()
def resizeEvent(self, event=None):
if event:
# This implies a vertical resize event only
@@ -429,15 +442,13 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def delete_books(self):
# TODO
# Implement this for the tableview
# The same process can be used to mirror selection
# ? Mirror selection
# Ask if library files are to be excluded from further scans
# Make a checkbox for this
# Get a list of QItemSelection objects
# What we're interested in is the indexes()[0] in each of them
# That gives a list of indexes from the view model
if self.listView.isVisible():
selected_books = self.lib_ref.item_proxy_model.mapSelectionToSource(
self.listView.selectionModel().selection())
@@ -711,12 +722,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# def dropEvent
def get_color(self):
signal_sender = self.sender().objectName()
profile_index = self.bookToolBar.profileBox.currentIndex()
current_profile = self.bookToolBar.profileBox.itemData(
profile_index, QtCore.Qt.UserRole)
# Retain current values on opening a new dialog
def open_color_dialog(current_color):
color_dialog = QtWidgets.QColorDialog()
new_color = color_dialog.getColor(current_color)
@@ -725,6 +730,21 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
else:
return current_color
signal_sender = self.sender().objectName()
if signal_sender == 'libraryBackground':
current_color = self.settings['listview_background']
new_color = open_color_dialog(current_color)
self.listView.setStyleSheet("QListView {{background-color: {0}}}".format(
new_color.name()))
self.settings['listview_background'] = new_color
return
profile_index = self.bookToolBar.profileBox.currentIndex()
current_profile = self.bookToolBar.profileBox.itemData(
profile_index, QtCore.Qt.UserRole)
# Retain current values on opening a new dialog
if signal_sender == 'fgColor':
current_color = current_profile['foreground']
new_color = open_color_dialog(current_color)

View File

@@ -52,6 +52,8 @@ class Settings:
self.parent.move(self.settings.value('windowPosition', QtCore.QPoint(0, 0)))
self.parent.settings['current_view'] = int(self.settings.value('currentView', 0))
self.parent.settings['main_window_headers'] = self.settings.value('tableHeaders', None)
self.parent.settings['listview_background'] = self.settings.value(
'listViewBackground', QtGui.QColor().fromRgb(76, 76, 76))
self.settings.endGroup()
self.settings.beginGroup('runtimeVariables')
@@ -104,6 +106,7 @@ class Settings:
self.settings.setValue('windowSize', self.parent.size())
self.settings.setValue('windowPosition', self.parent.pos())
self.settings.setValue('currentView', self.parent.stackedWidget.currentIndex())
self.settings.setValue('listViewBackground', self.parent.settings['listview_background'])
table_headers = []
for i in range(3):