Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34113458
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
14 KB
Subscribers
None
View Options
diff --git a/dialogs/adduseriddialog.cpp b/dialogs/adduseriddialog.cpp
index 6737439a9..c9559a318 100644
--- a/dialogs/adduseriddialog.cpp
+++ b/dialogs/adduseriddialog.cpp
@@ -1,148 +1,161 @@
/* -*- mode: c++; c-basic-offset:4 -*-
dialogs/adduseriddialog.cpp
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Kleopatra is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include <config-kleopatra.h>
#include "adduseriddialog.h"
#include "ui_adduseriddialog.h"
#include <utils/validation.h>
#include <QString>
#include <QStringList>
#include <QPushButton>
+#include <QValidator>
#include <cassert>
using namespace Kleo;
using namespace Kleo::Dialogs;
class AddUserIDDialog::Private {
friend class ::Kleo::Dialogs::AddUserIDDialog;
AddUserIDDialog * const q;
public:
explicit Private( AddUserIDDialog * qq )
: q( qq ),
ui( q )
{
}
private:
void slotUserIDChanged();
private:
struct UI : public Ui_AddUserIDDialog {
explicit UI( AddUserIDDialog * qq )
: Ui_AddUserIDDialog()
{
setupUi( qq );
nameLE->setValidator( Validation::pgpName( nameLE ) );
emailLE->setValidator( Validation::email( emailLE ) );
commentLE->setValidator( Validation::pgpComment( commentLE ) );
}
QPushButton * okPB() const {
return buttonBox->button( QDialogButtonBox::Ok );
}
} ui;
};
AddUserIDDialog::AddUserIDDialog( QWidget * p, Qt::WindowFlags f )
: QDialog( p, f ), d( new Private( this ) )
{
}
AddUserIDDialog::~AddUserIDDialog() {}
void AddUserIDDialog::setName( const QString & name ) {
d->ui.nameLE->setText( name );
}
QString AddUserIDDialog::name() const {
return d->ui.nameLE->text().trimmed();
}
void AddUserIDDialog::setEmail( const QString & email ) {
d->ui.emailLE->setText( email );
}
QString AddUserIDDialog::email() const {
return d->ui.emailLE->text().trimmed();
}
void AddUserIDDialog::setComment( const QString & comment ) {
d->ui.commentLE->setText( comment );
}
QString AddUserIDDialog::comment() const {
return d->ui.commentLE->text().trimmed();
}
+static bool has_intermediate_input( const QLineEdit * le ) {
+ QString text = le->text();
+ int pos = le->cursorPosition();
+ const QValidator * const v = le->validator();
+ return !v || v->validate( text, pos ) == QValidator::Intermediate ;
+}
void AddUserIDDialog::Private::slotUserIDChanged() {
bool ok = false;
QString error;
- if ( !ui.nameLE->hasAcceptableInput() )
+ if ( ui.nameLE->text().trimmed().isEmpty() )
+ error = i18nc("@info", "<interface>Real name</interface> is required, but missing.");
+ else if ( !ui.nameLE->hasAcceptableInput() )
error = i18nc("@info", "<interface>Real name</interface> must be at least 5 characters long.");
+ else if ( ui.emailLE->text().trimmed().isEmpty() )
+ error = i18nc("@info", "<interface>EMail address</interface> is required, but missing.");
+ else if ( has_intermediate_input( ui.emailLE ) )
+ error = i18nc("@info", "<interface>EMail address</interface> is incomplete." );
else if ( !ui.emailLE->hasAcceptableInput() )
error = i18nc("@info", "<interface>EMail address</interface> is invalid.");
else if ( !ui.commentLE->hasAcceptableInput() )
error = i18nc("@info", "<interface>Comment</interface> contains invalid characters.");
else
ok = true;
ui.okPB()->setEnabled( ok );
ui.errorLB->setText( error );
const QString name = q->name();
const QString email = q->email();
const QString comment = q->comment();
QStringList parts;
if ( !name.isEmpty() )
parts.push_back( name );
if ( !comment.isEmpty() )
parts.push_back( QLatin1Char( '(' ) + comment + QLatin1Char( ')' ) );
if ( !email.isEmpty() )
parts.push_back( QLatin1Char( '<' ) + email + QLatin1Char( '>' ) );
ui.resultLB->setText( parts.join( QLatin1String( " " ) ) );
}
#include "moc_adduseriddialog.cpp"
diff --git a/dialogs/adduseriddialog.ui b/dialogs/adduseriddialog.ui
index 5adbe1970..5457a9162 100644
--- a/dialogs/adduseriddialog.ui
+++ b/dialogs/adduseriddialog.ui
@@ -1,237 +1,266 @@
<ui version="4.0" >
<class>AddUserIDDialog</class>
<widget class="QDialog" name="AddUserIDDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>563</width>
- <height>242</height>
+ <width>554</width>
+ <height>250</height>
</rect>
</property>
<property name="windowTitle" >
<string>Add New User-ID</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>&Real name:</string>
</property>
<property name="buddy" >
<cstring>nameLE</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="nameLE" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>&EMail address:</string>
</property>
<property name="buddy" >
<cstring>emailLE</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="emailLE" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Co&mment (optional):</string>
</property>
<property name="buddy" >
<cstring>commentLE</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="commentLE" />
</item>
<item row="3" column="0" colspan="2" >
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="4" column="0" >
+ <item row="4" column="0" colspan="2" >
<widget class="QLabel" name="label_4" >
<property name="text" >
- <string>This is how it will look like:</string>
+ <string>This is how the new User-ID will be stored in the certificate:</string>
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
+ <item row="9" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
- <item row="8" column="0" colspan="2" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
+ <item row="12" column="0" colspan="2" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QLabel" name="errorLB" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="palette" >
+ <palette>
+ <active>
+ <colorrole role="WindowText" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>114</red>
+ <green>114</green>
+ <blue>114</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="4" column="1" >
+ <item row="6" column="0" colspan="2" >
<widget class="QLabel" name="resultLB" >
<property name="minimumSize" >
<size>
<width>300</width>
<height>0</height>
</size>
</property>
+ <property name="font" >
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="textFormat" >
<enum>Qt::PlainText</enum>
</property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
</widget>
</item>
- <item row="6" column="0" colspan="2" >
- <widget class="QLabel" name="errorLB" >
- <property name="palette" >
- <palette>
- <active>
- <colorrole role="WindowText" >
- <brush brushstyle="SolidPattern" >
- <color alpha="255" >
- <red>255</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText" >
- <brush brushstyle="SolidPattern" >
- <color alpha="255" >
- <red>255</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText" >
- <brush brushstyle="SolidPattern" >
- <color alpha="255" >
- <red>114</red>
- <green>114</green>
- <blue>114</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="text" >
- <string>Foo</string>
+ <item row="7" column="0" colspan="2" >
+ <widget class="Line" name="line_2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddUserIDDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>236</x>
<y>203</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>212</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddUserIDDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>325</x>
<y>203</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>212</y>
</hint>
</hints>
</connection>
<connection>
<sender>nameLE</sender>
<signal>textChanged(QString)</signal>
<receiver>AddUserIDDialog</receiver>
<slot>slotUserIDChanged()</slot>
<hints>
<hint type="sourcelabel" >
<x>414</x>
<y>16</y>
</hint>
<hint type="destinationlabel" >
<x>448</x>
<y>18</y>
</hint>
</hints>
</connection>
<connection>
<sender>emailLE</sender>
<signal>textChanged(QString)</signal>
<receiver>AddUserIDDialog</receiver>
<slot>slotUserIDChanged()</slot>
<hints>
<hint type="sourcelabel" >
<x>412</x>
<y>54</y>
</hint>
<hint type="destinationlabel" >
<x>450</x>
<y>58</y>
</hint>
</hints>
</connection>
<connection>
<sender>commentLE</sender>
<signal>textChanged(QString)</signal>
<receiver>AddUserIDDialog</receiver>
<slot>slotUserIDChanged()</slot>
<hints>
<hint type="sourcelabel" >
<x>402</x>
<y>96</y>
</hint>
<hint type="destinationlabel" >
<x>446</x>
<y>96</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotUserIDChanged()</slot>
</slots>
</ui>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Dec 5, 5:42 PM (1 d, 1 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
28/e2/fe0797449861516125166b3883f4
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment