Skip to content

Commit

Permalink
Completed first version of editor settings
Browse files Browse the repository at this point in the history
  • Loading branch information
amirgeva committed Oct 3, 2014
1 parent c95cd4f commit 08022c7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
9 changes: 9 additions & 0 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def settingsEditor(self):
d=EditorSettingsDialog()
if d.exec_():
d.save()
self.updateEditorsSettings()

def settingsFonts(self):
""" Edit the font settings for the code window and various panes """
Expand Down Expand Up @@ -235,6 +236,12 @@ def setAllFonts(self):
#self.loadFont('watchesfont',self.stackList)
self.loadFont('watchesfont',self.outputEdit)
self.loadFont('sourcesfont',self.workspaceTree)

def updateEditorsSettings(self):
s=QtCore.QSettings()
indent=(s.value('indent',2).toInt())[0]
for e in self.editors:
self.editors.get(e).indentWidth=indent

def findUndefinedReferences(self,output):
undefined=set()
Expand Down Expand Up @@ -492,6 +499,7 @@ def openSourceFile(self,path):
lines=f.readlines()
if lines:
firstLine=lines[0]
s=QtCore.QSettings()

editor=Qutepart()
editor.setPath(path)
Expand All @@ -500,6 +508,7 @@ def openSourceFile(self,path):
editor.drawIncorrectIndentation = True
editor.drawAnyWhitespace = False
editor.indentUseTabs = False
editor.indentWidth = (s.value('indent',2).toInt())[0]
editor.text="".join(lines)
editor.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
index=self.central.addTab(editor,os.path.basename(path))
Expand Down
23 changes: 22 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PyQt4 import QtCore
from PyQt4 import QtGui

import uis

class FontSettingsDialog(QtGui.QDialog):
def __init__(self,parent=None):
Expand Down Expand Up @@ -58,3 +58,24 @@ def accept(self):
settings.setValue(name,arr)
settings.sync()
super(FontSettingsDialog,self).accept()


class EditorSettingsDialog(QtGui.QDialog):
def __init__(self,parent=None):
super(EditorSettingsDialog,self).__init__(parent)
uis.loadDialog('editor_settings',self)
s=QtCore.QSettings()
self.indentSpaces.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('\d+')))
self.indentSpaces.setText(s.value('indent','2').toString())

def save(self):
s=QtCore.QSettings()
indent=2
try:
indent=int(self.indentSpaces.text())
except ValueError:
pass
s.setValue('indent',indent)
s.sync()


2 changes: 2 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def appendColorLine(output,line,color):


def appendLine(output,line):
if line.find('Nothing to be done for')>0:
return
if line!='':
parts=line.split(' ')
color='#000000'
Expand Down

0 comments on commit 08022c7

Please sign in to comment.