1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "passphraseforkeydialog.h"
36 #include <QtGui/QCheckBox>
37 #include <QtGui/QDialogButtonBox>
38 #include <QtGui/QLabel>
39 #include <QtGui/QLineEdit>
40 #include <QtGui/QPushButton>
41 #include <QtGui/QVBoxLayout>
43 using namespace Qt4ProjectManager;
45 PassphraseForKeyDialog::PassphraseForKeyDialog(const QString &keyName, QWidget *parent) :
51 QVBoxLayout *layout = new QVBoxLayout(this);
53 QHBoxLayout *hPasswordLayout = new QHBoxLayout;
55 QLabel *passphraseLabel = new QLabel(this);
56 passphraseLabel->setText(tr("Passphrase:"));
57 hPasswordLayout->addWidget(passphraseLabel);
59 m_passphraseEdit = new QLineEdit(this);
60 m_passphraseEdit->setEchoMode(QLineEdit::Password);
61 connect(m_passphraseEdit, SIGNAL(textChanged(QString)), this, SLOT(passphraseChanged()));
62 hPasswordLayout->addWidget(m_passphraseEdit);
64 m_saveCheckBox = new QCheckBox(this);
65 m_saveCheckBox->setText(tr("Save passphrase"));
66 m_saveCheckBox->setToolTip(tr("This is an insecure option. The password will be saved as plain text."));
68 m_buttonBox = new QDialogButtonBox(this);
69 m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
71 connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
72 connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
74 layout->addLayout(hPasswordLayout);
75 layout->addWidget(m_saveCheckBox);
76 layout->addItem(new QSpacerItem(0, 10));
77 layout->addWidget(m_buttonBox);
79 setWindowTitle(tr("Passphrase for %1").arg(keyName));
80 setFixedSize(sizeHint());
85 void PassphraseForKeyDialog::passphraseChanged()
87 // We tried the empty passphrase when we get here, so disallow it
88 Q_ASSERT(m_buttonBox->button(QDialogButtonBox::Ok));
89 m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!m_passphraseEdit->text().isEmpty());
92 QString PassphraseForKeyDialog::passphrase() const
94 return m_passphraseEdit->text();
97 bool PassphraseForKeyDialog::savePassphrase() const
99 return m_saveCheckBox->isChecked();