eric6/QScintilla/MarkupProviders/HyperlinkMarkupDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter data to insert a hyperlink.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_HyperlinkMarkupDialog import Ui_HyperlinkMarkupDialog
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 class HyperlinkMarkupDialog(QDialog, Ui_HyperlinkMarkupDialog):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing a dialog to enter data to insert a hyperlink.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 def __init__(self, textMayBeEmpty, targetMayBeEmpty, noTitle=False,
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 parent=None):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param textMayBeEmpty flag indicating, that the link text may
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 be empty
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type bool
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param targetMayBeEmpty flag indicating, that the link target may
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 be empty
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type bool
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param noTitle flag indicating, that no title is supported
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type bool
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type QWidget
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 super(HyperlinkMarkupDialog, self).__init__(parent)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__allowEmptyText = textMayBeEmpty
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__allowEmptyTarget = targetMayBeEmpty
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.titelEdit.setEnabled(not noTitle)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__updateOkButton()
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
45
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
46 msh = self.minimumSizeHint()
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
47 self.resize(max(self.width(), msh.width()), msh.height())
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def __updateOkButton(self):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 Private method to update the state of the OK button.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
5412
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
54 (bool(self.textEdit.text()) or self.__allowEmptyText) and
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 (bool(self.targetEdit.text()) or self.__allowEmptyTarget)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 )
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @pyqtSlot(str)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def on_textEdit_textChanged(self, txt):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Private slot handling a change of the link text.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @param txt link text
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @type str
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__updateOkButton()
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @pyqtSlot(str)
5412
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
69 def on_targetEdit_textChanged(self, txt):
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 Private slot handling a change of the link target.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @param txt link target
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @type str
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__updateOkButton()
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 def getData(self):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Public method to get the entered data.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @return tuple containing the link text, link target and the optional
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 link title
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @rtype tuple of (str, str, str)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 return (
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.textEdit.text(),
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.targetEdit.text(),
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.titelEdit.text()
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 )

eric ide

mercurial