mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 18:49:38 +12:00
Playing with styles
This commit is contained in:
parent
4fbf874854
commit
768243f5f9
|
@ -10,6 +10,7 @@ if __name__ == "__main__":
|
||||||
app.setOrganizationDomain("www.theologeek.ch")
|
app.setOrganizationDomain("www.theologeek.ch")
|
||||||
app.setApplicationName("snowFlaqe")
|
app.setApplicationName("snowFlaqe")
|
||||||
|
|
||||||
|
app.setStyle("Fusion")
|
||||||
|
|
||||||
from mainWindow import MainWindow
|
from mainWindow import MainWindow
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
self.tblDebugPersosInfos.setModel(self.mdlPersosInfos)
|
self.tblDebugPersosInfos.setModel(self.mdlPersosInfos)
|
||||||
self.treeDebugOutline.setModel(self.mdlOutline)
|
self.treeDebugOutline.setModel(self.mdlOutline)
|
||||||
|
|
||||||
|
# Playing with qStyle
|
||||||
|
self.cmbStyle.addItems(QStyleFactory.keys())
|
||||||
|
self.cmbStyle.setCurrentIndex([i.lower() for i in QStyleFactory.keys()].index(qApp.style().objectName()))
|
||||||
|
self.cmbStyle.currentIndexChanged[str].connect(qApp.setStyle)
|
||||||
|
|
||||||
self.loadProject("test_project")
|
self.loadProject("test_project")
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
|
@ -13,6 +13,8 @@ class collapsibleGroupBox(QGroupBox):
|
||||||
|
|
||||||
self.toggled.connect(self.setExpanded)
|
self.toggled.connect(self.setExpanded)
|
||||||
self.tempWidget = QWidget()
|
self.tempWidget = QWidget()
|
||||||
|
|
||||||
|
self.customStyle = False
|
||||||
|
|
||||||
def setExpanded(self, val):
|
def setExpanded(self, val):
|
||||||
self.setCollapsed(not val)
|
self.setCollapsed(not val)
|
||||||
|
@ -26,10 +28,99 @@ class collapsibleGroupBox(QGroupBox):
|
||||||
#print(l.contentsMargins().left(), l.contentsMargins().bottom(), l.contentsMargins().top(), )
|
#print(l.contentsMargins().left(), l.contentsMargins().bottom(), l.contentsMargins().top(), )
|
||||||
l.setContentsMargins(0, 0, 0, 0)
|
l.setContentsMargins(0, 0, 0, 0)
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
|
||||||
else:
|
else:
|
||||||
# Delete layout
|
# Delete layout
|
||||||
QWidget().setLayout(self.layout())
|
QWidget().setLayout(self.layout())
|
||||||
# Set saved layout
|
# Set saved layout
|
||||||
self.setLayout(self.tempWidget.layout())
|
self.setLayout(self.tempWidget.layout())
|
||||||
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||||
|
|
||||||
|
def paintEvent(self, event):
|
||||||
|
|
||||||
|
if not self.customStyle:
|
||||||
|
return QGroupBox.paintEvent(self, event)
|
||||||
|
|
||||||
|
p = QStylePainter(self)
|
||||||
|
opt = QStyleOptionGroupBox()
|
||||||
|
self.initStyleOption(opt)
|
||||||
|
|
||||||
|
style = qApp.style()
|
||||||
|
groupBox = opt
|
||||||
|
|
||||||
|
#// Draw frame
|
||||||
|
textRect = style.subControlRect(style.CC_GroupBox, opt, style.SC_GroupBoxLabel)
|
||||||
|
checkBoxRect = style.subControlRect(style.CC_GroupBox, opt, style.SC_GroupBoxCheckBox)
|
||||||
|
|
||||||
|
p.save()
|
||||||
|
titleRect = style.subControlRect(style.CC_GroupBox, opt, style.SC_GroupBoxFrame)
|
||||||
|
#r.setBottom(style.subControlRect(style.CC_GroupBox, opt, style.SC_GroupBoxContents).top())
|
||||||
|
titleRect.setHeight(textRect.height())
|
||||||
|
titleRect.moveTop(textRect.top())
|
||||||
|
|
||||||
|
p.setBrush(QBrush(QColor(Qt.blue).lighter(190)))
|
||||||
|
p.setPen(Qt.NoPen)
|
||||||
|
p.drawRoundedRect(titleRect, 10, 10)
|
||||||
|
p.restore()
|
||||||
|
|
||||||
|
if groupBox.subControls & QStyle.SC_GroupBoxFrame:
|
||||||
|
frame = QStyleOptionFrame()
|
||||||
|
#frame.operator=(groupBox)
|
||||||
|
frame.state = groupBox.state
|
||||||
|
frame.features = groupBox.features
|
||||||
|
frame.lineWidth = groupBox.lineWidth
|
||||||
|
frame.midLineWidth = groupBox.midLineWidth
|
||||||
|
frame.rect = style.subControlRect(style.CC_GroupBox, opt, style.SC_GroupBoxFrame)
|
||||||
|
p.save()
|
||||||
|
region = QRegion(groupBox.rect)
|
||||||
|
if groupBox.text:
|
||||||
|
ltr = groupBox.direction == Qt.LeftToRight
|
||||||
|
finalRect = QRect()
|
||||||
|
if groupBox.subControls & QStyle.SC_GroupBoxCheckBox:
|
||||||
|
finalRect = checkBoxRect.united(textRect)
|
||||||
|
finalRect.adjust(-4 if ltr else 0, 0, 0 if ltr else 4, 0)
|
||||||
|
else:
|
||||||
|
finalRect = textRect
|
||||||
|
|
||||||
|
region -= QRegion(finalRect)
|
||||||
|
|
||||||
|
p.setClipRegion(region)
|
||||||
|
style.drawPrimitive(style.PE_FrameGroupBox, frame, p)
|
||||||
|
p.restore()
|
||||||
|
|
||||||
|
##// Draw title
|
||||||
|
if groupBox.subControls & QStyle.SC_GroupBoxLabel and groupBox.text:
|
||||||
|
#textColor = QColor(groupBox.textColor)
|
||||||
|
#if textColor.isValid():
|
||||||
|
#p.setPen(textColor)
|
||||||
|
#alignment = int(groupBox.textAlignment)
|
||||||
|
#if not style.styleHint(QStyle.SH_UnderlineShortcut, opt):
|
||||||
|
#alignment |= Qt.TextHideMnemonic
|
||||||
|
|
||||||
|
#style.drawItemText(p, textRect, Qt.TextShowMnemonic | Qt.AlignHCenter | alignment,
|
||||||
|
#groupBox.palette, groupBox.state & style.State_Enabled, groupBox.text,
|
||||||
|
#QPalette.NoRole if textColor.isValid() else QPalette.WindowText)
|
||||||
|
|
||||||
|
p.save()
|
||||||
|
topt = QTextOption(Qt.AlignHCenter | Qt.AlignVCenter)
|
||||||
|
f = QFont()
|
||||||
|
f.setBold(True)
|
||||||
|
p.setFont(f)
|
||||||
|
p.setPen(Qt.darkBlue)
|
||||||
|
p.drawText(QRectF(titleRect), groupBox.text.replace("&", ""), topt)
|
||||||
|
p.restore()
|
||||||
|
|
||||||
|
if groupBox.state & style.State_HasFocus:
|
||||||
|
fropt = QStyleOptionFocusRect()
|
||||||
|
#fropt.operator=(groupBox)
|
||||||
|
fropt.state = groupBox.state
|
||||||
|
fropt.rect = textRect
|
||||||
|
style.drawPrimitive(style.PE_FrameFocusRect, fropt, p)
|
||||||
|
|
||||||
|
#// Draw checkbox
|
||||||
|
#if groupBox.subControls & style.SC_GroupBoxCheckBox:
|
||||||
|
#box = QStyleOptionButton()
|
||||||
|
##box.operator=(groupBox)
|
||||||
|
#box.state = groupBox.state
|
||||||
|
#box.rect = checkBoxRect
|
||||||
|
#style.drawPrimitive(style.PE_IndicatorCheckBox, box, p)
|
|
@ -89,6 +89,9 @@ class Ui_MainWindow(object):
|
||||||
self.txtGeneralEmail = QtWidgets.QLineEdit(self.grpAuthor)
|
self.txtGeneralEmail = QtWidgets.QLineEdit(self.grpAuthor)
|
||||||
self.txtGeneralEmail.setObjectName("txtGeneralEmail")
|
self.txtGeneralEmail.setObjectName("txtGeneralEmail")
|
||||||
self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.txtGeneralEmail)
|
self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.txtGeneralEmail)
|
||||||
|
self.cmbStyle = QtWidgets.QComboBox(self.grpAuthor)
|
||||||
|
self.cmbStyle.setObjectName("cmbStyle")
|
||||||
|
self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.cmbStyle)
|
||||||
self.horizontalLayout_26.addWidget(self.grpAuthor)
|
self.horizontalLayout_26.addWidget(self.grpAuthor)
|
||||||
self.verticalLayout_23.addLayout(self.horizontalLayout_26)
|
self.verticalLayout_23.addLayout(self.horizontalLayout_26)
|
||||||
self.tabMain.addTab(self.lytTabOverview, "")
|
self.tabMain.addTab(self.lytTabOverview, "")
|
||||||
|
@ -1270,9 +1273,9 @@ class Ui_MainWindow(object):
|
||||||
self.actShowHelp.setText(_translate("MainWindow", "Afficher les &bulles d\'aide"))
|
self.actShowHelp.setText(_translate("MainWindow", "Afficher les &bulles d\'aide"))
|
||||||
self.actShowHelp.setShortcut(_translate("MainWindow", "Ctrl+Shift+B"))
|
self.actShowHelp.setShortcut(_translate("MainWindow", "Ctrl+Shift+B"))
|
||||||
|
|
||||||
from ui.sldImportance import sldImportance
|
|
||||||
from ui.chkOutlineCompile import chkOutlineCompile
|
|
||||||
from ui.cmbOutlinePersoChoser import cmbOutlinePersoChoser
|
|
||||||
from ui.editorWidget import editorWidget
|
|
||||||
from ui.collapsibleGroupBox import collapsibleGroupBox
|
from ui.collapsibleGroupBox import collapsibleGroupBox
|
||||||
|
from ui.chkOutlineCompile import chkOutlineCompile
|
||||||
from ui.cmbOutlineStatusChoser import cmbOutlineStatusChoser
|
from ui.cmbOutlineStatusChoser import cmbOutlineStatusChoser
|
||||||
|
from ui.sldImportance import sldImportance
|
||||||
|
from ui.editorWidget import editorWidget
|
||||||
|
from ui.cmbOutlinePersoChoser import cmbOutlinePersoChoser
|
||||||
|
|
|
@ -160,6 +160,9 @@
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="txtGeneralEmail"/>
|
<widget class="QLineEdit" name="txtGeneralEmail"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="cmbStyle"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
<outlineItem title="Nouveau" type="folder" compile="2" wordCount="15">
|
<outlineItem title="Nouveau" type="folder" compile="2" wordCount="15">
|
||||||
<outlineItem title="Nouveau" type="scene" compile="2" text="return QTextEdit.resizeEvent(self, e) ad ad ad ad adaasd ad adsdasd ad e drset" wordCount="15"/>
|
<outlineItem title="Nouveau" type="scene" compile="2" text="return QTextEdit.resizeEvent(self, e) ad ad ad ad adaasd ad adsdasd ad e drset" wordCount="15"/>
|
||||||
</outlineItem>
|
</outlineItem>
|
||||||
<outlineItem title="Parent" type="folder" compile="2" wordCount="35">
|
<outlineItem title="Parent" type="folder" status="TODO" compile="2" wordCount="35">
|
||||||
<outlineItem title="Nouveau" type="folder" status="TODO" compile="2" wordCount="11">
|
<outlineItem title="Nouveau" type="folder" summarySentance="asd asd asd " status="First draft" compile="2" wordCount="11">
|
||||||
<outlineItem title="A" type="scene" compile="2" text="Du texteDu texteDu text ad ad ad ad " wordCount="8" setGoal="150"/>
|
<outlineItem title="A" type="scene" compile="2" text="Du texteDu texteDu text ad ad ad ad " wordCount="8" setGoal="10"/>
|
||||||
<outlineItem title="B" type="scene" compile="2" setGoal="50"/>
|
<outlineItem title="B" type="scene" compile="2" setGoal="3"/>
|
||||||
<outlineItem title="C" type="scene" compile="2" text="adasd ad ad " wordCount="3" setGoal="50"/>
|
<outlineItem title="C" type="scene" compile="2" text="adasd ad ad " wordCount="3" setGoal="3"/>
|
||||||
<outlineItem title="Nouveau" type="folder" compile="2" setGoal="100"/>
|
<outlineItem title="Nouveau" type="folder" compile="2" setGoal="3"/>
|
||||||
</outlineItem>
|
</outlineItem>
|
||||||
<outlineItem title="MOIMOIMOI" type="scene" POV="1" compile="2" text="ASDASd ASD ASDASd ASD ASDASd ASD " wordCount="6" setGoal="150"/>
|
<outlineItem title="MOIMOIMOI" type="scene" POV="1" compile="2" text="ASDASd ASD ASDASd ASD ASDASd ASD " wordCount="6" setGoal="10"/>
|
||||||
<outlineItem title="Nouveau" type="scene" POV="1" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4" setGoal="150"/>
|
<outlineItem title="Nouveau" type="scene" POV="1" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4" setGoal="10"/>
|
||||||
<outlineItem title="Nouveau" type="scene" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4" setGoal="25"/>
|
<outlineItem title="Nouveau" type="scene" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4" setGoal="10"/>
|
||||||
<outlineItem title="B" type="scene" compile="2" text="asd asd asd asd asd asd asd asd asd " wordCount="10" setGoal="25"/>
|
<outlineItem title="B" type="scene" compile="2" text="asd asd asd asd asd asd asd asd asd " wordCount="10" setGoal="10"/>
|
||||||
<outlineItem title="Nouveau" type="folder" compile="2"/>
|
<outlineItem title="Nouveau" type="folder" compile="2"/>
|
||||||
</outlineItem>
|
</outlineItem>
|
||||||
<outlineItem title="MOIMOIMOI" type="scene" POV="0" status="Second draft" compile="2" setGoal="2500"/>
|
<outlineItem title="MOIMOIMOI" type="scene" status="Second draft" compile="2" setGoal="2500"/>
|
||||||
<outlineItem title="A" type="scene" compile="2" setGoal="146"/>
|
<outlineItem title="A" type="scene" compile="2" setGoal="146"/>
|
||||||
<outlineItem title="Nouveau A" type="folder" compile="2" wordCount="217">
|
<outlineItem title="Nouveau A" type="folder" compile="2" wordCount="217">
|
||||||
<outlineItem title="Nouveau" type="scene" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4"/>
|
<outlineItem title="Nouveau" type="scene" compile="2" text="ASDASd ASD ASDASd ASD " wordCount="4"/>
|
||||||
|
|
Loading…
Reference in a new issue