From dd2fee81359384e52806ebc83ac17e42b78461f8 Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Wed, 14 May 2014 15:25:51 +0200 Subject: [PATCH] added the possibility to choose "cancel" on config --- mainwindow.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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){ -- 2.45.1