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