mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-29 00:59:47 +12:00
Fixes: Unable to change index cards background from image to a color
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.
This commit is contained in:
parent
a6b49e22f9
commit
8d356c52ce
|
@ -226,12 +226,16 @@ def findWidgetsOfClass(cls):
|
||||||
|
|
||||||
def findBackground(filename):
|
def findBackground(filename):
|
||||||
"""
|
"""
|
||||||
Returns the full path to a background file of name filename within ressource folders.
|
Returns the full path to a background file of name filename within resources folders.
|
||||||
"""
|
"""
|
||||||
return findFirstFile(re.escape(filename), "resources/backgrounds")
|
return findFirstFile(re.escape(filename), "resources/backgrounds")
|
||||||
|
|
||||||
|
|
||||||
def findFirstFile(regex, path="resources"):
|
def findFirstFile(regex, path="resources"):
|
||||||
|
"""
|
||||||
|
Returns full path of first file matching regular expression regex within folder path,
|
||||||
|
otherwise returns full path of last file in folder path.
|
||||||
|
"""
|
||||||
paths = allPaths(path)
|
paths = allPaths(path)
|
||||||
for p in paths:
|
for p in paths:
|
||||||
lst = os.listdir(p)
|
lst = os.listdir(p)
|
||||||
|
|
|
@ -50,7 +50,7 @@ outlineViewColumns = [Outline.title.value, Outline.POV.value, Outline.status.val
|
||||||
Outline.goalPercentage.value, Outline.label.value]
|
Outline.goalPercentage.value, Outline.label.value]
|
||||||
corkBackground = {
|
corkBackground = {
|
||||||
"color": "#926239",
|
"color": "#926239",
|
||||||
"image": ""
|
"image": "writingdesk"
|
||||||
}
|
}
|
||||||
defaultTextType = "md"
|
defaultTextType = "md"
|
||||||
fullScreenTheme = "spacedreams"
|
fullScreenTheme = "spacedreams"
|
||||||
|
|
|
@ -13,7 +13,7 @@ from PyQt5.QtWidgets import qApp
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
from manuskript.functions import allPaths, iconColor, writablePath, appPath, findWidgetsOfClass
|
from manuskript.functions import allPaths, iconColor, writablePath, appPath, findWidgetsOfClass
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, findBackground
|
||||||
from manuskript.ui.editors.tabSplitter import tabSplitter
|
from manuskript.ui.editors.tabSplitter import tabSplitter
|
||||||
from manuskript.ui.editors.themes import createThemePreview
|
from manuskript.ui.editors.themes import createThemePreview
|
||||||
from manuskript.ui.editors.themes import getThemeName
|
from manuskript.ui.editors.themes import getThemeName
|
||||||
|
@ -371,7 +371,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
||||||
|
|
||||||
def setCorkImageDefault(self):
|
def setCorkImageDefault(self):
|
||||||
if settings.corkBackground["image"] != "":
|
if settings.corkBackground["image"] != "":
|
||||||
i = self.cmbCorkImage.findData(settings.corkBackground["image"])
|
i = self.cmbCorkImage.findData(findBackground(settings.corkBackground["image"]))
|
||||||
if i != -1:
|
if i != -1:
|
||||||
self.cmbCorkImage.setCurrentIndex(i)
|
self.cmbCorkImage.setCurrentIndex(i)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,11 @@ class corkView(QListView, dndView, outlineBasics):
|
||||||
self.updateBackground()
|
self.updateBackground()
|
||||||
|
|
||||||
def updateBackground(self):
|
def updateBackground(self):
|
||||||
img = findBackground(settings.corkBackground["image"])
|
if settings.corkBackground["image"] != "":
|
||||||
|
img = findBackground(settings.corkBackground["image"])
|
||||||
|
else:
|
||||||
|
# No background image
|
||||||
|
img = ""
|
||||||
self.setStyleSheet("""QListView {{
|
self.setStyleSheet("""QListView {{
|
||||||
background:{color};
|
background:{color};
|
||||||
background-image: url({url});
|
background-image: url({url});
|
||||||
|
|
Loading…
Reference in a new issue