|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Text Mime Types configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 |
|
12 from E5Gui import E5MessageBox |
|
13 |
|
14 from .ConfigurationPageBase import ConfigurationPageBase |
|
15 from .Ui_MimeTypesPage import Ui_MimeTypesPage |
|
16 |
|
17 import Preferences |
|
18 |
|
19 |
|
20 class MimeTypesPage(ConfigurationPageBase, Ui_MimeTypesPage): |
|
21 """ |
|
22 Class implementing the Text Mime Types configuration page. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super().__init__() |
|
29 self.setupUi(self) |
|
30 self.setObjectName("MimeTypesPage") |
|
31 |
|
32 self.textMimeTypesList.setDefaultVisible(True) |
|
33 self.textMimeTypesList.setToDefault.connect(self.__setToDefault) |
|
34 |
|
35 # set initial values |
|
36 self.textMimeTypesList.setList( |
|
37 Preferences.getUI("TextMimeTypes")) |
|
38 |
|
39 def save(self): |
|
40 """ |
|
41 Public slot to save the Interface configuration. |
|
42 """ |
|
43 Preferences.setUI("TextMimeTypes", self.textMimeTypesList.getList()) |
|
44 |
|
45 @pyqtSlot() |
|
46 def __setToDefault(self): |
|
47 """ |
|
48 Private slot to set the message list to the default values. |
|
49 """ |
|
50 self.textMimeTypesList.setList( |
|
51 Preferences.Prefs.uiDefaults["TextMimeTypes"]) |
|
52 |
|
53 @pyqtSlot() |
|
54 def on_resetButton_clicked(self): |
|
55 """ |
|
56 Private slot to set the default list of mime types. |
|
57 """ |
|
58 ok = E5MessageBox.yesNo( |
|
59 self, |
|
60 self.tr("Reset Mime Types"), |
|
61 self.tr("""Do you really want to reset the configured list of""" |
|
62 """ mime types?""")) |
|
63 if ok: |
|
64 self.textMimeTypesList.setList( |
|
65 Preferences.Prefs.uiDefaults["TextMimeTypes"]) |
|
66 |
|
67 |
|
68 def create(dlg): |
|
69 """ |
|
70 Module function to create the configuration page. |
|
71 |
|
72 @param dlg reference to the configuration dialog |
|
73 @return reference to the instantiated page (ConfigurationPageBase) |
|
74 """ |
|
75 page = MimeTypesPage() |
|
76 return page |