mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-14 18:02:23 +12:00
Adds: custom item sizes in Tree View
This commit is contained in:
parent
40cc136836
commit
583734512b
|
@ -124,14 +124,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.makeUIConnections()
|
||||
|
||||
# self.loadProject(os.path.join(appPath(), "test_project.zip"))
|
||||
|
||||
|
||||
def updateDockVisibility(self, restore=False):
|
||||
"""
|
||||
Saves the state of the docks visibility. Or if `restore` is True,
|
||||
Saves the state of the docks visibility. Or if `restore` is True,
|
||||
restores from `self._dckVisibility`. This allows to hide the docks
|
||||
while showing the welcome screen, and then restore them as they
|
||||
were.
|
||||
|
||||
|
||||
If `self._dckVisibility` contains "LOCK", then we don't override values
|
||||
with current visibility state. This is used the first time we load.
|
||||
"LOCK" is then removed.
|
||||
|
@ -141,7 +141,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.dckNavigation,
|
||||
self.dckSearch,
|
||||
]
|
||||
|
||||
|
||||
for d in docks:
|
||||
if not restore:
|
||||
# We store the values, but only if "LOCK" is not present
|
||||
|
@ -152,11 +152,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
else:
|
||||
# Restore the dock's visibily based on stored value
|
||||
d.setVisible(self._dckVisibility[d.objectName()])
|
||||
|
||||
|
||||
# Lock is used only once, at start up. We can remove it
|
||||
if "LOCK" in self._dckVisibility:
|
||||
self._dckVisibility.pop("LOCK")
|
||||
|
||||
|
||||
def switchToWelcome(self):
|
||||
"""
|
||||
While switching to welcome screen, we have to hide all the docks.
|
||||
|
@ -171,7 +171,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.toolbar.setVisible(False)
|
||||
# Switch to welcome screen
|
||||
self.stack.setCurrentIndex(0)
|
||||
|
||||
|
||||
def switchToProject(self):
|
||||
"""Restores docks and toolbar visibility, and switch to project."""
|
||||
# Restores the docks visibility
|
||||
|
@ -404,6 +404,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.updateMenuDict()
|
||||
self.setDictionary()
|
||||
|
||||
iconSize = settings.viewSettings["Tree"]["iconSize"]
|
||||
self.treeRedacOutline.setIconSize(QSize(iconSize, iconSize))
|
||||
self.mainEditor.setFolderView(settings.folderView)
|
||||
self.mainEditor.updateFolderViewButtons(settings.folderView)
|
||||
self.mainEditor.tabSplitter.updateStyleSheet()
|
||||
|
@ -549,14 +551,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
sttgns.setValue("splitterRedacH", self.splitterRedacH.saveState())
|
||||
sttgns.setValue("splitterRedacV", self.splitterRedacV.saveState())
|
||||
sttgns.setValue("toolbar", self.toolbar.saveState())
|
||||
|
||||
|
||||
# If we are not in the welcome window, we update the visibility
|
||||
# of the docks widgets
|
||||
if self.stack.currentIndex() == 1:
|
||||
self.updateDockVisibility()
|
||||
# Storing the visibility of docks to restore it on restart
|
||||
sttgns.setValue("docks", self._dckVisibility)
|
||||
|
||||
|
||||
# Specific settings to save before quitting
|
||||
settings.lastTab = self.tabMain.currentIndex()
|
||||
|
||||
|
@ -588,7 +590,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
r = loadSave.saveProject() # version=0
|
||||
self.saveTimerNoChanges.stop()
|
||||
|
||||
|
||||
if r:
|
||||
feedback = self.tr("Project {} saved.").format(self.currentProject)
|
||||
else:
|
||||
|
@ -976,7 +978,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
#""
|
||||
#]
|
||||
#self.tabMain.setTabIcon(i, QIcon(appPath("icons/Custom/Tabs/{}".format(icons[i]))))
|
||||
|
||||
|
||||
icons = [QIcon.fromTheme("stock_view-details"), #info
|
||||
QIcon.fromTheme("application-text-template"), #applications-publishing
|
||||
F.themeIcon("characters"),
|
||||
|
@ -987,7 +989,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
QIcon.fromTheme("applications-debugging")
|
||||
]
|
||||
self.tabMain.setTabIcon(i, icons[i])
|
||||
|
||||
|
||||
item = QListWidgetItem(self.tabMain.tabIcon(i),
|
||||
self.tabMain.tabText(i))
|
||||
item.setSizeHint(QSize(item.sizeHint().width(), 64))
|
||||
|
|
|
@ -18,6 +18,7 @@ viewSettings = {
|
|||
"Background": "Nothing",
|
||||
"InfoFolder": "Nothing",
|
||||
"InfoText": "Nothing",
|
||||
"iconSize": 24,
|
||||
},
|
||||
"Cork": {
|
||||
"Icon": "Nothing",
|
||||
|
@ -45,8 +46,8 @@ autoSaveDelay = 5
|
|||
autoSaveNoChanges = True
|
||||
autoSaveNoChangesDelay = 5
|
||||
saveOnQuit = True
|
||||
outlineViewColumns = [Outline.title.value, Outline.POV.value, Outline.status.value,
|
||||
Outline.compile.value, Outline.wordCount.value, Outline.goal.value,
|
||||
outlineViewColumns = [Outline.title.value, Outline.POV.value, Outline.status.value,
|
||||
Outline.compile.value, Outline.wordCount.value, Outline.goal.value,
|
||||
Outline.goalPercentage.value, Outline.label.value]
|
||||
corkBackground = {
|
||||
"color": "#926239",
|
||||
|
@ -69,7 +70,7 @@ textEditor = {
|
|||
"textAlignment": 0, # 0: left, 1: center, 2: right, 3: justify
|
||||
"cursorWidth": 1
|
||||
}
|
||||
|
||||
|
||||
revisions = {
|
||||
"keep": True,
|
||||
"smartremove": True,
|
||||
|
@ -91,14 +92,14 @@ frequencyAnalyzer = {
|
|||
|
||||
viewMode = "fiction" # simple, fiction
|
||||
saveToZip = True
|
||||
|
||||
|
||||
def save(filename=None, protocol=None):
|
||||
|
||||
|
||||
global spellcheck, dict, corkSliderFactor, viewSettings, corkSizeFactor, folderView, lastTab, openIndexes, \
|
||||
autoSave, autoSaveDelay, saveOnQuit, autoSaveNoChanges, autoSaveNoChangesDelay, outlineViewColumns, \
|
||||
corkBackground, corkStyle, fullScreenTheme, defaultTextType, textEditor, revisions, frequencyAnalyzer, viewMode, \
|
||||
saveToZip
|
||||
|
||||
|
||||
allSettings = {
|
||||
"viewSettings": viewSettings,
|
||||
"dict": dict,
|
||||
|
@ -123,11 +124,11 @@ def save(filename=None, protocol=None):
|
|||
"viewMode": viewMode,
|
||||
"saveToZip": saveToZip,
|
||||
}
|
||||
|
||||
|
||||
#pp=pprint.PrettyPrinter(indent=4, compact=False)
|
||||
#print("Saving:")
|
||||
#pp.pprint(allSettings)
|
||||
|
||||
|
||||
if filename:
|
||||
f = open(filename, "wb")
|
||||
pickle.dump(allSettings, f)
|
||||
|
@ -145,12 +146,12 @@ def load(string, fromString=False, protocol=None):
|
|||
"""Load settings from 'string'. 'string' is the filename of the pickle dump.
|
||||
If fromString=True, string is the data of the pickle dumps."""
|
||||
global allSettings
|
||||
|
||||
|
||||
if not fromString:
|
||||
try:
|
||||
f = open(string, "rb")
|
||||
allSettings = pickle.load(f)
|
||||
|
||||
|
||||
except:
|
||||
print("{} doesn't exist, cannot load settings.".format(string))
|
||||
return
|
||||
|
@ -163,71 +164,77 @@ def load(string, fromString=False, protocol=None):
|
|||
#pp=pprint.PrettyPrinter(indent=4, compact=False)
|
||||
#print("Loading:")
|
||||
#pp.pprint(allSettings)
|
||||
|
||||
|
||||
if "viewSettings" in allSettings:
|
||||
global viewSettings
|
||||
viewSettings = allSettings["viewSettings"]
|
||||
|
||||
|
||||
for cat, name, default in [
|
||||
("Tree", "iconSize", 24), # Added in 0.6.0
|
||||
]:
|
||||
if not name in viewSettings[cat]:
|
||||
viewSettings[cat][name] = default
|
||||
|
||||
if "dict" in allSettings:
|
||||
global dict
|
||||
dict = allSettings["dict"]
|
||||
|
||||
|
||||
if "spellcheck" in allSettings:
|
||||
global spellcheck
|
||||
spellcheck = allSettings["spellcheck"]
|
||||
|
||||
|
||||
if "corkSizeFactor" in allSettings:
|
||||
global corkSizeFactor
|
||||
corkSizeFactor = allSettings["corkSizeFactor"]
|
||||
|
||||
|
||||
if "folderView" in allSettings:
|
||||
global folderView
|
||||
folderView = allSettings["folderView"]
|
||||
|
||||
|
||||
if "lastTab" in allSettings:
|
||||
global lastTab
|
||||
lastTab = allSettings["lastTab"]
|
||||
|
||||
|
||||
if "openIndexes" in allSettings:
|
||||
global openIndexes
|
||||
openIndexes = allSettings["openIndexes"]
|
||||
|
||||
|
||||
if "autoSave" in allSettings:
|
||||
global autoSave
|
||||
autoSave = allSettings["autoSave"]
|
||||
|
||||
|
||||
if "autoSaveDelay" in allSettings:
|
||||
global autoSaveDelay
|
||||
autoSaveDelay = allSettings["autoSaveDelay"]
|
||||
|
||||
|
||||
if "saveOnQuit" in allSettings:
|
||||
global saveOnQuit
|
||||
saveOnQuit = allSettings["saveOnQuit"]
|
||||
|
||||
|
||||
if "autoSaveNoChanges" in allSettings:
|
||||
global autoSaveNoChanges
|
||||
autoSaveNoChanges = allSettings["autoSaveNoChanges"]
|
||||
|
||||
|
||||
if "autoSaveNoChangesDelay" in allSettings:
|
||||
global autoSaveNoChangesDelay
|
||||
autoSaveNoChangesDelay = allSettings["autoSaveNoChangesDelay"]
|
||||
|
||||
|
||||
if "outlineViewColumns" in allSettings:
|
||||
global outlineViewColumns
|
||||
outlineViewColumns = allSettings["outlineViewColumns"]
|
||||
|
||||
|
||||
if "corkBackground" in allSettings:
|
||||
global corkBackground
|
||||
corkBackground = allSettings["corkBackground"]
|
||||
|
||||
|
||||
if "corkStyle" in allSettings:
|
||||
global corkStyle
|
||||
corkStyle = allSettings["corkStyle"]
|
||||
|
||||
|
||||
if "fullScreenTheme" in allSettings:
|
||||
global fullScreenTheme
|
||||
fullScreenTheme = allSettings["fullScreenTheme"]
|
||||
|
||||
|
||||
if "defaultTextType" in allSettings:
|
||||
global defaultTextType
|
||||
defaultTextType = allSettings["defaultTextType"]
|
||||
|
@ -235,10 +242,10 @@ def load(string, fromString=False, protocol=None):
|
|||
if "textEditor" in allSettings:
|
||||
global textEditor
|
||||
textEditor = allSettings["textEditor"]
|
||||
|
||||
|
||||
if not "textAlignment" in textEditor: # Added in 0.5.0
|
||||
textEditor["textAlignment"] = 0
|
||||
|
||||
|
||||
if not "cursorWidth" in textEditor: # Added in 0.5.0
|
||||
textEditor["cursorWidth"] = 1
|
||||
|
||||
|
@ -270,4 +277,4 @@ def load(string, fromString=False, protocol=None):
|
|||
|
||||
if "saveToZip" in allSettings:
|
||||
global saveToZip
|
||||
saveToZip = allSettings["saveToZip"]
|
||||
saveToZip = allSettings["saveToZip"]
|
||||
|
|
|
@ -36,8 +36,8 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
self.mw = mainWindow
|
||||
|
||||
# UI
|
||||
icons = [QIcon.fromTheme("configure"),
|
||||
QIcon.fromTheme("history-view"),
|
||||
icons = [QIcon.fromTheme("configure"),
|
||||
QIcon.fromTheme("history-view"),
|
||||
QIcon.fromTheme("gnome-settings"),
|
||||
themeIcon("label"),
|
||||
themeIcon("status"),
|
||||
|
@ -135,12 +135,17 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
]:
|
||||
item.setChecked(settings.viewSettings["Tree"][what] == value)
|
||||
item.toggled.connect(self.treeViewSettignsChanged)
|
||||
|
||||
|
||||
self.sldTreeIconSize.valueChanged.connect(self.treeViewSettignsChanged)
|
||||
self.sldTreeIconSize.valueChanged.connect(
|
||||
lambda v: self.lblTreeIconSize.setText("{}x{}".format(v, v)))
|
||||
self.sldTreeIconSize.setValue(settings.viewSettings["Tree"]["iconSize"])
|
||||
|
||||
self.rdoCorkOldStyle.setChecked(settings.corkStyle == "old")
|
||||
self.rdoCorkNewStyle.setChecked(settings.corkStyle == "new")
|
||||
self.rdoCorkNewStyle.toggled.connect(self.setCorkStyle)
|
||||
self.rdoCorkOldStyle.toggled.connect(self.setCorkStyle)
|
||||
|
||||
|
||||
self.populatesCmbBackgrounds(self.cmbCorkImage)
|
||||
self.setCorkImageDefault()
|
||||
self.updateCorkColor()
|
||||
|
@ -349,6 +354,11 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
if item.isChecked():
|
||||
settings.viewSettings["Tree"][what] = value
|
||||
|
||||
iconSize = self.sldTreeIconSize.value()
|
||||
if iconSize != settings.viewSettings["Tree"]["iconSize"]:
|
||||
settings.viewSettings["Tree"]["iconSize"] = iconSize
|
||||
self.mw.treeRedacOutline.setIconSize(QSize(iconSize, iconSize))
|
||||
|
||||
self.mw.treeRedacOutline.viewport().update()
|
||||
|
||||
def setCorkColor(self):
|
||||
|
@ -358,9 +368,9 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
if color.isValid():
|
||||
settings.corkBackground["color"] = color.name()
|
||||
self.updateCorkColor()
|
||||
# Update Cork view
|
||||
# Update Cork view
|
||||
self.mw.mainEditor.updateCorkBackground()
|
||||
|
||||
|
||||
def setCorkStyle(self):
|
||||
settings.corkStyle = "new" if self.rdoCorkNewStyle.isChecked() else "old"
|
||||
self.mw.mainEditor.updateCorkView()
|
||||
|
@ -375,7 +385,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
settings.corkBackground["image"] = img
|
||||
else:
|
||||
settings.corkBackground["image"] = ""
|
||||
# Update Cork view
|
||||
# Update Cork view
|
||||
self.mw.mainEditor.updateCorkBackground()
|
||||
|
||||
def populatesCmbBackgrounds(self, cmb):
|
||||
|
@ -433,7 +443,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
# Update background color in all tabSplitter (tabs)
|
||||
for w in mainWindow().findChildren(tabSplitter, QRegExp(".*")):
|
||||
w.updateStyleSheet()
|
||||
|
||||
|
||||
# Update background color in all folder text view:
|
||||
for w in mainWindow().findChildren(QWidget, QRegExp("editorWidgetFolderText")):
|
||||
w.setStyleSheet("background: {};".format(settings.textEditor["background"]))
|
||||
|
|
|
@ -494,6 +494,32 @@ class Ui_Settings(object):
|
|||
self.cmbTreeBackground.addItem("")
|
||||
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.cmbTreeBackground)
|
||||
self.verticalLayout_17.addWidget(self.groupBox_3)
|
||||
self.groupBox_16 = QtWidgets.QGroupBox(self.tab)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.groupBox_16.setFont(font)
|
||||
self.groupBox_16.setObjectName("groupBox_16")
|
||||
self.horizontalLayout_11 = QtWidgets.QHBoxLayout(self.groupBox_16)
|
||||
self.horizontalLayout_11.setObjectName("horizontalLayout_11")
|
||||
self.lblTreeIconSize = QtWidgets.QLabel(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.lblTreeIconSize.setFont(font)
|
||||
self.lblTreeIconSize.setObjectName("lblTreeIconSize")
|
||||
self.horizontalLayout_11.addWidget(self.lblTreeIconSize)
|
||||
self.sldTreeIconSize = QtWidgets.QSlider(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.sldTreeIconSize.setFont(font)
|
||||
self.sldTreeIconSize.setMinimum(16)
|
||||
self.sldTreeIconSize.setMaximum(128)
|
||||
self.sldTreeIconSize.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.sldTreeIconSize.setObjectName("sldTreeIconSize")
|
||||
self.horizontalLayout_11.addWidget(self.sldTreeIconSize)
|
||||
self.verticalLayout_17.addWidget(self.groupBox_16)
|
||||
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_9.setObjectName("horizontalLayout_9")
|
||||
self.groupBox_8 = QtWidgets.QGroupBox(self.tab)
|
||||
|
@ -1709,7 +1735,7 @@ class Ui_Settings(object):
|
|||
|
||||
self.retranslateUi(Settings)
|
||||
self.stack.setCurrentIndex(2)
|
||||
self.tabViews.setCurrentIndex(3)
|
||||
self.tabViews.setCurrentIndex(0)
|
||||
self.themeStack.setCurrentIndex(1)
|
||||
self.themeEditStack.setCurrentIndex(3)
|
||||
self.lstMenu.currentRowChanged['int'].connect(self.stack.setCurrentIndex)
|
||||
|
@ -1780,6 +1806,8 @@ class Ui_Settings(object):
|
|||
self.cmbTreeBackground.setItemText(2, _translate("Settings", "Label"))
|
||||
self.cmbTreeBackground.setItemText(3, _translate("Settings", "Progress"))
|
||||
self.cmbTreeBackground.setItemText(4, _translate("Settings", "Compile"))
|
||||
self.groupBox_16.setTitle(_translate("Settings", "Icon Size"))
|
||||
self.lblTreeIconSize.setText(_translate("Settings", "TextLabel"))
|
||||
self.groupBox_8.setTitle(_translate("Settings", "Folders"))
|
||||
self.rdoTreeItemCount.setText(_translate("Settings", "Show ite&m count"))
|
||||
self.rdoTreeWC.setText(_translate("Settings", "Show wordcount"))
|
||||
|
|
|
@ -792,7 +792,7 @@ text-align:center;</string>
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabViews">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
|
@ -984,6 +984,53 @@ text-align:center;</string>
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_16">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Icon Size</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTreeIconSize">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="sldTreeIconSize">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
|
|
Loading…
Reference in a new issue