5 #include "FingerNames.h"
10 FMEnroll::FMEnroll(DeviceModel device
, int finger
, QWidget
*parent
) :
11 KDialog(parent
), finger_(finger
), device_(device
) {
12 // Modal dialog, only Cancel button, precedent by separator
14 showButtonSeparator(true);
15 setButtons(KDialog::Cancel
);
18 dbc
= FMDbusConn::getConn();
20 // Init and traslate UI components
23 setMainWidget(mainPanel
);
26 statusLayout
->addWidget(statusLabel
);
27 statusLayout
->addWidget(actualStatus
);
28 mainLayout
->addLayout(statusLayout
);
30 stagesLayout
->addStretch();
31 for (int i
= 0; i
< ENROLL_STAGES
; i
++) {
32 stagesLayout
->addWidget(stages
[i
]);
34 stagesLayout
->addStretch();
36 mainLayout
->addLayout(stagesLayout
);
37 mainPanel
->setLayout(mainLayout
);
40 void FMEnroll::initComponents() {
41 mainPanel
= new QWidget();
42 statusLabel
= new QLabel();
43 actualStatus
= new QLabel();
44 statusLayout
= new QHBoxLayout();
45 stagesLayout
= new QHBoxLayout();
46 mainLayout
= new QVBoxLayout();
48 for (int i
= 0; i
< ENROLL_STAGES
; i
++) {
49 stages
[i
] = new QCheckBox();
50 stages
[i
]->setEnabled(false);
54 void FMEnroll::retranslate() {
56 setWindowTitle(i18n("Enrolling finger..."));
59 setWhatsThis(i18n("Enroll finger window"));
62 statusLabel
->setText(i18n("Status")+":");
64 // Set stages tooltips
65 for (int i
= 0; i
< ENROLL_STAGES
; i
++) {
66 QString msg
= i18n("Stage %1").arg(i
+ 1);
67 stages
[i
]->setToolTip(msg
);
68 stages
[i
]->setWhatsThis(i18n("Current enrollment progess..."));
75 FMEnroll::~FMEnroll() {
76 if (statusLabel
) delete statusLabel
;
77 if (actualStatus
) delete actualStatus
;
78 if (statusLayout
) delete statusLayout
;
79 for (int i
= 0; i
< ENROLL_STAGES
; i
++) {
80 if (stages
[i
]) delete stages
[i
];
82 if (stagesLayout
) delete stagesLayout
;
83 if (mainLayout
) delete mainLayout
;
84 if (mainPanel
) delete mainPanel
;
90 void FMEnroll::start() {
91 QDBusInterface
*dev
= dbc
->claimDevice(device_
.device
, getlogin());
93 dbc
->getEnrollStages(dev
);
94 dbc
->getScanType(dev
);
96 QString msg
= QString("Swipe \"%1\" on \"%2\"").arg(fingerNames
[finger_
].name
, device_
.name
);
97 actualStatus
->setText(i18n(msg
.toLatin1()));
99 setMaximumSize(minimumSizeHint());
102 dbc
->releaseDevice(dev
);