Skip to content

Commit e950292

Browse files
authored
UI feedback fixes (#1307)
IB-8249 Signed-off-by: Raul Metsma <[email protected]>
1 parent 000ed65 commit e950292

File tree

15 files changed

+144
-82
lines changed

15 files changed

+144
-82
lines changed

client/QPCSC.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Q_LOGGING_CATEGORY(SCard,"QPCSC.SCard")
3838

3939
static quint16 toUInt16(const QByteArray &data, int size)
4040
{
41-
return size >= 2 ? quint16((quint16(data[size - 2]) << 8) | quint16(data[size - 1])) : 0;
41+
return size >= 2 ? quint16((quint16(data[size - 2]) << 8) | quint8(data[size - 1])) : 0;
4242
}
4343

4444
static QStringList stateToString(DWORD state)
@@ -58,31 +58,31 @@ static QStringList stateToString(DWORD state)
5858
return result;
5959
}
6060

61-
template<typename Func, typename... Args>
62-
static auto SCCall(const char *file, int line, const char *function, Func func, Args... args)
61+
template<auto Func, typename... Args>
62+
static auto SCCall(const char *file, int line, const char *function, Args... args)
6363
{
64-
auto err = func(args...);
64+
auto err = Func(args...);
6565
if(SCard().isDebugEnabled())
6666
QMessageLogger(file, line, function, SCard().categoryName()).debug()
6767
<< function << Qt::hex << (unsigned long)err;
6868
return err;
6969
}
70-
#define SC(API, ...) SCCall(__FILE__, __LINE__, "SCard"#API, SCard##API, __VA_ARGS__)
70+
#define SC(API, ...) SCCall<SCard##API>(__FILE__, __LINE__, "SCard"#API, __VA_ARGS__)
7171

7272
QHash<DRIVER_FEATURES,quint32> QPCSCReader::Private::features()
7373
{
7474
if(!featuresList.isEmpty())
7575
return featuresList;
7676
DWORD size = 0;
77-
std::array<BYTE,256> feature{};
78-
if(SC(Control, card, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0U, feature.data(), DWORD(feature.size()), &size))
77+
std::array<PCSC_TLV_STRUCTURE,FEATURE_CCID_ESC_COMMAND> feature{};
78+
if(SC(Control, card, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0U, feature.data(), DWORD(feature.size() * sizeof(PCSC_TLV_STRUCTURE)), &size))
7979
return featuresList;
80-
for(auto p = feature.cbegin(); std::distance(feature.cbegin(), p) < size; )
80+
if(size % sizeof(PCSC_TLV_STRUCTURE))
81+
return featuresList;
82+
for(const auto &f: feature)
8183
{
82-
unsigned int tag = *p++, len = *p++, value = 0;
83-
for(unsigned int i = 0; i < len; ++i)
84-
value |= *p++ << 8 * i;
85-
featuresList[DRIVER_FEATURES(tag)] = qFromBigEndian<quint32>(value);
84+
if(f.tag)
85+
featuresList[DRIVER_FEATURES(f.tag)] = qFromBigEndian<quint32>(f.value);
8686
}
8787
return featuresList;
8888
}

client/QSmartCard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ QSmartCard::ErrorType QSmartCard::pinChange(QSmartCardData::PinType type, QWidge
383383
else
384384
{
385385
SslCertificate cert = d->t.authCert();
386-
title = cert.toString(cert.showCN() ? QStringLiteral("<b>CN,</b> serialNumber") : QStringLiteral("<b>GN SN,</b> serialNumber"));
386+
title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
387387
textBody = tr("To change %1 on a PinPad reader the old %1 code has to be entered first and then the new %1 code twice.").arg(QSmartCardData::typeString(type));
388388
}
389389
return change(type, parent, newPin, oldPin, title, textBody);
@@ -407,7 +407,7 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, bool
407407
else
408408
{
409409
SslCertificate cert = d->t.authCert();
410-
title = cert.toString(cert.showCN() ? QStringLiteral("<b>CN,</b> serialNumber") : QStringLiteral("<b>GN SN,</b> serialNumber"));
410+
title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
411411
textBody = isForgotPin ?
412412
tr("To change %1 code with the PUK code on a PinPad reader the PUK code has to be entered first and then the %1 code twice.").arg(QSmartCardData::typeString(type)) :
413413
tr("To unblock the %1 code on a PinPad reader the PUK code has to be entered first and then the %1 code twice.").arg(QSmartCardData::typeString(type));

client/dialogs/MobileDialog.ui

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<class>MobileDialog</class>
44
<widget class="QDialog" name="MobileDialog">
55
<property name="windowModality">
6-
<enum>Qt::WindowModality::WindowModal</enum>
6+
<enum>Qt::WindowModal</enum>
77
</property>
88
<property name="geometry">
99
<rect>
@@ -41,6 +41,7 @@ padding: 10px 14px;
4141
border: 1px solid #C4CBD8;
4242
border-radius: 4px;
4343
color: #07142A;
44+
background-color: white;
4445
placeholder-text-color: #607496;
4546
font-size: 16px;
4647
}
@@ -107,7 +108,7 @@ background-color: #2F70B6;
107108
<number>40</number>
108109
</property>
109110
<property name="sizeConstraint">
110-
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
111+
<enum>QLayout::SetDefaultConstraint</enum>
111112
</property>
112113
<property name="leftMargin">
113114
<number>40</number>
@@ -130,13 +131,13 @@ background-color: #2F70B6;
130131
</size>
131132
</property>
132133
<property name="focusPolicy">
133-
<enum>Qt::FocusPolicy::TabFocus</enum>
134+
<enum>Qt::TabFocus</enum>
134135
</property>
135136
<property name="text">
136137
<string>Enter your phone number to sign with mobile-ID</string>
137138
</property>
138139
<property name="alignment">
139-
<set>Qt::AlignmentFlag::AlignCenter</set>
140+
<set>Qt::AlignCenter</set>
140141
</property>
141142
<property name="wordWrap">
142143
<bool>true</bool>
@@ -184,6 +185,9 @@ background-color: #2F70B6;
184185
<height>20</height>
185186
</size>
186187
</property>
188+
<property name="focusPolicy">
189+
<enum>Qt::TabFocus</enum>
190+
</property>
187191
</widget>
188192
</item>
189193
</layout>
@@ -224,6 +228,9 @@ background-color: #2F70B6;
224228
<height>20</height>
225229
</size>
226230
</property>
231+
<property name="focusPolicy">
232+
<enum>Qt::TabFocus</enum>
233+
</property>
227234
</widget>
228235
</item>
229236
</layout>
@@ -264,7 +271,7 @@ background-color: #2F70B6;
264271
<item>
265272
<spacer name="buttonSpacer">
266273
<property name="orientation">
267-
<enum>Qt::Orientation::Horizontal</enum>
274+
<enum>Qt::Horizontal</enum>
268275
</property>
269276
<property name="sizeHint" stdset="0">
270277
<size>

client/dialogs/MobileProgress.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ MobileProgress::MobileProgress(QWidget *parent)
7070
d->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint);
7171
d->setupUi(d);
7272
d->code->setBuddy(d->signProgressBar);
73+
d->code->clear();
7374
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
7475
const auto styleSheet = R"(QProgressBar {
7576
background-color: #d3d3d3;

client/dialogs/MobileProgress.ui

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<class>MobileProgress</class>
44
<widget class="QDialog" name="MobileProgress">
55
<property name="windowModality">
6-
<enum>Qt::WindowModality::WindowModal</enum>
6+
<enum>Qt::WindowModal</enum>
77
</property>
88
<property name="geometry">
99
<rect>
@@ -35,6 +35,7 @@ padding: 10px 14px;
3535
border: 1px solid #C4CBD8;
3636
border-radius: 4px;
3737
color: #07142A;
38+
background-color: white;
3839
placeholder-text-color: #607496;
3940
font-size: 16px;
4041
}
@@ -168,20 +169,20 @@ background-color: #2F70B6;
168169
<string>Control code:</string>
169170
</property>
170171
<property name="alignment">
171-
<set>Qt::AlignmentFlag::AlignCenter</set>
172+
<set>Qt::AlignCenter</set>
172173
</property>
173174
</widget>
174175
</item>
175176
<item>
176177
<widget class="QLabel" name="code">
177178
<property name="focusPolicy">
178-
<enum>Qt::FocusPolicy::TabFocus</enum>
179+
<enum>Qt::TabFocus</enum>
179180
</property>
180181
<property name="text">
181182
<string notr="true">1234</string>
182183
</property>
183184
<property name="alignment">
184-
<set>Qt::AlignmentFlag::AlignCenter</set>
185+
<set>Qt::AlignCenter</set>
185186
</property>
186187
</widget>
187188
</item>
@@ -191,7 +192,7 @@ background-color: #2F70B6;
191192
<string notr="true">Make sure control code matches with one in phone screen and enter mobile-ID PIN2-code.</string>
192193
</property>
193194
<property name="alignment">
194-
<set>Qt::AlignmentFlag::AlignCenter</set>
195+
<set>Qt::AlignCenter</set>
195196
</property>
196197
<property name="wordWrap">
197198
<bool>true</bool>
@@ -218,7 +219,7 @@ background-color: #2F70B6;
218219
<number>0</number>
219220
</property>
220221
<property name="alignment">
221-
<set>Qt::AlignmentFlag::AlignCenter</set>
222+
<set>Qt::AlignCenter</set>
222223
</property>
223224
<property name="textVisible">
224225
<bool>false</bool>
@@ -232,7 +233,7 @@ background-color: #2F70B6;
232233
</item>
233234
</layout>
234235
</item>
235-
<item alignment="Qt::AlignmentFlag::AlignHCenter">
236+
<item alignment="Qt::AlignHCenter">
236237
<widget class="QPushButton" name="cancel">
237238
<property name="cursor">
238239
<cursorShape>PointingHandCursor</cursorShape>

client/dialogs/PinPopup.ui

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<class>PinPopup</class>
44
<widget class="QDialog" name="PinPopup">
55
<property name="windowModality">
6-
<enum>Qt::WindowModality::WindowModal</enum>
6+
<enum>Qt::WindowModal</enum>
77
</property>
88
<property name="geometry">
99
<rect>
@@ -38,6 +38,7 @@ padding: 10px 14px;
3838
border: 1px solid #C4CBD8;
3939
border-radius: 4px;
4040
color: #07142A;
41+
background-color: white;
4142
placeholder-text-color: #607496;
4243
font-size: 16px;
4344
}
@@ -74,7 +75,7 @@ background-color: #2F70B6;
7475
<number>40</number>
7576
</property>
7677
<property name="sizeConstraint">
77-
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
78+
<enum>QLayout::SetDefaultConstraint</enum>
7879
</property>
7980
<property name="leftMargin">
8081
<number>40</number>
@@ -97,13 +98,13 @@ background-color: #2F70B6;
9798
</size>
9899
</property>
99100
<property name="focusPolicy">
100-
<enum>Qt::FocusPolicy::TabFocus</enum>
101+
<enum>Qt::TabFocus</enum>
101102
</property>
102103
<property name="text">
103104
<string notr="true">&lt;b&gt;Mari Maasikas,&lt;/b&gt; 48405050123</string>
104105
</property>
105106
<property name="alignment">
106-
<set>Qt::AlignmentFlag::AlignCenter</set>
107+
<set>Qt::AlignCenter</set>
107108
</property>
108109
<property name="wordWrap">
109110
<bool>true</bool>
@@ -118,13 +119,13 @@ background-color: #2F70B6;
118119
<item>
119120
<widget class="QLabel" name="text">
120121
<property name="focusPolicy">
121-
<enum>Qt::FocusPolicy::TabFocus</enum>
122+
<enum>Qt::TabFocus</enum>
122123
</property>
123124
<property name="text">
124125
<string>You need to use a personal identification certificate for the selected activity.</string>
125126
</property>
126127
<property name="alignment">
127-
<set>Qt::AlignmentFlag::AlignCenter</set>
128+
<set>Qt::AlignCenter</set>
128129
</property>
129130
<property name="wordWrap">
130131
<bool>true</bool>
@@ -149,7 +150,7 @@ background-color: #2F70B6;
149150
<item>
150151
<widget class="QLineEdit" name="pin">
151152
<property name="echoMode">
152-
<enum>QLineEdit::EchoMode::Password</enum>
153+
<enum>QLineEdit::Password</enum>
153154
</property>
154155
</widget>
155156
</item>
@@ -161,6 +162,9 @@ background-color: #2F70B6;
161162
<height>20</height>
162163
</size>
163164
</property>
165+
<property name="focusPolicy">
166+
<enum>Qt::TabFocus</enum>
167+
</property>
164168
</widget>
165169
</item>
166170
</layout>
@@ -194,7 +198,7 @@ background-color: #2F70B6;
194198
<item>
195199
<spacer name="buttonSpacer">
196200
<property name="orientation">
197-
<enum>Qt::Orientation::Horizontal</enum>
201+
<enum>Qt::Horizontal</enum>
198202
</property>
199203
<property name="sizeHint" stdset="0">
200204
<size>

client/dialogs/PinUnblock.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,17 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t
4545
new Overlay(this);
4646

4747
auto pattern = [](QSmartCardData::PinType type) {
48-
return QStringLiteral("^\\d{%1,12}$").arg(QSmartCardData::minPinLen(type));
48+
return QRegularExpression(QStringLiteral("^\\d{%1,12}$").arg(QSmartCardData::minPinLen(type)));
4949
};
5050

5151
QRegularExpression regexpValidateCode;
52-
QRegularExpression regexpNewCode;
53-
regexpNewCode.setPattern(pattern(type));
52+
QRegularExpression regexpNewCode = pattern(type);
5453
switch(mode)
5554
{
5655
case PinUnblock::UnBlockPinWithPuk:
5756
ui->label->setText(tr("%1 unblocking").arg(QSmartCardData::typeString(type)));
5857
ui->change->setText(tr("Unblock"));
59-
regexpValidateCode.setPattern(pattern(QSmartCardData::PukType));
58+
regexpValidateCode = pattern(QSmartCardData::PukType);
6059
ui->line1_text->setText(tr("To unblock the certificate you have to enter the PUK code."));
6160
ui->line2_text->setText(tr("You can find your PUK code inside the ID-card codes envelope."));
6261
ui->line3_text->setText(tr("If you have forgotten the PUK code for your ID card, please visit "
@@ -65,7 +64,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t
6564
break;
6665
case PinUnblock::ChangePinWithPuk:
6766
ui->label->setText(tr("%1 code change").arg(QSmartCardData::typeString(type)));
68-
regexpValidateCode.setPattern(pattern(QSmartCardData::PukType));
67+
regexpValidateCode = pattern(QSmartCardData::PukType);
6968
ui->line1_text->setText(type == QSmartCardData::Pin2Type
7069
? tr("PIN2 code is used to digitally sign documents.")
7170
: tr("PIN1 code is used for confirming the identity of a person."));
@@ -75,7 +74,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t
7574
case PinUnblock::PinChange:
7675
ui->label->setText(tr("%1 code change").arg(QSmartCardData::typeString(type)));
7776
ui->labelPuk->setText(tr("Valid %1 code").arg(QSmartCardData::typeString(type)));
78-
regexpValidateCode.setPattern(pattern(type));
77+
regexpValidateCode = pattern(type);
7978
if(type == QSmartCardData::PukType)
8079
{
8180
ui->line1_text->setText(tr("PUK code is used for unblocking the certificates, when PIN1 or PIN2 has been entered 3 times incorrectly."));
@@ -100,8 +99,14 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t
10099
ui->repeat->setValidator(new QRegularExpressionValidator(regexpNewCode, ui->repeat));
101100
ui->puk->setValidator(new QRegularExpressionValidator(regexpValidateCode, ui->puk));
102101

102+
auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) {
103+
input->setStyleSheet(msg.isEmpty() ? QString() : QStringLiteral("border-color: #BE7884"));
104+
error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus);
105+
error->setText(msg);
106+
error->setHidden(msg.isEmpty());
107+
};
103108
if(leftAttempts < 3)
104-
ui->errorPuk->setText(mode == PinUnblock::PinChange ?
109+
setError(ui->puk, ui->errorPuk, mode == PinUnblock::PinChange ?
105110
tr("Remaining attempts: %1").arg(leftAttempts) :
106111
tr("PUK remaining attempts: %1").arg(leftAttempts));
107112

@@ -113,12 +118,6 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t
113118
if(auto *bullet = findChild<QLabel*>(QStringLiteral("line%1_bullet").arg(i)))
114119
bullet->setHidden(isHidden);
115120
}
116-
auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) {
117-
input->setStyleSheet(msg.isEmpty() ? QString() : QStringLiteral("border-color: #BE7884"));
118-
error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus);
119-
error->setText(msg);
120-
error->setHidden(msg.isEmpty());
121-
};
122121
connect(ui->cancel, &QPushButton::clicked, this, &PinUnblock::reject);
123122
connect(this, &PinUnblock::finished, this, &PinUnblock::close);
124123
connect(ui->pin, &QLineEdit::returnPressed, ui->change, &QPushButton::click);

0 commit comments

Comments
 (0)