mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-16 02:42:28 +12:00
Fullscreen theme list uses theme's propper name
This commit is contained in:
parent
7bb52c80a5
commit
694b30a600
|
@ -2,6 +2,7 @@
|
|||
#--!-- coding: utf8 --!--
|
||||
|
||||
import os
|
||||
import re
|
||||
from random import *
|
||||
|
||||
from PyQt5.QtCore import Qt, QRect, QStandardPaths, QObject, QRegExp
|
||||
|
@ -219,3 +220,19 @@ def findWidgetsOfClass(cls):
|
|||
@return: list of QWidgets
|
||||
"""
|
||||
return mainWindow().findChildren(cls, QRegExp())
|
||||
|
||||
|
||||
def findBackground(filename):
|
||||
"""
|
||||
Returns the full path to a background file of name filename within ressource folders.
|
||||
"""
|
||||
return findFirstFile(re.escape(filename), "resources/backgrounds")
|
||||
|
||||
|
||||
def findFirstFile(regex, path="resources"):
|
||||
paths = allPaths(path)
|
||||
for p in paths:
|
||||
lst = os.listdir(p)
|
||||
for l in lst:
|
||||
if re.match(regex, l):
|
||||
return os.path.join(p, l)
|
|
@ -326,6 +326,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
|
||||
def setCorkBackground(self, i):
|
||||
img = self.cmbCorkImage.itemData(i)
|
||||
img = os.path.basename(img)
|
||||
if img:
|
||||
settings.corkBackground["image"] = img
|
||||
else:
|
||||
|
|
|
@ -94,8 +94,13 @@ class fullScreenEditor(QWidget):
|
|||
lst = [i for i in os.listdir(p) if os.path.splitext(i)[1] == ".theme"]
|
||||
for t in lst:
|
||||
themeIni = os.path.join(p, t)
|
||||
self.lstThemes.addItem(os.path.splitext(t)[0])
|
||||
self.lstThemes.setCurrentText(settings.fullScreenTheme)
|
||||
name = loadThemeDatas(themeIni)["Name"]
|
||||
# self.lstThemes.addItem(os.path.splitext(t)[0])
|
||||
self.lstThemes.addItem(name)
|
||||
self.lstThemes.setItemData(self.lstThemes.count()-1, os.path.splitext(t)[0])
|
||||
|
||||
self.lstThemes.setCurrentIndex(self.lstThemes.findData(settings.fullScreenTheme))
|
||||
# self.lstThemes.setCurrentText(settings.fullScreenTheme)
|
||||
self.lstThemes.currentTextChanged.connect(self.setTheme)
|
||||
self.lstThemes.setMaximumSize(QSize(300, QFontMetrics(qApp.font()).height()))
|
||||
self.bottomPanel.layout().addWidget(QLabel(self.tr("Theme:"), self))
|
||||
|
@ -125,6 +130,7 @@ class fullScreenEditor(QWidget):
|
|||
self.btnClose.setVisible(not val)
|
||||
|
||||
def setTheme(self, themeName):
|
||||
themeName = self.lstThemes.currentData()
|
||||
settings.fullScreenTheme = themeName
|
||||
self._theme = findThemePath(themeName)
|
||||
self._themeDatas = loadThemeDatas(self._theme)
|
||||
|
|
|
@ -9,7 +9,7 @@ from PyQt5.QtCore import QSettings, QRect, QSize, Qt, QPoint, QFile, QIODevice,
|
|||
from PyQt5.QtGui import QPixmap, QPainter, QColor, QBrush, QImage, QTextBlockFormat, QTextCharFormat, QFont, qGray
|
||||
from PyQt5.QtWidgets import qApp, QFrame
|
||||
|
||||
from manuskript.functions import allPaths, appPath
|
||||
from manuskript.functions import allPaths, appPath, findBackground, findFirstFile
|
||||
from manuskript.ui.views.textEditView import textEditView
|
||||
|
||||
|
||||
|
@ -119,19 +119,6 @@ def findThemePath(themeName):
|
|||
return p
|
||||
|
||||
|
||||
def findBackground(filename):
|
||||
return findFirstFile(re.escape(filename), "resources/backgrounds")
|
||||
|
||||
|
||||
def findFirstFile(regex, path="resources"):
|
||||
paths = allPaths(path)
|
||||
for p in paths:
|
||||
lst = os.listdir(p)
|
||||
for l in lst:
|
||||
if re.match(regex, l):
|
||||
return os.path.join(p, l)
|
||||
|
||||
|
||||
def generateTheme(themeDatas, screenRect):
|
||||
# Window Background
|
||||
px = QPixmap(screenRect.size())
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
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
|
||||
|
@ -24,12 +25,13 @@ class corkView(QListView, dndView, outlineBasics):
|
|||
self.updateBackground()
|
||||
|
||||
def updateBackground(self):
|
||||
img = findBackground(settings.corkBackground["image"])
|
||||
self.setStyleSheet("""QListView {{
|
||||
background:{color};
|
||||
background-image: url({url});
|
||||
}}""".format(
|
||||
color=settings.corkBackground["color"],
|
||||
url=settings.corkBackground["image"]
|
||||
url=img
|
||||
))
|
||||
|
||||
def dragMoveEvent(self, event):
|
||||
|
|
Loading…
Reference in a new issue