Skip to content

Commit

Permalink
Sixth Release
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass committed Jul 9, 2021
1 parent ef0882c commit f413811
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 84 deletions.
262 changes: 189 additions & 73 deletions W_hotbox.py

Large diffs are not rendered by default.

66 changes: 55 additions & 11 deletions W_hotboxManager.py
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.
Expand Down Expand Up @@ -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__()
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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)

Expand All @@ -853,6 +868,7 @@ def lineNumberAreaPaintEvent(self, event):
bottom = top + int(self.blockBoundingRect(block).height())
blockNumber += 1


#--------------------------------------------------------------------------------------------------
#Auto indent
#--------------------------------------------------------------------------------------------------
Expand All @@ -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')
Expand All @@ -883,6 +898,7 @@ def keyPressEvent(self, event):
self.indentNewLine()
else:
QtGui.QPlainTextEdit.keyPressEvent(self, event)

#--------------------------------------------------------------------------------------------------

def getCursorInfo(self):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_addFolder_clicked.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_addFolder_hover.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_addFolder_neutral.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_add_clicked.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_add_hover.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_add_neutral.png
Binary file not shown.
Binary file removed icons/W_hotbox/hotbox_copy_clicked.png
Binary file not shown.

0 comments on commit f413811

Please sign in to comment.