|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the protobuf configuration page. |
|
8 """ |
|
9 |
|
10 from E5Gui.E5PathPicker import E5PathPickerModes |
|
11 |
|
12 from .ConfigurationPageBase import ConfigurationPageBase |
|
13 from .Ui_ProtobufPage import Ui_ProtobufPage |
|
14 |
|
15 import Preferences |
|
16 |
|
17 |
|
18 class ProtobufPage(ConfigurationPageBase, Ui_ProtobufPage): |
|
19 """ |
|
20 Class implementing the protobuf configuration page. |
|
21 """ |
|
22 def __init__(self): |
|
23 """ |
|
24 Constructor |
|
25 """ |
|
26 super().__init__() |
|
27 self.setupUi(self) |
|
28 self.setObjectName("ProtobufPage") |
|
29 |
|
30 self.protocPicker.setMode(E5PathPickerModes.OpenFileMode) |
|
31 self.protocPicker.setToolTip(self.tr( |
|
32 "Press to select the Protobuf compiler via a file selection" |
|
33 " dialog.")) |
|
34 |
|
35 self.grpcPythonPicker.setMode(E5PathPickerModes.OpenFileMode) |
|
36 self.grpcPythonPicker.setToolTip(self.tr( |
|
37 "Press to select the Python interpreter containing the gRPC" |
|
38 " compiler via a file selection dialog.")) |
|
39 |
|
40 # set initial values |
|
41 self.protocPicker.setText(Preferences.getProtobuf("protoc")) |
|
42 self.grpcPythonPicker.setText(Preferences.getProtobuf("grpcPython")) |
|
43 |
|
44 def save(self): |
|
45 """ |
|
46 Public slot to save the protobuf configuration. |
|
47 """ |
|
48 Preferences.setProtobuf("protoc", self.protocPicker.text()) |
|
49 Preferences.setProtobuf("grpcPython", self.grpcPythonPicker.text()) |
|
50 |
|
51 |
|
52 def create(dlg): |
|
53 """ |
|
54 Module function to create the configuration page. |
|
55 |
|
56 @param dlg reference to the configuration dialog |
|
57 @return reference to the instantiated page (ConfigurationPageBase) |
|
58 """ |
|
59 page = ProtobufPage() |
|
60 return page |