|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to configure the various view profiles. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from .Ui_ViewProfileToolboxesDialog import Ui_ViewProfileToolboxesDialog |
|
13 from .Ui_ViewProfileSidebarsDialog import Ui_ViewProfileSidebarsDialog |
|
14 |
|
15 |
|
16 class ViewProfileDialog(QDialog): |
|
17 """ |
|
18 Class implementing a dialog to configure the various view profiles. |
|
19 """ |
|
20 def __init__(self, layout, editVisibilities, debugVisibilities, |
|
21 parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param layout type of the window layout (string) |
|
26 @param editVisibilities list of flags giving the visibilities |
|
27 of the various parts for the 'edit' view profile (list of boolean) |
|
28 @param debugVisibilities list of flags giving the visibilities |
|
29 of the various parts for the 'debug' view profile (list of boolean) |
|
30 @param parent parent widget of this dialog (QWidget) |
|
31 @exception ValueError raised to indicate an invalid layout |
|
32 """ |
|
33 super().__init__(parent) |
|
34 |
|
35 if layout not in ("Toolboxes", "Sidebars"): |
|
36 raise ValueError( |
|
37 "Illegal layout given ({0}).".format(self.__layout)) |
|
38 |
|
39 self.__layout = layout |
|
40 if self.__layout == "Toolboxes": |
|
41 self.ui = Ui_ViewProfileToolboxesDialog() |
|
42 else: |
|
43 self.ui = Ui_ViewProfileSidebarsDialog() |
|
44 self.ui.setupUi(self) |
|
45 |
|
46 if self.__layout in ["Toolboxes", "Sidebars"]: |
|
47 # set the edit profile |
|
48 self.ui.epltCheckBox.setChecked(editVisibilities[0]) |
|
49 self.ui.ephtCheckBox.setChecked(editVisibilities[1]) |
|
50 self.ui.eprtCheckBox.setChecked(editVisibilities[2]) |
|
51 |
|
52 # set the debug profile |
|
53 self.ui.dpltCheckBox.setChecked(debugVisibilities[0]) |
|
54 self.ui.dphtCheckBox.setChecked(debugVisibilities[1]) |
|
55 self.ui.dprtCheckBox.setChecked(debugVisibilities[2]) |
|
56 |
|
57 msh = self.minimumSizeHint() |
|
58 self.resize(max(self.width(), msh.width()), msh.height()) |
|
59 |
|
60 def getVisibilities(self): |
|
61 """ |
|
62 Public method to retrieve the visibilities configuration. |
|
63 |
|
64 @return tuple of two lists giving the visibilities of the |
|
65 various parts (two lists of boolean) |
|
66 """ |
|
67 if self.__layout in ["Toolboxes", "Sidebars"]: |
|
68 return ( |
|
69 # edit profile |
|
70 [ |
|
71 self.ui.epltCheckBox.isChecked(), |
|
72 self.ui.ephtCheckBox.isChecked(), |
|
73 self.ui.eprtCheckBox.isChecked(), |
|
74 ], |
|
75 # debug profile |
|
76 [ |
|
77 self.ui.dpltCheckBox.isChecked(), |
|
78 self.ui.dphtCheckBox.isChecked(), |
|
79 self.ui.dprtCheckBox.isChecked(), |
|
80 ] |
|
81 ) |
|
82 |
|
83 return ( |
|
84 [True, True, True], # edit profile |
|
85 [True, True, True], # debug profile |
|
86 ) |