mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-28 03:00:59 +12:00
Bug corrections and small features
This commit is contained in:
parent
58f4e45e47
commit
86133d3912
|
@ -142,9 +142,15 @@ def appPath(suffix=None):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def writablePath(suffix=None):
|
def writablePath(suffix=None):
|
||||||
p = QStandardPaths.writableLocation(QStandardPaths.AppLocalDataLocation)
|
if hasattr(QStandardPaths, "AppLocalDataLocation"):
|
||||||
|
p = QStandardPaths.writableLocation(QStandardPaths.AppLocalDataLocation)
|
||||||
|
else:
|
||||||
|
# Qt < 5.4
|
||||||
|
p = QStandardPaths.writableLocation(QStandardPaths.DataLocation)
|
||||||
if suffix:
|
if suffix:
|
||||||
p = os.path.join(p, suffix)
|
p = os.path.join(p, suffix)
|
||||||
|
if not os.path.exists(p):
|
||||||
|
os.makedirs(p)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def allPaths(suffix=None):
|
def allPaths(suffix=None):
|
||||||
|
|
|
@ -20,13 +20,14 @@ class fullScreenEditor(QWidget):
|
||||||
# Text editor
|
# Text editor
|
||||||
self.editor = textEditView(self, dict=settings.dict)
|
self.editor = textEditView(self, dict=settings.dict)
|
||||||
self.editor.setFrameStyle(QFrame.NoFrame)
|
self.editor.setFrameStyle(QFrame.NoFrame)
|
||||||
self.editor.document().setPlainText(open(appPath("resources/themes/preview.txt")).read() * 5)
|
f = QFile(appPath("resources/themes/preview.txt"))
|
||||||
|
f.open(QIODevice.ReadOnly)
|
||||||
|
self.editor.setPlainText(QTextStream(f).readAll()*5)
|
||||||
self.editor.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
self.editor.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
self.editor.installEventFilter(self)
|
self.editor.installEventFilter(self)
|
||||||
self.editor.setMouseTracking(True)
|
self.editor.setMouseTracking(True)
|
||||||
|
|
||||||
|
|
||||||
# Scroll bar
|
# Scroll bar
|
||||||
if self._themeDatas["Foreground/Color"] == self._themeDatas["Background/Color"] or \
|
if self._themeDatas["Foreground/Color"] == self._themeDatas["Background/Color"] or \
|
||||||
self._themeDatas["Foreground/Opacity"] < 5:
|
self._themeDatas["Foreground/Opacity"] < 5:
|
||||||
|
@ -65,6 +66,10 @@ class fullScreenEditor(QWidget):
|
||||||
r.moveRight(rect.right())
|
r.moveRight(rect.right())
|
||||||
self.scrollBar.setGeometry(r)
|
self.scrollBar.setGeometry(r)
|
||||||
self.scrollBar.setVisible(False)
|
self.scrollBar.setVisible(False)
|
||||||
|
p = self.scrollBar.palette()
|
||||||
|
b = QBrush(self._background.copy(self.scrollBar.geometry()))
|
||||||
|
p.setBrush(QPalette.Base, b)
|
||||||
|
self.scrollBar.setPalette(p)
|
||||||
|
|
||||||
# Set Panel
|
# Set Panel
|
||||||
r = QRect(0, 0, 400, 120)
|
r = QRect(0, 0, 400, 120)
|
||||||
|
@ -76,6 +81,7 @@ class fullScreenEditor(QWidget):
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
if self._background:
|
if self._background:
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
|
painter.setClipRegion(event.region())
|
||||||
painter.drawPixmap(event.rect(), self._background, event.rect())
|
painter.drawPixmap(event.rect(), self._background, event.rect())
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
|
@ -104,12 +110,28 @@ class myScrollBar(QScrollBar):
|
||||||
def __init__(self, color=Qt.white, parent=None):
|
def __init__(self, color=Qt.white, parent=None):
|
||||||
QScrollBar.__init__(self, parent)
|
QScrollBar.__init__(self, parent)
|
||||||
self._color = color
|
self._color = color
|
||||||
|
#self.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
|
self.timer = QTimer()
|
||||||
|
self.timer.setInterval(250)
|
||||||
|
self.timer.setSingleShot(True)
|
||||||
|
self.timer.timeout.connect(self.hide)
|
||||||
|
self.valueChanged.connect(lambda v: self.timer.start())
|
||||||
|
self.valueChanged.connect(self.show)
|
||||||
|
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
opt = QStyleOptionSlider()
|
opt = QStyleOptionSlider()
|
||||||
self.initStyleOption(opt)
|
self.initStyleOption(opt)
|
||||||
style = qApp.style()
|
style = qApp.style()
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
|
|
||||||
|
# Background (Necessary with Qt 5.2 it seems, not with 5.4)
|
||||||
|
painter.save()
|
||||||
|
painter.setPen(Qt.NoPen)
|
||||||
|
painter.setBrush(self.palette().brush(QPalette.Base))
|
||||||
|
painter.drawRect(event.rect())
|
||||||
|
painter.restore()
|
||||||
|
|
||||||
#slider
|
#slider
|
||||||
r = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider)
|
r = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider)
|
||||||
painter.fillRect(r, self._color)
|
painter.fillRect(r, self._color)
|
||||||
|
|
|
@ -8,6 +8,7 @@ from enums import *
|
||||||
from functions import *
|
from functions import *
|
||||||
from ui.views.textEditView import *
|
from ui.views.textEditView import *
|
||||||
import settings
|
import settings
|
||||||
|
import re
|
||||||
|
|
||||||
def loadThemeDatas(themeFile):
|
def loadThemeDatas(themeFile):
|
||||||
settings = QSettings(themeFile, QSettings.IniFormat)
|
settings = QSettings(themeFile, QSettings.IniFormat)
|
||||||
|
@ -104,17 +105,21 @@ def createThemePreview(theme, screenRect, size=QSize(200, 120)):
|
||||||
return px
|
return px
|
||||||
|
|
||||||
def findThemePath(themeName):
|
def findThemePath(themeName):
|
||||||
return findFirstFile(themeName, "resources/themes", "{}.theme")
|
p = findFirstFile(re.escape("{}.theme".format(themeName)), "resources/themes")
|
||||||
|
if not p:
|
||||||
|
return findFirstFile(".*\.theme", "resources/themes")
|
||||||
|
else:
|
||||||
|
return p
|
||||||
|
|
||||||
def findBackground(filename):
|
def findBackground(filename):
|
||||||
return findFirstFile(filename, "resources/backgrounds")
|
return findFirstFile(re.escape(filename), "resources/backgrounds")
|
||||||
|
|
||||||
def findFirstFile(filename, path="resources", mask="{}"):
|
def findFirstFile(regex, path="resources"):
|
||||||
paths = allPaths(path)
|
paths = allPaths(path)
|
||||||
for p in paths:
|
for p in paths:
|
||||||
lst = os.listdir(p)
|
lst = os.listdir(p)
|
||||||
for l in lst:
|
for l in lst:
|
||||||
if l == mask.format(filename):
|
if re.match(regex, l):
|
||||||
return os.path.join(p, l)
|
return os.path.join(p, l)
|
||||||
|
|
||||||
def generateTheme(themeDatas, screenRect):
|
def generateTheme(themeDatas, screenRect):
|
||||||
|
@ -221,7 +226,9 @@ def addThemePreviewText(pixmap, themeDatas, screenRect):
|
||||||
previewText.setFrameStyle(QFrame.NoFrame)
|
previewText.setFrameStyle(QFrame.NoFrame)
|
||||||
previewText.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
previewText.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
previewText.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
previewText.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
previewText.setPlainText(open(appPath("resources/themes/preview.txt")).read())
|
f = QFile(appPath("resources/themes/preview.txt"))
|
||||||
|
f.open(QIODevice.ReadOnly)
|
||||||
|
previewText.setPlainText(QTextStream(f).readAll())
|
||||||
|
|
||||||
setThemeEditorDatas(previewText, themeDatas, pixmap, screenRect)
|
setThemeEditorDatas(previewText, themeDatas, pixmap, screenRect)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue