|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to change the default size settings of the Source |
|
8 Outline pane. |
|
9 """ |
|
10 |
|
11 from PyQt6.QtCore import pyqtSlot |
|
12 from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox |
|
13 |
|
14 from .Ui_EditorOutlineSizesDialog import Ui_EditorOutlineSizesDialog |
|
15 |
|
16 |
|
17 class EditorOutlineSizesDialog(QDialog, Ui_EditorOutlineSizesDialog): |
|
18 """ |
|
19 Class documentation goes here. |
|
20 """ |
|
21 def __init__(self, currentWidth, defaultWidth, defaultStepSize, |
|
22 parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param currentWidth value of the current width |
|
27 @type int |
|
28 @param defaultWidth value of the default width |
|
29 @type int |
|
30 @param defaultStepSize value of the step size |
|
31 @type int |
|
32 @param parent reference to the parent widget (defaults to None) |
|
33 @type QWidget (optional) |
|
34 """ |
|
35 super().__init__(parent) |
|
36 self.setupUi(self) |
|
37 |
|
38 self.__defaultWidth = defaultWidth |
|
39 self.__defaultStepSize = defaultStepSize |
|
40 |
|
41 self.sourceOutlineWidthSpinBox.setValue(currentWidth) |
|
42 self.sourceOutlineWidthStepSpinBox.setValue(defaultStepSize) |
|
43 |
|
44 msh = self.minimumSizeHint() |
|
45 self.resize(max(self.width(), msh.width()), msh.height()) |
|
46 |
|
47 @pyqtSlot(QAbstractButton) |
|
48 def on_buttonBox_clicked(self, button): |
|
49 """ |
|
50 Private slot to handle the selection of a dialog button. |
|
51 |
|
52 @param button reference to the clicked button |
|
53 @type QAbstractButton |
|
54 """ |
|
55 if button is self.buttonBox.button( |
|
56 QDialogButtonBox.StandardButton.RestoreDefaults |
|
57 ): |
|
58 self.sourceOutlineWidthSpinBox.setValue(self.__defaultWidth) |
|
59 self.sourceOutlineWidthStepSpinBox.setValue(self.__defaultStepSize) |
|
60 |
|
61 def getSizes(self): |
|
62 """ |
|
63 Public method to retrieve the entered values. |
|
64 |
|
65 @return tuple containing the values of the default width and step size |
|
66 @rtype tuple of (int, int) |
|
67 """ |
|
68 return ( |
|
69 self.sourceOutlineWidthSpinBox.value(), |
|
70 self.sourceOutlineWidthStepSpinBox.value() |
|
71 ) |