Skip to content

Commit

Permalink
Simplify the version checking code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
nallath committed May 19, 2022
1 parent 47e5de2 commit a4c3653
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions OrientationPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,22 @@ def __init__(self):
CuraApplication.getInstance().fileCompleted.connect(self._onFileCompleted)
CuraApplication.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
CuraApplication.getInstance().getPreferences().preferenceChanged.connect(self._onPreferencesChanged)

self.Major=4
self.Minor=0

try:
self.Major = int(CuraVersion.split(".")[0])
self.Minor = int(CuraVersion.split(".")[1])
except:
pass

if self.Major > 4:
self._qml_folder="qml_qt6"

# Use the qml_qt6 stuff for 5.0.0 and up
if Version(CuraVersion).getMajor() >= 5:
self._qml_folder = "qml_qt6"
else:
self._qml_folder="qml_qt5"


self._qml_folder = "qml_qt5"

def _onPreferencesChanged(self, name: str) -> None:
if name != "OrientationPlugin/do_auto_orientation":
return
self._do_auto_orientation = CuraApplication.getInstance().getPreferences().getValue("OrientationPlugin/do_auto_orientation")

def _createPopup(self) -> None:
# Create the plugin dialog component
# path = os.path.join(cast(str, PluginRegistry.getInstance().getPluginPath("OrientationPlugin")), "SettingsPopup.qml")
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), self._qml_folder, "SettingsPopup.qml")
path = os.path.join(cast(str, PluginRegistry.getInstance().getPluginPath(self.getPluginId())), self._qml_folder,
"SettingsPopup.qml")
self._popup = CuraApplication.getInstance().createQmlComponent(path)
if self._popup is None:
return
Expand Down

0 comments on commit a4c3653

Please sign in to comment.