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