1
/* Copyright (C) 2013 Jens-Malte Gottfried
3
This file is part of Tuchulcha.
5
Tuchulcha is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
10
Tuchulcha is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public License
16
along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
18
/** \file QTextInputDialog.h
19
* \brief Declaration of class QTextInputDialog
21
* \author <a href="mailto:jmgottfried@web.de">Jens-Malte Gottfried</a>
24
#include "QTextInputDialog.h"
25
#include <QVBoxLayout>
27
#include <QDialogButtonBox>
29
QTextInputDialog::QTextInputDialog(QWidget *pp, Qt::WindowFlags flags) :
32
QVBoxLayout *verticalLayout;
33
QDialogButtonBox *bBox;
35
verticalLayout = new QVBoxLayout(this);
36
lText = new QLabel(this);
37
lText->setObjectName(QString::fromUtf8("lText"));
38
verticalLayout->addWidget(lText);
40
eText = new QLineEdit(this);
41
eText->setObjectName(QString::fromUtf8("eText"));
42
verticalLayout->addWidget(eText);
44
bBox = new QDialogButtonBox(this);
45
bBox->setObjectName(QString::fromUtf8("bBox"));
46
bBox->setOrientation(Qt::Horizontal);
47
bBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
48
verticalLayout->addWidget(bBox);
50
connect(bBox, SIGNAL(accepted()), SLOT(accept()));
51
connect(bBox, SIGNAL(rejected()), SLOT(reject()));
52
connect(eText, SIGNAL(textChanged(QString)), SIGNAL(textValueChanged(QString)));
54
QMetaObject::connectSlotsByName(this);
57
QTextInputDialog::~QTextInputDialog() {
60
QString QTextInputDialog::getText(
61
QWidget *parent, const QString &title,
62
const QString &label, QLineEdit::EchoMode mode,
63
const QString &text, bool *ok, Qt::WindowFlags flags,
64
Qt::InputMethodHints inputMethodHints,
66
QTextInputDialog dialog(parent, flags);
67
dialog.setWindowTitle(title);
68
dialog.setLabelText(label);
69
dialog.setTextValue(text);
70
dialog.setTextEchoMode(mode);
71
dialog.setInputMethodHints(inputMethodHints);
72
dialog.setValidator(val);
74
int ret = dialog.exec();
78
return dialog.textValue();
84
void QTextInputDialog::done (int res) {
87
emit textValueSelected(textValue());
91
void QTextInputDialog::setTextEchoMode(QLineEdit::EchoMode mode) {
92
eText->setEchoMode(mode);
95
void QTextInputDialog::setLabelText(const QString& text) {
99
void QTextInputDialog::setTextValue(const QString& value) {
100
eText->setText(value);
103
QString QTextInputDialog::textValue() const {
104
return eText->text();
107
QString QTextInputDialog::labelText() const {
108
return lText->text();
111
QLineEdit::EchoMode QTextInputDialog::textEchoMode() const {
112
return eText->echoMode();
115
void QTextInputDialog::setValidator(const QValidator* val) {
116
eText->setValidator(val);
119
const QValidator* QTextInputDialog::validator() const {
120
return eText->validator();