Moved to patched fprintd (hyphen in device properties substitued by underscore)
[KFingerManager.git] / src / FMEnroll.cpp
blobb0cf470f840fef3eb8a73212d08c089842d27338
1 #include <KLocale>
2 #include <QtCore>
4 #include "FMEnroll.h"
5 #include "FingerNames.h"
7 /**
8 * FMEnroll constructor
9 */
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
13 setModal(true);
14 showButtonSeparator(true);
15 setButtons(KDialog::Cancel);
17 // D-Bus connection
18 dbc = FMDbusConn::getConn();
20 // Init and traslate UI components
21 initComponents();
22 retranslate();
23 setMainWidget(mainPanel);
25 // Layout
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() {
55 // Set Window Title
56 setWindowTitle(i18n("Enrolling finger..."));
58 // What's this
59 setWhatsThis(i18n("Enroll finger window"));
61 // Set status label
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..."));
72 /**
73 * FMEnroll destructor
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;
85 if (dbc) {
86 dbc->releaseConn();
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());
101 this->exec();
102 dbc->releaseDevice(dev);