-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
244 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#---------------------------------------------------------------------------------------------------------- | ||
# Wouter Gilsing | ||
# [email protected] | ||
version = '1.4' | ||
releaseDate = 'November 16 2016' | ||
version = '1.5' | ||
releaseDate = 'December 11 2016' | ||
|
||
#---------------------------------------------------------------------------------------------------------- | ||
# | ||
#LICENSE | ||
# | ||
#---------------------------------------------------------------------------------------------------------- | ||
|
||
''' | ||
Copyright (c) 2016, Wouter Gilsing | ||
All rights reserved. | ||
|
@@ -37,19 +38,22 @@ | |
|
||
#---------------------------------------------------------------------------------------------------------- | ||
|
||
import nuke | ||
|
||
from PySide import QtGui, QtCore | ||
|
||
import datetime | ||
import nuke | ||
import os | ||
import shutil | ||
import datetime | ||
import base64 | ||
import re | ||
import webbrowser | ||
import tarfile | ||
|
||
preferencesNode = nuke.toNode('preferences') | ||
|
||
#---------------------------------------------------------------------------------------------------------- | ||
|
||
class hotboxManager(QtGui.QWidget): | ||
def __init__(self, path = ''): | ||
super(hotboxManager, self).__init__() | ||
|
@@ -427,6 +431,7 @@ def loadScriptEditor(self): | |
activeColor = '#3a3a3a' | ||
lockedColor = '#262626' | ||
|
||
self.scriptEditorScript.savedText = '' | ||
|
||
if len(self.hotboxItemsTree.selectedItems) != 0: | ||
self.selectedItem = self.hotboxItemsTree.selectedItems[0] | ||
|
@@ -451,6 +456,7 @@ def loadScriptEditor(self): | |
for index, line in enumerate(openFile): | ||
if not line.startswith('#'): | ||
text = ''.join(openFile[index+1:]).replace('\t',' '*4) | ||
self.scriptEditorScript.savedText = text | ||
self.scriptEditorScript.setPlainText(text) | ||
break | ||
self.scriptEditorScript.setReadOnly(False) | ||
|
@@ -501,14 +507,22 @@ def saveScriptEditor(self): | |
|
||
name = self.scriptEditorName.text() | ||
|
||
#check whether button or subfolder | ||
if not os.path.isdir(self.selectedItem.path): | ||
|
||
newFileContent = fileHeader(name).getHeader() + self.scriptEditorScript.toPlainText() | ||
#save to disk | ||
text = self.scriptEditorScript.toPlainText() | ||
newFileContent = fileHeader(name).getHeader() + text | ||
currentFile = open(self.selectedItem.path, 'w') | ||
currentFile.write(newFileContent) | ||
currentFile.close() | ||
|
||
#change border color | ||
self.scriptEditorScript.savedText = text | ||
self.scriptEditorScript.updateSaveState(True) | ||
|
||
else: | ||
#save to disk | ||
currentFile = open(self.selectedItem.path+'/_name.json', 'w') | ||
currentFile.write(name) | ||
currentFile.close() | ||
|
@@ -758,8 +772,6 @@ def openAboutDialog(self): | |
class scriptEditorWidget(QtGui.QPlainTextEdit): | ||
''' | ||
Script editor widget. | ||
''' | ||
|
||
#Signal that will be emitted when the user has changed the text | ||
|
@@ -768,9 +780,13 @@ class scriptEditorWidget(QtGui.QPlainTextEdit): | |
def __init__(self): | ||
super(scriptEditorWidget, self).__init__() | ||
|
||
self.savedText = '' | ||
self.saveColor = 'grey' | ||
|
||
#Setup line numbers | ||
self.lineNumberArea = LineNumberArea(self) | ||
self.blockCountChanged.connect(self.updateLineNumberAreaWidth) | ||
self.textChanged.connect(self.updateSaveState) | ||
self.updateRequest.connect(self.updateLineNumberArea) | ||
self.updateLineNumberAreaWidth() | ||
|
||
|
@@ -843,7 +859,6 @@ def lineNumberAreaPaintEvent(self, event): | |
|
||
painter.setPen(textColor) | ||
|
||
|
||
number = "%s " % str(blockNumber + 1) | ||
painter.drawText(0, top, self.lineNumberArea.width(), self.fontMetrics().height(), QtCore.Qt.AlignRight, number) | ||
|
||
|
@@ -853,6 +868,7 @@ def lineNumberAreaPaintEvent(self, event): | |
bottom = top + int(self.blockBoundingRect(block).height()) | ||
blockNumber += 1 | ||
|
||
|
||
#-------------------------------------------------------------------------------------------------- | ||
#Auto indent | ||
#-------------------------------------------------------------------------------------------------- | ||
|
@@ -862,7 +878,6 @@ def keyPressEvent(self, event): | |
Custom actions for specific keystrokes | ||
''' | ||
|
||
|
||
#if Tab convert to Space | ||
if event.key() == 16777217: | ||
self.indentation('indent') | ||
|
@@ -883,6 +898,7 @@ def keyPressEvent(self, event): | |
self.indentNewLine() | ||
else: | ||
QtGui.QPlainTextEdit.keyPressEvent(self, event) | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
|
||
def getCursorInfo(self): | ||
|
@@ -1046,9 +1062,29 @@ def blocks2list(self, blocks, mode = None): | |
return text | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
#syntax hightlighting | ||
#current line hightlighting | ||
#-------------------------------------------------------------------------------------------------- | ||
|
||
def updateSaveState(self, saved = False): | ||
''' | ||
Change border color according to state of text | ||
''' | ||
|
||
if saved: | ||
newsaveColor = 'green' | ||
|
||
else: | ||
|
||
if self.toPlainText() == self.savedText: | ||
newsaveColor = 'grey' | ||
else: | ||
newsaveColor = 'orange' | ||
|
||
if newsaveColor != self.saveColor: | ||
self.saveColor = newsaveColor | ||
|
||
self.highlightCurrentLine() | ||
|
||
def highlightCurrentLine(self): | ||
''' | ||
Highlight currently selected line | ||
|
@@ -1057,7 +1093,15 @@ def highlightCurrentLine(self): | |
|
||
selection = QtGui.QTextEdit.ExtraSelection() | ||
|
||
lineColor = QtGui.QColor(88, 88, 88, 255) | ||
#change depending on save state | ||
if self.saveColor == 'orange': | ||
lineColor = QtGui.QColor(88, 88, 88, 255) | ||
|
||
elif self.saveColor == 'green': | ||
lineColor = QtGui.QColor(44, 88, 44, 255) | ||
self.saveColor = 'grey' | ||
else: | ||
lineColor = QtGui.QColor(44, 44, 44, 255) | ||
|
||
if not self.hasFocus(): | ||
lineColor = QtGui.QColor(88, 88, 88, 0) | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.