From 50f4640feaa00a0dd06dfe60d826e0a3276449dd Mon Sep 17 00:00:00 2001 From: Emmanuel Granatello Date: Mon, 1 Mar 2010 12:33:50 +0100 Subject: [PATCH] =?utf8?q?Best=20Score=20Inserita=20la=20funzionalit=C3=A0=20?= =?utf8?q?di=20best=20score=20utilizzando=20i=20QSetting?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 31 +++++++++++++++++++++++++++++-- mainwindow.h | 5 +++++ moc_mainwindow.cpp | 2 +- moc_mainwindow.o | Bin 0 -> 8420 bytes 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 moc_mainwindow.o diff --git a/mainwindow.cpp b/mainwindow.cpp index a508562..70fd57c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,12 +3,14 @@ #include #include #include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - + bestScore=0; + readSettings(); ui->setupUi(this); statusLed = new QLed(ui->verticalLayoutWidget); ui->horizontalLayout_4->insertWidget(0,statusLed); @@ -58,8 +60,20 @@ MainWindow::MainWindow(QWidget *parent) : //showMaximized(); } void MainWindow::sbagliato(int score){ - QString sscore("Score "); + + if(bestScore<= score){ + bestScore=score; + writeSettings(); + QString sscore("This is Best Score "); + sscore.append(QString::number(score)); + QMessageBox::warning(this, tr("End Game"),sscore,QMessageBox::Escape); + //tread.genera(); + exit(0); + } + QString sscore("Your Score: "); sscore.append(QString::number(score)); + sscore.append("\n Best score: "); + sscore.append(QString::number(bestScore)); QMessageBox::warning(this, tr("End Game"),sscore,QMessageBox::Escape); //tread.genera(); exit(0); @@ -206,4 +220,17 @@ void MainWindow::changeEvent(QEvent *e) break; } } +void MainWindow::writeSettings() +{ + QSettings settings("Emmynet Inc.", "QMemory"); + settings.setValue("bestscore",bestScore); + +} + +void MainWindow::readSettings() +{ + QSettings settings("Emmynet Inc.", "QMemory"); + bestScore=(settings.value("bestscore").toInt()); + +} diff --git a/mainwindow.h b/mainwindow.h index e1ab34a..41c929b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -35,6 +35,11 @@ signals: protected: void changeEvent(QEvent *e); +private: + void writeSettings(); + void readSettings(); + + int bestScore; Ui::MainWindow *ui; QList sequenza; TestThread tread; diff --git a/moc_mainwindow.cpp b/moc_mainwindow.cpp index 162f4d6..5d1d827 100644 --- a/moc_mainwindow.cpp +++ b/moc_mainwindow.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** -** Created: Fri Feb 26 16:31:33 2010 +** Created: Mon Mar 1 12:31:40 2010 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.1) ** ** WARNING! All changes made in this file will be lost! diff --git a/moc_mainwindow.o b/moc_mainwindow.o new file mode 100644 index 0000000000000000000000000000000000000000..0f7a29a4552ae4b34f3269bfa94c2b17090d98ce GIT binary patch literal 8420 zcmd^FeQX@X6`!+B>r#jCnWjL?r5JF4m|K6FLUCfB6XV3Wi|qsg;e5VZ`@p8O0=k|s3;X`sT2x-q-u)tN7VH9+nw3l z9p44|cSjn(`Mvk%z4>@EyZg=uquYl=p^#7|BpO8(3GvpaT}hWi+Qd3>nIpdtn0hUe zu5si-OjiEB9Bp16Xj&dvzjVxQ-go@y&nbF|fA$?;f&B1?ZAYUmmFVfC(NmS7))wfW zh@PVS#87Lqq)nuirq+{Z&z(E>`tg;Oqc2=fmeaqlvhVbA^x{hS%<{gL%0p+D%gxIV zT@G8#m3v#8DqXFW2U}a5o=e9T+Lqofw;n#T=D^iQ?d!$4)+L%*sYKs{-pq=lwH$r# z@X3poVH6f0I$Qa0-*H#2q#wMyyr&7QUsoY8)_eF z3^jv#2=xin=TLu*`YtJSpOJ>9K*Qjjuk1)#`8`%XT{s}bblJ8Gd6CLmsZ`P~jAXYI z$S~WiyuDFaX(YCNL{(#0HMXk8Hq{tGqcokI&028pdQDrU z;O(lx zyQc;(U4xga!JDtaJ6MBvqz3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