author | korovkin <korovkin> | 2006-05-06 19:19:00 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-06 19:19:00 (UTC) |
commit | dc719be35432469c24dd8d10136c1ea25c6861d2 (patch) (side-by-side diff) | |
tree | 6b4e970c2118a695a89ee4c46ac16fc68ec3bf4f | |
parent | 2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1 (diff) | |
download | opie-dc719be35432469c24dd8d10136c1ea25c6861d2.zip opie-dc719be35432469c24dd8d10136c1ea25c6861d2.tar.gz opie-dc719be35432469c24dd8d10136c1ea25c6861d2.tar.bz2 |
Added reject function to a Cancel button.
Added "AC" == "Backspace" button.
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.cc | 22 | ||||
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.h | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc index 3db6095..b03ae7d 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.cc +++ b/noncore/net/opietooth/blue-pin/pindlg.cc @@ -1,119 +1,141 @@ #include "pindlg.h" /* OPIE */ #include <qpe/config.h> #include <qpe/qpeapplication.h> /* QT */ #include <qcheckbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> /* STD */ #include <stdio.h> using namespace OpieTooth; PinDlg::PinDlg(QWidget* parent, const char* name, Qt::WFlags f ) : PinDlgBase( parent, name, f ) { m_mac = makeMacFromArgs(); if(m_mac.isEmpty()) { // can't obtain MAC printf("ERR\n"); ::exit(0); } else { test( m_mac ); txtStatus->setText(makeTextFromArgs()); QPEApplication::showDialog( this , false) ; } } PinDlg::~PinDlg() {} void PinDlg::setMac( const QString& mac ) { txtStatus->setText( mac ); } QString PinDlg::pin() const { return lnePin->text(); } void PinDlg::test( const QString& mac ) { if (!mac.isEmpty() ) { Config cfg("bluepin"); cfg.setGroup(mac); lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); } } QString PinDlg::makeTextFromArgs() { if(qApp->argc() > 2) { QCString dir(qApp->argv()[1]) ; QCString bdaddr(qApp->argv()[2]) ; QCString name; if ( qApp->argc() > 3 ) { name = qApp->argv()[3]; } QString status; if (dir == "out" ) { status = QObject::tr("Outgoing connection to "); } else status = QObject::tr("Incoming connection from "); status += name; status += "<br>"; status += "[" + bdaddr + "]"; return status ; } else return QString::null; } QString PinDlg::makeMacFromArgs() { if(qApp->argc() < 3) return QString::null; else return qApp->argv()[2] ; } +/* + * Add a number to the PIN number + */ void PinDlg::addnum() { if( sender()->inherits( "QPushButton") ) { const QPushButton* btn = static_cast<const QPushButton*> (sender()); lnePin->setText(lnePin->text() + btn->text()); } } +/* + * Delete a number from the end of the line + */ +void PinDlg::delnum() +{ + if( sender()->inherits( "QPushButton") ) { + const QPushButton* btn = static_cast<const QPushButton*> (sender()); + lnePin->setText(lnePin->text().remove(lnePin->text().length() - 1, 1)); + } +} + void PinDlg::accept() { if ( ckbPin->isChecked() ) { Config cfg("bluepin"); cfg.setGroup(m_mac ); cfg.writeEntryCrypt("pin", lnePin->text() ); } printf("PIN:%s\n", lnePin->text().latin1()); QDialog::accept(); qApp->quit(); ::exit(0); } +void PinDlg::reject() +{ + printf("ERR\n"); + QDialog::reject(); + qApp->quit(); + ::exit(0); +} + diff --git a/noncore/net/opietooth/blue-pin/pindlg.h b/noncore/net/opietooth/blue-pin/pindlg.h index 1817aa8..8557010 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.h +++ b/noncore/net/opietooth/blue-pin/pindlg.h @@ -1,34 +1,35 @@ #include <qdialog.h> #include "pindlgbase.h" namespace OpieTooth { class PinDlg : public PinDlgBase { Q_OBJECT public: PinDlg(QWidget* parent = 0,const char* name = 0, Qt::WFlags f = 0); ~PinDlg(); void setMac( const QString& ); QString pin() const; static QString appName() { return QString::fromLatin1("bluepin") ; } private: void test( const QString& mac ); QString makeTextFromArgs(); QString makeMacFromArgs(); QString m_mac; protected slots: void accept(); + void reject(); void addnum(); - + void delnum(); }; }; |