mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-29 00:59:47 +12:00
8d356c52ce
See issue #52. Enable selection of background color in addition to background image for index cards. This setting is accessed from the manuskript menu **Edit -> Settings -> Views -> Index cards**. Keep initial default of "writingdesk" background image for Index cards. Also update comments for functions to better describe how these work.
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
# --!-- coding: utf8 --!--
|
|
from PyQt5.QtWidgets import QListView
|
|
|
|
from manuskript import settings
|
|
from manuskript.functions import findBackground
|
|
from manuskript.ui.views.corkDelegate import corkDelegate
|
|
from manuskript.ui.views.dndView import dndView
|
|
from manuskript.ui.views.outlineBasics import outlineBasics
|
|
|
|
|
|
class corkView(QListView, dndView, outlineBasics):
|
|
def __init__(self, parent=None):
|
|
QListView.__init__(self, parent)
|
|
dndView.__init__(self, parent)
|
|
outlineBasics.__init__(self, parent)
|
|
|
|
self.setResizeMode(QListView.Adjust)
|
|
self.setWrapping(True)
|
|
self.setItemDelegate(corkDelegate())
|
|
self.setSpacing(5)
|
|
self.setVerticalScrollMode(self.ScrollPerPixel)
|
|
self.setFlow(self.LeftToRight)
|
|
self.setSelectionBehavior(self.SelectRows)
|
|
self.updateBackground()
|
|
|
|
def updateBackground(self):
|
|
if settings.corkBackground["image"] != "":
|
|
img = findBackground(settings.corkBackground["image"])
|
|
else:
|
|
# No background image
|
|
img = ""
|
|
self.setStyleSheet("""QListView {{
|
|
background:{color};
|
|
background-image: url({url});
|
|
background-attachment: fixed;
|
|
}}""".format(
|
|
color=settings.corkBackground["color"],
|
|
url=img
|
|
))
|
|
|
|
def dragMoveEvent(self, event):
|
|
dndView.dragMoveEvent(self, event)
|
|
QListView.dragMoveEvent(self, event)
|
|
|
|
def mouseReleaseEvent(self, event):
|
|
QListView.mouseReleaseEvent(self, event)
|
|
outlineBasics.mouseReleaseEvent(self, event)
|