From: Norbert Moutarde Date: Wed, 14 May 2014 13:25:51 +0000 (+0200) Subject: added the possibility to choose "cancel" on config X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=dd2fee81359384e52806ebc83ac17e42b78461f8;p=diary-mobile.git added the possibility to choose "cancel" on config --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 47f488e..6c8331f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -142,10 +142,14 @@ void MainWindow::action(const QString &a){ conf->setValue(b[1], b[2]); } else if(b[0]==QString("settext")){ - conf->setValue(b[1], QInputDialog::getText(this, "setText", b[1], QLineEdit::Normal, conf->value(b[1]).toString())); + bool ok; + QString a=QInputDialog::getText(this, "setText", b[1], QLineEdit::Normal, conf->value(b[1]).toString(), *ok); + if(ok)conf->setValue(b[1], a); } else if(b[0]==QString("setint")){ - conf->setValue(b[1], QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(b[1])).toInt())); + bool ok; + QString a=QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(b[1])).toInt(), 0, 100, 1, *ok); + if(ok)conf->setValue(b[1], a); } else if(b[0]==QString("start")){ getButtons(conf->value(QString("start")).toString()); @@ -490,7 +494,7 @@ void MainWindow::back(){ void MainWindow::keyReleaseEvent(QKeyEvent *event) { //static bool accepted=true; - event->setAccepted(1); + event->setAccepted(true); int k=event->key(); qDebug()<<"key pressed="<value(QString("volumdown")).toString()); + const QString a=conf->value(QString("volumdown")).toString(); + action(a); } else if(k==Qt::Key_VolumeUp){