diff --git a/.gitignore b/.gitignore
index 513a900..20472b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,12 +48,13 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
-scripts/python/searcher/db
-scripts/python/searcher/.history
+python2.7libs/*
+!python2.7libs/searcher/
+python2.7libs/searcher/searcher/db
+python2.7libs/searcher/searcher/.history
**.history*
-scripts/python/searcher/go/houdini
-
-
+python2.7libs/searcher/searcher/go/houdini
+python2.7libs/searcher/searcher/_conversion
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
diff --git a/scripts/python/__init__py b/out/linecounter.json
similarity index 100%
rename from scripts/python/__init__py
rename to out/linecounter.json
diff --git a/out/linecounter.txt b/out/linecounter.txt
new file mode 100644
index 0000000..eb91f58
--- /dev/null
+++ b/out/linecounter.txt
@@ -0,0 +1,116 @@
+===============================================================================
+EXTENSION NAME : linecounter
+EXTENSION VERSION : 0.2.7
+-------------------------------------------------------------------------------
+count time : 2020-03-13 02:25:02
+count workspace : e:\GitHub\Searcher
+total files : 35
+total code lines : 4969
+total comment lines : 607
+total blank lines : 741
+
+ statistics
+ | extension| total code| total comment| total blank|percent|
+ -------------------------------------------------------------------------
+ | | 158| 0| 27| 3.2|
+ | .md| 2| 0| 0| 0.040|
+ | .py| 4107| 607| 714| 83|
+ | .ui| 702| 0| 0| 14|
+ -------------------------------------------------------------------------
+.gitignore, code is 97, comment is 0, blank is 20.
+README.md, code is 2, comment is 0, blank is 0.
+scripts\456.py, code is 299, comment is 30, blank is 55.
+scripts\python\__init__py, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\__init__.py, code is 0, comment is 6, blank is 0.
+scripts\python\searcher\about.py, code is 27, comment is 0, blank is 7.
+scripts\python\searcher\about_ui.py, code is 68, comment is 8, blank is 13.
+scripts\python\searcher\animator.py, code is 46, comment is 1, blank is 11.
+scripts\python\searcher\bugreport.py, code is 27, comment is 0, blank is 7.
+scripts\python\searcher\bugreport_ui.py, code is 68, comment is 8, blank is 13.
+scripts\python\searcher\database.py, code is 324, comment is 61, blank is 52.
+scripts\python\searcher\datahandler.py, code is 64, comment is 6, blank is 23.
+scripts\python\searcher\enum.py, code is 29, comment is 6, blank is 3.
+scripts\python\searcher\HelpButton.py, code is 34, comment is 5, blank is 13.
+scripts\python\searcher\images\logo.png, it is a binary file.
+scripts\python\searcher\inspect.py, code is 637, comment is 66, blank is 138.
+scripts\python\searcher\language_en.py, code is 31, comment is 4, blank is 4.
+scripts\python\searcher\linklabel, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\platformselect.py, code is 25, comment is 0, blank is 6.
+scripts\python\searcher\ptime.py, code is 19, comment is 3, blank is 11.
+scripts\python\searcher\scratch, code is 61, comment is 0, blank is 7.
+scripts\python\searcher\searcher.py, code is 940, comment is 137, blank is 139.
+scripts\python\searcher\searcher_data.py, code is 57, comment is 1, blank is 13.
+scripts\python\searcher\searcher_settings.py, code is 419, comment is 66, blank is 55.
+scripts\python\searcher\searchersettings_ui.py, code is 165, comment is 23, blank is 51.
+scripts\python\searcher\session.py, code is 64, comment is 16, blank is 31.
+scripts\python\searcher\ui_files\about.ui, code is 120, comment is 0, blank is 0.
+scripts\python\searcher\ui_files\searcher_ui.py, code is 111, comment is 6, blank is 8.
+scripts\python\searcher\ui_files\searcher_ui.ui, code is 248, comment is 0, blank is 0.
+scripts\python\searcher\ui_files\SearcherSettings.py, code is 168, comment is 6, blank is 7.
+scripts\python\searcher\ui_files\SearcherSettings.ui, code is 334, comment is 0, blank is 0.
+scripts\python\searcher\util.py, code is 381, comment is 148, blank is 37.
+scripts\python\searcher\version.py, code is 7, comment is 0, blank is 2.
+scripts\python\searcher\widgets\__init__py, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\widgets\collapsedock.py, code is 97, comment is 0, blank is 15.
+===============================================================================
+===============================================================================
+EXTENSION NAME : linecounter
+EXTENSION VERSION : 0.2.7
+-------------------------------------------------------------------------------
+count time : 2020-03-13 02:28:04
+count workspace : e:\GitHub\Searcher
+total files : 39
+total code lines : 5092
+total comment lines : 607
+total blank lines : 790
+
+ statistics
+ | extension| total code| total comment| total blank|percent|
+ -------------------------------------------------------------------------
+ | .md| 2| 0| 0| 0.039|
+ | | 158| 0| 27| 3.1|
+ | .shelf| 23| 0| 3| 0.45|
+ | .py| 4107| 607| 714| 81|
+ | .txt| 100| 0| 46| 2.0|
+ | .ui| 702| 0| 0| 14|
+ -------------------------------------------------------------------------
+.gitignore, code is 97, comment is 0, blank is 20.
+Help\searcher\index.txt, code is 50, comment is 0, blank is 23.
+Help\searcher\main.txt, code is 50, comment is 0, blank is 23.
+README.md, code is 2, comment is 0, blank is 0.
+scripts\456.py, code is 299, comment is 30, blank is 55.
+scripts\python\__init__py, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\__init__.py, code is 0, comment is 6, blank is 0.
+scripts\python\searcher\about.py, code is 27, comment is 0, blank is 7.
+scripts\python\searcher\about_ui.py, code is 68, comment is 8, blank is 13.
+scripts\python\searcher\animator.py, code is 46, comment is 1, blank is 11.
+scripts\python\searcher\bugreport.py, code is 27, comment is 0, blank is 7.
+scripts\python\searcher\bugreport_ui.py, code is 68, comment is 8, blank is 13.
+scripts\python\searcher\database.py, code is 324, comment is 61, blank is 52.
+scripts\python\searcher\datahandler.py, code is 64, comment is 6, blank is 23.
+scripts\python\searcher\enum.py, code is 29, comment is 6, blank is 3.
+scripts\python\searcher\HelpButton.py, code is 34, comment is 5, blank is 13.
+scripts\python\searcher\images\logo.png, it is a binary file.
+scripts\python\searcher\inspect.py, code is 637, comment is 66, blank is 138.
+scripts\python\searcher\language_en.py, code is 31, comment is 4, blank is 4.
+scripts\python\searcher\linklabel, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\platformselect.py, code is 25, comment is 0, blank is 6.
+scripts\python\searcher\ptime.py, code is 19, comment is 3, blank is 11.
+scripts\python\searcher\scratch, code is 61, comment is 0, blank is 7.
+scripts\python\searcher\searcher.py, code is 940, comment is 137, blank is 139.
+scripts\python\searcher\searcher_data.py, code is 57, comment is 1, blank is 13.
+scripts\python\searcher\searcher_settings.py, code is 419, comment is 66, blank is 55.
+scripts\python\searcher\searchersettings_ui.py, code is 165, comment is 23, blank is 51.
+scripts\python\searcher\session.py, code is 64, comment is 16, blank is 31.
+scripts\python\searcher\ui_files\about.ui, code is 120, comment is 0, blank is 0.
+scripts\python\searcher\ui_files\searcher_ui.py, code is 111, comment is 6, blank is 8.
+scripts\python\searcher\ui_files\searcher_ui.ui, code is 248, comment is 0, blank is 0.
+scripts\python\searcher\ui_files\SearcherSettings.py, code is 168, comment is 6, blank is 7.
+scripts\python\searcher\ui_files\SearcherSettings.ui, code is 334, comment is 0, blank is 0.
+scripts\python\searcher\util.py, code is 381, comment is 148, blank is 37.
+scripts\python\searcher\version.py, code is 7, comment is 0, blank is 2.
+scripts\python\searcher\widgets\__init__py, code is 0, comment is 0, blank is 0.
+scripts\python\searcher\widgets\collapsedock.py, code is 97, comment is 0, blank is 15.
+toolbar\searcher.shelf, code is 12, comment is 0, blank is 2.
+toolbar\searchertool.shelf, code is 11, comment is 0, blank is 1.
+===============================================================================
diff --git a/scripts/python/searcher/.vscode/settings.json b/python2.7libs/searcher/.vscode/settings.json
similarity index 100%
rename from scripts/python/searcher/.vscode/settings.json
rename to python2.7libs/searcher/.vscode/settings.json
diff --git a/scripts/python/searcher/HelpButton.py b/python2.7libs/searcher/HelpButton.py
similarity index 100%
rename from scripts/python/searcher/HelpButton.py
rename to python2.7libs/searcher/HelpButton.py
diff --git a/scripts/python/searcher/__init__.py b/python2.7libs/searcher/__init__.py
similarity index 100%
rename from scripts/python/searcher/__init__.py
rename to python2.7libs/searcher/__init__.py
diff --git a/scripts/python/searcher/about.py b/python2.7libs/searcher/about.py
similarity index 100%
rename from scripts/python/searcher/about.py
rename to python2.7libs/searcher/about.py
diff --git a/scripts/python/searcher/about_ui.py b/python2.7libs/searcher/about_ui.py
similarity index 100%
rename from scripts/python/searcher/about_ui.py
rename to python2.7libs/searcher/about_ui.py
diff --git a/scripts/python/searcher/animator.py b/python2.7libs/searcher/animator.py
similarity index 100%
rename from scripts/python/searcher/animator.py
rename to python2.7libs/searcher/animator.py
diff --git a/scripts/python/searcher/bugreport.py b/python2.7libs/searcher/bugreport.py
similarity index 100%
rename from scripts/python/searcher/bugreport.py
rename to python2.7libs/searcher/bugreport.py
diff --git a/scripts/python/searcher/bugreport_ui.py b/python2.7libs/searcher/bugreport_ui.py
similarity index 100%
rename from scripts/python/searcher/bugreport_ui.py
rename to python2.7libs/searcher/bugreport_ui.py
diff --git a/python2.7libs/searcher/colorfieldselector.py b/python2.7libs/searcher/colorfieldselector.py
new file mode 100644
index 0000000..8a14c10
--- /dev/null
+++ b/python2.7libs/searcher/colorfieldselector.py
@@ -0,0 +1,121 @@
+import hou
+
+from hutil.Qt import QtCore
+from hutil.Qt import QtGui
+from hutil.Qt import QtWidgets
+
+_MIN_RGB_VALUE = 0
+_MAX_RGB_VALUE = 255
+
+class ColorFieldSelector(QtWidgets.QWidget):
+ """
+hou.qt.ColorField
+
+A widget for color input.
+
+The widget contains a color swatch button and an input field for RGBA
+values.
+
+This class inherits from Qt's QtWidgets.QWidget class.
+
+"""
+ def __init__(self, label="", include_alpha=False):
+ """
+__init__(self, label=\"\", include_alpha=False)
+
+ Create and return a new ColorField object.
+
+
+ label
+ If set to a non-empty string then a label is added to the color
+ field.
+
+ include_alpha
+ If True, then an alpha component is added to the color field.
+
+"""
+ QtWidgets.QWidget.__init__(self)
+
+ layout = QtWidgets.QHBoxLayout()
+ layout.setSpacing(hou.ui.scaledSize(2))
+ layout.setContentsMargins(0, 0, 0, 0)
+
+ self.colorSwatchButton = hou.qt.ColorSwatchButton(include_alpha)
+
+ # Use the color swatch button's colorChanged signal as our own.
+ self.colorChanged = self.colorSwatchButton.colorChanged
+
+ self.inputField = hou.qt.InputField(
+ hou.qt.InputField.FloatType,
+ 4 if include_alpha else 3)
+
+ if label is not None and label != "":
+ layout.addWidget(hou.qt.FieldLabel(label))
+
+ layout.addWidget(self.colorSwatchButton)
+ layout.addSpacing(hou.ui.scaledSize(5))
+ layout.addWidget(self.inputField)
+
+ # Connect color swatch button to field so their values
+ # are always in-sync.
+ self.colorSwatchButton.colorChanged.connect(
+ self._updateFieldFromColorSwatch)
+ self.inputField.valueChanged.connect(
+ self._updateColorSwatchFromField)
+
+ # Sync input field with color swatch.
+ self._updateFieldFromColorSwatch(self.colorSwatchButton.color())
+
+ self.setLayout(layout)
+
+ def color(self):
+ """
+color() -> QtGui.QColor
+
+ Return the field's current color.
+
+"""
+ return self.colorSwatchButton.color()
+
+ def setColor(self, color):
+ """
+setColor(color)
+
+ Set the field's current color. color must be a QtGui.QColor object.
+
+"""
+ self.colorSwatchButton.setColor(color)
+
+ # Update the input field with the new color.
+ self._updateFieldFromColorSwatch(color)
+
+ def _updateFieldFromColorSwatch(self, color):
+ if self.colorSwatchButton.hasAlpha():
+ self.inputField.setValues([
+ color.redF(), color.greenF(), color.blueF(), color.alphaF()])
+ else:
+ self.inputField.setValues([
+ color.redF(), color.greenF(), color.blueF()])
+
+ def _updateColorSwatchFromField(self):
+ values = list(self.inputField.values())
+
+ color = QtGui.QColor()
+ color.setRedF(self._clampRGBValue(values[0]))
+ color.setGreenF(self._clampRGBValue(values[1]))
+ color.setBlueF(self._clampRGBValue(values[2]))
+
+ if self.colorSwatchButton.hasAlpha():
+ color.setAlphaF(self._clampRGBValue(values[3]))
+
+ self.colorSwatchButton.setColor(color)
+
+ def _clampRGBValue(self, val):
+ if val > 1.0:
+ return 1.0
+
+ if val < 0.0:
+ return 0.0
+
+ return val
+
diff --git a/scripts/python/searcher/database.py b/python2.7libs/searcher/database.py
similarity index 73%
rename from scripts/python/searcher/database.py
rename to python2.7libs/searcher/database.py
index ccf8b88..9f6c367 100644
--- a/scripts/python/searcher/database.py
+++ b/python2.7libs/searcher/database.py
@@ -15,15 +15,21 @@
from playhouse.sqlite_ext import SqliteExtDatabase, RowIDField, FTS5Model, SearchField
import time
-def get_db():
- return getattr(hou.session, "DATABASE", None)
+# --------------------------------------------- hou.session
+# NOTE hou.session ----------------------------------------
+def get_settings():
+ return getattr(hou.session, "SETTINGS", None)
+
+def get_dbconnection():
+ return getattr(hou.session, "DBCONNECTION", None)
scriptpath = os.path.dirname(os.path.realpath(__file__))
-hou.session.DATABASE = DatabaseProxy()
-db = get_db()
+db = get_dbconnection()
-# -------------------------------------- DatabaseModels
-# SECTION DatabaseModels ------------------------------
+# --------------------------------------------------------- DatabaseModels
+# SECTION DatabaseModels -------------------------------------------------
+# ------------------------------------------------ Settings
+# NOTE Settings -------------------------------------------
class Settings(Model):
id = IntegerField(unique=True)
indexvalue = IntegerField()
@@ -37,7 +43,8 @@ class Meta:
table_name = 'settings'
database = db
-
+# ------------------------------------------------ HContext
+# NOTE HContext -------------------------------------------
class HContext(Model):
id = AutoField()
context = TextField(unique=True)
@@ -48,16 +55,20 @@ class Meta:
table_name = 'hcontext'
database = db
-class HContextIndex(FTS5Model):
- # rowid = RowIDField()
- context = SearchField()
- title = SearchField()
- description = SearchField()
+# # ------------------------------------------- HContextIndex
+# # NOTE HContextIndex --------------------------------------
+# class HContextIndex(FTS5Model):
+# # rowid = RowIDField()
+# context = SearchField()
+# title = SearchField()
+# description = SearchField()
- class Meta:
- database = db
- options = {'prefix': [2, 3], 'tokenize': 'porter'}
+# class Meta:
+# database = db
+# options = {'prefix': [2, 3], 'tokenize': 'porter'}
+# ------------------------------------------------- Hotkeys
+# NOTE Hotkeys --------------------------------------------
class Hotkeys(Model):
hotkey_symbol = CharField(unique=True)
label = CharField()
@@ -69,7 +80,8 @@ class Meta:
table_name = 'hotkeys'
database = db
-
+# -------------------------------------------- HotkeysIndex
+# NOTE HotkeysIndex ---------------------------------------
class HotkeysIndex(FTS5Model):
# rowid = RowIDField()
hotkey_symbol = SearchField(unindexed=True)
@@ -85,10 +97,10 @@ class Meta:
# table_name = 'hotkeysindex'
database = db
options = {'prefix': [2, 3], 'tokenize': 'porter'}
-#!SECTION
+# !SECTION
-# --------------------------------------------------------- DatabaseModels
-# SECTION DatabaseModels -------------------------------------------------
+# -------------------------------------------------------------- Functions
+# SECTION Functions ------------------------------------------------------
# ----------------------------------------------- py_unique
# NOTE py_unique ------------------------------------------
def py_unique(data):
@@ -128,9 +140,12 @@ def getcontexts(r, context_symbol, root):
return contextdata, hotkeydata
# !SECTION
+# ----------------------------------------------------------- Database
+# SECTION Database ---------------------------------------------------
class Databases(object):
def __init__(self):
- self.settings = searcher_data.loadsettings()
+
+ self.settings = get_settings()
self.isdebug = util.bc(self.settings[util.SETTINGS_KEYS[4]])
inmemory = util.bc(self.settings[util.SETTINGS_KEYS[0]])
if inmemory:
@@ -138,27 +153,28 @@ def __init__(self):
else:
val = (scriptpath + "/db/searcher.db")
- db.initialize(
- SqliteExtDatabase(
- val,
- pragmas=(
- ("cache_size", -1024 * 64),
- ("journal_mode", "wal"),
- ("synchronous", 0)
- )))
-
+ self.db = db
+ if not self.db:
+ hou.session.DBCONNECTION = DatabaseProxy()
+ self.db.initialize(
+ SqliteExtDatabase(
+ val,
+ pragmas=(
+ ("cache_size", -1024 * 64),
+ ("journal_mode", "off"),
+ ("temp_store", "memory"),
+ ("synchronous", 0)
+ )))
+ if inmemory or not os.path.isfile(self.settings[util.SETTINGS_KEYS[1]]):
+ db.create_tables([
+ Settings,
+ HContext,
+ Hotkeys,
+ HotkeysIndex]
+ )
+ self.initialsetup(self.cur)
+
self.cur = db.cursor()
- if inmemory:
- db.create_tables([
- Settings,
- HContext,
- HContextIndex,
- Hotkeys,
- HotkeysIndex]
- )
- self.initialsetup(self.cur)
-
- self.a = 1
self.isdebug = None
self.contexttime = 0
self.hotkeystime = 0
@@ -177,28 +193,34 @@ def getchangeindex(self):
# ------------------------------------------- getlastusedhk
# NOTE getlastusedhk --------------------------------------
- def getlastusedhk(self, cur):
+ def getlastusedhk(self):
try:
- cur.execute("SELECT lastused FROM settings")
- result = cur.fetchall()
- if str(result[0][0]) != "":
- lasthk = str(result[0][0]).split(' ')
+ lastkey = self.settings[util.SETTINGS_KEYS[11]]
+ if str(lastkey) != "":
+ lasthk = str(lastkey).split(' ')
+ hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
+
+ if len(hkcheck) is 0:
+ self.settings[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
+ return
+
rmresult = hou.hotkeys.removeAssignment(
str(lasthk[0]).strip(), str(lasthk[1]).strip())
if rmresult:
hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
hou.hotkeys.saveOverrides()
if len(hkcheck) is 0:
- Settings.update(lastused="").where(Settings.id == 1).execute()
- currentidx = hou.hotkeys.changeIndex()
+ self.settings[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
updatechangeindex(int(currentidx))
else:
hou.hotkeys.clearAssignments(str(lasthk[0]))
hou.hotkeys.saveOverrides()
hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
if len(hkcheck) is 0:
- Settings.update(lastused="").where(Settings.id == 1).execute()
- currentidx = hou.hotkeys.changeIndex()
+ self.settings[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
updatechangeindex(int(currentidx))
else:
if hou.isUIAvailable():
@@ -217,6 +239,8 @@ def getlastusedhk(self, cur):
else:
print("Could not query last assigned temp hotkey: " + str(e))
+ # -------------------------------------------- getdefhotkey
+ # NOTE getdefhotkey ---------------------------------------
def getdefhotkey(self):
try:
self.cur.execute("SELECT defaulthotkey FROM settings")
@@ -225,6 +249,8 @@ def getdefhotkey(self):
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not get Searcher default hotkey: " + str(e)), severity=hou.severityType.Error)
+ # -------------------------------------------- gethcontexts
+ # NOTE gethcontexts ---------------------------------------
def gethcontexts(self):
try:
self.cur.execute("SELECT * FROM hcontext")
@@ -233,13 +259,12 @@ def gethcontexts(self):
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not get Searcher hcontext: " + str(e)), severity=hou.severityType.Error)
+ # ------------------------------------------- gethcontextod
+ # NOTE gethcontextod --------------------------------------
def gethcontextod(self, inputlist):
try:
time1 = ptime.time()
result = []
- # query = (HContextIndex
- # .select(HContextIndex)
- # .where(HContextIndex.match(inputlist)))
query = (HContext
.select()
.where(HContext.context.in_(inputlist))).execute()
@@ -252,19 +277,8 @@ def gethcontextod(self, inputlist):
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Error)
- # def gethcontextod(self, inputlist):
- # try:
- # result = []
- # query = (HContext
- # .select()
- # .where(HContext.context.in_(inputlist))).execute()
- # for hctx in query:
- # result.append((hctx.title, hctx.description, hctx.context))
- # uniqueresult = py_unique(result)
- # return uniqueresult
- # except(AttributeError, TypeError) as e:
- # hou.ui.setStatusMessage(("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Error)
-
+ # ---------------------------------------- ctxfilterresults
+ # NOTE ctxfilterresults -----------------------------------
def ctxfilterresults(self, inputTerm):
try:
result = []
@@ -278,7 +292,8 @@ def ctxfilterresults(self, inputTerm):
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not get Searcher context results: " + str(e)), severity=hou.severityType.Error)
-
+ # ------------------------------------------- searchresults
+ # NOTE searchresults --------------------------------------
def searchresults(self, inputTerm, debug, limit=0):
self.isdebug = debug
try:
@@ -299,8 +314,12 @@ def searchresults(self, inputTerm, debug, limit=0):
return uniqueresult, self.hotkeystime
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not get Searcher results: " + str(e)), severity=hou.severityType.Error)
+ # !SECTION
- # ---------------------------------------------------------- Updates
+ # ------------------------------------------------------------ Updates
+ # SECTION Updates ----------------------------------------------------
+ # --------------------------------------- updatechangeindex
+ # NOTE updatechangeindex ----------------------------------
def updatechangeindex(self, indexval, new=False):
try:
if new is True:
@@ -324,6 +343,8 @@ def updatechangeindex(self, indexval, new=False):
else:
print("Could not update Searcher context database: " + str(e))
+ # --------------------------------------------- updatetmphk
+ # NOTE updatetmphk ----------------------------------------
def updatetmphk(self, tmpkey):
try:
_ = Settings.update(
@@ -331,14 +352,18 @@ def updatetmphk(self, tmpkey):
return
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not update Searcher temp hotkey: " + str(e)), severity=hou.severityType.Error)
-
+
+ # ------------------------------------------- updatelastkey
+ # NOTE updatelastkey --------------------------------------
def updatelastkey(self, lastkey):
try:
_ = Settings.update(lastused=lastkey).where(id == 1).execute()
return
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not update Searcher temp hotkey: " + str(e)), severity=hou.severityType.Error)
-
+
+ # ------------------------------------------- updatecontext
+ # NOTE updatecontext --------------------------------------
def updatecontext(self, debug):
self.isdebug = debug
try:
@@ -359,27 +384,33 @@ def updatecontext(self, debug):
hou.ui.setStatusMessage(
('DB update took %0.4f ms' % res), severity=hou.severityType.Message)
else:
- print('DB update took %0.4f ms' % res) # TODO Remove this timer
+ print('DB update took %0.4f ms' % res)
return res
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Error)
+ # !SECTION
+ # ------------------------------------------- cleardatabase
+ # NOTE cleardatabase --------------------------------------
def cleardatabase(self):
try:
delhk = "DELETE FROM hotkeys"
delctx = "DELETE FROM hcontext"
delhkindex = "DELETE FROM hotkeysindex"
- delhcindex = "DELETE FROM hcontextindex"
+ # delhcindex = "DELETE FROM hcontextindex"
self.cur.execute(delhk)
self.cur.execute(delctx)
+ self.cur.execute(delhkindex)
result = self.cur.fetchall()
return result
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(("Could not update Searcher temp hotkey: " + str(e)),severity=hou.severityType.Error)
- def initialsetup(self, cur):
+ # -------------------------------------------- initialsetup
+ # NOTE initialsetup ---------------------------------------
+ def initialsetup(self):
currentidx = hou.hotkeys.changeIndex()
chindex = self.getchangeindex()
@@ -396,12 +427,12 @@ def initialsetup(self, cur):
chindex = int(chindex[0][0])
if int(currentidx) != chindex:
- self.getlastusedhk(cur)
+ self.getlastusedhk()
self.updatecontext()
self.updatechangeindex(int(currentidx))
if hou.isUIAvailable():
hou.ui.setStatusMessage(
"Searcher database created and populated", severity=hou.severityType.Message)
-
-
\ No newline at end of file
+ # !SECTION
+# !SECTION
\ No newline at end of file
diff --git a/scripts/python/searcher/datahandler.py b/python2.7libs/searcher/datahandler.py
similarity index 91%
rename from scripts/python/searcher/datahandler.py
rename to python2.7libs/searcher/datahandler.py
index d7d7938..b0ef6ce 100644
--- a/scripts/python/searcher/datahandler.py
+++ b/python2.7libs/searcher/datahandler.py
@@ -15,6 +15,8 @@
reload(database)
+def get_db():
+ return getattr(hou.session, "DATABASE", None)
def worker():
hd.executeInMainThreadWithResult(DataHandler().updatedata)
@@ -24,7 +26,11 @@ class DataHandler(object):
"""Searcher data and communication handler"""
def __init__(self, debug=None):
- self.db = database.Databases()
+ self.db = get_db()
+ if not self.db:
+ hou.session.DATABASE = database.Databases()
+ self.db = get_db()
+
self.isdebug = debug
self.scriptpath = os.path.dirname(os.path.realpath(__file__))
# SECTION Function calls ------------------------------ Function calls
diff --git a/scripts/python/searcher/linklabel b/python2.7libs/searcher/db/__init__.py
similarity index 100%
rename from scripts/python/searcher/linklabel
rename to python2.7libs/searcher/db/__init__.py
diff --git a/python2.7libs/searcher/db/searcher.db b/python2.7libs/searcher/db/searcher.db
new file mode 100644
index 0000000..c8899f4
Binary files /dev/null and b/python2.7libs/searcher/db/searcher.db differ
diff --git a/scripts/python/searcher/enum.py b/python2.7libs/searcher/enum.py
similarity index 100%
rename from scripts/python/searcher/enum.py
rename to python2.7libs/searcher/enum.py
diff --git a/python2.7libs/searcher/images/branch-closed.png b/python2.7libs/searcher/images/branch-closed.png
new file mode 100644
index 0000000..213ffdd
Binary files /dev/null and b/python2.7libs/searcher/images/branch-closed.png differ
diff --git a/python2.7libs/searcher/images/branch-end.png b/python2.7libs/searcher/images/branch-end.png
new file mode 100644
index 0000000..54915b3
Binary files /dev/null and b/python2.7libs/searcher/images/branch-end.png differ
diff --git a/python2.7libs/searcher/images/branch-end.svg b/python2.7libs/searcher/images/branch-end.svg
new file mode 100644
index 0000000..cc66807
--- /dev/null
+++ b/python2.7libs/searcher/images/branch-end.svg
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/python2.7libs/searcher/images/branch-more.png b/python2.7libs/searcher/images/branch-more.png
new file mode 100644
index 0000000..664ad44
Binary files /dev/null and b/python2.7libs/searcher/images/branch-more.png differ
diff --git a/python2.7libs/searcher/images/branch-more.svg b/python2.7libs/searcher/images/branch-more.svg
new file mode 100644
index 0000000..5d03abf
--- /dev/null
+++ b/python2.7libs/searcher/images/branch-more.svg
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/python2.7libs/searcher/images/branch-open.png b/python2.7libs/searcher/images/branch-open.png
new file mode 100644
index 0000000..e8cad95
Binary files /dev/null and b/python2.7libs/searcher/images/branch-open.png differ
diff --git a/python2.7libs/searcher/images/branch-vline.png b/python2.7libs/searcher/images/branch-vline.png
new file mode 100644
index 0000000..8f0c336
Binary files /dev/null and b/python2.7libs/searcher/images/branch-vline.png differ
diff --git a/python2.7libs/searcher/images/branch-vline.svg b/python2.7libs/searcher/images/branch-vline.svg
new file mode 100644
index 0000000..4140e5f
--- /dev/null
+++ b/python2.7libs/searcher/images/branch-vline.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/python2.7libs/searcher/images/collapsed.svg b/python2.7libs/searcher/images/collapsed.svg
new file mode 100644
index 0000000..2b5c523
--- /dev/null
+++ b/python2.7libs/searcher/images/collapsed.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/python2.7libs/searcher/images/icon_branch_closed.png b/python2.7libs/searcher/images/icon_branch_closed.png
new file mode 100644
index 0000000..fa785cc
Binary files /dev/null and b/python2.7libs/searcher/images/icon_branch_closed.png differ
diff --git a/python2.7libs/searcher/images/icon_branch_end.png b/python2.7libs/searcher/images/icon_branch_end.png
new file mode 100644
index 0000000..d90a04c
Binary files /dev/null and b/python2.7libs/searcher/images/icon_branch_end.png differ
diff --git a/python2.7libs/searcher/images/icon_branch_more.png b/python2.7libs/searcher/images/icon_branch_more.png
new file mode 100644
index 0000000..bdbe4ed
Binary files /dev/null and b/python2.7libs/searcher/images/icon_branch_more.png differ
diff --git a/python2.7libs/searcher/images/icon_branch_open.png b/python2.7libs/searcher/images/icon_branch_open.png
new file mode 100644
index 0000000..9dd05d6
Binary files /dev/null and b/python2.7libs/searcher/images/icon_branch_open.png differ
diff --git a/python2.7libs/searcher/images/icon_vline.png b/python2.7libs/searcher/images/icon_vline.png
new file mode 100644
index 0000000..14228c8
Binary files /dev/null and b/python2.7libs/searcher/images/icon_vline.png differ
diff --git a/scripts/python/searcher/images/logo.png b/python2.7libs/searcher/images/logo.png
similarity index 100%
rename from scripts/python/searcher/images/logo.png
rename to python2.7libs/searcher/images/logo.png
diff --git a/python2.7libs/searcher/images/opened.svg b/python2.7libs/searcher/images/opened.svg
new file mode 100644
index 0000000..4fecc28
--- /dev/null
+++ b/python2.7libs/searcher/images/opened.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/python2.7libs/searcher/images/stylesheet-branch-closed.png b/python2.7libs/searcher/images/stylesheet-branch-closed.png
new file mode 100644
index 0000000..213ffdd
Binary files /dev/null and b/python2.7libs/searcher/images/stylesheet-branch-closed.png differ
diff --git a/python2.7libs/searcher/images/stylesheet-branch-end.png b/python2.7libs/searcher/images/stylesheet-branch-end.png
new file mode 100644
index 0000000..2c87b4f
Binary files /dev/null and b/python2.7libs/searcher/images/stylesheet-branch-end.png differ
diff --git a/python2.7libs/searcher/images/stylesheet-branch-more.png b/python2.7libs/searcher/images/stylesheet-branch-more.png
new file mode 100644
index 0000000..664ad44
Binary files /dev/null and b/python2.7libs/searcher/images/stylesheet-branch-more.png differ
diff --git a/python2.7libs/searcher/images/stylesheet-branch-open.png b/python2.7libs/searcher/images/stylesheet-branch-open.png
new file mode 100644
index 0000000..e8cad95
Binary files /dev/null and b/python2.7libs/searcher/images/stylesheet-branch-open.png differ
diff --git a/python2.7libs/searcher/images/stylesheet-vline.png b/python2.7libs/searcher/images/stylesheet-vline.png
new file mode 100644
index 0000000..8f0c336
Binary files /dev/null and b/python2.7libs/searcher/images/stylesheet-vline.png differ
diff --git a/scripts/python/searcher/inspect.py b/python2.7libs/searcher/inspect.py
similarity index 100%
rename from scripts/python/searcher/inspect.py
rename to python2.7libs/searcher/inspect.py
diff --git a/python2.7libs/searcher/language_en.py b/python2.7libs/searcher/language_en.py
new file mode 100644
index 0000000..9728ecb
--- /dev/null
+++ b/python2.7libs/searcher/language_en.py
@@ -0,0 +1,60 @@
+# SECTION Language US
+language = "en"
+
+# NOTE Tooltips
+TT_MW = {
+ "searchbox" : "Begin typing to search or click magnifying glass icon to display options",
+ "contexttoggle" : "Toggle to enable or disable the 'context' column in the search results",
+ "pinwindow" : "Pin the search window to keep it from closing automatically when losing focus",
+ "searchfilter" : "Select a predefined filter",
+ "opensettingstool" : "General application settings",
+ "searchresultstree" : "Press tab to highlight or double click an action to attempt to perform it. Some actions only work in specific contexts",
+ "helpButton" : "Open help panel",
+ "metricposmain" : "Change the position of metrics to Houdinis main window",
+ "metricposself" : "Change the position of metrics to Searchers window",
+}
+# NOTE Tooltops Settings
+TT_SETTINGS = {
+ "about_btn": "Contact and other info",
+ "projectTitle" : "Thanks for using Searcher!",
+ "lang_cbox" : "When translations become available they can be selected here",
+ "inmemory_chk" : "Enable to use an in-memory database instead of SQLite file",
+ "windowsize_chk" : "Enable to save the size and location of the main window upon closing. Defaults to center (1000px, 600px)",
+ "maxresults_lbl" : "Maximum results to load per query as you type your search term. (Too many can make results feel sluggish)",
+ "maxresults_txt" : "Maximum results to load per query as you type your search term (Too many can make results feel sluggish)",
+ "animatedsettings_chk" : "Enables animated menus",
+ "dbpath_icon": "",
+ "dbpath_lbl" : "The location in which Searcher stores it's database file",
+ "databasepath_txt" : "The location in which Searcher stores it's database file",
+ "defaulthotkey_lbl" : ("If left to the default value of (Ctrl+Alt+Shift+F7), "
+ "in the event that Searcher detects a conflict it will "
+ "automatically attempt to try different key combinations."),
+ "defaulthotkey_txt" : ("If left to the default value of (Ctrl+Alt+Shift+F7), "
+ "in the event that Searcher detects a conflict it will "
+ "automatically attempt to try different key combinations."),
+ "cleardata_btn" : "If, for some reason, Searcher is having issues this function will clear out the database and start fresh",
+ "save_btn" : "Save your settings",
+ "discard_btn" : "Disgard settings changes",
+ "debugflag_chk": "Toggle debug messages",
+ "debuglevel_cbx": "Select level of debugging",
+ "bug_btn": "Bug report form",
+ "theme_btn": "Change colors",
+ "metrics_chk": "Enable performance metrics to view query and render times",
+}
+
+ERRORMSG = {
+ "cleardatabase" : "Could not clear db for refresh: ",
+ "updatecontext" : "Could not update Searcher context database: ",
+ "updatechangeindex" : "Could not update Searcher context database: ",
+ "getlastusedhk1" : "Could not query last assigned temp hotkey: ",
+ "getlastusedhk2" : "Could not clear last assigned temp hotkey: ",
+ "getlastusedh3" : "Could not clear last assigned temp hotkey on last attempt: ",
+ "getchangeindex" : "Could not get Searcher changeindex: ",
+}
+
+MESSAGES = {
+ "initialsetup1" : "Searcher database created",
+ "initialsetup2" : "Searcher database created and populated",
+}
+
+# !SECTION
diff --git a/scripts/python/searcher/widgets/__init__py b/python2.7libs/searcher/linklabel
similarity index 100%
rename from scripts/python/searcher/widgets/__init__py
rename to python2.7libs/searcher/linklabel
diff --git a/scripts/python/searcher/platformselect.py b/python2.7libs/searcher/platformselect.py
similarity index 100%
rename from scripts/python/searcher/platformselect.py
rename to python2.7libs/searcher/platformselect.py
diff --git a/scripts/python/searcher/ptime.py b/python2.7libs/searcher/ptime.py
similarity index 100%
rename from scripts/python/searcher/ptime.py
rename to python2.7libs/searcher/ptime.py
diff --git a/python2.7libs/searcher/resizehandle.py b/python2.7libs/searcher/resizehandle.py
new file mode 100644
index 0000000..6dd8c55
--- /dev/null
+++ b/python2.7libs/searcher/resizehandle.py
@@ -0,0 +1,122 @@
+# coding=utf-8
+import os
+import sys
+
+hver = 0
+if os.environ["HFS"] != "":
+ ver = os.environ["HFS"]
+ hver = int(ver[ver.rindex('.')+1:])
+ from hutil.Qt import QtGui
+ from hutil.Qt import QtCore
+ from hutil.Qt import QtWidgets
+else:
+ from PyQt5 import QtGui
+ from PyQt5 import QtCore
+ from PyQt5 import QtWidgets
+
+class ResizeHandle(QtWidgets.QSizeGrip):
+ def __init__(self, parent, target):
+ """ ResizeHandle has separate parent widget and target widget. They can be same,
+ of course, but this allows more freedom in placement of resizehandles.
+ :param parent: parent widget to host the handle widget
+ :param target: target widget which is affected by resizing
+ """
+ super(ResizeHandle, self).__init__(parent)
+ self.target = target
+ self.pressed = False
+ self.adjust = None
+
+ def mousePressEvent(self, e):
+ self.pressed = True
+ grandparent = self.target.parent()
+ rrect = self.target.geometry()
+ bottom_right = grandparent.mapToGlobal(rrect.bottomRight())
+ self.adjust = bottom_right - e.globalPos()
+
+ def mouseReleaseEvent(self, e):
+ self.pressed = False
+ self.adjust = None
+
+ def mouseMoveEvent(self, e):
+ if e.buttons() != QtCore.Qt.LeftButton:
+ return
+ if not self.pressed:
+ return
+ gp = e.globalPos()
+ size = self.target.size()
+ rrect = self.target.geometry()
+ grandparent = self.target.parent()
+ bottom_right = grandparent.mapToGlobal(rrect.bottomRight())
+ size_diff = bottom_right - gp - self.adjust
+ nw = max(16, size.width() - size_diff.x())
+ nh = max(16, size.height() - size_diff.y())
+ self.target.setMinimumSize(nw, nh)
+ pw = self.parentWidget()
+ if hasattr(pw, 'update_size'):
+ pw.update_size()
+ self.resizable.resize(size.width() - size_diff.x(), size.height() - size_diff.y())
+
+ def eventFilter(self, obj, event):
+ """ Remove check for hiding size grip on full screen --
+ widgets should be always resizable.
+ :param obj:
+ :param event:
+ :return:
+ """
+ return False
+
+
+class GraphicsResizeHandle(QtWidgets.QSizeGrip):
+ def __init__(self, view, host):
+ QtWidgets.QSizeGrip.__init__(self, view)
+ self.pressed = False
+ self.adjust = None
+ self.update_position()
+ self.show()
+
+ def update_position(self):
+ v = ctrl.graph_view
+ br = self.host.sceneBoundingRect().bottomRight()
+ bottom_right = v.mapFromScene(br)
+ self.move(bottom_right)
+
+ def mousePressEvent(self, e):
+ self.pressed = True
+ v = ctrl.graph_view
+ br = self.host.sceneBoundingRect().bottomRight()
+ global_bottom_right = v.mapToGlobal(v.mapFromScene(br))
+ self.adjust = global_bottom_right - e.globalPos()
+
+ def mouseReleaseEvent(self, e):
+ self.pressed = False
+ self.adjust = None
+
+ def mouseMoveEvent(self, e):
+ """ Implements dragging the handle (if handle is pressed)
+ :param e:
+ :return:
+ """
+ if e.buttons() != QtCore.Qt.LeftButton:
+ return
+ if not self.pressed:
+ return
+ gp = e.globalPos()
+ h = self.host
+ br = h.sceneBoundingRect().bottomRight()
+ global_bottom_right = ctrl.graph_view.mapToGlobal(ctrl.graph_view.mapFromScene(br))
+ size_diff = global_bottom_right - gp - self.adjust
+ new_width = h.width - size_diff.x()
+ new_height = h.height - size_diff.y()
+ h.set_user_size(new_width, new_height)
+ h.update_label()
+ self.update_position()
+ ctrl.forest.draw()
+
+ def eventFilter(self, obj, event):
+ """ Remove check for hiding size grip on full screen --
+ widgets should be always resizable.
+ :param obj:
+ :param event:
+ :return:
+ """
+ return False
\ No newline at end of file
diff --git a/scripts/python/searcher/scratch b/python2.7libs/searcher/scratch
similarity index 100%
rename from scripts/python/searcher/scratch
rename to python2.7libs/searcher/scratch
diff --git a/scripts/python/searcher/searcher.py b/python2.7libs/searcher/searcher.py
similarity index 70%
rename from scripts/python/searcher/searcher.py
rename to python2.7libs/searcher/searcher.py
index 6f93100..58d97a3 100644
--- a/scripts/python/searcher/searcher.py
+++ b/python2.7libs/searcher/searcher.py
@@ -1,17 +1,20 @@
-# region Imports
from __future__ import print_function
from __future__ import absolute_import
import weakref
from searcher import util
+from searcher import style
from searcher import ptime
from searcher import animator
from searcher import database
from searcher import HelpButton
from searcher import datahandler
+from searcher import searcher_ui
from searcher import searcher_data
from searcher import searcher_settings
+from searcher import searcher_settings_ui
from searcher import language_en as la
+from searcher import resizehandle
import hou
import platform
@@ -27,13 +30,21 @@
from hutil.Qt import QtGui
from hutil.Qt import QtCore
from hutil.Qt import QtWidgets
+else:
+ from PyQt5 import QtGui
+ from PyQt5 import QtCore
+ from PyQt5 import QtWidgets
+reload(searcher_settings_ui)
reload(searcher_settings)
reload(searcher_data)
+reload(resizehandle)
+reload(searcher_ui)
reload(datahandler)
reload(HelpButton)
reload(animator)
reload(database)
+reload(style)
reload(ptime)
reload(util)
reload(la)
@@ -68,6 +79,11 @@
# -------------------------------------------------------------------- Class Functions
+def get_settings():
+ return getattr(hou.session, "SETTINGS", None)
+
+def get_dbhandler():
+ return getattr(hou.session, "DBHANDLER", None)
def keyconversion(key):
for i in range(len(key)):
@@ -86,46 +102,57 @@ class Searcher(QtWidgets.QWidget):
def __init__(self, kwargs, settings, windowsettings):
super(Searcher, self).__init__(hou.qt.mainWindow())
self._drag_active = False
+ self.settingdata = settings
self.animationDuration = 200
- self.uiwidth = int(520)
- self.uiheight = int(300)
# Setting vars
kwargs = kwargs
- self.settingdata = settings
self.windowsettings = windowsettings
self.isdebug = util.Dbug(
- util.bc(self.settingdata[util.SETTINGS_KEYS[4]]),
- str(self.settingdata[util.SETTINGS_KEYS[10]])
+ self.settingdata[util.SETTINGS_KEYS[4]],
+ str(self.settingdata[util.SETTINGS_KEYS[10]]),
+ self.settingdata[util.SETTINGS_KEYS[12]],
+ self.settingdata[util.SETTINGS_KEYS[13]],
)
+ self.appcolors = util.AppColors(self.settingdata[util.SETTINGS_KEYS[14]])
self.menuopened = False
self.windowispin = util.bc(self.settingdata[util.SETTINGS_KEYS[5]])
self.showctx = util.bc(self.settingdata[util.SETTINGS_KEYS[7]])
self.originalsize = self.settingdata[util.SETTINGS_KEYS[3]]
- self.animatedsettings = util.bc(
- self.settingdata[util.SETTINGS_KEYS[8]])
- self.mainlayout = QtWidgets.QVBoxLayout()
+ self.animatedsettings = self.settingdata[util.SETTINGS_KEYS[8]]
self.settingslayout = QtWidgets.QVBoxLayout()
self.app = QtWidgets.QApplication.instance()
# UI Vars
- self.handler, self.tmpkey = self.initialsetup()
+ if self.animatedsettings:
+ self.uiwidth = int(520)
+ self.uiheight = int(300)
+ else:
+ self.uiwidth = int(520)
+ self.uiheight = int(242)
+
+ self.handler = self.initialsetup()
self.ui = searcher_settings.SearcherSettings(
self.handler,
- self.tmpkey,
+ self.uiwidth,
+ self.uiheight,
self
)
if self.animatedsettings:
self.anim = animator.Animator(self.ui, self.anim_complete)
- # Functional Vars
+ # Performance timers
self.endtime = 0
- self.lastused = {}
self.starttime = 0
- self.treecatnum = 0
self.hotkeystime = 0
+ self.regtimetotal = 0
self.hcontexttime = 0
+
+ # Functional Vars
+ self.lastused = {}
+ self.treecatnum = 0
self.treeitemsnum = 0
+ self.tmpkey = None
self.tmpsymbol = None
self.searching = False
self.ctxsearch = False
@@ -142,6 +169,7 @@ def __init__(self, kwargs, settings, windowsettings):
# Event System Initialization
self.installEventFilter(self)
+ self.metricpos.installEventFilter(self)
self.searchbox.installEventFilter(self)
self.pinwindow.installEventFilter(self)
self.helpButton.installEventFilter(self)
@@ -164,33 +192,32 @@ def buildsettingsmenu(self):
self.ui.setWindowFlags(
QtCore.Qt.Tool |
QtCore.Qt.CustomizeWindowHint |
- QtCore.Qt.FramelessWindowHint |
- QtCore.Qt.WindowStaysOnTopHint
+ QtCore.Qt.FramelessWindowHint
)
self.ui.setAttribute(QtCore.Qt.WA_StyledBackground, True)
- self.ui.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
+ if self.settingdata[util.SETTINGS_KEYS[8]]:
+ self.ui.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
self.ui.setStyleSheet("QWidget { background: rgb(58, 58, 58); }"
- "QWidget#SearcherSettings { border: 2px solid rgb(35, 35, 35); } ")
+ "QWidget#SearcherSettings { border: 0px solid rgb(35, 35, 35); } ")
self.settingslayout = self.ui.settingslayout
if self.animatedsettings:
- self.anim.setContentLayout(self.settingslayout)
- self.anim.resize(
- self.uiwidth,
- self.uiheight
- )
- self.ui.resize(
+ self.anim.setContentLayout(self.settingslayout)
+ self.anim.resize(
self.uiwidth,
self.uiheight
)
-
+ self.ui.resize(
+ self.uiwidth,
+ self.uiheight
+ )
# !SECTION
# ----------------------------------------------------------------- UI
# SECTION UI ---------------------------------------------------------
- # ------------------------------------- setupresulttree
- # NOTE setupresulttree --------------------------------
+ # ----------------------------------- Setup Result Tree
+ # NOTE Setup Result Tree ------------------------------
def setupresulttree(self):
cols = 4
self.searchresultstree.setColumnCount(cols)
@@ -214,229 +241,72 @@ def setupresulttree(self):
self.searchresultstree.hideColumn(4)
self.searchresultstree.header().setMinimumSectionSize(85)
- self.searchresultstree.header().setSectionResizeMode(
- 0, QtWidgets.QHeaderView.ResizeToContents)
- self.searchresultstree.header().setSectionResizeMode(
- 1, QtWidgets.QHeaderView.ResizeToContents)
- self.searchresultstree.header().setSectionResizeMode(
- 2, QtWidgets.QHeaderView.ResizeToContents)
- self.searchresultstree.header().setSectionResizeMode(
- 3, QtWidgets.QHeaderView.Stretch)
- self.searchresultstree.header().setSectionResizeMode(
- 4, QtWidgets.QHeaderView.ResizeToContents)
- self.searchresultstree.setStyleSheet("""QHeaderView::section{
- color: rgb(200, 200, 200);
- resize:both;
- overflow:auto;
- padding: 4px;
- height:20px;
- border: 0px solid rgb(150, 150, 150);
- border-bottom: 1px solid rgb(150, 150, 150);
- border-left:0px solid rgb(50, 50, 50);
- border-right:1px solid rgb(60, 60, 60);
- background: rgb(36, 36, 36);
- }""")
-
- # -------------------------------------- Build Settings
- # NOTE Build Settings ---------------------------------
+ self.searchresultstree.header().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
+ self.searchresultstree.header().setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
+ self.searchresultstree.header().setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
+ self.searchresultstree.header().setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch)
+ self.searchresultstree.header().setSectionResizeMode(4, QtWidgets.QHeaderView.ResizeToContents)
+ self.searchresultstree.setStyleSheet(style.gettreeviewstyle())
+
+ # -------------------------------------------- UI Setup
+ # NOTE UI Setup ---------------------------------------
def uisetup(self):
names = ["open", "save", "hotkey", "perference"]
self.completer = QtWidgets.QCompleter(names)
- # Layout
- self.gridLayout = QtWidgets.QGridLayout()
- self.gridLayout.setSpacing(0)
- self.gridLayout.setContentsMargins(0, 0, 0, 0)
- self.verticalLayout = QtWidgets.QVBoxLayout()
- self.verticalLayout.setSpacing(0)
-
- self.titlerow = QtWidgets.QHBoxLayout()
- self.titlerow.setSpacing(5)
-
- self.titlespacer1 = QtWidgets.QSpacerItem(
- 8, 0,
- QtWidgets.QSizePolicy.Fixed,
- QtWidgets.QSizePolicy.Minimum
- )
-
- self.searcherlbl = QtWidgets.QLabel("Searcher")
- font = QtGui.QFont()
- font.setPointSize(15)
- self.searcherlbl.setFont(font)
- self.searcherlbl.setAlignment(QtCore.Qt.AlignCenter)
-
- self.titlespacer2 = QtWidgets.QSpacerItem(
- 40, 0,
- QtWidgets.QSizePolicy.Expanding,
- QtWidgets.QSizePolicy.Minimum
- )
-
- self.contexttoggle = QtWidgets.QPushButton()
- self.helpButton = HelpButton.HelpButton("main", la.ln_helppanel, 16)
- self.pinwindow_btn = QtWidgets.QToolButton()
- self.opensettings_btn = QtWidgets.QToolButton()
-
- self.titlespacer3 = QtWidgets.QSpacerItem(
- 8, 0,
- QtWidgets.QSizePolicy.Fixed,
- QtWidgets.QSizePolicy.Minimum
- )
-
- # ----------------------------------- Search Filter
- # NOTE Search Filter ------------------------------
- self.searchrow = QtWidgets.QHBoxLayout()
- self.searchrow.setSpacing(0)
- self.frame = QtWidgets.QFrame()
- searchframe_details = QtWidgets.QSizePolicy(
- QtWidgets.QSizePolicy.Preferred,
- QtWidgets.QSizePolicy.Preferred
- )
- searchframe_details.setHorizontalStretch(2)
- searchframe_details.setVerticalStretch(0)
- searchframe_details.setHeightForWidth(
- self.frame.sizePolicy().hasHeightForWidth())
- self.frame.setSizePolicy(searchframe_details)
- self.frame.setMinimumSize(QtCore.QSize(0, 20))
- self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
- self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
- self.searchfilter_btn = QtWidgets.QToolButton(self.frame)
- self.searchfilter_btn.setGeometry(QtCore.QRect(0, 0, 26, 20))
- self.searchfilter_btn.setBaseSize(QtCore.QSize(16, 16))
- self.searchfilter_btn.setStyleSheet(
- u"background-color: rgb(19, 19, 19);")
- self.searchfilter_btn.setArrowType(QtCore.Qt.NoArrow)
+ self.sui = searcher_ui.Ui_Searcher()
+ self.sui.setupUi(self)
+ self.setLayout(self.sui.mainlayout)
+
+ # ---------------------------------- UI Connections
+ # NOTE UI Connections -----------------------------
+ self.metricpos = self.sui.metricpos
+ self.contexttoggle = self.sui.contexttoggle
+ self.searchfilter = self.sui.searchfilter_btn
+ self.pinwindow = self.sui.pinwindow_btn
+ self.helpButton = self.sui.helpButton
+ self.opensettingstool = self.sui.opensettings_btn
+ self.searchresultstree = self.sui.searchresults_tree
+ self.searchbox = self.sui.searchbox_txt
+ self.infolbl = self.sui.info_lbl
# -------------------------------------- Search Box
# NOTE Search Box ---------------------------------
- self.searchbox_txt = QtWidgets.QLineEdit()
- searchbox_details = QtWidgets.QSizePolicy(
- QtWidgets.QSizePolicy.Expanding,
- QtWidgets.QSizePolicy.Minimum
- )
- searchbox_details.setHorizontalStretch(99)
- searchbox_details.setVerticalStretch(0)
- searchbox_details.setHeightForWidth(
- self.searchbox_txt.sizePolicy().hasHeightForWidth())
- self.searchbox_txt.setSizePolicy(searchbox_details)
- self.searchbox_txt.setMinimumSize(QtCore.QSize(50, 0))
- self.searchbox_txt.setMouseTracking(False)
- self.searchbox_txt.setStyleSheet(u"background-color: rgb(19, 19, 19);")
- self.searchbox_txt.setFrame(False)
-
- # ------------------------------------ Results Tree
- # NOTE Results Tree -------------------------------
- self.searchresults_tree = QtWidgets.QTreeWidget()
- __qtreewidgetitem = QtWidgets.QTreeWidgetItem()
- __qtreewidgetitem.setText(0, u"1")
- resultstree_header = QtGui.QFont()
- resultstree_header.setPointSize(9)
- __qtreewidgetitem.setFont(0, resultstree_header)
- self.searchresults_tree.setHeaderItem(__qtreewidgetitem)
- resultstree_details = QtWidgets.QSizePolicy(
- QtWidgets.QSizePolicy.Preferred,
- QtWidgets.QSizePolicy.Expanding
- )
- resultstree_details.setHorizontalStretch(0)
- resultstree_details.setVerticalStretch(0)
- # resultstree_details.setHeightForWidth(
- # self.searchresults_tree.sizePolicy().hasHeightForWidth())
- self.searchresults_tree.setSizePolicy(resultstree_details)
- resultstree_font = QtGui.QFont()
- resultstree_font.setPointSize(9)
- self.searchresults_tree.setFont(resultstree_font)
- self.searchresults_tree.setMouseTracking(False)
- self.searchresults_tree.setFocusPolicy(QtCore.Qt.NoFocus)
- self.searchresults_tree.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.searchresults_tree.setLineWidth(0)
- self.searchresults_tree.setSizeAdjustPolicy(
- QtWidgets.QAbstractScrollArea.AdjustToContents)
- self.searchresults_tree.setAlternatingRowColors(True)
- self.searchresults_tree.setSelectionMode(
- QtWidgets.QAbstractItemView.SingleSelection)
- self.searchresults_tree.setSelectionBehavior(
- QtWidgets.QAbstractItemView.SelectRows)
-
- # -------------------------------------- Info Panel
- # NOTE Info Panel ---------------------------------
- self.infobar = QtWidgets.QHBoxLayout()
- self.infobar.setObjectName("infobar")
- self.infobargrid = QtWidgets.QGridLayout()
- self.infobargrid.setObjectName("infobargrid")
- self.info_lbl = QtWidgets.QLabel()
- self.infolbl_font = QtGui.QFont()
- self.infolbl_font.setPointSize(8)
- self.infolbl_font.setBold(False)
- self.infolbl_font.setWeight(50)
- self.info_lbl.setFont(self.infolbl_font)
- self.info_lbl.setStyleSheet(u"background-color: rgb(26, 26, 26);")
- self.info_lbl.setMargin(2)
- self.info_lbl.setIndent(5)
- self.overlay = overlayLabel(self.info_lbl)
- self.overlay.setFont(self.infolbl_font)
- self.overlay.setStyleSheet(u"background-color: rgb(26, 26, 26);")
- self.overlay.setMargin(2)
- self.overlay.setIndent(5)
- self.treetotal_lbl = QtWidgets.QLabel()
- treetotal_size = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
- treetotal_size.setHorizontalStretch(0)
- treetotal_size.setVerticalStretch(0)
- treetotal_size.setHeightForWidth(self.treetotal_lbl.sizePolicy().hasHeightForWidth())
- self.treetotal_lbl.setSizePolicy(treetotal_size)
- self.treetotal_lbl.setMinimumSize(QtCore.QSize(150, 0))
- self.treetotal_lbl.setMaximumSize(QtCore.QSize(150, 16777215))
- self.treetotal_lbl.setObjectName("treetotal_lbl")
- self.treetotal_lbl.setStyleSheet(u"background-color: rgb(26, 26, 26);")
- self.treetotal_lbl.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
-
- # --------------------------- Layout Implementation
- # NOTE Layout Implementation ----------------------
- self.titlerow.addItem(self.titlespacer1)
- self.titlerow.addWidget(self.searcherlbl)
- self.titlerow.addItem(self.titlespacer2)
- self.titlerow.addWidget(self.contexttoggle)
- self.titlerow.addWidget(self.helpButton)
- self.titlerow.addWidget(self.pinwindow_btn)
- self.titlerow.addWidget(self.opensettings_btn)
- self.titlerow.addItem(self.titlespacer3)
- self.verticalLayout.addLayout(self.titlerow)
- self.searchrow.addWidget(self.frame)
- self.searchrow.addWidget(self.searchbox_txt)
- self.verticalLayout.addLayout(self.searchrow)
- self.verticalLayout.addWidget(self.searchresults_tree)
- self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
-
- self.infobargrid.addWidget(self.overlay, 1, 0, 1, 1)
- self.infobargrid.addWidget(self.info_lbl, 1, 0, 1, 1)
- self.infobargrid.addWidget(self.treetotal_lbl, 1, 1, 1, 1)
-
- self.infobar.addLayout(self.infobargrid)
- self.gridLayout.addLayout(self.infobar, 3, 0, 1, 1)
-
- # NOTE Layout to functionality connection ---------
- self.searchfilter = self.searchfilter_btn
- self.pinwindow = self.pinwindow_btn
- self.opensettingstool = self.opensettings_btn
- self.searchresultstree = self.searchresults_tree
- self.searchbox = self.searchbox_txt
- self.infolbl = self.info_lbl
-
- # ---------------------------- Settings and details
- # NOTE Settings and details -----------------------
+ self.searchbox.textChanged.connect(self.textchange_cb)
+ self.searchbox.customContextMenuRequested.connect(self.openmenu)
self.searchbox.setPlaceholderText(" Begin typing to search..")
self.searchbox.setFocusPolicy(QtCore.Qt.StrongFocus)
self.searchbox.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.searchbox.setClearButtonEnabled(True)
+ # ----------------------------------- Search Filter
+ # NOTE Search Filter ------------------------------
self.searchfilter.clicked.connect(self.searchfilter_cb)
- searchfilter_button_size = hou.ui.scaledSize(12)
+ self.searchfilter.setFixedWidth(26)
+ self.searchfilter.setFixedHeight(26)
self.searchfilter.setProperty("flat", True)
self.searchfilter.setIcon(util.SEARCH_ICON)
self.searchfilter.setIconSize(QtCore.QSize(
- searchfilter_button_size,
- searchfilter_button_size
+ hou.ui.scaledSize(16),
+ hou.ui.scaledSize(16)
))
- self.setctxicon()
+ # -------------------------------------- Metric Pos
+ # NOTE Metric Pos ---------------------------------
+ self.setmetricicon()
+ self.metricpos.clicked.connect(self.metricpos_cb)
+ metricpos_button_size = hou.ui.scaledSize(16)
+ self.metricpos.setProperty("flat", True)
+ self.metricpos.setIconSize(QtCore.QSize(
+ metricpos_button_size,
+ metricpos_button_size
+ ))
+ self.metricpos.setVisible(
+ self.settingdata[util.SETTINGS_KEYS[12]])
+
+ # ---------------------------------- Context Toggle
+ # NOTE Context Toggle -----------------------------
+ self.contexttoggle.clicked[bool].connect(self.showctx_cb)
self.contexttoggle.setCheckable(True)
self.contexttoggle.setChecked(self.showctx)
self.contexttoggle.setFixedWidth(20)
@@ -447,12 +317,15 @@ def uisetup(self):
contexttoggle_button_size,
contexttoggle_button_size
))
- self.contexttoggle.clicked[bool].connect(self.showctx_cb)
+ self.setctxicon()
self.contexttoggle.setStyleSheet("QPushButton { width: 8px; border: none; }"
"QPushButton:checked { width: 8px; border: none;}")
- self.pinwindow.clicked.connect(self.pinwindow_cb)
+
+ # -------------------------------------- Pin Window
+ # NOTE Pin Window ---------------------------------
self.setpinicon()
+ self.pinwindow.clicked.connect(self.pinwindow_cb)
pinwindow_button_size = hou.ui.scaledSize(16)
self.pinwindow.setProperty("flat", True)
self.pinwindow.setIconSize(QtCore.QSize(
@@ -460,6 +333,8 @@ def uisetup(self):
pinwindow_button_size
))
+ # ----------------------------------- Settings Menu
+ # NOTE Settings Menu ------------------------------
self.opensettingstool.setCheckable(True)
self.opensettingstool.setChecked(False)
self.opensettingstool.clicked.connect(self.opensettings_cb)
@@ -471,23 +346,23 @@ def uisetup(self):
opensettingstool_button_size
))
- self.searchbox.textChanged.connect(self.textchange_cb)
- self.searchbox.customContextMenuRequested.connect(self.openmenu)
+ # ------------------------------------- Result Tree
+ # NOTE Result Tree --------------------------------
self.searchresultstree.itemActivated.connect(self.searchclick_cb)
- self.mainlayout.setAlignment(QtCore.Qt.AlignBottom)
- self.mainlayout.setContentsMargins(0, 0, 0, 0)
- self.mainlayout.setGeometry(QtCore.QRect(0, 0, 1400, 1200))
+ # ---------------------------------------- Info Bar
+ # NOTE Info Bar -----------------------------------
+ self.info_lbl = self.sui.info_lbl
+ self.treetotal_lbl = self.sui.treetotal_lbl
- self.mainlayout.addLayout(self.gridLayout)
- self.setLayout(self.mainlayout)
-
- self.searchbox.setToolTip(la.ln_searchbox)
- self.contexttoggle.setToolTip(la.ln_contexttoggle)
- self.pinwindow.setToolTip(la.ln_pinwindow)
- self.searchfilter.setToolTip(la.ln_searchfilter)
- self.opensettingstool.setToolTip(la.ln_opensettingstool)
- self.searchresultstree.setToolTip(la.ln_searchresultstree)
+ # ---------------------------------------- Tooltips
+ # NOTE Tooltips -----------------------------------
+ self.searchbox.setToolTip(la.TT_MW[self.searchbox.objectName()])
+ self.contexttoggle.setToolTip(la.TT_MW[self.contexttoggle.objectName()])
+ self.pinwindow.setToolTip(la.TT_MW[self.pinwindow.objectName()])
+ self.searchfilter.setToolTip(la.TT_MW[self.searchfilter.objectName()])
+ self.opensettingstool.setToolTip(la.TT_MW[self.opensettingstool.objectName()])
+ self.searchresultstree.setToolTip(la.TT_MW[self.searchresultstree.objectName()])
self.setupresulttree()
self.searchbox.setFocus()
@@ -508,7 +383,11 @@ def count_chars(self, txt):
# --------------------------------------- Initial Setup
# NOTE Initial Setup ----------------------------------
def initialsetup(self):
- self.handler = datahandler.DataHandler(self.isdebug)
+ self.handler = get_dbhandler()
+ if not self.handler:
+ hou.session.DBHANDLER = datahandler.DataHandler(self.isdebug)
+ self.handler = get_dbhandler()
+
currentidx = hou.hotkeys.changeIndex()
chindex = self.handler.getchangeindex()
@@ -527,18 +406,19 @@ def initialsetup(self):
self.handler.updatedataasync(self.isdebug)
self.handler.updatechangeindex(int(currentidx))
- tmpkey = self.handler.getdefaulthotkey()
- self.tmpkey = tmpkey[0][0]
- return self.handler, self.tmpkey
+ return self.handler
- # ------------------------------------------- Panel/Node
- # NOTE Panel/Node -------------------------------------
+ # ------------------------------------------------ Node
+ # NOTE Node -------------------------------------------
def getnode(self):
nodeSelect = hou.selectedNodes()
for node in nodeSelect:
getName = node.name()
- print(getName)
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print(getName)
+ # ------------------------------------------------- Pane
+ # NOTE Pane --------------------------------------------
def getpane(self):
try:
return hou.ui.paneTabUnderCursor().type()
@@ -556,6 +436,26 @@ def getpane(self):
def searchfilter_cb(self):
self.openmenu()
+ # --------------------------------------- setmetricicon
+ # NOTE setmetricicon ----------------------------------
+ def setmetricicon(self):
+ if self.isdebug.mainwindow:
+ self.metricpos.setIcon(util.UP_ICON)
+ self.metricpos.setToolTip(la.TT_MW['metricposself'])
+
+ else:
+ self.metricpos.setIcon(util.DOWN_ICON)
+ self.metricpos.setToolTip(la.TT_MW['metricposmain'])
+
+
+ # ---------------------------------------- metricpos_cb
+ # NOTE metricpos_cb -----------------------------------
+ def metricpos_cb(self):
+ self.isdebug.mainwindow = not self.isdebug.mainwindow
+ self.settingdata[util.SETTINGS_KEYS[13]] = self.isdebug.mainwindow
+ searcher_data.savesettings(self.settingdata)
+ self.setmetricicon()
+
# ------------------------------------------ setctxicon
# NOTE setctxicon -------------------------------------
def setctxicon(self):
@@ -606,24 +506,34 @@ def opensettings_cb(self, doopen):
def open_settings(self, doopen):
if doopen:
pos = self.opensettingstool.mapToGlobal(
- QtCore.QPoint(-self.ui.width() + 31, 26))
+ QtCore.QPoint(-self.ui.width() + 31, 28))
self.ui.setGeometry(
pos.x(),
pos.y(),
self.ui.width(),
self.ui.height()
)
+ self.ui.updatecurrentvalues()
self.ui.show()
self.ui.activateWindow()
self.ui.setFocus()
if self.animatedsettings:
self.anim.start_animation(True)
else:
- if self.animatedsettings:
+ if self.ui.performcheck:
+ if self.ui.checkforchanges():
+ self.ui.savecheck()
+ if self.animatedsettings and not self.ui.waitforclose:
+ if self.ui.bugreport.isVisible():
+ self.ui.bugreport.close()
_ = self.anim.start_animation(False)
else:
self.ui.isopened = True
+ if self.ui.bugreport.isVisible():
+ self.ui.bugreport.close()
self.ui.close()
+ if self.ui.waitforclose:
+ self.close()
def anim_complete(self):
if self.ui.isopened:
@@ -645,12 +555,13 @@ def globalkeysearch(self):
# ----------------------------------------- ctxsearcher
# NOTE ctxsearcher ------------------------------------
def ctxsearcher(self, ctx=None):
+ self.starttime = ptime.time()
results = None
ctxresult = []
if ctx is None:
self.ctxsearch = True
- if self.isdebug:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
print(self.getpane())
ctxresult = util.PANETYPES[self.getpane()]
results = self.handler.searchctx(ctxresult)
@@ -663,7 +574,7 @@ def ctxsearcher(self, ctx=None):
elif ctx == ":c":
self.ctxsearch = True
ctxresult = util.PANETYPES[self.getpane()]
- if self.isdebug:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
print(self.getpane())
results = self.handler.searchctx(ctxresult)
@@ -683,7 +594,7 @@ def ctxsearcher(self, ctx=None):
# --------------------------------------- textchange_cb
# NOTE textchange_cb ----------------------------------
def textchange_cb(self, text):
- self.starttime = ptime.time()
+ self.starttime = ptime.time() # ----------------------------- # ANCHOR Search Timer Start
if len(text) > 0:
self.infolbl.setText(self.searchresultstree.toolTip())
if text in util.CTXSHOTCUTS:
@@ -694,13 +605,18 @@ def textchange_cb(self, text):
text = re.sub(allowed, '', text)
str = text.split()
searchstring = ['%s*' % (x,) for x in str]
- txt, timer = self.handler.searchtext(
- ' '.join(searchstring),
- self.isdebug,
- self.settingdata[util.SETTINGS_KEYS[9]]
- )
- self.hotkeystime = timer
- self.searchtablepopulate(txt)
+ regtime = ptime.time() # ----------------------------- # ANCHOR Regex Timer Start
+ self.regtimetotal = ((regtime - self.starttime) * 1000.0)
+ if searchstring:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print(searchstring)
+ txt, timer = self.handler.searchtext(
+ ' '.join(searchstring),
+ self.isdebug,
+ self.settingdata[util.SETTINGS_KEYS[9]]
+ )
+ self.hotkeystime = timer
+ self.searchtablepopulate(txt)
else:
self.searching = False
self.treetotal_lbl.setText("")
@@ -726,6 +642,98 @@ def searchclick_cb(self, item, column):
self.processkey(hk)
self.tmpsymbol = None
return
+
+ # !SECTION
+
+ # -------------------------------------------------- Hotkey Processing
+ # SECTION Hotkey Processing ------------------------------------------
+ # -------------------------------------- processkey
+ # NOTE processkey ---------------------------------
+ def savelastkey(self, symbol, key):
+ self.settingdata[util.SETTINGS_KEYS[11]] = (str(symbol) + " " + str(key[0]))
+ searcher_data.savesettings(self.settingdata)
+
+ # -------------------------------------- processkey
+ # NOTE processkey ---------------------------------
+ def processkey(self, key, tmphk=False):
+ if tmphk:
+ self.savelastkey(self.tmpsymbol, key)
+
+ key = key[0].split('+')
+
+ skey = None
+ ikey = None
+ key = keyconversion(key)
+ modifiers = util.MODIFIERS
+ mod_flag = QtCore.Qt.KeyboardModifiers()
+ for i in range(len(key)):
+ if str(key[i]) in modifiers:
+ mod_flag = mod_flag | util.MODIFIERS[str(key[i])]
+ else:
+ skey = key[i]
+ ikey = util.KEY_DICT[str(key[i])]
+
+ keypress = QtGui.QKeyEvent(
+ QtGui.QKeyEvent.KeyPress, # Keypress event identifier
+ ikey, # Qt key identifier
+ mod_flag, # Qt key modifier
+ skey # String of Qt key identifier
+ )
+
+ hou.ui.mainQtWindow().setFocus()
+ try:
+ hd.executeDeferred(self.app.sendEvent, hou.ui.mainQtWindow(), keypress)
+ self.close()
+
+ except(AttributeError, TypeError) as e:
+ hou.ui.setStatusMessage(
+ ("Could not trigger hotkey event: " + str(e)),
+ severity=hou.severityType.Warning
+ )
+ print("Could not trigger hotkey event: " + str(e))
+
+ # ---------------------------------- setKeysChanged
+ # NOTE setKeysChanged -----------------------------
+ def setKeysChanged(self, changed):
+ if self.keys_changed and not changed:
+ if not hou.hotkeys.saveOverrides():
+ print("ERROR: Couldn't save hotkey override file.")
+ self.keys_changed = changed
+ self.chindex = hou.hotkeys.changeIndex()
+ self.handler.updatechangeindex(self.chindex)
+
+ # -------------------------------- createtemphotkey
+ # NOTE createtemphotkey ---------------------------
+ def createtemphotkey(self, symbol):
+ hkeys = util.gethotkeys()
+ hou.hotkeys._createBackupTables()
+ for i in range(len(hkeys)):
+ result = hou.hotkeys.findConflicts(symbol, hkeys[i])
+ if not result:
+ assignresult = hou.hotkeys.addAssignment(symbol, hkeys[i])
+ if assignresult:
+ self.tmpkey = hkeys[i]
+ else:
+ pass
+ else:
+ pass
+
+ self.keys_changed = True
+ self.setKeysChanged(False)
+ return result
+
+ # -------------------------------- removetemphotkey
+ # NOTE removetemphotkey ---------------------------
+ def removetemphotkey(self, symbol, tmpkey):
+ hou.hotkeys._restoreBackupTables()
+ hou.hotkeys.revertToDefaults(symbol, True)
+ self.keys_changed = True
+ self.setKeysChanged(False)
+ hkcheck = hou.hotkeys.assignments(str(symbol))
+ if len(hkcheck) is 0:
+ self.settingdata[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(self.settingdata)
+
# !SECTION
# ------------------------------------------------------------- Search
@@ -777,16 +785,14 @@ def getContext(self, ctx):
except:
return None
- print ("Hou Context: ", hou_context)
+ print("Hou Context: ", hou_context)
return util.CONTEXTTYPE[hou_context]
- # endregion
-
# --------------------------------- searchtablepopulate
# NOTE searchtablepopulate ----------------------------
def searchtablepopulate(self, data):
if len(data) > 0:
- goalnum = 15
+ goalnum = 17
self.treecatnum = 0
self.treeitemsnum = 0
self.searchresultstree.clear()
@@ -803,8 +809,7 @@ def searchtablepopulate(self, data):
result, hctimer = self.handler.gethcontextod(context_list)
self.hcontexttime = hctimer
-
- treebuildtimer = ptime.time()
+ treebuildtimer = ptime.time() # ----------------------------- # ANCHOR Tree builder Start
for hc in range(len(result)):
hcontext_tli[result[hc][2]] = (QtWidgets.QTreeWidgetItem(
self.searchresultstree, [
@@ -812,6 +817,7 @@ def searchtablepopulate(self, data):
result[hc][1]
]
))
+
self.searchresultstree.expandItem(hcontext_tli[result[hc][2]])
self.treecatnum += 1
@@ -840,100 +846,28 @@ def searchtablepopulate(self, data):
]
))
self.treeitemsnum += 1
- treebuildtimerend = ptime.time()
+
+ treebuildtimerend = ptime.time() # ----------------------------- # ANCHOR Tree Builder End
treebuildtotal = ((treebuildtimerend - treebuildtimer) * 1000.0)
# Display the number of added results by iteration
- catval = ("%d : Contexts | " % self.treecatnum)
- itmval = ("%d : Results " % self.treeitemsnum)
- catval = catval.rjust(goalnum - self.count_chars(str(self.treecatnum)), " ")
- itmval = itmval.rjust((goalnum + 2) - self.count_chars(str(self.treeitemsnum)), " ")
- self.treetotal_lbl.setText((catval + itmval))
-
+ resulttotal = style.styleresulttotal(self.appcolors, self.treecatnum, self.treeitemsnum, goalnum)
+ self.treetotal_lbl.setText(resulttotal)
+
# Performance monitors to check how long different aspects take to run ----------
- self.endtime = ptime.time()
+ self.endtime = ptime.time() # ----------------------------- # ANCHOR Search Timer End
totaltime = ((self.endtime - self.starttime) * 1000.0)
- if self.isdebug and self.isdebug.level in {"TIMER", "ALL"}:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- (('Context Search %0.4f ms | ' % self.hcontexttime)
- + ('Hotkey Search %0.4f ms | ' % self.hotkeystime)
- + ('Tree build %0.4f ms | ' % treebuildtotal)
- + ('Total : %0.4f ms' % (totaltime))) , severity=hou.severityType.Message)
- else:
- print('Search took %0.4f ms' % self.hotkeystime)
-
- # !SECTION
-
- # -------------------------------------------------- Hotkey Processing
- # SECTION Hotkey Processing ------------------------------------------
- # -------------------------------------- processkey
- # NOTE processkey ---------------------------------
- def processkey(self, key, tmphk=False):
- hk = key
- if tmphk:
- lastkey = (str(self.tmpsymbol) + " " + str(hk[0]))
- self.handler.updatelasthk(lastkey)
-
- key = key[0].split('+')
-
- skey = None
- ikey = None
- key = keyconversion(key)
- modifiers = util.MODIFIERS
- mod_flag = QtCore.Qt.KeyboardModifiers()
- for i in range(len(key)):
- if str(key[i]) in modifiers:
- mod_flag = mod_flag | util.MODIFIERS[str(key[i])]
- else:
- skey = key[i]
- ikey = util.KEY_DICT[str(key[i])]
-
- keypress = QtGui.QKeyEvent(
- QtGui.QKeyEvent.KeyPress, # Keypress event identifier
- ikey, # Qt key identifier
- mod_flag, # Qt key modifier
- skey # String of Qt key identifier
- )
-
- hou.ui.mainQtWindow().setFocus()
- try:
- hd.executeDeferred(self.app.sendEvent, hou.ui.mainQtWindow(), keypress)
- self.close()
-
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not trigger hotkey event: " + str(e)),
- severity=hou.severityType.Warning
- )
-
- # ---------------------------------- setKeysChanged
- # NOTE setKeysChanged -----------------------------
- def setKeysChanged(self, changed):
- if self.keys_changed and not changed:
- if not hou.hotkeys.saveOverrides():
- print("ERROR: Couldn't save hotkey override file.")
- self.keys_changed = changed
- self.chindex = hou.hotkeys.changeIndex()
- self.handler.updatechangeindex(self.chindex)
-
- # -------------------------------- createtemphotkey
- # NOTE createtemphotkey ---------------------------
- def createtemphotkey(self, symbol):
- hou.hotkeys._createBackupTables()
- result = hou.hotkeys.addAssignment(symbol, self.tmpkey)
- self.keys_changed = True
- self.setKeysChanged(False)
- return result
-
- # -------------------------------- removetemphotkey
- # NOTE removetemphotkey ---------------------------
- def removetemphotkey(self, symbol, tmpkey):
- hou.hotkeys._restoreBackupTables()
- hou.hotkeys.revertToDefaults(symbol, True)
- self.keys_changed = True
- self.setKeysChanged(False)
+ if self.isdebug.performance:
+ outdata = [self.regtimetotal, self.hcontexttime, self.hotkeystime, treebuildtotal, totaltime]
+ perftime = style.styletimers(self.appcolors, outdata)
+ if self.isdebug.mainwindow:
+ if hou.isUIAvailable():
+ hou.ui.setStatusMessage(perftime, severity=hou.severityType.Message)
+ else:
+ print(perftime)
+ else:
+ self.infolbl.setText(perftime)
# !SECTION
# --------------------------------------------------------- Animations
@@ -961,6 +895,7 @@ def fade_out(self, target, duration):
self.an.setStartValue(1)
self.an.setEndValue(0)
self.an.start()
+
# !SECTION
# ------------------------------------------------------------- Events
@@ -1031,8 +966,6 @@ def eventFilter(self, obj, event):
self.searchresultstree.topLevelItem(0).child(0))
return True
else:
- # self.searchbox.releaseKeyboard()
- # self.searchbox.clearFocus()
if self.menuopened:
self.searchmenu.setFocus()
else:
@@ -1111,18 +1044,10 @@ def eventFilter(self, obj, event):
self.deleteLater()
return QtCore.QObject.eventFilter(self, obj, event)
# !SECTION
- # endregion
-# endregion
-
-
-class overlayLabel(QtWidgets.QLabel):
- def __init__(self, parent=None):
- super(overlayLabel, self).__init__(parent)
- self.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
-
-# ------------------------------------------------------------------------ Setup Functions
+# -------------------------------------------------------------- Setup
+# SECTION Setup ------------------------------------------------------
def center():
return parent_widget.mapToGlobal(
QtCore.QPoint(
@@ -1131,27 +1056,23 @@ def center():
)
)
-
+# ----------------------------------- Create Window
+# NOTE Create Window ------------------------------
def CreateSearcherPanel(kwargs, searcher_window=None):
kwargs = kwargs
- try:
- searcher_window.close()
- searcher_window.deleteLater()
- except:
- pass
- settings = searcher_data.loadsettings()
+ settings = get_settings()
windowsettings = QtCore.QSettings("instance.id", "Searcher")
searcher_window = Searcher(kwargs, settings, windowsettings)
+ searcher_window.setStyleSheet(u"background-color: rgb(42,42,42);")
searcher_window.setWindowFlags(
QtCore.Qt.Tool |
QtCore.Qt.CustomizeWindowHint |
- QtCore.Qt.WindowStaysOnTopHint
+ QtCore.Qt.FramelessWindowHint
+
)
- # util.SETTINGS_KEYS[2] = savewindowsize
- # util.SETTINGS_KEYS[3] = windowsize
if util.bc(settings[util.SETTINGS_KEYS[2]]) and windowsettings.value("geometry") is not None:
searcher_window.restoreGeometry(windowsettings.value("geometry"))
else:
@@ -1170,4 +1091,5 @@ def CreateSearcherPanel(kwargs, searcher_window=None):
searcher_window.setWindowTitle('Searcher')
searcher_window.show()
searcher_window.activateWindow()
-# endregion
+
+# !SECTION
\ No newline at end of file
diff --git a/scripts/python/searcher/searcher_data.py b/python2.7libs/searcher/searcher_data.py
similarity index 86%
rename from scripts/python/searcher/searcher_data.py
rename to python2.7libs/searcher/searcher_data.py
index 80062c7..6e5c278 100644
--- a/scripts/python/searcher/searcher_data.py
+++ b/python2.7libs/searcher/searcher_data.py
@@ -50,14 +50,15 @@ def savesettings(settingdict):
else:
print("Could not save settings: " + str(e))
-
def loadsettings():
results = {}
try:
settingsdata.beginGroup('Searcher')
for i in range(len(util.SETTINGS_KEYS)):
- results.update(
- {util.SETTINGS_KEYS[i]: settingsdata.value(util.SETTINGS_KEYS[i])})
+ if util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] in {"bool", "flag"}:
+ results.update({util.SETTINGS_KEYS[i]: util.bc(settingsdata.value(util.SETTINGS_KEYS[i]))})
+ else:
+ results.update({util.SETTINGS_KEYS[i]: settingsdata.value(util.SETTINGS_KEYS[i])})
settingsdata.endGroup()
return results
diff --git a/scripts/python/searcher/searcher_settings.py b/python2.7libs/searcher/searcher_settings.py
similarity index 62%
rename from scripts/python/searcher/searcher_settings.py
rename to python2.7libs/searcher/searcher_settings.py
index 597feab..774b959 100644
--- a/scripts/python/searcher/searcher_settings.py
+++ b/python2.7libs/searcher/searcher_settings.py
@@ -2,14 +2,16 @@
from __future__ import print_function
from __future__ import absolute_import
+from searcher import util
from searcher import about
+from searcher import theme
+from searcher import about_ui
+from searcher import theme_ui
from searcher import bugreport
from searcher import bugreport_ui
-from searcher import about_ui
from searcher import searcher_data
-from searcher import util
from searcher import language_en as la
-from searcher import searchersettings_ui
+from searcher import searcher_settings_ui
from builtins import range
from past.utils import old_div
@@ -35,10 +37,12 @@
from hutil.Qt import QtUiTools
reload(about)
+reload(theme)
reload(about_ui)
+reload(theme_ui)
reload(bugreport)
reload(bugreport_ui)
-reload(searchersettings_ui)
+reload(searcher_settings_ui)
# -------------------------------------------------------------------- App Info
__package__ = "Searcher"
@@ -47,6 +51,11 @@
__copyright__ = "2020 All rights reserved. See LICENSE for more details."
__status__ = "Prototype"
+# --------------------------------------------- hou.session
+# NOTE hou.session ----------------------------------------
+def get_settings():
+ return getattr(hou.session, "SETTINGS", None)
+
the_scaled_icon_size = hou.ui.scaledSize(16)
the_icon_size = 16
@@ -58,7 +67,7 @@ def bc(v):
class SearcherSettings(QtWidgets.QWidget):
""" Searcher Settings and Debug Menu"""
- def __init__(self, handler, tmphotkey, parent=None):
+ def __init__(self, handler, width, height, parent=None):
super(SearcherSettings, self).__init__(parent=parent)
# -------------------------------------------- settings
# NOTE settings ---------------------------------------
@@ -79,35 +88,52 @@ def __init__(self, handler, tmphotkey, parent=None):
self.canedit = False
self.KeySequence = None
self.hkholder = ""
- self.defaulthotkey = tmphotkey
self.datahandler = handler
- self.tmphotkey = tmphotkey
self.isopened = False
-
- self.setObjectName('searcher-settings')
+ self.resetdb = False
+ self.waitforclose = False
+ self.modifylayout = False
+ self.uiwidth = width
+ self.uiheight = height
+
# --------------------------------------------- beginui
# NOTE beginui ----------------------------------------
+ self.setObjectName('searcher-settings')
self.setAutoFillBackground(True)
self.setBackgroundRole(QtGui.QPalette.Window)
- self.settings = searcher_data.loadsettings()
- self.isdebug = util.Dbug(util.bc(self.settings[util.SETTINGS_KEYS[4]]), str(self.settings[util.SETTINGS_KEYS[10]]))
+ self.settings = get_settings()
+ self.isdebug = util.Dbug(
+ self.settings[util.SETTINGS_KEYS[4]],
+ str(self.settings[util.SETTINGS_KEYS[10]]),
+ self.settings[util.SETTINGS_KEYS[12]],
+ self.settings[util.SETTINGS_KEYS[13]],
+ )
self.la = la.TT_SETTINGS
# Load UI File
- self.ui = searchersettings_ui.Ui_SearcherSettings()
- self.ui.setupUi(self, self.width, self.height, bc(self.settings[util.SETTINGS_KEYS[8]]))
+ self.ui = searcher_settings_ui.Ui_SearcherSettings()
+ self.ui.setupUi(self, self.uiwidth, self.uiheight, bc(self.settings[util.SETTINGS_KEYS[8]]))
self.ui.retranslateUi(self)
- self.bugreport = bugreport.BugReport(self.parentwindow)
+ self.bugreport = bugreport.BugReport(self)
self.bugreport.setAttribute(QtCore.Qt.WA_StyledBackground, True)
self.bugreport.setWindowFlags(
QtCore.Qt.Tool |
- QtCore.Qt.WindowStaysOnTopHint |
+ # QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.FramelessWindowHint |
QtCore.Qt.NoDropShadowWindowHint
)
- self.bugreport.setParent(self.parentwindow)
- self.bugreport.resize(520, 250)
+ self.bugreport.resize(width, height - 60)
+
+ self.theme = theme.Theme(self)
+ self.theme.setAttribute(QtCore.Qt.WA_StyledBackground, True)
+ self.theme.setWindowFlags(
+ QtCore.Qt.Tool |
+ # QtCore.Qt.WindowStaysOnTopHint |
+ QtCore.Qt.FramelessWindowHint |
+ QtCore.Qt.NoDropShadowWindowHint
+ )
+ self.theme.resize(width, height - 190)
self.settingslayout = QtWidgets.QVBoxLayout()
@@ -121,22 +147,37 @@ def __init__(self, handler, tmphotkey, parent=None):
self.savewindowsize.setToolTip(la.TT_SETTINGS[self.savewindowsize.objectName()])
# secondrow
+ self.ui.maxresults_lbl.setToolTip(la.TT_SETTINGS[self.ui.maxresults_lbl.objectName()])
self.maxresults = self.ui.maxresults_txt
self.maxresults.setToolTip(la.TT_SETTINGS[self.maxresults.objectName()])
self.animatedsettings = self.ui.animatedsettings_chk
self.animatedsettings.setToolTip(la.TT_SETTINGS[self.animatedsettings.objectName()])
+
# thirdrow
+ self.ui.defaulthotkey_lbl.setToolTip(la.TT_SETTINGS[self.ui.defaulthotkey_lbl.objectName()])
self.defaulthotkey = self.ui.defaulthotkey_txt
self.defaulthotkey.setToolTip(la.TT_SETTINGS[self.defaulthotkey.objectName()])
+
+ # fourthrow
+ self.ui.dbpath_lbl.setToolTip(la.TT_SETTINGS[self.ui.dbpath_lbl.objectName()])
self.database_path = self.ui.databasepath_txt
self.database_path.setToolTip(la.TT_SETTINGS[self.database_path.objectName()])
+ self.dbpath_btn = self.ui.dbpath_icon
+ dbpath_button_size = hou.ui.scaledSize(16)
+ self.dbpath_btn.setProperty("flat", True)
+ self.dbpath_btn.setIcon(util.FILE_ICON)
+ self.dbpath_btn.setIconSize(QtCore.QSize(
+ dbpath_button_size,
+ dbpath_button_size
+ ))
- # fourthrow
- self.test1 = self.ui.test1_btn
+ # fifthrow
+ self.metrics = self.ui.metrics_chk
+ self.metrics.setToolTip(la.TT_SETTINGS[self.metrics.objectName()])
self.cleardata = self.ui.cleardata_btn
self.cleardata.setToolTip(la.TT_SETTINGS[self.cleardata.objectName()])
- # fifthrow
+ # sixthrow
self.about = self.ui.about_btn
self.about.setToolTip(la.TT_SETTINGS[self.about.objectName()])
about_button_size = hou.ui.scaledSize(32)
@@ -148,6 +189,7 @@ def __init__(self, handler, tmphotkey, parent=None):
))
self.bugreportbtn = self.ui.bug_btn
+ self.bugreportbtn.setToolTip(la.TT_SETTINGS[self.bugreportbtn.objectName()])
self.bugreportbtn.setCheckable(True)
self.bugreportbtn.setChecked(False)
bugreport_button_size = hou.ui.scaledSize(21)
@@ -158,6 +200,18 @@ def __init__(self, handler, tmphotkey, parent=None):
bugreport_button_size
))
+ self.themebtn = self.ui.theme_btn
+ self.themebtn.setToolTip(la.TT_SETTINGS[self.themebtn.objectName()])
+ self.themebtn.setCheckable(True)
+ self.themebtn.setChecked(False)
+ theme_button_size = hou.ui.scaledSize(21)
+ self.themebtn.setProperty("flat", True)
+ self.themebtn.setIcon(util.BUG_ICON)
+ self.themebtn.setIconSize(QtCore.QSize(
+ theme_button_size,
+ theme_button_size
+ ))
+
self.debuglevel = self.ui.debuglevel_cbx
for lvl in util.DEBUG_LEVEL:
self.debuglevel.addItem(str(lvl))
@@ -175,8 +229,6 @@ def __init__(self, handler, tmphotkey, parent=None):
# -------------------------------------------- sixthrow
# NOTE sixthrow ---------------------------------------
- # self.in_memory_db.stateChanged.connect(self.toggledebug)
- self.hotkey_icon.clicked.connect(self.hotkeyicon_cb)
info_button_size = hou.ui.scaledSize(16)
self.hotkey_icon.setProperty("flat", True)
self.hotkey_icon.setIcon(util.INFO_ICON)
@@ -185,15 +237,14 @@ def __init__(self, handler, tmphotkey, parent=None):
info_button_size
))
- self.defaulthotkey.setToolTip(la.TT_SETTINGS[self.discarddata.objectName()])
- self.defaulthotkey.setStyleSheet(util.TOOLTIP)
-
# --------------------------------------------- connect
# NOTE connect ----------------------------------------
- self.test1.clicked.connect(self.test1_cb)
+ self.hotkey_icon.clicked.connect(self.hotkeyicon_cb)
+ self.dbpath_btn.clicked.connect(self.dbpath_cb)
self.cleardata.clicked.connect(self.cleardata_cb)
self.about.clicked.connect(self.about_cb)
self.bugreportbtn.clicked.connect(self.bug_cb)
+ self.themebtn.clicked.connect(self.theme_cb)
self.savedata.clicked.connect(self.save_cb)
self.discarddata.clicked.connect(self.discard_cb)
@@ -205,6 +256,10 @@ def __init__(self, handler, tmphotkey, parent=None):
# ---------------------------------------- eventfilters
# NOTE eventfilters -----------------------------------
self.installEventFilter(self)
+ self.ui.maxresults_lbl.installEventFilter(self)
+ self.ui.defaulthotkey_lbl.installEventFilter(self)
+ self.ui.dbpath_lbl.installEventFilter(self)
+ self.bugreportbtn.installEventFilter(self)
self.about.installEventFilter(self)
self.cleardata.installEventFilter(self)
self.savedata.installEventFilter(self)
@@ -214,48 +269,81 @@ def __init__(self, handler, tmphotkey, parent=None):
# --------------------------------------------------------------- Callbacks
# SECTION Callbacks -------------------------------------------------------
-
+ # ---------------------------------------------- bug_cb
+ # NOTE bug_cb -----------------------------------------
def bug_cb(self, toggled):
- pos = self.bugreportbtn.mapToGlobal(
- QtCore.QPoint( -43, 35))
- self.bugreport.setGeometry(
- pos.x(),
- pos.y(),
- self.bugreport.width(),
- self.bugreport.height()
- )
-
- if toggled == True:
+ if toggled == True and not self.bugreport.isVisible():
+ if self.animatedsettings.isChecked():
+ pos = self.bugreportbtn.mapToGlobal(
+ QtCore.QPoint( -43, 34))
+ else:
+ pos = self.bugreportbtn.mapToGlobal(
+ QtCore.QPoint( -45, 35))
+ self.bugreport.setGeometry(
+ pos.x(),
+ pos.y(),
+ self.bugreport.width(),
+ self.bugreport.height()
+ )
self.bugreport.show()
else:
self.bugreport.close()
- self.bugreport.setParent(None)
+
+ # -------------------------------------------- theme_cb
+ # NOTE theme_cb ---------------------------------------
+ def theme_cb(self, toggled):
+ if toggled == True and not self.theme.isVisible():
+ if self.animatedsettings.isChecked():
+ pos = self.themebtn.mapToGlobal(
+ QtCore.QPoint( -77, 34))
+ else:
+ pos = self.themebtn.mapToGlobal(
+ QtCore.QPoint( -79, 35))
+ self.theme.setGeometry(
+ pos.x(),
+ pos.y(),
+ self.theme.width(),
+ self.theme.height()
+ )
+ self.theme.show()
+ else:
+ self.theme.close()
+
# -------------------------------------------- about_cb
# NOTE about_cb ---------------------------------------
def about_cb(self):
- self.about = about.About(self.parentwindow)
- self.about.setAttribute(QtCore.Qt.WA_StyledBackground, True)
- self.about.setWindowFlags(
+ self.aboutui = about.About(self.parentwindow)
+ self.aboutui.setAttribute(QtCore.Qt.WA_StyledBackground, True)
+ self.aboutui.setWindowFlags(
QtCore.Qt.Popup |
QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.NoDropShadowWindowHint |
QtCore.Qt.WindowStaysOnTopHint
-
)
- self.about.setParent(self.parentwindow)
- self.about.move(self.pos().x() - 175, self.pos().y())
- self.about.show()
+ self.aboutui.setParent(self.parentwindow)
+ self.aboutui.move(self.pos().x() - 175, self.pos().y())
+ self.aboutui.show()
+ # --------------------------------------- hotkeyicon_cb
# NOTE hotkeyicon_cb ----------------------------------
def hotkeyicon_cb(self):
self.settings['in_memory_db'] = self.in_memory_db.isChecked()
print(self.settings['in_memory_db'])
- # ----------------------------------------- toggledebug
- # NOTE toggledebug ------------------------------------
- def toggledebug(self):
- self.settings['in_memory_db'] = self.in_memory_db.isChecked()
- print(self.settings['in_memory_db'])
+ # ------------------------------------------- dbpath_cb
+ # NOTE dbpath_cb --------------------------------------
+ def dbpath_cb(self):
+ path = os.path.normpath(self.database_path.text()).replace("\\", "/")
+ dbpath = hou.expandString(hou.ui.selectFile(
+ start_directory=os.path.dirname(path),
+ title="Save Database",
+ pattern="searcher.db",
+ file_type=hou.fileType.Clip,
+ default_value="searcher.db"))
+ if dbpath != "":
+ if not dbpath.endswith("searcher.db"):
+ dbpath = dbpath + "searcher.db"
+ self.database_path.setText((os.path.normpath(dbpath)))
# ---------------------------------------- defaulthk_cb
# NOTE defaulthk_cb -----------------------------------
@@ -289,10 +377,7 @@ def save_cb(self):
self.defaulthotkey.setFocus()
self.canedit = True
else:
- if self.defaulthotkey.text() != self.tmphotkey:
- self.tmphotkey = self.defaulthotkey.text()
- self.datahandler.updatetmphotkey(self.tmphotkey)
-
+ self.checkforchanges()
for i in range(len(util.SETTINGS_KEYS)):
if util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "bool":
self.settings[util.SETTINGS_KEYS[i]] = getattr(self, util.SETTINGS_KEYS[i]).isChecked()
@@ -307,16 +392,40 @@ def save_cb(self):
print(self.settings)
searcher_data.savesettings(self.settings)
+ if self.resetdb:
+ hou.session.DBCONNECTION = None
+ hou.session.DATABASE = None
+ self.resetdb = False
+ if self.modifylayout:
+ self.parentwindow.sui.metricpos.setVisible(
+ self.settings[util.SETTINGS_KEYS[12]])
self.performcheck = False
- if self.animatedsettings:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ self.bugreportbtn.setChecked(False)
+ if self.theme.isVisible():
+ self.theme.close()
+ self.themebtn.setChecked(False)
+ if self.animatedsettings.isChecked() and not self.waitforclose:
self.parentwindow.anim.start_animation(False)
self.isopened = True
+ elif self.waitforclose:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ self.close()
+ self.parentwindow.close()
else:
self.close()
# ------------------------------------------ discard_cb
# NOTE discard_cb -------------------------------------
def discard_cb(self):
- if self.animatedsettings:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ self.bugreportbtn.setChecked(False)
+ if self.theme.isVisible():
+ self.theme.close()
+ self.themebtn.setChecked(False)
+ if self.settings[util.SETTINGS_KEYS[8]]:
self.parentwindow.anim.start_animation(False)
self.isopened = True
self.performcheck=True
@@ -364,18 +473,52 @@ def fieldsetup(self):
# ------------------------------------- checkforchanges
# NOTE checkforchanges --------------------------------
def checkforchanges(self):
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print(len(util.SETTINGS_KEYS))
for i in range(len(util.SETTINGS_KEYS)):
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print(i)
if util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "bool":
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Name: ", getattr(self, util.SETTINGS_KEYS[i]).objectName())
+ print("Shown settings: ", getattr(self, util.SETTINGS_KEYS[i]).isChecked())
+ print("Current settings: ", bc(self.currentsettings[util.SETTINGS_KEYS[i]]))
if getattr(self, util.SETTINGS_KEYS[i]).isChecked() != bc(self.currentsettings[util.SETTINGS_KEYS[i]]):
+ if util.SETTINGS_KEYS[i] == util.SETTINGS_KEYS[0]:
+ self.resetdb = True
+ elif util.SETTINGS_KEYS[i] == util.SETTINGS_KEYS[8]:
+ self.waitforclose = True
+ elif util.SETTINGS_KEYS[i] == util.SETTINGS_KEYS[12]:
+ self.modifylayout = True
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Offending item: ", i)
return True
elif util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "text":
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Name: ", getattr(self, util.SETTINGS_KEYS[i]).objectName())
+ print("Shown settings: ", getattr(self, util.SETTINGS_KEYS[i]).text())
+ print("Current settings: ",self.currentsettings[util.SETTINGS_KEYS[i]])
if getattr(self, util.SETTINGS_KEYS[i]).text() != self.currentsettings[util.SETTINGS_KEYS[i]]:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Offending item: ", i)
return True
elif util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "intval":
- if getattr(self, util.SETTINGS_KEYS[i]).value() != self.currentsettings[util.SETTINGS_KEYS[i]]:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Name: ", getattr(self, util.SETTINGS_KEYS[i]).objectName())
+ print("Shown settings: ", getattr(self, util.SETTINGS_KEYS[i]).value())
+ print("Current settings: ",self.currentsettings[util.SETTINGS_KEYS[i]])
+ if getattr(self, util.SETTINGS_KEYS[i]).value() != int(self.currentsettings[util.SETTINGS_KEYS[i]]):
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Offending item: ", i)
return True
elif util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "cbx":
- if getattr(self, util.SETTINGS_KEYS[i]).currentText() != self.currentsettings[util.SETTINGS_KEYS[i]]:
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Name: ", getattr(self, util.SETTINGS_KEYS[i]).objectName())
+ print("Shown settings: ", getattr(self, util.SETTINGS_KEYS[i]).currentText())
+ print("Current settings: ", str(self.currentsettings[util.SETTINGS_KEYS[i]]))
+ if getattr(self, util.SETTINGS_KEYS[i]).currentText() != str(self.currentsettings[util.SETTINGS_KEYS[i]]):
+ if self.isdebug and self.isdebug.level in {"ALL"}:
+ print("Offending item: ", i)
return True
return False
# ------------------------------------------- savecheck
@@ -391,19 +534,18 @@ def savecheck(self):
self.save_cb()
self.hkholder = ""
elif buttonindex == 1:
- self.defaulthotkey.setText(self.hkholder)
self.hkholder = ""
# !SECTION
- # ------------------------------------------------------------------ Events
- # SECTION Events ----------------------------------------------------------
+ # ------------------------------------------------------------- Events
+ # SECTION Events -----------------------------------------------------
def eventFilter(self, obj, event):
# ------------------------------------------ Window
# NOTE Window -------------------------------------
if event.type() == QtCore.QEvent.WindowActivate:
self.ui.isopened = True
self.performcheck = True
- self.updatecurrentvalues()
+ # self.updatecurrentvalues()
return True
# ------------------------------------------- Mouse
@@ -430,15 +572,37 @@ def eventFilter(self, obj, event):
self.debugflag.setVisible(True)
if event.key() == QtCore.Qt.Key_Escape:
- if self.performcheck:
- if self.checkforchanges():
- self.savecheck()
- if self.animatedsettings:
- self.parentwindow.anim.start_animation(False)
- self.isopened = True
- self.performcheck=True
- else:
- self.close()
+ if obj == self:
+ if self.performcheck:
+ if self.checkforchanges():
+ self.savecheck()
+ if self.animatedsettings.isChecked() and not self.waitforclose:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ self.bugreportbtn.setChecked(False)
+ if self.theme.isVisible():
+ self.theme.close()
+ self.themebtn.setChecked(False)
+ self.parentwindow.anim.start_animation(False)
+ self.isopened = True
+ return True
+ elif self.waitforclose:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ if self.theme.isVisible():
+ self.theme.close()
+ self.themebtn.setChecked(False)
+ self.close()
+ self.parentwindow.close()
+ return True
+ else:
+ if self.bugreport.isVisible():
+ self.bugreport.close()
+ if self.theme.isVisible():
+ self.theme.close()
+ self.themebtn.setChecked(False)
+ self.close()
+ return True
else:
self.keyindex += 1
self.keystring = hou.qt.qtKeyToString(
@@ -471,6 +635,7 @@ def eventFilter(self, obj, event):
# NOTE Close --------------------------------------
if event.type() == QtCore.QEvent.Close:
self.ui.isopened = False
+ self.resetdb = False
self.parentwindow.opensettingstool.setChecked(False)
self.performcheck=True
diff --git a/scripts/python/searcher/searchersettings_ui.py b/python2.7libs/searcher/searcher_settings_ui.py
similarity index 91%
rename from scripts/python/searcher/searchersettings_ui.py
rename to python2.7libs/searcher/searcher_settings_ui.py
index 636c315..44c98df 100644
--- a/scripts/python/searcher/searchersettings_ui.py
+++ b/python2.7libs/searcher/searcher_settings_ui.py
@@ -18,7 +18,7 @@ def setupUi(self, SearcherSettings, width, height, animated):
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(SearcherSettings.sizePolicy().hasHeightForWidth())
SearcherSettings.setSizePolicy(sizePolicy)
- SearcherSettings.setMinimumSize(QtCore.QSize(450, 300))
+ SearcherSettings.setMinimumSize(QtCore.QSize(width, height))
SearcherSettings.setBaseSize(QtCore.QSize(0, 0))
self.gridLayout = QtWidgets.QGridLayout(SearcherSettings)
@@ -75,7 +75,7 @@ def setupUi(self, SearcherSettings, width, height, animated):
self.secondrow.addItem(spacerItem)
self.maxresults_lbl = QtWidgets.QLabel(SearcherSettings)
- self.maxresults_lbl.setObjectName("label_3")
+ self.maxresults_lbl.setObjectName("maxresults_lbl")
self.secondrow.addWidget(self.maxresults_lbl)
self.maxresults_txt = QtWidgets.QSpinBox(SearcherSettings)
self.maxresults_txt.setMinimum(1)
@@ -97,7 +97,7 @@ def setupUi(self, SearcherSettings, width, height, animated):
self.thirdrow.setObjectName("thirdrow")
self.defaulthotkey_lbl = QtWidgets.QLabel(SearcherSettings)
- self.defaulthotkey_lbl.setObjectName("label_2")
+ self.defaulthotkey_lbl.setObjectName("defaulthotkey_lbl")
self.thirdrow.addWidget(self.defaulthotkey_lbl)
self.defaulthotkey_txt = QtWidgets.QLineEdit(SearcherSettings)
@@ -118,7 +118,7 @@ def setupUi(self, SearcherSettings, width, height, animated):
self.fourthrow.setObjectName("fourthrow")
self.dbpath_lbl = QtWidgets.QLabel(SearcherSettings)
- self.dbpath_lbl.setObjectName("label")
+ self.dbpath_lbl.setObjectName("dbpath_lbl")
self.fourthrow.addWidget(self.dbpath_lbl)
self.databasepath_txt = QtWidgets.QLineEdit(SearcherSettings)
@@ -137,12 +137,14 @@ def setupUi(self, SearcherSettings, width, height, animated):
self.fifthrow.setObjectName("fifthrow")
self.maint_lbl = QtWidgets.QLabel(SearcherSettings)
- self.maint_lbl.setObjectName("label_4")
+ self.maint_lbl.setObjectName("maint_lbl")
self.fifthrow.addWidget(self.maint_lbl)
- self.test1_btn = QtWidgets.QPushButton(SearcherSettings)
- self.test1_btn.setObjectName("test1_btn")
- self.fifthrow.addWidget(self.test1_btn)
+ self.metrics_chk = QtWidgets.QCheckBox(SearcherSettings)
+ self.metrics_chk.setLayoutDirection(QtCore.Qt.RightToLeft)
+ self.metrics_chk.setTristate(False)
+ self.metrics_chk.setObjectName("metrics_chk")
+ self.fifthrow.addWidget(self.metrics_chk)
self.cleardata_btn = QtWidgets.QPushButton(SearcherSettings)
self.cleardata_btn.setObjectName("cleardata_btn")
@@ -171,6 +173,10 @@ def setupUi(self, SearcherSettings, width, height, animated):
self.bug_btn.setObjectName("bug_btn")
self.sixthrow.addWidget(self.bug_btn)
+ self.theme_btn = QtWidgets.QToolButton(SearcherSettings)
+ self.theme_btn.setObjectName("theme_btn")
+ self.sixthrow.addWidget(self.theme_btn)
+
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.sixthrow.addItem(spacerItem1)
@@ -227,12 +233,13 @@ def retranslateUi(self, SearcherSettings):
# -------------------------------------------------- fifthrow
self.maint_lbl.setText(_translate("SearcherSettings", "Maintenance utilities:"))
- self.test1_btn.setText(_translate("SearcherSettings", "Maint Button"))
+ self.metrics_chk.setText(_translate("SearcherSettings", "Enable performance metrics"))
self.cleardata_btn.setText(_translate("SearcherSettings", "Clear Data"))
# ------------------------------------------------- sixthrow
self.about_btn.setText(_translate("SearcherSettings", "..."))
- self.bug_btn.setText(_translate("About", "..."))
+ self.bug_btn.setText(_translate("SearcherSettings", "..."))
+ self.theme_btn.setText(_translate("SearcherSettings", "..."))
self.debugflag_chk.setText(_translate("SearcherSettings", "Debug Mode"))
self.discard_btn.setText(_translate("SearcherSettings", "Discard"))
self.save_btn.setText(_translate("SearcherSettings", "Save"))
diff --git a/python2.7libs/searcher/searcher_ui.py b/python2.7libs/searcher/searcher_ui.py
new file mode 100644
index 0000000..b7f601a
--- /dev/null
+++ b/python2.7libs/searcher/searcher_ui.py
@@ -0,0 +1,277 @@
+from __future__ import print_function
+from __future__ import absolute_import
+
+import os
+import sys
+
+hver = 0
+if os.environ["HFS"] != "":
+ ver = os.environ["HFS"]
+ hver = int(ver[ver.rindex('.')+1:])
+ from hutil.Qt import QtGui
+ from hutil.Qt import QtCore
+ from hutil.Qt import QtWidgets
+else:
+ from PyQt5 import QtGui
+ from PyQt5 import QtCore
+ from PyQt5 import QtWidgets
+
+from searcher import HelpButton
+from searcher import language_en as la
+
+class Ui_Searcher(object):
+ def setupUi(self, Searcher):
+
+ Searcher.setObjectName("Searcher")
+ Searcher.setWindowModality(QtCore.Qt.NonModal)
+ Searcher.setStyleSheet(u"background-color: rgb(42,42,42); border: 0px solid black")
+
+ self.mainlayout = QtWidgets.QVBoxLayout()
+ self.gridLayout = QtWidgets.QGridLayout()
+ self.gridLayout.setSpacing(0)
+ self.gridLayout.setContentsMargins(0, 0, 0, 0)
+
+ self.verticalLayout = QtWidgets.QVBoxLayout()
+ self.verticalLayout.setSpacing(0)
+
+ self.titlerow = QtWidgets.QHBoxLayout()
+ self.titlerow.setSpacing(5)
+
+ self.titlespacer1 = QtWidgets.QSpacerItem(
+ 8, 0,
+ QtWidgets.QSizePolicy.Fixed,
+ QtWidgets.QSizePolicy.Minimum
+ )
+
+ # ------------------------------------------ Header
+ # NOTE Header -------------------------------------
+ self.searcherlbl = QtWidgets.QLabel("Searcher")
+ font = QtGui.QFont()
+ font.setPointSize(15)
+ self.searcherlbl.setFont(font)
+ self.searcherlbl.setAlignment(QtCore.Qt.AlignCenter)
+
+ self.titlespacer2 = QtWidgets.QSpacerItem(
+ 40, 30,
+ QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Minimum
+ )
+
+ self.metricpos = QtWidgets.QToolButton()
+ self.metricpos.setObjectName("metricpos")
+
+ self.contexttoggle = QtWidgets.QPushButton()
+ self.contexttoggle.setObjectName("contexttoggle")
+
+ self.helpButton = HelpButton.HelpButton("main", la.TT_MW['helpButton'], 16)
+ self.helpButton.setObjectName("helpButton")
+
+ self.pinwindow_btn = QtWidgets.QToolButton()
+ self.pinwindow_btn.setObjectName("pinwindow")
+
+ self.opensettings_btn = QtWidgets.QToolButton()
+ self.opensettings_btn.setObjectName("opensettingstool")
+
+ self.titlespacer3 = QtWidgets.QSpacerItem(
+ 8, 0,
+ QtWidgets.QSizePolicy.Fixed,
+ QtWidgets.QSizePolicy.Minimum
+ )
+
+ # ----------------------------------- Search Filter
+ # NOTE Search Filter ------------------------------
+ self.searchrow = QtWidgets.QHBoxLayout()
+ self.searchrow.setSpacing(0)
+ self.frame = QtWidgets.QFrame()
+ searchframe_details = QtWidgets.QSizePolicy(
+ QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Preferred
+ )
+ searchframe_details.setHorizontalStretch(0)
+ searchframe_details.setVerticalStretch(0)
+ searchframe_details.setHeightForWidth(
+ self.frame.sizePolicy().hasHeightForWidth())
+ self.frame.setSizePolicy(searchframe_details)
+ self.frame.setMinimumSize(QtCore.QSize(20, 20))
+ self.frame.setMaximumSize(QtCore.QSize(500, 200))
+ self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
+ self.frame.setFrameShadow(QtWidgets.QFrame.Plain)
+ self.frame.setStyleSheet(u"background-color: rgb(19, 19, 19); color: rgb(19, 19, 19);")
+ self.searchfilter_btn = QtWidgets.QToolButton(self.frame)
+ self.searchfilter_btn.setObjectName("searchfilter")
+ self.searchfilter_btn.setGeometry(QtCore.QRect(0, 0, 36, 36))
+ self.searchfilter_btn.setBaseSize(QtCore.QSize(30, 30))
+ self.searchfilter_btn.setStyleSheet(u"background-color: rgb(19, 19, 19);")
+ self.searchfilter_btn.setArrowType(QtCore.Qt.NoArrow)
+ self.searchfilter_btn.setParent(self.frame)
+
+ # -------------------------------------- Search Box
+ # NOTE Search Box ---------------------------------
+ self.searchbox_txt = QtWidgets.QLineEdit()
+ self.searchbox_txt.setObjectName("searchbox")
+ searchbox_details = QtWidgets.QSizePolicy(
+ QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Minimum
+ )
+ searchbox_details.setHorizontalStretch(99)
+ searchbox_details.setVerticalStretch(0)
+ # searchbox_details.setHeightForWidth(
+ # self.searchbox_txt.sizePolicy().hasHeightForWidth())
+ self.searchbox_txt.setSizePolicy(searchbox_details)
+ self.searchbox_txt.setMinimumSize(QtCore.QSize(50, 0))
+ self.searchbox_txt.setMouseTracking(False)
+ self.searchbox_txt.setStyleSheet(u"background-color: rgb(19, 19, 19);")
+ self.searchbox_txt.setFrame(False)
+
+ # ------------------------------------ Results Tree
+ # NOTE Results Tree -------------------------------
+ self.searchresults_tree = QtWidgets.QTreeWidget()
+ self.searchresults_tree.setObjectName("searchresultstree")
+
+ # Header ---------
+ __qtreewidgetitem = QtWidgets.QTreeWidgetItem()
+ __qtreewidgetitem.setText(0, u"1")
+ resultstree_header = QtGui.QFont()
+ resultstree_header.setPointSize(9)
+ __qtreewidgetitem.setFont(0, resultstree_header)
+ self.searchresults_tree.setHeaderItem(__qtreewidgetitem)
+
+ resultstree_details = QtWidgets.QSizePolicy(
+ QtWidgets.QSizePolicy.Preferred,
+ QtWidgets.QSizePolicy.Expanding
+ )
+ resultstree_details.setHorizontalStretch(0)
+ resultstree_details.setVerticalStretch(0)
+ self.searchresults_tree.setSizePolicy(resultstree_details)
+
+ resultstree_font = QtGui.QFont()
+ resultstree_font.setPointSize(9)
+ self.searchresults_tree.setFont(resultstree_font)
+
+ self.searchresults_tree.setMouseTracking(False)
+ self.searchresults_tree.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.searchresults_tree.setFrameShadow(QtWidgets.QFrame.Sunken)
+ self.searchresults_tree.setLineWidth(0)
+
+ self.searchresults_tree.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
+ self.searchresults_tree.setAlternatingRowColors(True)
+ self.searchresults_tree.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
+ self.searchresults_tree.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
+
+ # -------------------------------------- Info Panel
+ # NOTE Info Panel ---------------------------------
+ self.infobar = QtWidgets.QHBoxLayout()
+ self.infobar.setObjectName("infobar")
+ self.infobargrid = QtWidgets.QGridLayout()
+ self.infobargrid.setObjectName("infobargrid")
+
+ # -------------------------------------- Info Panel
+ # NOTE Info Panel ---------------------------------
+ self.info_lbl = QtWidgets.QLabel()
+ self.infolbl_font = QtGui.QFont()
+ self.infolbl_font.setPointSize(9)
+ self.infolbl_font.setBold(False)
+ self.infolbl_font.setWeight(50)
+ self.info_lbl.setFont(self.infolbl_font)
+ self.info_lbl.setStyleSheet(u"background-color: rgb(11,11,11); border-bottom: 1px solid rgb(100, 100, 100);")
+ self.info_lbl.setMargin(3)
+ self.info_lbl.setIndent(5)
+
+ # -------------------------------------- Info Panel
+ # NOTE Info Panel ---------------------------------
+ self.overlay = overlayLabel(self.info_lbl)
+ self.overlay.setFont(self.infolbl_font)
+ self.overlay.setStyleSheet(u"background-color: rgb(11,11,11); border-bottom: 1px solid rgb(100, 100, 100); ")
+ self.overlay.setMargin(3)
+ self.overlay.setIndent(5)
+
+ # -------------------------------------- Info Panel
+ # NOTE Info Panel ---------------------------------
+ self.treetotal_lbl = QtWidgets.QLabel()
+ self.treetotal_lbl.setObjectName("treetotal_lbl")
+ # Size ----------
+ treetotal_size = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
+ treetotal_size.setHorizontalStretch(0)
+ treetotal_size.setVerticalStretch(0)
+ treetotal_size.setHeightForWidth(self.treetotal_lbl.sizePolicy().hasHeightForWidth())
+ self.treetotal_lbl.setSizePolicy(treetotal_size)
+ self.treetotal_lbl.setMinimumSize(QtCore.QSize(160, 0))
+ self.treetotal_lbl.setMaximumSize(QtCore.QSize(160, 16777215))
+ self.treetotal_lbl.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
+
+ # Style ---------
+ self.treetotallbl_font = QtGui.QFont()
+ self.treetotallbl_font.setPointSize(9)
+ self.treetotallbl_font.setBold(False)
+ self.treetotallbl_font.setWeight(50)
+ self.treetotal_lbl.setFont(self.treetotallbl_font)
+ self.treetotal_lbl.setStyleSheet(u"background-color: rgb(11,11,11); border-bottom: 1px solid rgb(100, 100, 100); ")
+ self.treetotal_lbl.setMargin(3)
+ self.treetotal_lbl.setIndent(5)
+
+ # ------------------------------------------ Layout
+ # NOTE Layout -------------------------------------
+ self.titlerow.addItem(self.titlespacer1)
+ self.titlerow.addWidget(self.searcherlbl)
+ self.titlerow.addItem(self.titlespacer2)
+ self.titlerow.addWidget(self.metricpos)
+ self.titlerow.addWidget(self.contexttoggle)
+ self.titlerow.addWidget(self.helpButton)
+ self.titlerow.addWidget(self.pinwindow_btn)
+ self.titlerow.addWidget(self.opensettings_btn)
+ self.titlerow.addItem(self.titlespacer3)
+ self.verticalLayout.addLayout(self.titlerow)
+
+ # self.searchrow.addWidget(self.frame)
+ self.searchgrid = QtWidgets.QGridLayout()
+ self.searchgrid.addWidget(self.frame, 1,0,1,1)
+ self.searchgrid.addWidget(self.searchfilter_btn, 1,0,1,1)
+ self.searchgrid.addWidget(self.searchbox_txt, 1,1,1,1)
+ self.searchrow.addLayout(self.searchgrid)
+ self.verticalLayout.addLayout(self.searchrow)
+
+ self.verticalLayout.addWidget(self.searchresults_tree)
+ self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
+
+
+ self.infobargrid.addWidget(self.overlay, 1, 0, 1, 1)
+ self.infobargrid.addWidget(self.info_lbl, 1, 0, 1, 1)
+ self.infobargrid.addWidget(self.treetotal_lbl, 1, 1, 1, 1)
+ self.infobar.addLayout(self.infobargrid)
+ self.gridLayout.addLayout(self.infobar, 3, 0, 1, 1)
+
+
+ self.mainlayout.setContentsMargins(0, 0, 0, 0)
+
+ # --------------------------------------- ResizeHandles
+ # NOTE ResizeHandles ----------------------------------
+ self.leftresize = QtWidgets.QSizeGrip(self.info_lbl)
+ self.leftresize.setStyleSheet(u"color: rgba(0,0,0, 0); background-color: rgba(0,0,0, 0);")
+ pos = self.info_lbl.mapToGlobal(
+ QtCore.QPoint(0, 0))
+ self.leftresize.setGeometry(
+ pos.x(),
+ pos.y(),
+ self.leftresize.width(),
+ self.leftresize.height()
+ )
+
+ self.rightresize = QtWidgets.QSizeGrip(self.treetotal_lbl)
+ self.rightresize.setStyleSheet(u"color: rgba(0,0,0, 0); background-color: rgba(0,0,0, 0);")
+ pos = self.treetotal_lbl.mapToGlobal(
+ QtCore.QPoint(100, 0))
+ self.rightresize.setGeometry(
+ pos.x(),
+ pos.y(),
+ self.rightresize.width(),
+ self.rightresize.height()
+ )
+
+ self.mainlayout.addLayout(self.gridLayout)
+
+
+
+class overlayLabel(QtWidgets.QLabel):
+ def __init__(self, parent=None):
+ super(overlayLabel, self).__init__(parent)
+ self.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
\ No newline at end of file
diff --git a/scripts/python/searcher/session.py b/python2.7libs/searcher/session.py
similarity index 100%
rename from scripts/python/searcher/session.py
rename to python2.7libs/searcher/session.py
diff --git a/python2.7libs/searcher/style.py b/python2.7libs/searcher/style.py
new file mode 100644
index 0000000..b5e9769
--- /dev/null
+++ b/python2.7libs/searcher/style.py
@@ -0,0 +1,119 @@
+from __future__ import print_function
+from __future__ import absolute_import
+
+import os
+from searcher import util
+
+script_path = os.path.dirname(os.path.realpath(__file__))
+
+settings = util.get_settings()
+
+def count_chars(txt):
+ result = 0
+ for char in txt:
+ result += 1 # same as result = result + 1
+ return result
+
+# ------------------------------------------------ UI Style
+# NOTE UI Style -------------------------------------------
+MENUSTYLE = """QMenu {background-color: rgb(64,64,64); menu-scrollable: 1; margin: 0px;}
+ QMenu:item {background-color: rgb(46,46,46); padding: 5px 25px; margin: 1px; height:16px;}
+ QMenu:item:selected {background-color: rgb(64,64,64);}
+ QMenu:separator {background-color: rgb(0,0,0); height: 1px; margin: 5px;}
+ QMenu:icon {padding: 5px;}
+ QMenu:icon:checked {flat: true;}"""
+
+TOOLTIP = """QToolTip {background-color: rgb(64,64,64); menu-scrollable: 1; margin: 0px;}
+ QToolTip:item {background-color: rgb(46,46,46); padding: 5px 25px; margin: 1px; height:16px;}
+ QToolTip:icon {padding: 5px;}
+ QToolTip:icon:checked {flat: true;}"""
+
+def styleresulttotal(appcolors, treecatnum, treeitemsnum, goalnum):
+ catval = ("%d : Contexts | " % (appcolors.stats1, treecatnum, appcolors.text1 ))
+ itmval = ("%d : Results " % (appcolors.stats1, treeitemsnum, appcolors.text1))
+ catval = catval.rjust(goalnum - count_chars(str(treecatnum)), " ")
+ itmval = itmval.rjust((goalnum + 2) - count_chars(str(treeitemsnum)), " ")
+ return (catval + itmval)
+
+def styletimers(appcolors, outdata):
+ return (("Search regex %0.4f ms | " % (str(appcolors.text1), str(appcolors.stats1), outdata[0]))
+ + ("Context Search %0.4f ms | " % (str(appcolors.text1), str(appcolors.stats1), outdata[1]))
+ + ("Hotkey Search %0.4f ms | " % (str(appcolors.text1), str(appcolors.stats1), outdata[2]))
+ + ("Tree build %0.4f ms | " % (str(appcolors.text1), str(appcolors.stats1), outdata[3]))
+ + ("Total : %0.4f ms " % (str(appcolors.text1), str(appcolors.stats1), outdata[4])))
+
+
+
+def gettreeviewstyle():
+ PATH = os.path.join(script_path, "images")
+ root = PATH.replace("\\", "/")
+ sheet = ""
+ sheet += (
+ "QTreeWidget { background: rgb(32, 32, 32); alternate-background-color: rgb(39, 39, 39) \n} "
+ )
+ sheet += (
+ """QHeaderView::section {\n
+ background: rgb(53, 53, 53);
+ color: rgb(200, 200, 200);
+ resize:both;
+ overflow:auto;
+ padding: 4px;
+ height:20px;
+ border:
+ 0px solid rgb(150, 150, 150);
+ border-bottom: 1px solid rgb(150, 150, 150);
+ border-left:0px solid rgb(25, 25, 25);
+ border-right:1px solid rgb(35, 35, 35) \n}\n
+
+ QScrollBar::vertical { \n width: 12px; \n } \n
+ QScrollBar::handle:vertical {\n background: rgb(19,19,19) \n}\n
+ """
+ )
+ sheet += (
+ "QTreeWidget::item::has-children { text-align: center; color: rgba(255, 193, 7, 0.8); border: 0px solid rgba(71, 71, 71, 0.8); padding-bottom: 0px; padding-top: 0px; border-radius: 0px; \n} "
+ )
+ sheet += (
+ "QTreeWidget::branch:has-siblings:!adjoins-item\n {\n border-image: url(%s/icon_vline.png) 0; \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::branch:has-siblings:adjoins-item\n {\n border-image: url(%s/icon_branch_more.png) 0; \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::branch:!has-children:!has-siblings:adjoins-item\n {\n border-image: url(%s/icon_branch_end.png) 0; \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::branch:has-children:!has-siblings:closed,"
+ )
+ sheet += (
+ "QTreeWidget::branch:closed:has-children:has-siblings\n {\n margin: 4px; border-image: none; image: url(%s/icon_branch_closed.png); \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::branch:open:has-children:!has-siblings,")
+ sheet += (
+ "QTreeWidget::branch:open:has-children:has-siblings\n {\n margin: 4px; border-image: none; image: url(%s/icon_branch_open.png); \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::indicator:unchecked\n {\n image: url(%s/icon_branch_closed.png); \n}"
+ % root
+ )
+ sheet += (
+ "QTreeWidget::indicator:checked\n {\n image: url(%s/icon_branch_open.png); \n}"
+ % root
+ )
+ sheet += "QTreeWidget::indicator { width: 16px; height: 16px;}"
+ sheet += (
+ "QGroupBox::indicator:unchecked\n {\n image: url(%s/icon_branch_closed.png); \n}"
+ % root
+ )
+ sheet += (
+ "QGroupBox::indicator:checked\n {\n image: url(%s/icon_branch_open.png); \n}"
+ % root
+ )
+ sheet += "QGroupBox::indicator { width: 16px; height: 16px;}"
+
+ return sheet
diff --git a/python2.7libs/searcher/theme.py b/python2.7libs/searcher/theme.py
new file mode 100644
index 0000000..3b7bd45
--- /dev/null
+++ b/python2.7libs/searcher/theme.py
@@ -0,0 +1,138 @@
+from __future__ import print_function
+from __future__ import absolute_import
+
+from searcher import theme_ui
+from searcher import util
+from searcher import searcher_data
+
+import os
+import sys
+
+import hou
+hver = 0
+if os.environ["HFS"] != "":
+ ver = os.environ["HFS"]
+ hver = int(ver[ver.rindex('.')+1:])
+ from hutil.Qt import QtGui
+ from hutil.Qt import QtCore
+ from hutil.Qt import QtWidgets
+ if hver >= 395:
+ from hutil.Qt import QtUiTools
+ elif hver <= 394 and hver >= 391:
+ from hutil.Qt import _QtUiTools
+ elif hver < 391 and hver >= 348:
+ from hutil.Qt import QtUiTools
+
+scriptpath = os.path.dirname(os.path.realpath(__file__))
+
+def name(**variables):
+ return [x for x in variables]
+
+def getHexColor(color):
+ if isinstance(color, hou.Color):
+ color = color.rgb()
+
+ rgb = [('00' + hex(int(v * 0xff))[2:])[-2:] for v in color[:3]]
+ return "#" + ''.join(rgb)
+
+def getRGBColor(hex):
+ hex = hex.lstrip('#')
+ hlen = len(hex)
+ return tuple(int(hex[i:i+hlen/3], 16) / 255.0 for i in range(0, hlen, hlen/3))
+
+class Theme(QtWidgets.QWidget):
+ """ Searcher coloring"""
+
+ def __init__(self, parent=None):
+ super(Theme, self).__init__(parent=parent)
+ self.setParent(parent)
+ self.ui = theme_ui.Ui_Theme()
+ self.ui.setupUi(self)
+ self.ui.retranslateUi(self)
+
+ self.settings = util.get_settings()
+ self.colors = self.settings[util.SETTINGS_KEYS[14]]
+
+ self.text1 = self.ui.text1
+ self.text1.setText(self.settings[util.SETTINGS_KEYS[14]]['text1'])
+ self.text1btn = self.ui.text1btn
+ self.text1btn.setStyleSheet("background-color:" + self.text1.text())
+ self.text1btn.setAutoFillBackground(True)
+ self.text1btn.clicked.connect(self.chooseColor)
+
+ self.text2 = self.ui.text2
+ self.text2.setText(self.settings[util.SETTINGS_KEYS[14]]['text2'])
+ self.text2btn = self.ui.text2btn
+ self.text2btn.setStyleSheet("background-color:" + self.text2.text())
+ self.text2btn.setAutoFillBackground(True)
+ self.text2btn.clicked.connect(self.chooseColor)
+
+ self.stats1 = self.ui.stats1
+ self.stats1.setText(self.settings[util.SETTINGS_KEYS[14]]['stats1'])
+ self.stats1btn = self.ui.stats1btn
+ self.stats1btn.setStyleSheet("background-color:" + self.stats1.text())
+ self.stats1btn.setAutoFillBackground(True)
+ self.stats1btn.clicked.connect(self.chooseColor)
+
+ self.stats2 = self.ui.stats2
+ self.stats2.setText(self.settings[util.SETTINGS_KEYS[14]]['stats2'])
+ self.stats2btn = self.ui.stats2btn
+ self.stats2btn.setStyleSheet("background-color:" + self.stats2.text())
+ self.stats2btn.setAutoFillBackground(True)
+ self.stats2btn.clicked.connect(self.chooseColor)
+
+ self.save = self.ui.savetheme
+
+
+
+ self.save.pressed.connect(self.save_cb)
+
+ def save_cb(self):
+ self.settings[util.SETTINGS_KEYS[14]]['text1'] = self.text1.text()
+ self.settings[util.SETTINGS_KEYS[14]]['text2'] = self.text2.text()
+ self.settings[util.SETTINGS_KEYS[14]]['stats1'] = self.stats1.text()
+ self.settings[util.SETTINGS_KEYS[14]]['stats2'] = self.stats2.text()
+
+ searcher_data.savesettings(self.settings[util.SETTINGS_KEYS[14]])
+
+ def button1_cb(self):
+ new_color = hou.ui.selectColor()
+ self.button1.set
+
+ color = hou.qt.toQColor(new_color)
+ self.colorfield.setColor(color)
+ hou.Color
+ print(new_color)
+ print(new_color.rgb())
+ c = getHexColor(new_color)
+ print(c)
+ print(getRGBColor(c))
+
+ def chooseColor(self):
+ sender = self.sender()
+ name = sender.objectName()
+ colorfield = getattr(self, name)
+
+ qcolor = QtGui.QColor()
+ qcolor.setNamedColor(colorfield.text())
+ color = hou.Color()
+ color.setRGB((
+ qcolor.redF(),
+ qcolor.greenF(),
+ qcolor.blueF())
+ )
+
+ result = hou.ui.selectColor(initial_color = color)
+
+ if result:
+ rgb = result.rgb()
+ newcolor = QtGui.QColor(
+ rgb[0]*255,
+ rgb[1]*255,
+ rgb[2]*255
+ )
+
+ if newcolor.isValid():
+ colorfield.setText(newcolor.name())
+ sender.setStyleSheet("background-color:" + colorfield.text())
+
diff --git a/python2.7libs/searcher/theme_ui.py b/python2.7libs/searcher/theme_ui.py
new file mode 100644
index 0000000..d942a07
--- /dev/null
+++ b/python2.7libs/searcher/theme_ui.py
@@ -0,0 +1,188 @@
+from hutil.Qt import QtCore, QtGui, QtWidgets
+import os
+
+scriptpath = os.path.dirname(os.path.realpath(__file__))
+
+
+class Ui_Theme(object):
+ def setupUi(self, Theme):
+ Theme.setObjectName("Theme")
+ Theme.setWindowModality(QtCore.Qt.NonModal)
+ Theme.resize(450, 300)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(Theme.sizePolicy().hasHeightForWidth())
+ Theme.setSizePolicy(sizePolicy)
+ Theme.setMinimumSize(QtCore.QSize(100, 0))
+ Theme.setBaseSize(QtCore.QSize(0, 0))
+ Theme.setStyleSheet("")
+ self.gridLayout = QtWidgets.QGridLayout(Theme)
+ self.gridLayout.setContentsMargins(-1, -1, -1, 6)
+ self.gridLayout.setSpacing(6)
+ self.gridLayout.setObjectName("gridLayout")
+ self.r1 = QtWidgets.QHBoxLayout()
+ self.r1.setObjectName("r1")
+ self.c1 = QtWidgets.QVBoxLayout()
+ self.c1.setObjectName("c1")
+ self.h3_c1 = QtWidgets.QHBoxLayout()
+ self.h3_c1.setObjectName("h3_c1")
+ spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h3_c1.addItem(spacerItem)
+ self.label = QtWidgets.QLabel(Theme)
+ self.label.setObjectName("label")
+ self.h3_c1.addWidget(self.label)
+ self.text1btn = QtWidgets.QToolButton(Theme)
+ self.text1btn.setObjectName("text1")
+ self.h3_c1.addWidget(self.text1btn)
+ self.text1 = QtWidgets.QLineEdit(Theme)
+ self.text1.setObjectName("text1_txt")
+ self.h3_c1.addWidget(self.text1)
+ self.c1.addLayout(self.h3_c1)
+ self.h4_c1 = QtWidgets.QHBoxLayout()
+ self.h4_c1.setObjectName("h4_c1")
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h4_c1.addItem(spacerItem1)
+ self.label_2 = QtWidgets.QLabel(Theme)
+ self.label_2.setObjectName("label_2")
+ self.h4_c1.addWidget(self.label_2)
+ self.text2btn = QtWidgets.QToolButton(Theme)
+ self.text2btn.setObjectName("text2")
+ self.h4_c1.addWidget(self.text2btn)
+ self.text2 = QtWidgets.QLineEdit(Theme)
+ self.text2.setObjectName("text2_txt")
+ self.h4_c1.addWidget(self.text2)
+ self.c1.addLayout(self.h4_c1)
+ self.h2_c1 = QtWidgets.QHBoxLayout()
+ self.h2_c1.setObjectName("h2_c1")
+ spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h2_c1.addItem(spacerItem2)
+ self.label_3 = QtWidgets.QLabel(Theme)
+ self.label_3.setObjectName("label_3")
+ self.h2_c1.addWidget(self.label_3)
+ self.stats1btn = QtWidgets.QToolButton(Theme)
+ self.stats1btn.setObjectName("stats1")
+ self.h2_c1.addWidget(self.stats1btn)
+ self.stats1 = QtWidgets.QLineEdit(Theme)
+ self.stats1.setObjectName("stats1_txt")
+ self.h2_c1.addWidget(self.stats1)
+ self.c1.addLayout(self.h2_c1)
+ self.h1_c1 = QtWidgets.QHBoxLayout()
+ self.h1_c1.setObjectName("h1_c1")
+ spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h1_c1.addItem(spacerItem3)
+ self.label_4 = QtWidgets.QLabel(Theme)
+ self.label_4.setObjectName("label_4")
+ self.h1_c1.addWidget(self.label_4)
+ self.stats2btn = QtWidgets.QToolButton(Theme)
+ self.stats2btn.setObjectName("stats2")
+ self.h1_c1.addWidget(self.stats2btn)
+ self.stats2 = QtWidgets.QLineEdit(Theme)
+ self.stats2.setObjectName("stats2_txt")
+ self.h1_c1.addWidget(self.stats2)
+ self.c1.addLayout(self.h1_c1)
+ self.r1.addLayout(self.c1)
+ self.c2 = QtWidgets.QVBoxLayout()
+ self.c2.setObjectName("c2")
+ self.h1_c2 = QtWidgets.QHBoxLayout()
+ self.h1_c2.setObjectName("h1_c2")
+ spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h1_c2.addItem(spacerItem4)
+ self.label_8 = QtWidgets.QLabel(Theme)
+ self.label_8.setObjectName("label_8")
+ self.h1_c2.addWidget(self.label_8)
+ self.toolButton_5 = QtWidgets.QToolButton(Theme)
+ self.toolButton_5.setObjectName("toolButton_5")
+ self.h1_c2.addWidget(self.toolButton_5)
+ self.lineEdit_2 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_2.setObjectName("lineEdit_2")
+ self.h1_c2.addWidget(self.lineEdit_2)
+ self.c2.addLayout(self.h1_c2)
+ self.h2_c2 = QtWidgets.QHBoxLayout()
+ self.h2_c2.setObjectName("h2_c2")
+ spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h2_c2.addItem(spacerItem5)
+ self.label_7 = QtWidgets.QLabel(Theme)
+ self.label_7.setObjectName("label_7")
+ self.h2_c2.addWidget(self.label_7)
+ self.toolButton_6 = QtWidgets.QToolButton(Theme)
+ self.toolButton_6.setObjectName("toolButton_6")
+ self.h2_c2.addWidget(self.toolButton_6)
+ self.lineEdit_3 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_3.setObjectName("lineEdit_3")
+ self.h2_c2.addWidget(self.lineEdit_3)
+ self.c2.addLayout(self.h2_c2)
+ self.h3_c2 = QtWidgets.QHBoxLayout()
+ self.h3_c2.setObjectName("h3_c2")
+ spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h3_c2.addItem(spacerItem6)
+ self.label_6 = QtWidgets.QLabel(Theme)
+ self.label_6.setObjectName("label_6")
+ self.h3_c2.addWidget(self.label_6)
+ self.toolButton_7 = QtWidgets.QToolButton(Theme)
+ self.toolButton_7.setObjectName("toolButton_7")
+ self.h3_c2.addWidget(self.toolButton_7)
+ self.lineEdit_4 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_4.setObjectName("lineEdit_4")
+ self.h3_c2.addWidget(self.lineEdit_4)
+ self.c2.addLayout(self.h3_c2)
+ self.h4_c2 = QtWidgets.QHBoxLayout()
+ self.h4_c2.setObjectName("h4_c2")
+ spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h4_c2.addItem(spacerItem7)
+ self.label_5 = QtWidgets.QLabel(Theme)
+ self.label_5.setObjectName("label_5")
+ self.h4_c2.addWidget(self.label_5)
+ self.toolButton_8 = QtWidgets.QToolButton(Theme)
+ self.toolButton_8.setObjectName("toolButton_8")
+ self.h4_c2.addWidget(self.toolButton_8)
+ self.lineEdit = QtWidgets.QLineEdit(Theme)
+ self.lineEdit.setObjectName("lineEdit")
+ self.h4_c2.addWidget(self.lineEdit)
+ self.c2.addLayout(self.h4_c2)
+ self.r1.addLayout(self.c2)
+ self.gridLayout.addLayout(self.r1, 0, 0, 1, 1)
+ self.r2 = QtWidgets.QVBoxLayout()
+ self.r2.setObjectName("r2")
+ self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem8)
+ self.savetheme = QtWidgets.QPushButton(Theme)
+ self.savetheme.setObjectName("savetheme")
+ self.horizontalLayout_2.addWidget(self.savetheme)
+ self.r2.addLayout(self.horizontalLayout_2)
+ self.gridLayout.addLayout(self.r2, 1, 0, 1, 1)
+
+ self.retranslateUi(Theme)
+ QtCore.QMetaObject.connectSlotsByName(Theme)
+
+ def retranslateUi(self, Theme):
+ _translate = QtCore.QCoreApplication.translate
+ Theme.setWindowTitle(_translate("Theme", "Form"))
+ self.label.setText(_translate("Theme", "Text1"))
+ self.text1btn.setText(_translate("Theme", "..."))
+ self.label_2.setText(_translate("Theme", "Text2"))
+ self.text2btn.setText(_translate("Theme", "..."))
+ self.label_3.setText(_translate("Theme", "Stats1"))
+ self.stats1btn.setText(_translate("Theme", "..."))
+ self.label_4.setText(_translate("Theme", "Stats2"))
+ self.stats2btn.setText(_translate("Theme", "..."))
+ self.label_8.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_5.setText(_translate("Theme", "..."))
+ self.label_7.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_6.setText(_translate("Theme", "..."))
+ self.label_6.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_7.setText(_translate("Theme", "..."))
+ self.label_5.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_8.setText(_translate("Theme", "..."))
+ self.savetheme.setText(_translate("Theme", "Save"))
+
+class LinkLabel(QtWidgets.QLabel):
+ def __init__(self, parent, text):
+ super(LinkLabel, self).__init__(parent)
+
+ self.setText(text)
+ self.setTextFormat(QtCore.Qt.RichText)
+ self.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
+ self.setOpenExternalLinks(True)
\ No newline at end of file
diff --git a/scripts/python/searcher/ui_files/SearcherSettings.py b/python2.7libs/searcher/ui_files/SearcherSettings.py
similarity index 100%
rename from scripts/python/searcher/ui_files/SearcherSettings.py
rename to python2.7libs/searcher/ui_files/SearcherSettings.py
diff --git a/scripts/python/searcher/ui_files/SearcherSettings.ui b/python2.7libs/searcher/ui_files/SearcherSettings.ui
similarity index 100%
rename from scripts/python/searcher/ui_files/SearcherSettings.ui
rename to python2.7libs/searcher/ui_files/SearcherSettings.ui
diff --git a/scripts/python/searcher/ui_files/about.ui b/python2.7libs/searcher/ui_files/about.ui
similarity index 100%
rename from scripts/python/searcher/ui_files/about.ui
rename to python2.7libs/searcher/ui_files/about.ui
diff --git a/scripts/python/searcher/ui_files/searcher_ui.py b/python2.7libs/searcher/ui_files/searcher_ui.py
similarity index 100%
rename from scripts/python/searcher/ui_files/searcher_ui.py
rename to python2.7libs/searcher/ui_files/searcher_ui.py
diff --git a/scripts/python/searcher/ui_files/searcher_ui.ui b/python2.7libs/searcher/ui_files/searcher_ui.ui
similarity index 100%
rename from scripts/python/searcher/ui_files/searcher_ui.ui
rename to python2.7libs/searcher/ui_files/searcher_ui.ui
diff --git a/python2.7libs/searcher/ui_files/theme.py b/python2.7libs/searcher/ui_files/theme.py
new file mode 100644
index 0000000..5430ad3
--- /dev/null
+++ b/python2.7libs/searcher/ui_files/theme.py
@@ -0,0 +1,185 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'theme.ui'
+#
+# Created by: PyQt5 UI code generator 5.14.1
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+
+class Ui_Theme(object):
+ def setupUi(self, Theme):
+ Theme.setObjectName("Theme")
+ Theme.setWindowModality(QtCore.Qt.NonModal)
+ Theme.resize(535, 164)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(Theme.sizePolicy().hasHeightForWidth())
+ Theme.setSizePolicy(sizePolicy)
+ Theme.setMinimumSize(QtCore.QSize(100, 0))
+ Theme.setBaseSize(QtCore.QSize(0, 0))
+ Theme.setStyleSheet("")
+ self.gridLayout = QtWidgets.QGridLayout(Theme)
+ self.gridLayout.setContentsMargins(-1, -1, -1, 6)
+ self.gridLayout.setSpacing(6)
+ self.gridLayout.setObjectName("gridLayout")
+ self.r1 = QtWidgets.QHBoxLayout()
+ self.r1.setObjectName("r1")
+ self.c1 = QtWidgets.QVBoxLayout()
+ self.c1.setObjectName("c1")
+ self.h3_c1 = QtWidgets.QHBoxLayout()
+ self.h3_c1.setObjectName("h3_c1")
+ spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h3_c1.addItem(spacerItem)
+ self.label = QtWidgets.QLabel(Theme)
+ self.label.setObjectName("label")
+ self.h3_c1.addWidget(self.label)
+ self.text1btn = QtWidgets.QToolButton(Theme)
+ self.text1btn.setObjectName("text1btn")
+ self.h3_c1.addWidget(self.text1btn)
+ self.text1 = QtWidgets.QLineEdit(Theme)
+ self.text1.setObjectName("text1")
+ self.h3_c1.addWidget(self.text1)
+ self.c1.addLayout(self.h3_c1)
+ self.h4_c1 = QtWidgets.QHBoxLayout()
+ self.h4_c1.setObjectName("h4_c1")
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h4_c1.addItem(spacerItem1)
+ self.label_2 = QtWidgets.QLabel(Theme)
+ self.label_2.setObjectName("label_2")
+ self.h4_c1.addWidget(self.label_2)
+ self.text2btn = QtWidgets.QToolButton(Theme)
+ self.text2btn.setObjectName("text2btn")
+ self.h4_c1.addWidget(self.text2btn)
+ self.text2 = QtWidgets.QLineEdit(Theme)
+ self.text2.setObjectName("text2")
+ self.h4_c1.addWidget(self.text2)
+ self.c1.addLayout(self.h4_c1)
+ self.h2_c1 = QtWidgets.QHBoxLayout()
+ self.h2_c1.setObjectName("h2_c1")
+ spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h2_c1.addItem(spacerItem2)
+ self.label_3 = QtWidgets.QLabel(Theme)
+ self.label_3.setObjectName("label_3")
+ self.h2_c1.addWidget(self.label_3)
+ self.stats1btn = QtWidgets.QToolButton(Theme)
+ self.stats1btn.setObjectName("stats1btn")
+ self.h2_c1.addWidget(self.stats1btn)
+ self.stats = QtWidgets.QLineEdit(Theme)
+ self.stats1setObjectName("stats1")
+ self.h2_c1.addWidget(self.stats1)
+ self.c1.addLayout(self.h2_c1)
+ self.h1_c1 = QtWidgets.QHBoxLayout()
+ self.h1_c1.setObjectName("h1_c1")
+ spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h1_c1.addItem(spacerItem3)
+ self.label_4 = QtWidgets.QLabel(Theme)
+ self.label_4.setObjectName("label_4")
+ self.h1_c1.addWidget(self.label_4)
+ self.stats2btn = QtWidgets.QToolButton(Theme)
+ self.stats2btn.setObjectName("stats2btn")
+ self.h1_c1.addWidget(self.stats2btn)
+ self.stats2 = QtWidgets.QLineEdit(Theme)
+ self.stats2.setObjectName("stats2")
+ self.h1_c1.addWidget(self.stats2)
+ self.c1.addLayout(self.h1_c1)
+ self.r1.addLayout(self.c1)
+ self.c2 = QtWidgets.QVBoxLayout()
+ self.c2.setObjectName("c2")
+ self.h1_c2 = QtWidgets.QHBoxLayout()
+ self.h1_c2.setObjectName("h1_c2")
+ spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h1_c2.addItem(spacerItem4)
+ self.label_8 = QtWidgets.QLabel(Theme)
+ self.label_8.setObjectName("label_8")
+ self.h1_c2.addWidget(self.label_8)
+ self.toolButton_5 = QtWidgets.QToolButton(Theme)
+ self.toolButton_5.setObjectName("toolButton_5")
+ self.h1_c2.addWidget(self.toolButton_5)
+ self.lineEdit_2 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_2.setObjectName("lineEdit_2")
+ self.h1_c2.addWidget(self.lineEdit_2)
+ self.c2.addLayout(self.h1_c2)
+ self.h2_c2 = QtWidgets.QHBoxLayout()
+ self.h2_c2.setObjectName("h2_c2")
+ spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h2_c2.addItem(spacerItem5)
+ self.label_7 = QtWidgets.QLabel(Theme)
+ self.label_7.setObjectName("label_7")
+ self.h2_c2.addWidget(self.label_7)
+ self.toolButton_6 = QtWidgets.QToolButton(Theme)
+ self.toolButton_6.setObjectName("toolButton_6")
+ self.h2_c2.addWidget(self.toolButton_6)
+ self.lineEdit_3 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_3.setObjectName("lineEdit_3")
+ self.h2_c2.addWidget(self.lineEdit_3)
+ self.c2.addLayout(self.h2_c2)
+ self.h3_c2 = QtWidgets.QHBoxLayout()
+ self.h3_c2.setObjectName("h3_c2")
+ spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h3_c2.addItem(spacerItem6)
+ self.label_6 = QtWidgets.QLabel(Theme)
+ self.label_6.setObjectName("label_6")
+ self.h3_c2.addWidget(self.label_6)
+ self.toolButton_7 = QtWidgets.QToolButton(Theme)
+ self.toolButton_7.setObjectName("toolButton_7")
+ self.h3_c2.addWidget(self.toolButton_7)
+ self.lineEdit_4 = QtWidgets.QLineEdit(Theme)
+ self.lineEdit_4.setObjectName("lineEdit_4")
+ self.h3_c2.addWidget(self.lineEdit_4)
+ self.c2.addLayout(self.h3_c2)
+ self.h4_c2 = QtWidgets.QHBoxLayout()
+ self.h4_c2.setObjectName("h4_c2")
+ spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.h4_c2.addItem(spacerItem7)
+ self.label_5 = QtWidgets.QLabel(Theme)
+ self.label_5.setObjectName("label_5")
+ self.h4_c2.addWidget(self.label_5)
+ self.toolButton_8 = QtWidgets.QToolButton(Theme)
+ self.toolButton_8.setObjectName("toolButton_8")
+ self.h4_c2.addWidget(self.toolButton_8)
+ self.lineEdit = QtWidgets.QLineEdit(Theme)
+ self.lineEdit.setObjectName("lineEdit")
+ self.h4_c2.addWidget(self.lineEdit)
+ self.c2.addLayout(self.h4_c2)
+ self.r1.addLayout(self.c2)
+ self.gridLayout.addLayout(self.r1, 0, 0, 1, 1)
+ self.r2 = QtWidgets.QVBoxLayout()
+ self.r2.setObjectName("r2")
+ self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem8)
+ self.savetheme = QtWidgets.QPushButton(Theme)
+ self.savetheme.setObjectName("savetheme")
+ self.horizontalLayout_2.addWidget(self.savetheme)
+ self.r2.addLayout(self.horizontalLayout_2)
+ self.gridLayout.addLayout(self.r2, 1, 0, 1, 1)
+
+ self.retranslateUi(Theme)
+ QtCore.QMetaObject.connectSlotsByName(Theme)
+
+ def retranslateUi(self, Theme):
+ _translate = QtCore.QCoreApplication.translate
+ Theme.setWindowTitle(_translate("Theme", "Form"))
+ self.label.setText(_translate("Theme", "Text1"))
+ self.text1btn.setText(_translate("Theme", "..."))
+ self.label_2.setText(_translate("Theme", "Text2"))
+ self.text2btn.setText(_translate("Theme", "..."))
+ self.label_3.setText(_translate("Theme", "Stats1"))
+ self.stats1btn.setText(_translate("Theme", "..."))
+ self.label_4.setText(_translate("Theme", "Stats2"))
+ self.stats2btn.setText(_translate("Theme", "..."))
+ self.label_8.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_5.setText(_translate("Theme", "..."))
+ self.label_7.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_6.setText(_translate("Theme", "..."))
+ self.label_6.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_7.setText(_translate("Theme", "..."))
+ self.label_5.setText(_translate("Theme", "TextLabel"))
+ self.toolButton_8.setText(_translate("Theme", "..."))
+ self.savetheme.setText(_translate("Theme", "Save"))
diff --git a/python2.7libs/searcher/ui_files/theme.ui b/python2.7libs/searcher/ui_files/theme.ui
new file mode 100644
index 0000000..94f3741
--- /dev/null
+++ b/python2.7libs/searcher/ui_files/theme.ui
@@ -0,0 +1,363 @@
+
+
+ Theme
+
+
+ Qt::NonModal
+
+
+
+ 0
+ 0
+ 535
+ 164
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+
+
+
+ 6
+
+
+ 6
+
+ -
+
+
-
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Text1
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Text2
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Stats1
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Stats2
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Save
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/python/searcher/util.py b/python2.7libs/searcher/util.py
similarity index 70%
rename from scripts/python/searcher/util.py
rename to python2.7libs/searcher/util.py
index 1113b2f..093dc72 100644
--- a/scripts/python/searcher/util.py
+++ b/python2.7libs/searcher/util.py
@@ -1,4 +1,3 @@
-# ------------------------------------------------------------------------ Imports
from __future__ import print_function
from __future__ import absolute_import
from searcher import enum
@@ -12,53 +11,90 @@
ver = os.environ["HFS"]
hver = int(ver[ver.rindex('.')+1:])
from hutil.Qt import QtCore
-# endregion
+script_path = os.path.dirname(os.path.realpath(__file__))
+
+# ------------------------------------------------------- Helper Functions
+# SECTION Helper Functions -----------------------------------------------
+# --------------------------------------------- DEBUG_LEVEL
+# NOTE DEBUG_LEVEL ----------------------------------------
DEBUG_LEVEL = enum.Enum('NONE', 'TIMER', 'ALL')
class Dbug(object):
- def __init__(self, enabled, level):
+ def __init__(self, enabled, level, perf, mainwindow=False):
self.enabled = enabled
self.level = level
+ self.performance = perf
+ self.mainwindow = mainwindow
def __nonzero__(self): return bool(self.enabled)
+class AppColors(object):
+ def __init__(self, colors={}):
+ self.text1 = colors['text1']
+ self.text2 = colors['text2']
+ self.stats1 = colors['stats1']
+ self.stats2 = colors['stats2']
-SequenceT = Tuple[str, ...]
+# -------------------------------------------- get_settings
+# NOTE get_settings ---------------------------------------
+def get_settings():
+ return getattr(hou.session, "SETTINGS", None)
-# ------------------------------------------------------------------------ Helper Functions
+# ------------------------------------------ Bool Converter
+# NOTE Bool Converter -------------------------------------
def bc(v):
return str(v).lower() in ("yes", "true", "t", "1")
-# endregion
-# ------------------------------------------------------------------------ Application Settings
+# !SECTION
+
+# --------------------------------------------------------------- Settings
+# SECTION Settings -------------------------------------------------------
+# ------------------------------------------- SETTINGS_KEYS
+# NOTE SETTINGS_KEYS --------------------------------------
SETTINGS_KEYS = [
- 'in_memory_db', # 0
- 'database_path', # 1
- 'savewindowsize', # 2
- 'windowsize', # 3
- 'debugflag', # 4
- 'pinwindow', # 5
- 'defaulthotkey', # 6
- 'showctx', # 7
- 'animatedsettings', # 8
- 'maxresults', # 9
- 'debuglevel' # 10
+ 'in_memory_db', # 0
+ 'database_path', # 1
+ 'savewindowsize', # 2
+ 'windowsize', # 3
+ 'debugflag', # 4
+ 'pinwindow', # 5
+ 'defaulthotkey', # 6
+ 'showctx', # 7
+ 'animatedsettings', # 8
+ 'maxresults', # 9
+ 'debuglevel', # 10
+ 'lastkey', # 11
+ 'metrics', # 12
+ 'metricsmainwindow', # 13
+ 'appcolors', # 14
]
-# Include parameter type if it is to be processed by settings menu, else mark NA
+# ------------------------------------------ SETTINGS_TYPES
+# Include parameter type if it is to be processed, else mark NA
+# {bool, text, int, intval} get processed by settings menu
+# {flag} is a bool but handled separate from settings menu
+# {NA} is other, handled separaretly as well
+# NOTE SETTINGS_TYPES -------------------------------------
SETTINGS_TYPES = {
- SETTINGS_KEYS[0]: 'bool', # in_memory_db
- SETTINGS_KEYS[1]: 'text', # database_path
- SETTINGS_KEYS[2]: 'bool', # savewindowsize
- SETTINGS_KEYS[3]: 'int', # windowsize
- SETTINGS_KEYS[4]: 'bool', # debugflag
- SETTINGS_KEYS[5]: 'NA', # pinwindow
- SETTINGS_KEYS[6]: 'text', # defaulthotkey
- SETTINGS_KEYS[7]: 'NA', # showctx
- SETTINGS_KEYS[8]: 'bool', # animatedsettings
- SETTINGS_KEYS[9]: 'intval', # maxresults
- SETTINGS_KEYS[10]: 'cbx', # debuglevel
+ SETTINGS_KEYS[0]: 'bool', # in_memory_db
+ SETTINGS_KEYS[1]: 'text', # database_path
+ SETTINGS_KEYS[2]: 'bool', # savewindowsize
+ SETTINGS_KEYS[3]: 'int', # windowsize
+ SETTINGS_KEYS[4]: 'bool', # debugflag
+ SETTINGS_KEYS[5]: 'flag', # pinwindow
+ SETTINGS_KEYS[6]: 'text', # defaulthotkey
+ SETTINGS_KEYS[7]: 'flag', # showctx
+ SETTINGS_KEYS[8]: 'bool', # animatedsettings
+ SETTINGS_KEYS[9]: 'intval', # maxresults
+ SETTINGS_KEYS[10]: 'cbx', # debuglevel
+ SETTINGS_KEYS[11]: 'NA', # lastkey
+ SETTINGS_KEYS[12]: 'bool', # metrics
+ SETTINGS_KEYS[13]: 'flag', # metricsmainwindow
+ SETTINGS_KEYS[14]: 'NA', # appcolors
}
+# ---------------------------------------- DEFAULT_SETTINGS
+# Default settings automatically applied upon creations
+# NOTE DEFAULT_SETTINGS -----------------------------------
DEFAULT_SETTINGS = {
SETTINGS_KEYS[0]: "False", # in_memory_db
SETTINGS_KEYS[1]: "", # database_path
@@ -71,10 +107,29 @@ def bc(v):
SETTINGS_KEYS[8]: "True", # animatedsettings
SETTINGS_KEYS[9]: 100, # maxresults
SETTINGS_KEYS[10]: "NONE", # debuglevel
+ SETTINGS_KEYS[11]: "", # lastkey
+ SETTINGS_KEYS[12]: "False", # metrics
+ SETTINGS_KEYS[13]: "False", # metricsmainwindow
+ SETTINGS_KEYS[14]: { # appcolors
+ "text1" : "#55cd49",
+ "text2" : "#55cd49",
+ "stats1" : "Orange",
+ "stats2" : "Yellow",
+ },
}
+# !SECTION
-# ------------------------------------------------------------------------ Key Translations
-# Directional conversion
+# ------------------------------------------------------- Key Translations
+# SECTION Key Translations -----------------------------------------------
+
+# --------------------------------------------- CTXSHOTCUTS
+# Context shortcodes for predefined results
+# NOTE CTXSHOTCUTS ----------------------------------------
+CTXSHOTCUTS = [":v", ":c", ":g"]
+
+# ------------------------------------------ KEYCONVERSIONS
+# Convertions for arrow keys (Should be moved to main dict)
+# NOTE KEYCONVERSIONS -------------------------------------
KEYCONVERSIONS = {
"DownArrow": "down",
"UpArrow": "up",
@@ -82,7 +137,9 @@ def bc(v):
"RightArrow": "right",
}
+# ---------------------------------------------- HOTKEYLIST
# List of possible hotkeys to use a temp keys when running commands
+# NOTE HOTKEYLIST -----------------------------------------
HOTKEYLIST = [
(u"Ctrl+Alt+Shift+F7"),
(u"Ctrl+Alt+Shift+F6"),
@@ -91,7 +148,22 @@ def bc(v):
(u"Ctrl+Alt+Shift+F10")
]
+def gethotkeys():
+ hkeys = []
+ settings = get_settings()
+ hkeys.append(settings[SETTINGS_KEYS[6]])
+ for key in HOTKEYLIST:
+ hkeys.append(key)
+ return hkeys
+
+# Used for bitmasking to determine modifiers
+MODIFIERS = {}
+# Used for constructing a bitmasked modifier
+REVERSE_MODIFIERS = {}
+
+# ------------------------------------------- MODIFIER_KEYS
# Used to detect if a keypress was just a modifier
+# NOTE MODIFIER_KEYS --------------------------------------
MODIFIER_KEYS = {
QtCore.Qt.Key_Alt: "Alt",
QtCore.Qt.Key_Meta: "Meta",
@@ -99,12 +171,18 @@ def bc(v):
QtCore.Qt.Key_Control: "Ctrl",
}
-# Used for bitmasking to determine modifiers
-MODIFIERS = {}
-# Used for constructing a bitmasked modifier
-REVERSE_MODIFIERS = {}
+# NOTE MODIFIERS ------------------------------------------
+MODIFIERS = {
+ "Shift": QtCore.Qt.ShiftModifier,
+ "Control": QtCore.Qt.ControlModifier,
+ "Ctrl": QtCore.Qt.ControlModifier,
+ "Meta": QtCore.Qt.MetaModifier,
+ "Alt": QtCore.Qt.AltModifier,
+}
+# -------------------------------------------- SPECIAL_KEYS
# Special keys
+# NOTE SPECIAL_KEYS ---------------------------------------
SPECIAL_KEYS = {
QtCore.Qt.Key_Backspace: "BACKSPACE",
QtCore.Qt.Key_Delete: "DELETE",
@@ -124,8 +202,9 @@ def bc(v):
QtCore.Qt.Key_Home: "Page_Home",
}
-# --------------------------------------------------- Platform conversions
+# ------------------------------------------------ Platform
# # Platform conversions
+# NOTE Platform -------------------------------------------
# if platform == "linux" or platform == "linux2":
# tmp = {
# QtCore.Qt.ShiftModifier: "Shift",
@@ -171,14 +250,8 @@ def bc(v):
# REVERSE_MODIFIERS.update(tmp)
# endregion
-MODIFIERS = {
- "Shift": QtCore.Qt.ShiftModifier,
- "Control": QtCore.Qt.ControlModifier,
- "Ctrl": QtCore.Qt.ControlModifier,
- "Meta": QtCore.Qt.MetaModifier,
- "Alt": QtCore.Qt.AltModifier,
-}
-
+# ------------------------------------------------ KEY_DICT
+# NOTE KEY_DICT -------------------------------------------
KEY_DICT = {
# ------------------------------------- Grey keys
"Escape": QtCore.Qt.Key_Escape,
@@ -349,7 +422,12 @@ def bc(v):
"AsciiTilde": QtCore.Qt.Key_AsciiTilde,
"~": QtCore.Qt.Key_AsciiTilde,
}
+# !SECTION
+# --------------------------------------------------- Houdini Translations
+# SECTION Houdini Translations -------------------------------------------
+# --------------------------------------------- CONTEXTTYPE
+# NOTE CONTEXTTYPE ----------------------------------------
CONTEXTTYPE = {
"Cop2": "COP",
"CopNet": "COPNET",
@@ -367,6 +445,8 @@ def bc(v):
"VopNet": "VEX",
}
+# ----------------------------------------------- PANETYPES
+# NOTE PANETYPES ------------------------------------------
PANETYPES = {
hou.paneTabType.AssetBrowser: ["h.pane.projectm"],
hou.paneTabType.BundleList: ["h.pane.bundle"],
@@ -392,12 +472,10 @@ def bc(v):
hou.paneTabType.Textport: ["h.pane.textport"],
hou.paneTabType.TreeView: ["tree"],
}
-# endregion
-
-# ------------------------------------------------------------------------ UI Constants
-ICON_SIZE = hou.ui.scaledSize(32)
-EDIT_ICON_SIZE = hou.ui.scaledSize(28)
+# !SECTION
+# --------------------------------------------------------------- UI Info
+# SECTION UI Info -------------------------------------------------------
# DOP_pyrosolver
# MISC_database
# MISC_python
@@ -410,6 +488,16 @@ def bc(v):
# NETVIEW_image_link
# NETVIEW_image_link_located
+# --------------------------------------------------- Icons
+# NOTE Icons ----------------------------------------------
+ICON_SIZE = hou.ui.scaledSize(32)
+EDIT_ICON_SIZE = hou.ui.scaledSize(28)
+
+ABOUT_ICON1 = hou.ui.createQtIcon(
+ 'NETVIEW_info_button',
+ EDIT_ICON_SIZE,
+ EDIT_ICON_SIZE
+)
BUG_ICON = hou.ui.createQtIcon(
'NETVIEW_64bit_badge',
@@ -423,14 +511,20 @@ def bc(v):
EDIT_ICON_SIZE
)
+DOWN_ICON = hou.ui.createQtIcon(
+ 'BUTTONS_down',
+ EDIT_ICON_SIZE,
+ EDIT_ICON_SIZE
+)
+
EXPAND_ICON = hou.ui.createQtIcon(
'BUTTONS_expand_right',
EDIT_ICON_SIZE,
EDIT_ICON_SIZE
)
-INFO_ICON = hou.ui.createQtIcon(
- 'BUTTONS_info',
+FILE_ICON = hou.ui.createQtIcon(
+ 'BUTTONS_folder',
EDIT_ICON_SIZE,
EDIT_ICON_SIZE
)
@@ -441,8 +535,8 @@ def bc(v):
EDIT_ICON_SIZE
)
-ABOUT_ICON1 = hou.ui.createQtIcon(
- 'NETVIEW_info_button',
+INFO_ICON = hou.ui.createQtIcon(
+ 'BUTTONS_info',
EDIT_ICON_SIZE,
EDIT_ICON_SIZE
)
@@ -471,18 +565,12 @@ def bc(v):
EDIT_ICON_SIZE
)
-MENUSTYLE = """QMenu {background-color: rgb(64,64,64); menu-scrollable: 1; margin: 0px;}
- QMenu:item {background-color: rgb(46,46,46); padding: 5px 25px; margin: 1px; height:16px;}
- QMenu:item:selected {background-color: rgb(64,64,64);}
- QMenu:separator {background-color: rgb(0,0,0); height: 1px; margin: 5px;}
- QMenu:icon {padding: 5px;}
- QMenu:icon:checked {flat: true;}"""
-
-TOOLTIP = """QToolTip {background-color: rgb(64,64,64); menu-scrollable: 1; margin: 0px;}
- QToolTip:item {background-color: rgb(46,46,46); padding: 5px 25px; margin: 1px; height:16px;}
- QToolTip:icon {padding: 5px;}
- QToolTip:icon:checked {flat: true;}"""
+UP_ICON = hou.ui.createQtIcon(
+ 'BUTTONS_up',
+ EDIT_ICON_SIZE,
+ EDIT_ICON_SIZE
+)
-CTXSHOTCUTS = [":v", ":c", ":g"]
-# endregion
+# !SECTION
+ # color: rgb(246, 158, 50);
\ No newline at end of file
diff --git a/scripts/python/searcher/version.py b/python2.7libs/searcher/version.py
similarity index 100%
rename from scripts/python/searcher/version.py
rename to python2.7libs/searcher/version.py
diff --git a/python2.7libs/searcher/widgets/__init__py b/python2.7libs/searcher/widgets/__init__py
new file mode 100644
index 0000000..e69de29
diff --git a/scripts/python/searcher/widgets/collapsedock.py b/python2.7libs/searcher/widgets/collapsedock.py
similarity index 100%
rename from scripts/python/searcher/widgets/collapsedock.py
rename to python2.7libs/searcher/widgets/collapsedock.py
diff --git a/resources/branch-closed.png b/resources/branch-closed.png
new file mode 100644
index 0000000..213ffdd
Binary files /dev/null and b/resources/branch-closed.png differ
diff --git a/resources/branch-end.png b/resources/branch-end.png
new file mode 100644
index 0000000..54915b3
Binary files /dev/null and b/resources/branch-end.png differ
diff --git a/resources/branch-end.svg b/resources/branch-end.svg
new file mode 100644
index 0000000..cc66807
--- /dev/null
+++ b/resources/branch-end.svg
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/resources/branch-more.png b/resources/branch-more.png
new file mode 100644
index 0000000..664ad44
Binary files /dev/null and b/resources/branch-more.png differ
diff --git a/resources/branch-more.svg b/resources/branch-more.svg
new file mode 100644
index 0000000..5d03abf
--- /dev/null
+++ b/resources/branch-more.svg
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/resources/branch-open.png b/resources/branch-open.png
new file mode 100644
index 0000000..e8cad95
Binary files /dev/null and b/resources/branch-open.png differ
diff --git a/resources/branch-vline.png b/resources/branch-vline.png
new file mode 100644
index 0000000..8f0c336
Binary files /dev/null and b/resources/branch-vline.png differ
diff --git a/resources/branch-vline.svg b/resources/branch-vline.svg
new file mode 100644
index 0000000..4140e5f
--- /dev/null
+++ b/resources/branch-vline.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/resources/collapsed.svg b/resources/collapsed.svg
new file mode 100644
index 0000000..2b5c523
--- /dev/null
+++ b/resources/collapsed.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/resources/icon_branch_closed.png b/resources/icon_branch_closed.png
new file mode 100644
index 0000000..fa785cc
Binary files /dev/null and b/resources/icon_branch_closed.png differ
diff --git a/resources/icon_branch_end.png b/resources/icon_branch_end.png
new file mode 100644
index 0000000..d90a04c
Binary files /dev/null and b/resources/icon_branch_end.png differ
diff --git a/resources/icon_branch_more.png b/resources/icon_branch_more.png
new file mode 100644
index 0000000..bdbe4ed
Binary files /dev/null and b/resources/icon_branch_more.png differ
diff --git a/resources/icon_branch_open.png b/resources/icon_branch_open.png
new file mode 100644
index 0000000..9dd05d6
Binary files /dev/null and b/resources/icon_branch_open.png differ
diff --git a/resources/icon_vline.png b/resources/icon_vline.png
new file mode 100644
index 0000000..14228c8
Binary files /dev/null and b/resources/icon_vline.png differ
diff --git a/resources/opened.svg b/resources/opened.svg
new file mode 100644
index 0000000..4fecc28
--- /dev/null
+++ b/resources/opened.svg
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/scripts/456.py b/scripts/456.py
index 6afc55b..7facd6a 100644
--- a/scripts/456.py
+++ b/scripts/456.py
@@ -1,4 +1,6 @@
from __future__ import print_function
+from __future__ import absolute_import
+
from searcher import searcher_data
from searcher import util
from searcher import platformselect
@@ -26,14 +28,18 @@
inspect.getsourcefile(lambda: 0)
)
-def get_db():
- return getattr(hou.session, "DATABASE", None)
+def get_settings():
+ return getattr(hou.session, "SETTINGS", None)
+
+def get_dbconnection():
+ return getattr(hou.session, "DBCONNECTION", None)
scriptpath = os.path.dirname(current_file_path)
-dbpath = os.path.join(scriptpath, "python/searcher/db/searcher.db")
+dbpath = os.path.join(scriptpath, "../python2.7libs/searcher/db/searcher.db")
-hou.session.DATABASE = DatabaseProxy()
-db = get_db()
+hou.session.SETTINGS = {}
+hou.session.DBCONNECTION = DatabaseProxy()
+db = DatabaseProxy()
settingdata = {}
isloading = True
tempkey = ""
@@ -62,16 +68,6 @@ class Meta:
table_name = 'hcontext'
database = db
-class HContextIndex(FTS5Model):
- # rowid = RowIDField()
- context = SearchField()
- title = SearchField()
- description = SearchField()
-
- class Meta:
- database = db
- options = {'prefix': [2, 3], 'tokenize': 'porter'}
-
class Hotkeys(Model):
hotkey_symbol = CharField(unique=True)
label = CharField()
@@ -96,9 +92,8 @@ class Meta:
database = db
options = {'prefix': [2, 3], 'tokenize': 'porter'}
-def create_tables():
- with db:
- db.create_tables([Settings, HContext, HContextIndex, Hotkeys, HotkeysIndex])
+def create_tables(dbc):
+ dbc.create_tables([Settings, HContext, Hotkeys, HotkeysIndex])
def worker():
hd.executeInMainThreadWithResult(updatecontext)
@@ -144,9 +139,9 @@ def initialsetup(cur):
updatedataasync()
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- "Searcher database created", severity=hou.severityType.Message)
+ la.MESSAGES['initialsetup1'], severity=hou.severityType.Message)
else:
- print("Searcher database created")
+ print(la.MESSAGES['initialsetup1'])
else:
chindex = int(chindex[0][0])
@@ -157,7 +152,7 @@ def initialsetup(cur):
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- "Searcher database created and populated", severity=hou.severityType.Message)
+ la.MESSAGES['initialsetup2'], severity=hou.severityType.Message)
# --------------------------------------------------------------- Retrieve
# SECTION Retrieve -------------------------------------------------------
@@ -171,26 +166,32 @@ def getchangeindex(cur):
except(AttributeError, TypeError) as e:
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- ("Could not get Searcher changeindex: " + str(e)), severity=hou.severityType.Warning)
+ (la.ERRORMSG['getchangeindex'] + str(e)), severity=hou.severityType.Warning)
else:
- print("Could not get Searcher changeindex: " + str(e))
+ print(la.ERRORMSG['getchangeindex'] + str(e))
# ------------------------------------------- getlastusedhk
# NOTE getlastusedhk --------------------------------------
def getlastusedhk(cur):
+ settingdata = get_settings()
+ lastkey = settingdata[util.SETTINGS_KEYS[11]]
try:
- cur.execute("SELECT lastused FROM settings")
- result = cur.fetchall()
- if str(result[0][0]) != "":
- lasthk = str(result[0][0]).split(' ')
- rmresult = hou.hotkeys.removeAssignment(
- str(lasthk[0]).strip(), str(lasthk[1]).strip())
+ if str(lastkey) != "":
+ lasthk = str(lastkey).split(' ')
+ hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
+
+ if len(hkcheck) is 0:
+ settingdata[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
+ return
+
+ rmresult = hou.hotkeys.removeAssignment(str(lasthk[0]).strip(), str(lasthk[1]).strip())
if rmresult:
hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
hou.hotkeys.saveOverrides()
if len(hkcheck) is 0:
- Settings.update(lastused="").where(
- Settings.id == 1).execute()
+ settingdata[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
currentidx = hou.hotkeys.changeIndex()
updatechangeindex(int(currentidx))
else:
@@ -198,30 +199,29 @@ def getlastusedhk(cur):
hou.hotkeys.saveOverrides()
hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
if len(hkcheck) is 0:
- Settings.update(lastused="").where(
- Settings.id == 1).execute()
+ settingdata[util.SETTINGS_KEYS[11]] = ""
+ searcher_data.savesettings(settingdata)
currentidx = hou.hotkeys.changeIndex()
updatechangeindex(int(currentidx))
else:
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- ("Could not clear last assigned temp hotkey on last attempt:"), severity=hou.severityType.Warning)
+ (la.ERRORMSG['getlastusedhk3']), severity=hou.severityType.Warning)
else:
- print(
- "Could not clear last assigned temp hotkey on last attempt:")
+ print(la.ERRORMSG['getlastusedhk3'])
else:
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- ("Could not clear last assigned temp hotkey:"), severity=hou.severityType.Warning)
+ (la.ERRORMSG['getlastusedhk2']), severity=hou.severityType.Warning)
else:
- print("Could not clear last assigned temp hotkey:")
+ print(la.ERRORMSG['getlastusedhk2'])
except(AttributeError, TypeError) as e:
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- ("Could not query last assigned temp hotkey:" + str(e)), severity=hou.severityType.Warning)
+ (la.ERRORMSG['getlastusedhk1'] + str(e)), severity=hou.severityType.Warning)
else:
- print("Could not query last assigned temp hotkey: " + str(e))
+ print(la.ERRORMSG['getlastusedhk1'] + str(e))
# !SECTION
# ----------------------------------------------------------------- Update
@@ -268,37 +268,28 @@ def updatechangeindex(indexval, new=False):
Settings.id == 1).execute()
except(AttributeError, TypeError) as e:
if hou.isUIAvailable():
- hou.ui.setStatusMessage(("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Warning)
+ hou.ui.setStatusMessage(
+ (la.ERRORMSG['updatechangeindex'] + str(e)), severity=hou.severityType.Warning)
else:
- print("Could not update Searcher context database: " + str(e))
+ print(la.ERRORMSG['updatechangeindex'] + str(e))
# ------------------------------------------- updatecontext
# NOTE updatecontext --------------------------------------
def updatecontext(debug=False):
try:
- time1 = time.time()
cleardatabase()
ctxdata, hkeydata = getdata()
with db.atomic():
for data_dict in ctxdata:
HContext.replace_many(data_dict).execute()
- HContextIndex.replace_many(data_dict).execute()
with db.atomic():
for idx in hkeydata:
Hotkeys.replace_many(idx).execute()
HotkeysIndex.replace_many(idx).execute()
- time2 = time.time()
- if debug:
- res = ((time2 - time1) * 1000.0)
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ('DB update took %0.4f ms' % res), severity=hou.severityType.Message)
- else:
- print('DB update took %0.4f ms' % res)
- return res
+
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Warning)
+ (la.ERRORMSG['updatecontext'] + str(e)), severity=hou.severityType.Warning)
# endregion
# ------------------------------------------- cleardatabase
@@ -307,17 +298,19 @@ def cleardatabase():
try:
delhk = "DELETE FROM hotkeys"
delctx = "DELETE FROM hcontext"
+ delhkindex = "DELETE FROM hotkeysindex"
db.cursor().execute(delhk)
db.cursor().execute(delctx)
+ db.cursor().execute(delhkindex)
result = db.cursor().fetchall()
return result
except(AttributeError, TypeError) as e:
if hou.isUIAvailable():
hou.ui.setStatusMessage(
- ("Could not clear db for refresh: " + str(e)), severity=hou.severityType.Warning)
+ (la.ERRORMSG['cleardatabase'] + str(e)), severity=hou.severityType.Warning)
else:
- print("Could not clear db for refresh: " + str(e))
+ print(la.ERRORMSG['cleardatabase'] + str(e))
# !SECTION
def deferaction(action, val):
@@ -327,14 +320,17 @@ def checklasthk(cur):
getlastusedhk(cur)
def main():
- if os.path.isfile(searcher_data.searcher_settings):
- settingdata = searcher_data.loadsettings()
- else:
+ if not os.path.isfile(searcher_data.searcher_settings):
searcher_data.createdefaults()
- settingdata = searcher_data.loadsettings()
+
+ hou.session.SETTINGS = searcher_data.loadsettings()
+ settingdata = get_settings()
+
isdebug = util.Dbug(
- util.bc(settingdata[util.SETTINGS_KEYS[4]]),
- str(settingdata[util.SETTINGS_KEYS[10]])
+ settingdata[util.SETTINGS_KEYS[4]],
+ str(settingdata[util.SETTINGS_KEYS[10]]),
+ settingdata[util.SETTINGS_KEYS[12]],
+ settingdata[util.SETTINGS_KEYS[13]],
)
inmemory = util.bc(settingdata[util.SETTINGS_KEYS[0]])
@@ -348,27 +344,30 @@ def main():
val,
pragmas=(
("cache_size", -1024 * 64),
- ("journal_mode", "wal"),
+ ("journal_mode", "off"),
+ ("temp_store", "memory"),
("synchronous", 0)
)))
+ hou.session.DBCONNECTION = db
+ dbc = get_dbconnection()
time1 = ptime.time()
if inmemory:
- create_tables()
- cur = db.cursor()
- deferaction(initialsetup, cur)
+ create_tables(dbc)
+ cur = dbc.cursor()
+ initialsetup(cur)
else:
if not os.path.isfile(dbpath):
- create_tables()
- cur = db.cursor()
+ create_tables(dbc)
+ cur = dbc.cursor()
deferaction(initialsetup, cur)
else:
- cur = db.cursor()
+ cur = dbc.cursor()
deferaction(dbupdate, cur)
time2 = ptime.time()
- if isdebug and isdebug.level in {"TIMER", "ALL"}:
+ if isdebug and isdebug.level in {"TIMER", "ALL"}:
res = ((time2 - time1) * 1000.0)
if hou.isUIAvailable():
hou.ui.setStatusMessage(
diff --git a/scripts/456.py.bak b/scripts/456.py.bak
deleted file mode 100644
index d98e72a..0000000
--- a/scripts/456.py.bak
+++ /dev/null
@@ -1,329 +0,0 @@
-from __future__ import print_function
-from searcher import searcher_data
-from searcher import util
-
-from peewee import *
-from peewee import SQL
-from playhouse.sqlite_ext import SqliteExtDatabase, FTSModel, SearchField
-# from playhouse.apsw_ext import APSWDatabase
-import inspect
-import threading
-import time
-import hou
-import hdefereval as hd
-import os
-import sys
-
-# info
-__author__ = "instance.id"
-__copyright__ = "2020 All rights reserved. See LICENSE for more details."
-__status__ = "Prototype"
-
-
-current_file_path = os.path.abspath(
- inspect.getsourcefile(lambda: 0)
-)
-
-scriptpath = os.path.dirname(current_file_path)
-dbpath = os.path.join(scriptpath, "python/searcher/db/searcher.db")
-
-# db = SqliteExtDatabase(':memory:')
-db = SqliteExtDatabase(dbpath)
-dbc = None
-settingdata = {}
-isloading = True
-tempkey = ""
-
-class settings(Model):
- id = IntegerField(unique=True)
- indexvalue = IntegerField()
- defaulthotkey = TextField()
- searchdescription = IntegerField()
- searchprefix = IntegerField()
- searchcurrentcontext = IntegerField()
- lastused = TextField()
-
- class Meta:
- table_name = 'settings'
- database = db
-
-
-class hcontext(Model):
- id = AutoField()
- context = CharField(unique=True)
- title = TextField()
- description = TextField()
-
- class Meta:
- table_name = 'hcontext'
- database = db
-
-
-class hotkeys(Model):
- hotkey_symbol = CharField(unique=True)
- label = TextField()
- description = TextField()
- assignments = TextField()
- context = TextField()
-
- class Meta:
- table_name = 'hotkeys'
- database = db
-
-
-class hotkeyindex(FTSModel):
- description = SearchField()
- label = SearchField()
-
- class Meta:
- table_name = 'hotkeyindex'
- database = db
- extension_options = {'tokenize': 'porter',
- 'description': hotkeys.description}
-
-
-def create_tables():
- with db:
- db.create_tables([settings, hcontext, hotkeys])
-
-
-def worker():
- hd.executeInMainThreadWithResult(updatecontext)
-
-
-def py_unique(data):
- return list(set(data))
-
-
-def getdata():
- rval = []
- contextdata = []
- hotkeydata = []
-
- def getcontexts(r, context_symbol, root):
- keys = None
- branches = hou.hotkeys.contextsInContext(context_symbol)
- for branch in branches:
- branch_path = "%s/%s" % (r, branch['label'])
- contextdata.append(
- {'context': branch['symbol'], 'title': branch['label'], 'description': branch['help']})
- commands = hou.hotkeys.commandsInContext(branch['symbol'])
- for command in commands:
- keys = hou.hotkeys.assignments(command['symbol'])
- ctx = command['symbol'].rsplit('.', 1)
- hotkeydata.append(
- {'hotkey_symbol': command['symbol'], 'label': command['label'], 'description': command['help'],
- 'assignments': " ".join(keys), 'context': ctx[0]})
- getcontexts(branch_path, branch['symbol'], root)
-
- getcontexts("", "", rval)
- return contextdata, hotkeydata
-
-
-# ---------------------------------------------------------- Initial Setup
-
-
-def initialsetup(cur):
- currentidx = hou.hotkeys.changeIndex()
- chindex = getchangeindex(cur)
-
- if len(chindex) == 0:
- chindex = int(currentidx)
- updatechangeindex(chindex, True)
- updatedataasync()
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- "Searcher database created", severity=hou.severityType.Message)
- else:
- print("Searcher database created")
- else:
- chindex = int(chindex[0][0])
-
- if int(currentidx) != chindex:
- getlastusedhk(cur)
- updatedataasync()
- updatechangeindex(int(currentidx))
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- "Searcher database created and populated", severity=hou.severityType.Message)
-
-
-def dbupdate(cur):
- currentidx = hou.hotkeys.changeIndex()
- chindex = getchangeindex(cur)
-
- if int(currentidx) != chindex:
- getlastusedhk(cur)
- updatedataasync()
- updatechangeindex(int(currentidx))
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- "Searcher database updated", severity=hou.severityType.Message)
-
-
-def updatedataasync():
- thread = threading.Thread(target=worker)
- thread.daemon = True
- thread.start()
-
-# endregionc
-
-# ---------------------------------------------------------- Retrieve
-
-
-def getchangeindex(cur):
- try:
- cur.execute("SELECT indexvalue FROM settings")
- result = cur.fetchall()
- return result
- except(AttributeError, TypeError) as e:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not get Searcher changeindex: " + str(e)), severity=hou.severityType.Warning)
- else:
- print("Could not get Searcher changeindex: " + str(e))
-
-
-def getlastusedhk(cur):
- try:
- cur.execute("SELECT lastused FROM settings")
- result = cur.fetchall()
- if str(result[0][0]) != "":
- lasthk = str(result[0][0]).split(' ')
- rmresult = hou.hotkeys.removeAssignment(
- str(lasthk[0]).strip(), str(lasthk[1]).strip())
- if rmresult:
- hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
- hou.hotkeys.saveOverrides()
- if len(hkcheck) is 0:
- settings.update(lastused="").where(
- settings.id == 1).execute()
- currentidx = hou.hotkeys.changeIndex()
- updatechangeindex(int(currentidx))
- else:
- hou.hotkeys.clearAssignments(str(lasthk[0]))
- hou.hotkeys.saveOverrides()
- hkcheck = hou.hotkeys.assignments(str(lasthk[0]))
- if len(hkcheck) is 0:
- settings.update(lastused="").where(
- settings.id == 1).execute()
- currentidx = hou.hotkeys.changeIndex()
- updatechangeindex(int(currentidx))
- else:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not clear last assigned temp hotkey on last attempt:"), severity=hou.severityType.Warning)
- else:
- print(
- "Could not clear last assigned temp hotkey on last attempt:")
- else:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not clear last assigned temp hotkey:"), severity=hou.severityType.Warning)
- else:
- print("Could not clear last assigned temp hotkey:")
-
- except(AttributeError, TypeError) as e:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not query last assigned temp hotkey:" + str(e)), severity=hou.severityType.Warning)
- else:
- print("Could not query last assigned temp hotkey: " + str(e))
-
-# ---------------------------------------------------------- Updates
-
-
-def updatechangeindex(indexval, new=False):
- try:
- if new is True:
- defaultkey = ""
- for i in range(len(util.HOTKEYLIST)):
- result = hou.hotkeys.findConflicts("h", util.HOTKEYLIST[i])
- if not result:
- defaultkey = util.HOTKEYLIST[i]
-
- settings.insert(indexvalue=indexval,
- defaulthotkey=defaultkey, searchdescription=0, searchprefix=0, searchcurrentcontext=0, lastused="", id=1).execute()
- else:
- settings.update(indexvalue=indexval).where(
- settings.id == 1).execute()
- except(AttributeError, TypeError) as e:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)),
- severity=hou.severityType.Warning
- )
- else:
- print("Could not update Searcher context database: " + str(e))
-
-
-def updatecontext(debug=False):
- try:
- time1 = time.time()
- cleardatabase()
- ctxdata, hkeydata = getdata()
- with db.atomic():
- for data_dict in ctxdata:
- hcontext.replace_many(data_dict).execute()
- with db.atomic():
- for idx in hkeydata:
- hotkeys.replace_many(idx).execute()
- time2 = time.time()
- if debug:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ('DB update took %0.3f ms' %
- ((time2 - time1) * 1000.0)), severity=hou.severityType.Message)
- else:
- print('DB update took %0.3f ms' %
- ((time2 - time1) * 1000.0)) # TODO Remove this timer
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Warning)
-# endregion
-
-
-def cleardatabase():
- try:
- delhk = "DELETE FROM hotkeys"
- delctx = "DELETE FROM hcontext"
- db.cursor().execute(delhk)
- db.cursor().execute(delctx)
- result = db.cursor().fetchall()
-
- return result
- except(AttributeError, TypeError) as e:
- if hou.isUIAvailable():
- hou.ui.setStatusMessage(
- ("Could not clear db for refresh: " + str(e)), severity=hou.severityType.Warning)
- else:
- print("Could not clear db for refresh: " + str(e))
-
-
-def deferaction(action, val):
- hd.executeDeferred(action, val)
- # hd.execute_deferred_after_waiting(action, 25)
-
-
-def checklasthk(cur):
- getlastusedhk(cur)
-
-
-def main():
- if os.path.isfile(searcher_data.searcher_settings):
- settingdata = searcher_data.loadsettings()
- else:
- searcher_data.createdefaults()
- settingdata = searcher_data.loadsettings()
-
- if not os.path.isfile(dbpath):
- create_tables()
- cur = db.cursor()
- deferaction(initialsetup, cur)
- else:
- cur = db.cursor()
- deferaction(dbupdate, cur)
-
-
-if __name__ == '__main__':
- main()
diff --git a/scripts/python/searcher/database-bak.py b/scripts/python/searcher/database-bak.py
deleted file mode 100644
index f4befc6..0000000
--- a/scripts/python/searcher/database-bak.py
+++ /dev/null
@@ -1,261 +0,0 @@
-# region Imports
-from __future__ import print_function
-from __future__ import absolute_import
-import weakref
-
-import hou
-import os
-
-from searcher import util
-
-
-from peewee import *
-from playhouse.sqlite_ext import SqliteExtDatabase, SearchField, FTSModel
-import time
-
-scriptpath = os.path.dirname(os.path.realpath(__file__))
-db = SqliteExtDatabase(scriptpath + "/db/searcher.db")
-cur = db.cursor()
-
-
-class settings(Model):
- id = IntegerField(unique=True)
- indexvalue = IntegerField()
- defaulthotkey = TextField()
- searchdescription = IntegerField()
- searchprefix = IntegerField()
- searchcurrentcontext = IntegerField()
- lastused = TextField()
-
- class Meta:
- table_name = 'settings'
- database = db
-
-
-class hcontext(Model):
- id = AutoField()
- context = CharField(unique=True)
- title = TextField()
- description = TextField()
-
- class Meta:
- table_name = 'hcontext'
- database = db
-
-
-class hotkeys(Model):
- hotkey_symbol = CharField(unique=True)
- label = TextField()
- description = TextField()
- assignments = TextField()
- context = TextField()
-
- class Meta:
- table_name = 'hotkeys'
- database = db
-
-
-class hotkeyindex(FTSModel):
- description = SearchField()
- label = SearchField()
-
- class Meta:
- table_name = 'hotkeyindex'
- database = db
- options = {'tokenize': 'porter',
- 'description': hotkeys.description}
-
-
-db.create_tables([settings, hcontext, hotkeys])
-
-
-def py_unique(data):
- return list(set(data))
-
-
-def getdata():
- rval = []
- contextdata = []
- hotkeydata = []
-
- def getcontexts(r, context_symbol, root):
- keys = None
- branches = hou.hotkeys.contextsInContext(context_symbol)
- for branch in branches:
- branch_path = "%s/%s" % (r, branch['label'])
- contextdata.append(
- {'context': branch['symbol'], 'title': branch['label'], 'description': branch['help']})
- commands = hou.hotkeys.commandsInContext(branch['symbol'])
- for command in commands:
- keys = hou.hotkeys.assignments(command['symbol'])
- ctx = command['symbol'].rsplit('.', 1)
- hotkeydata.append(
- {'hotkey_symbol': command['symbol'], 'label': command['label'], 'description': command['help'],
- 'assignments': " ".join(keys), 'context': ctx[0]})
- getcontexts(branch_path, branch['symbol'], root)
-
- getcontexts("", "", rval)
- return contextdata, hotkeydata
-
-
-class Databases(object):
- def __init__(self):
- self.a = 1
- # self.settingdata = settings
- # if self.settingdata[0]:
- # db = SqliteExtDatabase(':memory:')
-
- # ---------------------------------------------------------- Retrieve
- def getchangeindex(self):
- try:
- cur.execute("SELECT indexvalue FROM settings")
- result = cur.fetchall()
- return result
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not get Searcher changeindex: " + str(e)), severity=hou.severityType.Error)
-
- def getdefhotkey(self):
- try:
- cur.execute("SELECT defaulthotkey FROM settings")
- result = cur.fetchall()
- return result
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not get Searcher default hotkey: " + str(e)), severity=hou.severityType.Error)
-
- def gethcontexts(self):
- try:
- cur.execute("SELECT * FROM hcontext")
- result = cur.fetchall()
- return result
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not get Searcher hcontext: " + str(e)), severity=hou.severityType.Error)
-
- def gethcontextod(self, inputlist):
- try:
- result = []
- query = (hcontext
- .select()
- .where(hcontext.context.in_(inputlist))).execute()
- for hctx in query:
- result.append((hctx.title, hctx.description, hctx.context))
- uniqueresult = py_unique(result)
- return uniqueresult
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Error)
-
- def ctxfilterresults(self, inputTerm):
- try:
- result = []
- query = (hotkeys
- .select()
- .where(hotkeys.context.in_(inputTerm))).execute()
- for hctx in query:
- result.append((hctx.label, hctx.description,
- hctx.assignments, hctx.hotkey_symbol, hctx.context))
- uniqueresult = py_unique(result)
- return uniqueresult
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not get Searcher context results: " + str(e)), severity=hou.severityType.Error)
-
- def searchresults(self, inputTerm):
- try:
- cur.execute(
- "SELECT label, description, assignments, hotkey_symbol, context FROM hotkeys WHERE label LIKE '%"
- + str(inputTerm)
- + "%' OR description LIKE '%"
- + str(inputTerm)
- + "%' LIMIT 25"
- )
- result = cur.fetchall()
- uniqueresult = py_unique(result)
- return uniqueresult
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not get Searcher results: " + str(e)), severity=hou.severityType.Error)
- # endregion
-
- # ---------------------------------------------------------- Updates
-
- def updatechangeindex(self, indexval, new=False):
- try:
- if new is True:
- defaultkey = (u"Ctrl+Alt+Shift+F7")
- settings.insert(indexvalue=indexval,
- defaulthotkey=defaultkey, searchdescription=0, searchprefix=0, searchcurrentcontext=0, id=1).execute()
- else:
- settings.update(indexvalue=indexval).where(
- settings.id == 1).execute()
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)),
- severity=hou.severityType.Error
- )
-
- def updatetmphk(self, tmpkey):
- try:
- _ = settings.update(
- defaulthotkey=tmpkey).where(id == 1).execute()
- return
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher temp hotkey: " + str(e)), severity=hou.severityType.Error)
-
- def updatelastkey(self, lastkey):
- try:
- _ = settings.update(
- lastused=lastkey).where(id == 1).execute()
- return
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher temp hotkey: " + str(e)), severity=hou.severityType.Error)
-
- def updatecontext(self, debug=None):
- try:
- time1 = time.time()
- self.cleardatabase()
- ctxdata, hkeydata = getdata()
- with db.atomic():
- for data_dict in ctxdata:
- hcontext.replace_many(data_dict).execute()
- with db.atomic():
- for idx in hkeydata:
- hotkeys.replace_many(idx).execute()
- time2 = time.time()
- if debug:
- hou.ui.setStatusMessage(
- ('DB update took %0.3f ms' %
- ((time2 - time1) * 1000.0)), severity=hou.severityType.Message)
- print('DB update took %0.3f ms' %
- ((time2 - time1) * 1000.0)) # TODO Remove this timer
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher context database: " + str(e)), severity=hou.severityType.Error)
-
- # with db.atomic():
- # for idx in range(0, len(ctxdata), 100):
- # hcontext.replace_many(ctxdata[idx:idx+100]).execute()
- # with db.atomic():
- # for idx in range(0, len(hkeydata), 100):
- # hotkeys.replace_many(hkeydata[idx:idx+100]).execute()
-
- # endregion
-
- def cleardatabase(self):
- try:
- delhk = "DELETE FROM hotkeys"
- delctx = "DELETE FROM hcontext"
- cur.execute(delhk)
- cur.execute(delctx)
- result = cur.fetchall()
-
- return result
- except(AttributeError, TypeError) as e:
- hou.ui.setStatusMessage(
- ("Could not update Searcher temp hotkey: " + str(e)),
- severity=hou.severityType.Error
- )
diff --git a/scripts/python/searcher/language_en.py b/scripts/python/searcher/language_en.py
deleted file mode 100644
index 5cff590..0000000
--- a/scripts/python/searcher/language_en.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# SECTION Language US
-language = "en"
-
-# NOTE Tooltips
-ln_searchbox = "Begin typing to search or click magnifying glass icon to display options"
-ln_contexttoggle = "Toggle to enable or disable the 'context' column in the search results"
-ln_pinwindow = "Pin the search window to keep it from closing automatically when losing focus"
-ln_searchfilter = "Select a predefined filter"
-ln_opensettingstool = "General application settings"
-ln_searchresultstree = "Press tab to highlight or double click an action to attempt to perform it. Some actions only work in specific contexts"
-ln_helppanel = "Open help panel"
-
-# NOTE Tooltops Settings
-TT_SETTINGS = {
- "about_btn": "Thanks for using Searcher!",
- "projectTitle" : "Thanks for using Searcher!",
- "lang_cbox" : "When translations become available they can be selected here",
- "inmemory_chk" : "Enable to use an im-memory database instead of SQLite file",
- "windowsize_chk" : "Enable to save the size and location of the main window upon closing. Defaults to center (1000px, 600px)",
- "maxresults_lbl" : "Maximum results to load per query as you type your search term",
- "maxresults_txt" : "Maximum results to load per query as you type your search term",
- "animatedsettings_chk" : "Enables animated menus",
- "dbpath_icon": "",
- "dbpath_lbl" : "The location in which Searcher stores it's database file",
- "databasepath_txt" : "The location in which Searcher stores it's database file",
- "defaulthotkey_lbl" : ("If left to the default value of (Ctrl+Alt+Shift+F7), "
- "in the event that Searcher detects a conflict it will "
- "automatically attempt to try different key combinations."),
- "defaulthotkey_txt" : ("If left to the default value of (Ctrl+Alt+Shift+F7), "
- "in the event that Searcher detects a conflict it will "
- "automatically attempt to try different key combinations."),
- "cleardata_btn" : "If, for some reason, Searcher is having issues this function will clear out the database and start fresh",
- "save_btn" : "Save your settings",
- "discard_btn" : "Disgard settings changes",
- "debugflag_chk": "Toggle debug messages",
- "debuglevel_cbx": "Select level of debugging",
-}
-# !SECTION
diff --git a/scripts/python/searcher/searcher_settings_bak.py b/scripts/python/searcher/searcher_settings_bak.py
deleted file mode 100644
index 53e2cbf..0000000
--- a/scripts/python/searcher/searcher_settings_bak.py
+++ /dev/null
@@ -1,297 +0,0 @@
-from __future__ import division
-from __future__ import print_function
-from __future__ import absolute_import
-
-from searcher import searcher_data
-from searcher import util
-
-from builtins import range
-from past.utils import old_div
-import platform
-import os
-
-import sys
-import hou
-import hdefereval
-from hutil import py23
-hver = 0
-if os.environ["HFS"] != "":
- ver = os.environ["HFS"]
- hver = int(ver[ver.rindex('.')+1:])
- from hutil.Qt import QtGui
- from hutil.Qt import QtCore
- from hutil.Qt import QtWidgets
- if hver >= 395:
- from hutil.Qt import QtUiTools
- elif hver <= 394 and hver >= 391:
- from hutil.Qt import _QtUiTools
- elif hver < 391 and hver >= 348:
- from hutil.Qt import QtUiTools
-
-
-# -------------------------------------------------------------------- App Info
-__package__ = "Searcher"
-__version__ = "0.1b"
-__author__ = "instance.id"
-__copyright__ = "2020 All rights reserved. See LICENSE for more details."
-__status__ = "Prototype"
-# endregion
-
-the_scaled_icon_size = hou.ui.scaledSize(16)
-the_icon_size = 16
-
-num = 0
-# info
-__author__ = "instance.id"
-__copyright__ = "2020 All rights reserved."
-__status__ = "Prototype"
-
-scriptpath = os.path.dirname(os.path.realpath(__file__))
-
-
-def bc(v):
- return str(v).lower() in ("yes", "true", "t", "1")
-
-
-class SearcherSettings(QtWidgets.QWidget):
- """ Searcher Settings and Debug Menu"""
-
- def __init__(self, handler, tmphotkey, parent=None):
- super(SearcherSettings, self).__init__(parent=parent)
-
- # ------------------------------------------------- Component variables
- self.settings = {}
- self.context_dict = {}
- self.command_dict = {}
- self.contexts = None
- self.commands = None
- self.addKeyWidget = None
- self.context_data = None
- self.command_data = None
- self.keys_changed = False
- self.keystring = ""
- self.keyindex = 0
- self.canedit = False
- self.KeySequence = None
- self.hkholder = ""
- self.defaulthotkey = tmphotkey
- self.datahandler = handler
- self.tmphotkey = tmphotkey
-
- self.setObjectName('searcher-settings')
- # ------------------------------------------------- Build UI
- self.setAutoFillBackground(True)
- self.setBackgroundRole(QtGui.QPalette.Window)
- self.settings = searcher_data.loadsettings()
- self.isdebug = bc(self.settings[util.SETTINGS_KEYS[4]])
-
- # Load UI File
- loader = None
- if int(hver) >= 391 and int(hver) <= 394:
- loader = _QtUiTools.QUiLoader()
- else:
- loader = QtUiTools.QUiLoader()
- self.ui = loader.load(scriptpath + '/searchersettings.ui')
-
- # Get UI Elements
- self.hotkey_icon = self.ui.findChild(
- QtWidgets.QToolButton,
- "hotkey_icon"
- )
- self.debugflag = self.ui.findChild(
- QtWidgets.QCheckBox,
- "debugflag_chk"
- )
- self.in_memory_db = self.ui.findChild(
- QtWidgets.QCheckBox,
- "inmemory_chk"
- )
- self.savewindowsize = self.ui.findChild(
- QtWidgets.QCheckBox,
- "windowsize_chk"
- )
- self.defaulthotkey = self.ui.findChild(
- QtWidgets.QLineEdit,
- "defaulthotkey_txt"
- )
- self.database_path = self.ui.findChild(
- QtWidgets.QLineEdit,
- "databasepath_txt"
- )
- self.test1 = self.ui.findChild(
- QtWidgets.QPushButton,
- "test1_btn"
- )
- self.cleardata = self.ui.findChild(
- QtWidgets.QPushButton,
- "cleardata_btn"
- )
- self.savedata = self.ui.findChild(
- QtWidgets.QPushButton,
- "save_btn"
- )
- self.discarddata = self.ui.findChild(
- QtWidgets.QPushButton,
- "discard_btn"
- )
-
- mainlayout = QtWidgets.QVBoxLayout()
- mainlayout.addWidget(self.ui)
-
- # ------------------------------------------------- Create Connections
- # self.in_memory_db.stateChanged.connect(self.toggledebug)
- self.hotkey_icon.clicked.connect(self.hotkeyicon_cb)
- self.hotkey_icon.setIcon(util.INFO_ICON)
- info_button_size = hou.ui.scaledSize(16)
- self.hotkey_icon.setProperty("flat", True)
- self.hotkey_icon.setIcon(util.INFO_ICON)
- self.hotkey_icon.setIconSize(QtCore.QSize(
- info_button_size,
- info_button_size
- ))
-
- self.defaulthotkey.setText(self.tmphotkey)
- self.defaulthotkey.setStatusTip("Status Tip?")
- self.defaulthotkey.setWhatsThis("Whats this?")
- # self.defaulthotkey.setToolTip(
- # "If left to the default value of (Ctrl+Alt+Shift+F7), in the event that Searcher detects a conflict it will automatically attempt to try different key combinations.")
- self.defaulthotkey.setStyleSheet(util.TOOLTIP)
- self.database_path.setText(str(self.settings['database_path']))
- self.test1.clicked.connect(self.test1_cb)
- self.cleardata.clicked.connect(self.cleardata_cb)
- self.savedata.clicked.connect(self.save_cb)
- self.discarddata.clicked.connect(self.discard_cb)
-
- # ------------------------------------------------- Apply Layout
- self.setLayout(mainlayout)
- self.installEventFilter(self)
-
- self.debugflag.setChecked(bc(self.settings[util.SETTINGS_KEYS[4]]))
- self.debugflag.setVisible(bc(self.settings[util.SETTINGS_KEYS[4]]))
- self.in_memory_db.setChecked(bc(self.settings[util.SETTINGS_KEYS[0]]))
- self.savewindowsize.setChecked(
- bc(self.settings[util.SETTINGS_KEYS[2]]))
-
- # ------------------------------------------------- Add EventFilters
- self.defaulthotkey.installEventFilter(self)
- self.debugflag.installEventFilter(self)
-
- # ----------------------------------------------------------------------------------- Callbacks
- def hotkeyicon_cb(self):
- self.settings['in_memory_db'] = self.in_memory_db.isChecked()
- print(self.settings['in_memory_db'])
-
- def toggledebug(self):
- self.settings['in_memory_db'] = self.in_memory_db.isChecked()
- print(self.settings['in_memory_db'])
-
- def defaulthk_cb(self):
- return
-
- def test1_cb(self):
- hkeys = []
- for i in range(len(util.HOTKEYLIST)):
- result = hou.hotkeys.findConflicts("h", util.HOTKEYLIST[i])
- if result:
- print ("Confliction found: {}".format(result))
- else:
- print("No Confliction: {}".format(result))
- hkeys.append(result)
- print (hkeys)
-
- def cleardata_cb(self):
- self.datahandler.cleardb()
-
- def save_cb(self):
- if self.defaulthotkey.text() == "":
- buttonindex = hou.ui.displayMessage("Please enter a hotkey")
- self.activateWindow()
- self.defaulthotkey.setFocus()
- self.canedit = True
- else:
- if self.defaulthotkey.text() != self.tmphotkey:
- self.tmphotkey = self.defaulthotkey.text()
- self.datahandler.updatetmphotkey(self.tmphotkey)
-
- for i in range(len(util.SETTINGS_KEYS)):
- if util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "bool":
- self.settings[util.SETTINGS_KEYS[i]] = getattr(
- self, util.SETTINGS_KEYS[i]).isChecked()
- elif util.SETTINGS_TYPES[util.SETTINGS_KEYS[i]] == "text":
- self.settings[util.SETTINGS_KEYS[i]] = getattr(
- self, util.SETTINGS_KEYS[i]).text()
-
- if self.isdebug:
- print(self.settings)
-
- searcher_data.savesettings(self.settings)
- self.close()
-
- def discard_cb(self):
- self.defaulthotkey.setText(self.tmphotkey)
- self.hkholder = ""
- self.close()
-
- # ----------------------------------------------------------------------------------- Actions
- def savecheck(self):
- buttonindex = hou.ui.displayMessage(
- "Save changes?", buttons=('Save', 'Discard'), default_choice=0, title="Unsaved Changes:",)
- if buttonindex == 0:
- self.tmphotkey = self.defaulthotkey.text()
- self.datahandler.updatetmphotkey(self.tmphotkey)
- self.hkholder = ""
- elif buttonindex == 1:
- self.defaulthotkey.setText(self.hkholder)
- self.hkholder = ""
-
- # ----------------------------------------------------------------------------------- Events
- def eventFilter(self, obj, event):
- # ------------------------------------------------- Mouse
- if event.type() == QtCore.QEvent.MouseButtonDblClick:
- self.hkholder = self.defaulthotkey.text()
- self.defaulthotkey.setText("")
- self.defaulthotkey.setPlaceholderText("Input key sequence")
- self.canedit = True
- # ------------------------------------------------- Keypress
- if event.type() == QtCore.QEvent.KeyPress:
- if event.key() == QtCore.Qt.Key_D:
- if not self.debugflag.isVisible():
- self.debugflag.setVisible(True)
-
- if event.key() == QtCore.Qt.Key_Escape:
- if self.canedit is False:
- self.close()
- else:
- self.keyindex += 1
- self.keystring = hou.qt.qtKeyToString(
- event.key(),
- int(event.modifiers()),
- event.text()
- )
- if self.canedit:
- if self.keystring not in ["Esc", "Backspace"]:
- if self.defaulthotkey.hasFocus():
- self.KeySequence = QtGui.QKeySequence(
- self.keystring).toString()
- self.defaulthotkey.setText(self.KeySequence)
- if self.keystring in ["Esc", "Backspace"]:
- self.defaulthotkey.setText(self.hkholder)
-
- # ------------------------------------------------- Keyrelease
- if event.type() == QtCore.QEvent.KeyRelease:
- if event.key() == QtCore.Qt.Key_Escape:
- return QtCore.QObject.eventFilter(self, obj, event)
- else:
- self.keyindex -= 1
- if self.keyindex == 0:
- if self.defaulthotkey.text() == "":
- self.defaulthotkey.setText(self.hkholder)
- if self.defaulthotkey.text() != "":
- self.canedit = False
-
- # ------------------------------------------------- Close
- if event.type() == QtCore.QEvent.Close:
- if self.canedit is False and self.hkholder != "":
- self.savecheck()
-
- return QtCore.QObject.eventFilter(self, obj, event)
diff --git a/toolbar/searcher.shelf b/toolbar/searcher.shelf
index 89bfadd..a50cac1 100644
--- a/toolbar/searcher.shelf
+++ b/toolbar/searcher.shelf
@@ -6,7 +6,9 @@
a single file. -->
-