Constructor and destructor in FMDbusConn are now hidden, access to
[KFingerManager.git] / src / FMEnroll.cpp
blob48826a93621a02fab719e99655e13923b978d0f2
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 iface = dbc->claimDevice(device_.device, getlogin());
22 // Init and traslate UI components
23 initComponents();
24 retranslate();
25 setMainWidget(mainPanel);
27 // Layout
28 statusLayout->addWidget(statusLabel);
29 statusLayout->addWidget(actualStatus);
30 mainLayout->addLayout(statusLayout);
32 stagesLayout->addStretch();
33 for (int i = 0; i < ENROLL_STAGES; i++) {
34 stagesLayout->addWidget(stages[i]);
36 stagesLayout->addStretch();
38 mainLayout->addLayout(stagesLayout);
39 mainPanel->setLayout(mainLayout);
41 setMaximumSize(minimumSizeHint());
44 void FMEnroll::initComponents() {
45 mainPanel = new QWidget();
46 statusLabel = new QLabel();
47 actualStatus = new QLabel();
48 statusLayout = new QHBoxLayout();
49 stagesLayout = new QHBoxLayout();
50 mainLayout = new QVBoxLayout();
52 for (int i = 0; i < ENROLL_STAGES; i++) {
53 stages[i] = new QCheckBox();
54 stages[i]->setEnabled(false);
58 void FMEnroll::retranslate() {
59 // Set Window Title
60 setWindowTitle(i18n("Enrolling finger..."));
62 // What's this
63 setWhatsThis(i18n("Enroll finger window"));
65 // Set status label
66 statusLabel->setText(i18n("Status")+":");
68 // Set stages tooltips
69 for (int i = 0; i < ENROLL_STAGES; i++) {
70 QString msg = i18n("Stage %1").arg(i + 1);
71 stages[i]->setToolTip(msg);
72 stages[i]->setWhatsThis(i18n("Current enrollment progess..."));
75 QString msg = QString("Swipe \"%1\" on \"%2\"").arg(fingerNames[finger_].name, device_.name);
76 actualStatus->setText(i18n(msg.toLatin1()));
79 /**
80 * FMEnroll destructor
82 FMEnroll::~FMEnroll() {
83 if (statusLabel) delete statusLabel;
84 if (actualStatus) delete actualStatus;
85 if (statusLayout) delete statusLayout;
86 for (int i = 0; i < ENROLL_STAGES; i++) {
87 if (stages[i]) delete stages[i];
89 if (stagesLayout) delete stagesLayout;
90 if (mainLayout) delete mainLayout;
91 if (mainPanel) delete mainPanel;
92 if (dbc) {
93 dbc->releaseDevice(device_.device);
94 dbc->releaseConn();