|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2002 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Goto dialog. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
11 |
|
12 from .Ui_GotoDialog import Ui_GotoDialog |
|
13 |
|
14 |
|
15 class GotoDialog(QDialog, Ui_GotoDialog): |
|
16 """ |
|
17 Class implementing the Goto dialog. |
|
18 """ |
|
19 def __init__(self, maximum, curLine, parent, name=None, modal=False): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param maximum maximum allowed for the spinbox (integer) |
|
24 @param curLine current line number (integer) |
|
25 @param parent parent widget of this dialog (QWidget) |
|
26 @param name name of this dialog (string) |
|
27 @param modal flag indicating a modal dialog (boolean) |
|
28 """ |
|
29 super().__init__(parent) |
|
30 if name: |
|
31 self.setObjectName(name) |
|
32 self.setupUi(self) |
|
33 self.setModal(modal) |
|
34 |
|
35 self.linenumberSpinBox.setMaximum(maximum) |
|
36 self.linenumberSpinBox.setValue(curLine) |
|
37 self.linenumberSpinBox.selectAll() |
|
38 |
|
39 self.buttonBox.button( |
|
40 QDialogButtonBox.StandardButton.Ok).setDefault(True) |
|
41 |
|
42 msh = self.minimumSizeHint() |
|
43 self.resize(max(self.width(), msh.width()), msh.height()) |
|
44 |
|
45 def getLinenumber(self): |
|
46 """ |
|
47 Public method to retrieve the linenumber. |
|
48 |
|
49 @return line number (int) |
|
50 """ |
|
51 return self.linenumberSpinBox.value() |