-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathaddonmanager_python_deps_gui.py
More file actions
81 lines (66 loc) · 3.56 KB
/
addonmanager_python_deps_gui.py
File metadata and controls
81 lines (66 loc) · 3.56 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2022 FreeCAD Project Association
# SPDX-FileNotice: Part of the AddonManager.
################################################################################
# #
# This addon is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as #
# published by the Free Software Foundation, either version 2.1 #
# of the License, or (at your option) any later version. #
# #
# This addon is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty #
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #
# See the GNU Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public #
# License along with this addon. If not, see https://www.gnu.org/licenses #
# #
################################################################################
"""GUI for python dependency management."""
import os
import addonmanager_freecad_interface as fci
from addonmanager_python_deps import PythonPackageListModel
from PySideWrapper import QtWidgets
translate = fci.translate
class PythonPackageManagerGui:
"""GUI for managing Python packages"""
def __init__(self, addons):
self.dlg = fci.loadUi(
os.path.join(os.path.dirname(__file__), "PythonDependencyUpdateDialog.ui")
)
self.dlg.setObjectName("AddonManager_PythonDependencyUpdateDialog")
self.model = PythonPackageListModel(addons)
self.dlg.tableView.setModel(self.model)
self.dlg.tableView.horizontalHeader().setStretchLastSection(True)
self.dlg.tableView.horizontalHeader().setSectionResizeMode(
0, QtWidgets.QHeaderView.ResizeMode.ResizeToContents
)
self.dlg.tableView.horizontalHeader().setSectionResizeMode(
1, QtWidgets.QHeaderView.ResizeMode.ResizeToContents
)
self.dlg.tableView.horizontalHeader().setSectionResizeMode(
2, QtWidgets.QHeaderView.ResizeMode.ResizeToContents
)
self.dlg.tableView.horizontalHeader().setSectionResizeMode(
3, QtWidgets.QHeaderView.ResizeMode.ResizeToContents
)
self.dlg.buttonUpdateAll.clicked.connect(self._update_button_clicked)
self.model.modelReset.connect(self._model_was_reset)
self.model.update_complete.connect(self._update_complete)
def show(self):
self.dlg.buttonUpdateAll.setEnabled(False)
self.dlg.updateInProgressLabel.show()
self.model.reset_package_list()
self.dlg.labelInstallationPath.setText(self.model.vendor_path)
self.dlg.exec()
def _update_button_clicked(self):
self.dlg.buttonUpdateAll.setEnabled(False)
self.dlg.updateInProgressLabel.show()
self.model.update_all_packages()
def _model_was_reset(self):
self.dlg.updateInProgressLabel.hide()
self.dlg.buttonUpdateAll.setEnabled(self.model.updates_are_available())
def _update_complete(self):
self.dlg.updateInProgressLabel.hide()
self.model.reset_package_list()