-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
59 lines (50 loc) · 1.86 KB
/
Copy pathutils.py
File metadata and controls
59 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- encoding: utf-8 -*-
"""
Module with some helper functions
"""
from nodeeditor import _QT_API_NAME as QT_API
from qtpy.QtCore import QFile
from qtpy.QtWidgets import QApplication
from nodeeditor.utils_no_qt import pp, dumpException
def loadStylesheet(filename: str):
"""
Loads an qss stylesheet to the current QApplication instance
:param filename: Filename of qss stylesheet
:type filename: str
"""
print('STYLE loading:', filename)
file = QFile(filename)
file.open(QFile.ReadOnly | QFile.Text)
stylesheet = file.readAll()
QApplication.instance().setStyleSheet(str(stylesheet, encoding='utf-8'))
def loadStylesheets(*args):
"""
Loads multiple qss stylesheets. Concatenates them together and applies the final stylesheet to the current QApplication instance
:param args: variable number of filenames of qss stylesheets
:type args: str, str,...
"""
res = ''
for arg in args:
file = QFile(arg)
file.open(QFile.ReadOnly | QFile.Text)
stylesheet = file.readAll()
res += "\n" + str(stylesheet, encoding='utf-8')
QApplication.instance().setStyleSheet(res)
def isCTRLPressed(event):
from qtpy.QtCore import Qt
if QT_API in ("pyqt5", "pyside2"):
return event.modifiers() & Qt.CTRL
if QT_API in ("pyqt6", "pyside6"):
return event.modifiers() & Qt.KeyboardModifier.ControlModifier
def isSHIFTPressed(event):
from qtpy.QtCore import Qt
if QT_API in ("pyqt5", "pyside2"):
return event.modifiers() & Qt.SHIFT
if QT_API in ("pyqt6", "pyside6"):
return event.modifiers() & Qt.KeyboardModifier.ShiftModifier
def isALTPressed(event):
from qtpy.QtCore import Qt
if QT_API in ("pyqt5", "pyside2"):
return event.modifiers() & Qt.ALT
if QT_API in ("pyqt6", "pyside6"):
return event.modifiers() & Qt.KeyboardModifier.AltModifier