Added Parameters_SearchBar.py for parametes across the addon
This commit is contained in:
parent
53ed074ba5
commit
38b68fe3d7
80
Parameters_SearchBar.py
Normal file
80
Parameters_SearchBar.py
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
import FreeCAD as App
|
||||||
|
import FreeCADGui as Gui
|
||||||
|
from PySide.QtGui import QColor
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Define the translation
|
||||||
|
translate = App.Qt.translate
|
||||||
|
|
||||||
|
preferences = App.ParamGet("User parameter:BaseApp/Preferences/Mod/FreeCAD-Ribbon")
|
||||||
|
|
||||||
|
|
||||||
|
class Settings:
|
||||||
|
|
||||||
|
# region -- Functions to read the settings from the FreeCAD Parameters
|
||||||
|
# and make sure that a None type result is ""
|
||||||
|
def GetStringSetting(settingName: str) -> str:
|
||||||
|
result = preferences.GetString(settingName)
|
||||||
|
|
||||||
|
if result.lower() == "none":
|
||||||
|
result = ""
|
||||||
|
return result
|
||||||
|
|
||||||
|
def GetIntSetting(settingName: str) -> int:
|
||||||
|
result = preferences.GetInt(settingName)
|
||||||
|
if result == "":
|
||||||
|
result = None
|
||||||
|
return result
|
||||||
|
|
||||||
|
def GetFloatSetting(settingName: str) -> int:
|
||||||
|
result = preferences.GetFloat(settingName)
|
||||||
|
if result == "":
|
||||||
|
result = None
|
||||||
|
return result
|
||||||
|
|
||||||
|
def GetBoolSetting(settingName: str) -> bool:
|
||||||
|
result = preferences.GetBool(settingName)
|
||||||
|
if str(result).lower() == "none":
|
||||||
|
result = False
|
||||||
|
return result
|
||||||
|
|
||||||
|
def GetColorSetting(settingName: str) -> object:
|
||||||
|
# Create a tuple from the int value of the color
|
||||||
|
result = QColor.fromRgba(preferences.GetUnsigned(settingName)).toTuple()
|
||||||
|
|
||||||
|
# correct the order of the tuple and divide them by 255
|
||||||
|
result = (result[3] / 255, result[0] / 255, result[1] / 255, result[2] / 255)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|
||||||
|
# region - Functions to write settings to the FreeCAD Parameters
|
||||||
|
#
|
||||||
|
#
|
||||||
|
def SetStringSetting(settingName: str, value: str):
|
||||||
|
if value.lower() == "none":
|
||||||
|
value = ""
|
||||||
|
preferences.SetString(settingName, value)
|
||||||
|
return
|
||||||
|
|
||||||
|
def SetBoolSetting(settingName: str, value):
|
||||||
|
if str(value).lower() == "true":
|
||||||
|
Bool = True
|
||||||
|
if str(value).lower() == "none" or str(value).lower() != "true":
|
||||||
|
Bool = False
|
||||||
|
preferences.SetBool(settingName, Bool)
|
||||||
|
return
|
||||||
|
|
||||||
|
def SetIntSetting(settingName: str, value: int):
|
||||||
|
if str(value).lower() != "":
|
||||||
|
preferences.SetInt(settingName, value)
|
||||||
|
|
||||||
|
|
||||||
|
# region - Define the resources ----------------------------------------------------------------------------------------
|
||||||
|
ICON_LOCATION = os.path.join(os.path.dirname(__file__), "Resources", "Icons")
|
||||||
|
# endregion ------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# The pixmap for the general tool icon
|
||||||
|
genericToolIcon_Pixmap = os.path.join(ICON_LOCATION, "Tango-Tools-spanner-hammer.svg")
|
|
@ -3,11 +3,9 @@ import FreeCAD as App
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
from PySide import QtGui
|
from PySide import QtGui
|
||||||
import Serialize_SearchBar
|
import Serialize_SearchBar
|
||||||
import path
|
import Parameters_SearchBar as Parameters
|
||||||
|
|
||||||
ICON_LOCATION = os.path.join(os.path.dirname(__file__), "Resources", "Icons")
|
genericToolIcon = QtGui.QIcon(QtGui.QIcon(Parameters.genericToolIcon_Pixmap))
|
||||||
|
|
||||||
genericToolIcon = QtGui.QIcon(QtGui.QIcon(os.path.join(ICON_LOCATION, "Tango-Tools-spanner-hammer.svg")))
|
|
||||||
|
|
||||||
|
|
||||||
def getParam(grpPath, type_, name):
|
def getParam(grpPath, type_, name):
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import os
|
import os
|
||||||
from PySide import QtGui
|
from PySide import QtGui
|
||||||
import Serialize_SearchBar
|
import Serialize_SearchBar
|
||||||
|
import Parameters_SearchBar as Parameters
|
||||||
|
|
||||||
|
genericToolIcon = QtGui.QIcon(QtGui.QIcon(Parameters.genericToolIcon_Pixmap))
|
||||||
|
|
||||||
|
|
||||||
def refreshToolsAction(nfo):
|
def refreshToolsAction(nfo):
|
||||||
|
@ -16,9 +19,6 @@ def refreshToolsToolTip(nfo, setParent):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
genericToolIcon = QtGui.QIcon(QtGui.QIcon(os.path.dirname(__file__) + "/Tango-Tools-spanner-hammer.svg"))
|
|
||||||
|
|
||||||
|
|
||||||
def refreshToolsResultsProvider():
|
def refreshToolsResultsProvider():
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,11 +3,12 @@ from PySide import QtGui
|
||||||
from PySide import QtCore
|
from PySide import QtCore
|
||||||
import FreeCADGui # just used for FreeCADGui.updateGui()
|
import FreeCADGui # just used for FreeCADGui.updateGui()
|
||||||
from SearchBoxLight import SearchBoxLight
|
from SearchBoxLight import SearchBoxLight
|
||||||
|
import Parameters_SearchBar as Parameters
|
||||||
|
|
||||||
|
genericToolIcon = QtGui.QIcon(QtGui.QIcon(Parameters.genericToolIcon_Pixmap))
|
||||||
|
|
||||||
globalIgnoreFocusOut = False
|
globalIgnoreFocusOut = False
|
||||||
|
|
||||||
genericToolIcon = QtGui.QIcon(QtGui.QIcon(os.path.dirname(__file__) + "/Tango-Tools-spanner-hammer.svg"))
|
|
||||||
|
|
||||||
|
|
||||||
def easyToolTipWidget(html):
|
def easyToolTipWidget(html):
|
||||||
foo = QtGui.QTextEdit()
|
foo = QtGui.QTextEdit()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user