1# This file is part of ReText 2# Copyright: 2012-2021 Dmitry Shachnev 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 2 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17from ReText import globalSettings 18from ReText.highlighter import ReTextHighlighter 19 20from PyQt5.QtWidgets import QCheckBox, QDialog, QDialogButtonBox, \ 21 QLabel, QLineEdit, QTextEdit, QVBoxLayout 22 23class HtmlDialog(QDialog): 24 def __init__(self, parent=None): 25 QDialog.__init__(self, parent) 26 self.resize(700, 600) 27 verticalLayout = QVBoxLayout(self) 28 self.textEdit = QTextEdit(self) 29 self.textEdit.setReadOnly(True) 30 self.textEdit.setFont(globalSettings.editorFont) 31 self.hl = ReTextHighlighter(self.textEdit.document()) 32 self.hl.docType = 'html' 33 verticalLayout.addWidget(self.textEdit) 34 buttonBox = QDialogButtonBox(self) 35 buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Close) 36 buttonBox.rejected.connect(self.close) 37 verticalLayout.addWidget(buttonBox) 38 39class LocaleDialog(QDialog): 40 def __init__(self, parent, defaultText=None): 41 QDialog.__init__(self, parent) 42 verticalLayout = QVBoxLayout(self) 43 self.label = QLabel(self) 44 self.label.setText(self.tr('Enter locale name (example: en_US)')) 45 verticalLayout.addWidget(self.label) 46 self.localeEdit = QLineEdit(self) 47 if defaultText: 48 self.localeEdit.setText(defaultText) 49 verticalLayout.addWidget(self.localeEdit) 50 self.checkBox = QCheckBox(self.tr('Set as default'), self) 51 verticalLayout.addWidget(self.checkBox) 52 buttonBox = QDialogButtonBox(self) 53 buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.Ok) 54 verticalLayout.addWidget(buttonBox) 55 buttonBox.accepted.connect(self.accept) 56 buttonBox.rejected.connect(self.reject) 57