[svn] pinentry - r169 - in trunk: . qt
svn author wk
cvs at cvs.gnupg.org
Tue Sep 18 19:45:39 CEST 2007
Author: wk
Date: 2007-09-18 19:45:38 +0200 (Tue, 18 Sep 2007)
New Revision: 169
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/qt/main.cpp
trunk/qt/pinentrydialog.cpp
trunk/qt/pinentrydialog.h
trunk/qt/secqlineedit.cpp
trunk/qt/secqlineedit.h
Log:
Implemented quality bar for QT.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/ChangeLog 2007-09-18 17:45:38 UTC (rev 169)
@@ -1,5 +1,12 @@
2007-09-18 Werner Koch <wk at g10code.com>
+ * qt/secqlineedit.h (SecQLineEdit): New signal textModified.
+ * qt/secqlineedit.cpp (finishChange): Emit it.
+ * qt/pinentrydialog.cpp (setPinentryInfo): New.
+ (PinEntryDialog): Add arg ENABLE_QUALITY_BAR.
+ * qt/pinentrydialog.h (setPinentryInfo): New.
+ (PinEntryDialog): Add arg ENABLE_QUALITY_BAR.
+
* pinentry/pinentry.h (struct pinentry): Add member QUALITY_BAR
and CTX_ASSUAN.
* pinentry/pinentry.c (cmd_setqualitybar): New.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/NEWS 2007-09-18 17:45:38 UTC (rev 169)
@@ -1,7 +1,10 @@
Noteworthy changes in version 0.7.4
------------------------------------------------
+* Pinentry-gtk-2 and pinentry-qt now support a simple passphrase
+ quality indicator.
+
Noteworthy changes in version 0.7.3 (2007-07-06)
------------------------------------------------
Modified: trunk/qt/main.cpp
===================================================================
--- trunk/qt/main.cpp 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/qt/main.cpp 2007-09-18 17:45:38 UTC (rev 169)
@@ -68,8 +68,9 @@
if (pe->parent_wid)
parent = new ForeignWidget (pe->parent_wid);
- PinEntryDialog pinentry (parent, 0, true);
+ PinEntryDialog pinentry (parent, NULL, true, !!pe->quality_bar);
+ pinentry.setPinentryInfo (pe);
pinentry.setPrompt (QString::fromUtf8 (pe->prompt));
pinentry.setDescription (QString::fromUtf8 (pe->description));
/* If we reuse the same dialog window. */
Modified: trunk/qt/pinentrydialog.cpp
===================================================================
--- trunk/qt/pinentrydialog.cpp 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/qt/pinentrydialog.cpp 2007-09-18 17:45:38 UTC (rev 169)
@@ -1,5 +1,6 @@
/* pinentrydialog.cpp - A secure KDE dialog for PIN entry.
Copyright (C) 2002 Klarälvdalens Datakonsult AB
+ Copyright (C) 2007 g10 Code GmbH
Written by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>.
This program is free software; you can redistribute it and/or
@@ -17,16 +18,20 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
+
#include <qlayout.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qmessagebox.h>
+#include <qprogressbar.h>
#include "secqlineedit.h"
#include "pinentrydialog.h"
+#include "pinentry.h"
-PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name, bool modal )
+PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name,
+ bool modal, bool enable_quality_bar )
: QDialog( parent, name, modal ), _grabbed( false )
{
QBoxLayout* top = new QVBoxLayout( this, 6 );
@@ -41,6 +46,16 @@
_error = new QLabel( this );
labelLayout->addWidget( _error );
+ if (enable_quality_bar)
+ {
+ _quality_bar = new QProgressBar (this);
+ _quality_bar->setCenterIndicator (true);
+ labelLayout->addWidget ( _quality_bar );
+ _have_quality_bar = true;
+ }
+ else
+ _have_quality_bar = false;
+
_desc = new QLabel( this );
labelLayout->addWidget( _desc );
@@ -67,12 +82,12 @@
this, SIGNAL( accepted() ) );
connect( _cancel, SIGNAL( clicked() ),
this, SIGNAL( rejected() ) );
-
+ connect( _edit, SIGNAL( textModified(const SecQString&) ),
+ this, SLOT( updateQuality(const SecQString&) ) );
connect (this, SIGNAL (accepted ()),
this, SLOT (accept ()));
connect (this, SIGNAL (rejected ()),
this, SLOT (reject ()));
-
_edit->setFocus();
}
@@ -103,6 +118,42 @@
QDialog::keyPressEvent( e );
}
+
+void PinEntryDialog::updateQuality( const SecQString & txt )
+{
+ char *pin;
+ int length;
+ int percent;
+ QPalette pal;
+
+ if (!_have_quality_bar || !_pinentry_info)
+ return;
+ pin = (char*)txt.utf8();
+ length = strlen (pin);
+ percent = length? pinentry_inq_quality (_pinentry_info, pin, length) : 0;
+ ::secmem_free (pin);
+ if (!length)
+ {
+ _quality_bar->reset ();
+ }
+ else
+ {
+ pal = _quality_bar->palette ();
+ if (percent < 0)
+ {
+ pal.setColor (QColorGroup::Highlight, QColor("red"));
+ percent = -percent;
+ }
+ else
+ {
+ pal.setColor (QColorGroup::Highlight, QColor("green"));
+ }
+ _quality_bar->setPalette (pal);
+ _quality_bar->setProgress (percent);
+ }
+}
+
+
void PinEntryDialog::setDescription( const QString& txt )
{
_desc->setText( txt );
@@ -117,7 +168,8 @@
void PinEntryDialog::setError( const QString& txt )
{
- if( !txt.isNull() )_icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Critical ) );
+ if ( !txt.isNull() )
+ _icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Critical ) );
_error->setText( txt );
}
@@ -155,3 +207,9 @@
{
_cancel->setText( txt );
}
+
+
+void PinEntryDialog::setPinentryInfo (pinentry_t peinfo )
+{
+ _pinentry_info = peinfo;
+}
Modified: trunk/qt/pinentrydialog.h
===================================================================
--- trunk/qt/pinentrydialog.h 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/qt/pinentrydialog.h 2007-09-18 17:45:38 UTC (rev 169)
@@ -21,9 +21,11 @@
#define __PINENTRYDIALOG_H__
#include <qdialog.h>
+#include "pinentry.h"
class QLabel;
class QPushButton;
+class QProgressBar;
class SecQLineEdit;
class SecQString;
@@ -36,7 +38,8 @@
Q_PROPERTY( QString prompt READ prompt WRITE setPrompt )
public:
friend class PinEntryController; // TODO: remove when assuan lets me use Qt eventloop.
- PinEntryDialog( QWidget* parent = 0, const char* name = 0, bool modal = false );
+ PinEntryDialog( QWidget* parent = 0, const char* name = 0,
+ bool modal = false, bool enable_quality_bar = false );
void setDescription( const QString& );
QString description() const;
@@ -53,6 +56,11 @@
void setOkText( const QString& );
void setCancelText( const QString& );
+ void setPinentryInfo (pinentry_t);
+
+public slots:
+ void updateQuality(const SecQString &);
+
signals:
void accepted();
void rejected();
@@ -67,10 +75,13 @@
QLabel* _desc;
QLabel* _error;
QLabel* _prompt;
+ QProgressBar* _quality_bar;
SecQLineEdit* _edit;
QPushButton* _ok;
QPushButton* _cancel;
bool _grabbed;
+ bool _have_quality_bar;
+ pinentry_t _pinentry_info;
};
Modified: trunk/qt/secqlineedit.cpp
===================================================================
--- trunk/qt/secqlineedit.cpp 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/qt/secqlineedit.cpp 2007-09-18 17:45:38 UTC (rev 169)
@@ -288,6 +288,9 @@
the Return or Enter key is pressed the returnPressed() signal is
emitted.
+ When the text changes the textModified() signal is emitted in all
+ cases.
+
By default, SecQLineEdits have a frame as specified by the Windows
and Motif style guides; you can turn it off by calling
setFrame(FALSE).
@@ -1845,6 +1848,7 @@
textDirty = FALSE;
emit q->textChanged( text );
}
+ emit q->textModified( text );
#if defined(QT_ACCESSIBILITY_SUPPORT)
QAccessible::updateAccessibility( q, 0, QAccessible::ValueChanged );
#endif
Modified: trunk/qt/secqlineedit.h
===================================================================
--- trunk/qt/secqlineedit.h 2007-09-18 11:38:21 UTC (rev 168)
+++ trunk/qt/secqlineedit.h 2007-09-18 17:45:38 UTC (rev 169)
@@ -184,6 +184,7 @@
signals:
void textChanged( const SecQString &);
+ void textModified( const SecQString &);
void returnPressed();
void lostFocus();
void selectionChanged();
More information about the Gnupg-commits
mailing list