|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for the 'diffsettings' command. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtWidgets import QDialog |
|
13 |
|
14 from .Ui_DjangoDiffsettingsDataDialog import Ui_DjangoDiffsettingsDataDialog |
|
15 |
|
16 |
|
17 class DjangoDiffsettingsDataDialog(QDialog, Ui_DjangoDiffsettingsDataDialog): |
|
18 """ |
|
19 Class implementing a dialog to enter the data for the 'diffsettings' |
|
20 command. |
|
21 """ |
|
22 def __init__(self, django, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param django reference to the Django project object |
|
27 @type Project |
|
28 @param parent reference to the parent widget |
|
29 @type QWidget |
|
30 """ |
|
31 super(DjangoDiffsettingsDataDialog, self).__init__(parent) |
|
32 self.setupUi(self) |
|
33 |
|
34 self.__version = django.getDjangoVersion() |
|
35 if self.__version < (1, 11, 0): |
|
36 self.defaultEdit.setEnabled(False) |
|
37 if self.__version < (2, 0, 0): |
|
38 self.formatComboBox.setEnabled(False) |
|
39 else: |
|
40 self.formatComboBox.addItem(self.tr("Hash Format"), "hash") |
|
41 self.formatComboBox.addItem(self.tr("Unified Diff"), "unified") |
|
42 |
|
43 msh = self.minimumSizeHint() |
|
44 self.resize(max(self.width(), msh.width()), msh.height()) |
|
45 |
|
46 def getData(self): |
|
47 """ |
|
48 Public method to get the dialog data. |
|
49 |
|
50 @return tuple containing a flag indicating to show all settings, |
|
51 the name of a module containing the default settings and the |
|
52 output format (Django 2.0.0+) |
|
53 @rtype tuple of (bool, str, str) |
|
54 """ |
|
55 if self.__version < (2, 0, 0): |
|
56 outputFormat = "" |
|
57 else: |
|
58 outputFormat = self.formatComboBox.itemData( |
|
59 self.formatComboBox.currentIndex()) |
|
60 |
|
61 return (self.allCheckBox.isChecked(), self.defaultEdit.text(), |
|
62 outputFormat) |