|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2004 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to set the scene sizes. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from .Ui_UMLSceneSizeDialog import Ui_UMLSceneSizeDialog |
|
13 |
|
14 |
|
15 class UMLSceneSizeDialog(QDialog, Ui_UMLSceneSizeDialog): |
|
16 """ |
|
17 Class implementing a dialog to set the scene sizes. |
|
18 """ |
|
19 def __init__(self, w, h, minW, minH, parent=None, name=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param w current width of scene |
|
24 @type int |
|
25 @param h current height of scene |
|
26 @type int |
|
27 @param minW minimum width allowed |
|
28 @type int |
|
29 @param minH minimum height allowed |
|
30 @type int |
|
31 @param parent parent widget of this dialog |
|
32 @type QWidget |
|
33 @param name name of this widget |
|
34 @type str |
|
35 """ |
|
36 super().__init__(parent) |
|
37 if name: |
|
38 self.setObjectName(name) |
|
39 self.setupUi(self) |
|
40 |
|
41 self.widthSpinBox.setValue(w) |
|
42 self.heightSpinBox.setValue(h) |
|
43 self.widthSpinBox.setMinimum(minW) |
|
44 self.heightSpinBox.setMinimum(minH) |
|
45 self.widthSpinBox.selectAll() |
|
46 self.widthSpinBox.setFocus() |
|
47 |
|
48 msh = self.minimumSizeHint() |
|
49 self.resize(max(self.width(), msh.width()), msh.height()) |
|
50 |
|
51 def getData(self): |
|
52 """ |
|
53 Public method to retrieve the entered data. |
|
54 |
|
55 @return tuple giving the selected width and height |
|
56 @rtype tuple of (int, int) |
|
57 """ |
|
58 return (self.widthSpinBox.value(), self.heightSpinBox.value()) |