furter corrections
This commit is contained in:
parent
1859382302
commit
fd0500382c
43
InitGui.py
43
InitGui.py
|
@ -1,9 +1,9 @@
|
|||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
|
||||
from PySide6.QtWidgets import QWidgetAction, QToolBar, QMainWindow, QWidget, QDialog
|
||||
from PySide6.QtGui import QCursor, QShortcut, QKeySequence, QAction
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide.QtWidgets import QWidgetAction, QToolBar, QMainWindow, QWidget, QDialog
|
||||
from PySide.QtGui import QCursor, QShortcut, QKeySequence, QAction
|
||||
from PySide.QtCore import Qt
|
||||
|
||||
# Avoid garbage collection by storing the action in a global variable
|
||||
wax = None
|
||||
|
@ -26,6 +26,7 @@ def addToolSearchBox():
|
|||
global wax, sea, tbr
|
||||
mw = Gui.getMainWindow()
|
||||
import SearchBox
|
||||
from PySide.QtWidgets import QToolBar
|
||||
|
||||
if mw:
|
||||
if sea is None:
|
||||
|
@ -65,41 +66,5 @@ def AddPointerBox():
|
|||
return
|
||||
|
||||
|
||||
def SearchBoxFunction():
|
||||
import SearchBoxLight
|
||||
|
||||
global wax, sea, tbr
|
||||
mw = Gui.getMainWindow()
|
||||
|
||||
if mw:
|
||||
if sea is None:
|
||||
sea = SearchBoxLight.SearchBoxLight(
|
||||
getItemGroups=lambda: __import__("GetItemGroups").getItemGroups(),
|
||||
getToolTip=lambda groupId, setParent: __import__("GetItemGroups").getToolTip(groupId, setParent),
|
||||
getItemDelegate=lambda: __import__("IndentedItemDelegate").IndentedItemDelegate(),
|
||||
)
|
||||
sea.resultSelected.connect(
|
||||
lambda index, groupId: __import__("GetItemGroups").onResultSelected(index, groupId)
|
||||
)
|
||||
|
||||
if wax is None:
|
||||
wax = QWidgetAction(None)
|
||||
wax.setWhatsThis(
|
||||
translate(
|
||||
"SearchBar",
|
||||
"Use this search bar to find tools, document objects, preferences and more",
|
||||
)
|
||||
)
|
||||
|
||||
sea.setWhatsThis(
|
||||
translate(
|
||||
"SearchBar",
|
||||
"Use this search bar to find tools, document objects, preferences and more",
|
||||
)
|
||||
)
|
||||
wax.setDefaultWidget(sea)
|
||||
return wax
|
||||
|
||||
|
||||
addToolSearchBox()
|
||||
Gui.getMainWindow().workbenchActivated.connect(addToolSearchBox)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import StyleMapping
|
||||
|
||||
# Define the translation
|
||||
|
@ -7,10 +8,10 @@ translate = App.Qt.translate
|
|||
|
||||
|
||||
def loadAllWorkbenches():
|
||||
import FreeCADGui as Gui
|
||||
from PySide.QtGui import QLabel
|
||||
from PySide.QtCore import Qt, SIGNAL, Signal, QObject, QThread, QSize
|
||||
from PySide.QtGui import QIcon, QPixmap, QAction, QGuiApplication
|
||||
import FreeCADGui as Gui
|
||||
|
||||
activeWorkbench = Gui.activeWorkbench().name()
|
||||
lbl = QLabel(translate("SearchBar", "Loading workbench … (…/…)"))
|
||||
|
@ -19,11 +20,11 @@ def loadAllWorkbenches():
|
|||
# Get the stylesheet from the main window and use it for this form
|
||||
lbl.setStyleSheet("background-color: " + StyleMapping.ReturnStyleItem("Background_Color") + ";")
|
||||
|
||||
# Get the main window from FreeCAD
|
||||
mw = Gui.getMainWindow()
|
||||
# Center the widget
|
||||
cp = QGuiApplication.screenAt(mw.pos()).geometry().center()
|
||||
lbl.move(cp)
|
||||
# # Get the main window from FreeCAD
|
||||
# mw = Gui.getMainWindow()
|
||||
# # Center the widget
|
||||
# cp = QGuiApplication.screenAt(mw.pos()).geometry().center()
|
||||
# lbl.move(cp)
|
||||
|
||||
lbl.show()
|
||||
lst = Gui.listWorkbenches()
|
||||
|
|
41
SearchBox.py
41
SearchBox.py
|
@ -49,6 +49,11 @@ globalIgnoreFocusOut = False
|
|||
# Define the translation
|
||||
translate = App.Qt.translate
|
||||
|
||||
# Avoid garbage collection by storing the action in a global variable
|
||||
wax = None
|
||||
sea = None
|
||||
tbr = None
|
||||
|
||||
|
||||
def easyToolTipWidget(html):
|
||||
foo = QTextEdit()
|
||||
|
@ -58,6 +63,42 @@ def easyToolTipWidget(html):
|
|||
return foo
|
||||
|
||||
|
||||
def SearchBoxFunction():
|
||||
import SearchBoxLight
|
||||
|
||||
global wax, sea, tbr
|
||||
mw = Gui.getMainWindow()
|
||||
|
||||
if mw:
|
||||
if sea is None:
|
||||
sea = SearchBoxLight.SearchBoxLight(
|
||||
getItemGroups=lambda: __import__("GetItemGroups").getItemGroups(),
|
||||
getToolTip=lambda groupId, setParent: __import__("GetItemGroups").getToolTip(groupId, setParent),
|
||||
getItemDelegate=lambda: __import__("IndentedItemDelegate").IndentedItemDelegate(),
|
||||
)
|
||||
sea.resultSelected.connect(
|
||||
lambda index, groupId: __import__("GetItemGroups").onResultSelected(index, groupId)
|
||||
)
|
||||
|
||||
if wax is None:
|
||||
wax = QWidgetAction(None)
|
||||
wax.setWhatsThis(
|
||||
translate(
|
||||
"SearchBar",
|
||||
"Use this search bar to find tools, document objects, preferences and more",
|
||||
)
|
||||
)
|
||||
|
||||
sea.setWhatsThis(
|
||||
translate(
|
||||
"SearchBar",
|
||||
"Use this search bar to find tools, document objects, preferences and more",
|
||||
)
|
||||
)
|
||||
wax.setDefaultWidget(sea)
|
||||
return wax
|
||||
|
||||
|
||||
class SearchBox(QLineEdit):
|
||||
# The following block of code is present in the lightweight proxy SearchBoxLight
|
||||
"""
|
||||
|
|
|
@ -91,105 +91,6 @@ def ReturnStyleItem(ControlName, ShowCustomIcon=False, IgnoreOverlay=False):
|
|||
return None
|
||||
|
||||
|
||||
def ReturnStyleSheet(control, radius="2px", padding_right="0px", padding_bottom="0px", width="16px"):
|
||||
"""
|
||||
Enter one of the names below:
|
||||
|
||||
control (string):
|
||||
toolbutton,
|
||||
toolbuttonLarge,
|
||||
applicationbutton,
|
||||
"""
|
||||
StyleSheet = ""
|
||||
try:
|
||||
BorderColor = ReturnStyleItem("Border_Color")
|
||||
BackgroundColor = ReturnStyleItem("Background_Color")
|
||||
ApplicationButton = ReturnStyleItem("ApplicationButton_Background")
|
||||
HoverColor = ReturnStyleItem("Background_Color_Hover")
|
||||
FontColor = ReturnStyleItem("FontColor")
|
||||
|
||||
AppColor_1 = ApplicationButton
|
||||
AppColor_2 = ApplicationButton
|
||||
AppColor_3 = ApplicationButton
|
||||
AppBorder_1 = BorderColor
|
||||
AppBorder_2 = BorderColor
|
||||
if BackgroundColor is not None and BorderColor is not None:
|
||||
if control.lower() == "toolbutton":
|
||||
if Parameters_Ribbon.BORDER_TRANSPARANT is True:
|
||||
BorderColor = BackgroundColor
|
||||
StyleSheet = (
|
||||
"""QLayout {spacing: 0px}"""
|
||||
+ """QToolButton, QTextEdit {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
color: """
|
||||
+ FontColor
|
||||
+ """;background: """
|
||||
+ BackgroundColor
|
||||
+ """;padding-bottom: """
|
||||
+ padding_bottom
|
||||
+ """;padding-right: """
|
||||
+ padding_right
|
||||
+ """;padding-left: 0px;
|
||||
spacing: 0px;}"""
|
||||
+ """QToolButton::menu-arrow {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: center right;
|
||||
}"""
|
||||
+ """QToolButton::menu-button {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: """
|
||||
+ width
|
||||
+ """;
|
||||
border-radius: """
|
||||
+ radius
|
||||
+ """px;"""
|
||||
+ """padding: 0px;
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: center right;
|
||||
}"""
|
||||
+ """QToolButton:hover, QTextEdit:hover {
|
||||
margin: 0px 0px 0px 0px;
|
||||
padding: 0px;
|
||||
border: none;
|
||||
background: """
|
||||
+ HoverColor
|
||||
+ """;padding-bottom: """
|
||||
+ padding_bottom
|
||||
+ """;padding-right: """
|
||||
+ padding_right
|
||||
+ """;border: 0.5px solid"""
|
||||
+ BorderColor
|
||||
+ """;}"""
|
||||
)
|
||||
return StyleSheet
|
||||
if control.lower() == "applicationbutton":
|
||||
StyleSheet = (
|
||||
"""QToolButton {
|
||||
border-radius : """
|
||||
+ radius
|
||||
+ """;padding-right: """
|
||||
+ padding_right
|
||||
+ """;background-color: """
|
||||
+ AppColor_1
|
||||
+ """;border: 0.5px solid"""
|
||||
+ BorderColor
|
||||
+ """;}"""
|
||||
+ """QToolButton:hover { """
|
||||
+ """border: 2px solid"""
|
||||
+ BorderColor
|
||||
+ """;border-radius : """
|
||||
+ radius
|
||||
+ """;}"""
|
||||
)
|
||||
|
||||
return StyleSheet
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return StyleSheet
|
||||
|
||||
|
||||
def ReturnColor(ColorType="Background_Color"):
|
||||
mw: QMainWindow = Gui.getMainWindow()
|
||||
palette = mw.style().standardPalette()
|
||||
|
|
Loading…
Reference in New Issue
Block a user