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