From 8dfbb92bb4f9b6337f02cc4396452efae6b8d207 Mon Sep 17 00:00:00 2001 From: Thomas Walton Date: Tue, 1 May 2012 22:07:14 -0400 Subject: [PATCH 01/14] Updated files....cpp,.h,.ui, and README only --- finalTimer/README | 18 +++ finalTimer/dependent.cpp | 55 +++++++-- finalTimer/dependent.h | 12 +- finalTimer/dependent.ui | 200 ++++++++++++++++++--------------- finalTimer/finalTimer.pro | 24 ---- finalTimer/finalTimer.pro.user | 113 ------------------- finalTimer/main.cpp | 2 + finalTimer/mainwindow.cpp | 42 ------- finalTimer/mainwindow.h | 32 ------ finalTimer/mainwindow.ui | 38 +++++-- finalTimer/singletimer.ui | 124 ++++++++++++-------- 11 files changed, 282 insertions(+), 378 deletions(-) create mode 100644 finalTimer/README delete mode 100755 finalTimer/finalTimer.pro delete mode 100755 finalTimer/finalTimer.pro.user delete mode 100755 finalTimer/mainwindow.cpp delete mode 100755 finalTimer/mainwindow.h diff --git a/finalTimer/README b/finalTimer/README new file mode 100644 index 0000000..fb5b87c --- /dev/null +++ b/finalTimer/README @@ -0,0 +1,18 @@ +A Timer application with two options. A single up/down timer or a dependent timer. + +In order to properly compile this program in a linux environment you must install the qt4 libraries if +they are not already on your system. To do this run this command from the terminal: + +sudo apt-get install libxtst-dev build-essential libqt4-dev qt4-qmake + +In order to run the program you type qmake and then make from the command line. This should create an executable +called finalTimer. To execute the program type ./finalTimer + + +User instructions: + +There are two buttons in the main window. The single timer button lauches a window that has a single count up or +count down timer. There are two options to choose what will occur when the timer finishes. The dependent timer button launches +a new timer that has dependencies. There is a About button for user instructions. + + diff --git a/finalTimer/dependent.cpp b/finalTimer/dependent.cpp index 63e379e..b24ee41 100755 --- a/finalTimer/dependent.cpp +++ b/finalTimer/dependent.cpp @@ -16,7 +16,11 @@ dependent::~dependent() { delete ui; } - +/* +*on_pushStart_clicked +* On click event function for starting execution and connecting +* appropiate signals and slots. +*/ void dependent::on_pushStart_clicked() { @@ -31,17 +35,24 @@ void dependent::on_pushStart_clicked() mytimer->start(1000); } +/*stop +* Function to disconnect slots and signals when timers expire +* checks the main timer spin box values +*/ + void dependent::stop() { if(ui->spinBox_main_h->value() == 0 && ui->spinBox_main_m->value() == 0 && ui->spinBox_main_s->value() == 0){ disconnect(mytimer, SIGNAL(timeout()), this, SLOT(secDown())); } - // if(ui->spinBox_dep_h->value() == 0 && ui->spinBox_dep_m->value() == 0 && ui->spinBox_dep_s->value() == 0){ - // mytimer->disconnect(); - // mytimer->stop(); - //} + } +/*secUp +* Updates the main timer spin boxes and resets the boxes +* as dependent timer counts up +*/ + void dependent::secUp(){ ui->spinBox_main_s->stepUp(); if(ui->spinBox_main_s->value()==60){ @@ -54,6 +65,11 @@ void dependent::secUp(){ } } +/*secDown +* Updates the main timer spin boxes and reset as needed +* as dependent timer counts down +*/ + void dependent::secDown(){ ui->spinBox_main_s->stepDown(); if(ui->spinBox_main_s->value() == 0){ @@ -71,7 +87,9 @@ void dependent::secDown(){ ui->spinBox_main_s->setValue(59); } - +/*on_pushSet_Clicked +* +*/ void dependent::on_pushSet_clicked() { dep_h = ui->spinBox_main_h->value(); @@ -83,13 +101,17 @@ void dependent::on_pushSet_clicked() ui->spinBox_main_s->setValue(0); } } - +/*depSecUp +* +*/ void dependent::depSecUp(){ if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()){ connect(mytimer, SIGNAL(timeout()), this, SLOT(depUpStart())); } } - +/*depUpStart +* Starts the depenent timer up +*/ void dependent::depUpStart(){ ui->spinBox_dep_s->stepUp(); if(ui->spinBox_dep_s->value()==60){ @@ -102,6 +124,9 @@ void dependent::depUpStart(){ } } +/* +* Updates the dependent timer seconds spinbox +*/ void dependent::depSecDown(){ ui->spinBox_dep_s->stepDown(); if(ui->spinBox_dep_s->value() == 0){ @@ -118,21 +143,29 @@ void dependent::depSecDown(){ ui->spinBox_dep_s->setValue(59); } - +/* +* +*/ void dependent::checkToConnect(){ if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()-1) connect(mytimer, SIGNAL(timeout()), this, SLOT(depSecDown())); } +/* +* Function disconnects the signal from the slot and stops countings +*/ void dependent::on_pushStop_clicked() { mytimer->disconnect(); mytimer->stop(); } +/* +* Message box for user instructions +*/ void dependent::on_pushAbout_clicked() { - QMessageBox::information(this, "How to Use", - "countUp Instructions:\nSet the main timer to when you want the dependent timer to start and click 'set'.\n You can change the dependent timer after this. For example if you want to start at with the dependent timer at 5s, set the main timer, and then change the \n dependent timer spinbox to 5.\ncountDown Instructions:\nThe dependent timer can start when the main timer is 0:0:0 or you can set the dependent timer to start at specific time.\n Set the dependent timer as with the countUp instructions.\n You can then change the dependent timer.\n For example, set main timer to 5s, click set. Then\n change the dependent timer spin boxes to where you want to start."); + QMessageBox::information(this, "How to use", + "Count Up Instructions:\nSet the main timer to when you want the dependent timer to start and click 'set'.\n You can change the dependent timer after this. For example, if you want to start the dependent timer at 5s, set the main timer, and then change the\ndependent timer input box to 5.\n Count Down Instructions:\nThe dependent timer can start when the main timer is 0:0:0 or you can set the dependent timer to start at specific time.\n Set the dependent timer per the Count Up instructions.\n You can then change the dependent timer.\n For example, set main timer to 5s, click set. Then\n change the dependent timer spin boxes to where you want to start."); } diff --git a/finalTimer/dependent.h b/finalTimer/dependent.h index d1cfa4b..b7e5bcc 100755 --- a/finalTimer/dependent.h +++ b/finalTimer/dependent.h @@ -33,12 +33,12 @@ public slots: private: Ui::dependent *ui; QTimer *mytimer; - int main_h; - int main_m; - int main_s; - int dep_h; - int dep_m; - int dep_s; + int main_h; // main timer hours + int main_m; // main timer minutes + int main_s; // main timer seconds + int dep_h; // dependent timer hours + int dep_m; // dependent timer minutes + int dep_s; // dependent timer seconds private slots: void on_pushAbout_clicked(); diff --git a/finalTimer/dependent.ui b/finalTimer/dependent.ui index 58f0f85..97486e2 100755 --- a/finalTimer/dependent.ui +++ b/finalTimer/dependent.ui @@ -6,87 +6,20 @@ 0 0 - 303 - 196 + 455 + 416 - - - 303 - 196 - - - Dialog + Dependent Timers - - - - 10 - 30 - 160 - 80 - - - - - - - - - - - - - - - - - - - - - - countUp - - - - - - - countDown - - - - - - - - - - - Start - - - - - - - Stop - - - - - - - - 170 - 140 - 75 - 23 + 330 + 160 + 71 + 31 @@ -96,12 +29,17 @@ - 70 - 10 - 61 + 120 + 20 + 121 16 + + + 16 + + Main Timer @@ -109,12 +47,17 @@ - 50 - 120 - 91 - 16 + 90 + 110 + 171 + 31 + + + 16 + + Dependent Timer @@ -122,9 +65,9 @@ - 180 - 170 - 91 + 260 + 120 + 141 17 @@ -135,10 +78,10 @@ - 9 - 140 - 161 - 22 + 60 + 150 + 251 + 51 @@ -156,16 +99,89 @@ - 220 - 30 - 75 - 23 + 300 + 300 + 101 + 41 About + + + + 50 + 230 + 311 + 51 + + + + + + + Count Up + + + + + + + Count Down + + + + + + + + + 60 + 50 + 251 + 51 + + + + + + + + + + + + + + + + + + 20 + 300 + 121 + 41 + + + + Start + + + + + + 160 + 300 + 121 + 41 + + + + Stop + + diff --git a/finalTimer/finalTimer.pro b/finalTimer/finalTimer.pro deleted file mode 100755 index c1f7c01..0000000 --- a/finalTimer/finalTimer.pro +++ /dev/null @@ -1,24 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2012-04-29T19:29:40 -# -#------------------------------------------------- - -QT += core gui - -TARGET = finalTimer -TEMPLATE = app - - -SOURCES += main.cpp\ - mainwindow.cpp \ - singletimer.cpp \ - dependent.cpp - -HEADERS += mainwindow.h \ - singletimer.h \ - dependent.h - -FORMS += mainwindow.ui \ - singletimer.ui \ - dependent.ui diff --git a/finalTimer/finalTimer.pro.user b/finalTimer/finalTimer.pro.user deleted file mode 100755 index 666fc2b..0000000 --- a/finalTimer/finalTimer.pro.user +++ /dev/null @@ -1,113 +0,0 @@ - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - System - - - - ProjectExplorer.Project.Target.0 - - Desktop - Qt4ProjectManager.Target.DesktopTarget - 0 - 0 - - - qmake - QtProjectManager.QMakeBuildStep - - - - Make - Qt4ProjectManager.MakeStep - false - - - - 2 - - Make - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop - 2 - 2 - true - - - - qmake - QtProjectManager.QMakeBuildStep - - - - Make - Qt4ProjectManager.MakeStep - false - - - - 2 - - Make - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop - 2 - 2 - true - - 2 - - finalTimer - Qt4ProjectManager.Qt4RunConfiguration - 2 - - finalTimer.pro - false - false - - false - false - - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 4 - - diff --git a/finalTimer/main.cpp b/finalTimer/main.cpp index a001eb2..c811da0 100755 --- a/finalTimer/main.cpp +++ b/finalTimer/main.cpp @@ -1,6 +1,8 @@ #include #include "mainwindow.h" +// Main Qt application start + int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/finalTimer/mainwindow.cpp b/finalTimer/mainwindow.cpp deleted file mode 100755 index e5ad455..0000000 --- a/finalTimer/mainwindow.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -//open a single timer window -void MainWindow::openSingle(){ - //open multiple timing windows and allow control to main - //I chose this since one of the ideas of the project was - //to have multiple timers available to someone - oneTimer = new singleTimer(this); - oneTimer->show(); - - //you would use these lines if you only wanted the user to have one window - //disables control leaving the opened window - //singleTimer oneTimer; - //oneTimer.setModal(true); - //oneTimer.exec(); -} - -//open a timing window with one dependent timer and one independent timer -void MainWindow::openDependent(){ - mainTimer = new dependent(); - mainTimer->show(); - /* - dependent mainTimer; - mainTimer.setModal(true); - mainTimer.exec(); - */ -} - diff --git a/finalTimer/mainwindow.h b/finalTimer/mainwindow.h deleted file mode 100755 index 734c6c0..0000000 --- a/finalTimer/mainwindow.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include "singletimer.h" -#include "dependent.h" - -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - - - //functions to open the individual timing windows -private slots: - void openSingle(); - void openDependent(); - -private: - Ui::MainWindow *ui; - singleTimer *oneTimer; - dependent *mainTimer; -}; - -#endif // MAINWINDOW_H diff --git a/finalTimer/mainwindow.ui b/finalTimer/mainwindow.ui index fd584d1..740b541 100755 --- a/finalTimer/mainwindow.ui +++ b/finalTimer/mainwindow.ui @@ -1,45 +1,52 @@ + MainWindow 0 0 - 136 - 128 + 400 + 400 - 136 - 128 + 400 + 400 - MainWindow + Timer Program + + + + 30 0 - 75 - 23 + 150 + 60 Single Timer + + 10 - 30 - 121 - 41 + 80 + 200 + 60 @@ -48,6 +55,8 @@ One Dependent Timer + + @@ -58,6 +67,9 @@ One Dependent Timer + + + TopToolBarArea @@ -68,6 +80,8 @@ One Dependent Timer + + @@ -78,8 +92,8 @@ One Dependent Timer openSingle() - 160 - 85 + 300 + 300 96 diff --git a/finalTimer/singletimer.ui b/finalTimer/singletimer.ui index 8961133..f1a712e 100755 --- a/finalTimer/singletimer.ui +++ b/finalTimer/singletimer.ui @@ -6,20 +6,20 @@ 0 0 - 319 - 166 + 619 + 367 - Dialog + Single Timer - 20 - 10 - 161 - 51 + 40 + 60 + 231 + 71 @@ -37,19 +37,23 @@ - 230 - 70 - 61 + 360 + 150 + 201 31 + + + 12 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">countDown</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> options</span></p></body></html> +</style></head><body style=" font-family:'Bitstream Charter'; font-size:12pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt;">Count Down Options</span></p></body></html> Qt::RichText @@ -58,24 +62,24 @@ p, li { white-space: pre-wrap; } - 10 - 70 - 191 - 19 + 20 + 160 + 291 + 51 - + - countUp + Count Down - + - countDown + Count Up @@ -84,10 +88,10 @@ p, li { white-space: pre-wrap; } - 210 - 110 - 96 - 42 + 360 + 190 + 211 + 101 @@ -107,31 +111,59 @@ p, li { white-space: pre-wrap; } - + - 20 - 100 - 161 - 25 + 40 + 250 + 111 + 41 - - - - - Start - - - - - - - Stop - - - - + + + 16 + + + + Start + + + + + + 190 + 250 + 111 + 41 + + + + + 16 + + + + Stop + + + + + + 90 + 20 + 141 + 23 + + + + + 16 + + + + Single Timer + From c5b9f409b239f70f4edba078f3edeabbb0644f00 Mon Sep 17 00:00:00 2001 From: Thomas Walton Date: Wed, 2 May 2012 00:11:05 -0400 Subject: [PATCH 02/14] Add these --- finalTimer/finalTimer.pro | 24 +++++++ finalTimer/finalTimer.pro.user | 113 +++++++++++++++++++++++++++++++++ finalTimer/mainwindow.cpp | 42 ++++++++++++ finalTimer/mainwindow.h | 32 ++++++++++ 4 files changed, 211 insertions(+) create mode 100755 finalTimer/finalTimer.pro create mode 100755 finalTimer/finalTimer.pro.user create mode 100755 finalTimer/mainwindow.cpp create mode 100755 finalTimer/mainwindow.h diff --git a/finalTimer/finalTimer.pro b/finalTimer/finalTimer.pro new file mode 100755 index 0000000..c1f7c01 --- /dev/null +++ b/finalTimer/finalTimer.pro @@ -0,0 +1,24 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-04-29T19:29:40 +# +#------------------------------------------------- + +QT += core gui + +TARGET = finalTimer +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp \ + singletimer.cpp \ + dependent.cpp + +HEADERS += mainwindow.h \ + singletimer.h \ + dependent.h + +FORMS += mainwindow.ui \ + singletimer.ui \ + dependent.ui diff --git a/finalTimer/finalTimer.pro.user b/finalTimer/finalTimer.pro.user new file mode 100755 index 0000000..666fc2b --- /dev/null +++ b/finalTimer/finalTimer.pro.user @@ -0,0 +1,113 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop + 2 + 2 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop + 2 + 2 + true + + 2 + + finalTimer + Qt4ProjectManager.Qt4RunConfiguration + 2 + + finalTimer.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/finalTimer/mainwindow.cpp b/finalTimer/mainwindow.cpp new file mode 100755 index 0000000..e5ad455 --- /dev/null +++ b/finalTimer/mainwindow.cpp @@ -0,0 +1,42 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +//open a single timer window +void MainWindow::openSingle(){ + //open multiple timing windows and allow control to main + //I chose this since one of the ideas of the project was + //to have multiple timers available to someone + oneTimer = new singleTimer(this); + oneTimer->show(); + + //you would use these lines if you only wanted the user to have one window + //disables control leaving the opened window + //singleTimer oneTimer; + //oneTimer.setModal(true); + //oneTimer.exec(); +} + +//open a timing window with one dependent timer and one independent timer +void MainWindow::openDependent(){ + mainTimer = new dependent(); + mainTimer->show(); + /* + dependent mainTimer; + mainTimer.setModal(true); + mainTimer.exec(); + */ +} + diff --git a/finalTimer/mainwindow.h b/finalTimer/mainwindow.h new file mode 100755 index 0000000..734c6c0 --- /dev/null +++ b/finalTimer/mainwindow.h @@ -0,0 +1,32 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "singletimer.h" +#include "dependent.h" + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + + + //functions to open the individual timing windows +private slots: + void openSingle(); + void openDependent(); + +private: + Ui::MainWindow *ui; + singleTimer *oneTimer; + dependent *mainTimer; +}; + +#endif // MAINWINDOW_H From 7588101cdff658b3b6a77a3af7b0d7902c9f754a Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 2 May 2012 23:18:07 -0400 Subject: [PATCH 03/14] Moved README --- finalTimer/README => README | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename finalTimer/README => README (100%) diff --git a/finalTimer/README b/README similarity index 100% rename from finalTimer/README rename to README From f6c59d4645a7c437f284bcd181bd15fbb3a02ca4 Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 2 May 2012 23:23:35 -0400 Subject: [PATCH 04/14] added my contributions file --- CONTRIBUTIONS.tavispa | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CONTRIBUTIONS.tavispa diff --git a/CONTRIBUTIONS.tavispa b/CONTRIBUTIONS.tavispa new file mode 100644 index 0000000..15033fc --- /dev/null +++ b/CONTRIBUTIONS.tavispa @@ -0,0 +1,5 @@ +My contributions to this project involved developing the layout for the timer GUI and locating resources for us to use to develop in QT. +I also attempted to manage the repo but we had some problems with it where we couldn't it to sync correctly so we often did things through +dropbox instead. +I wrote prototype code in C and Qt's C++ to demonstrate the single timer application. +I wrote the code for the single timer application and made the decisions on the GUI architecture, and decided on its limitations for the scope of this project. From a25fb6ef382093a317db7599b4aca02b6c04d642 Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 2 May 2012 23:42:44 -0400 Subject: [PATCH 05/14] Fixing window sizes --- finalTimer/dependent.ui | 416 +++++++++++++++++++-------------------- finalTimer/mainwindow.ui | 236 +++++++++++----------- 2 files changed, 319 insertions(+), 333 deletions(-) diff --git a/finalTimer/dependent.ui b/finalTimer/dependent.ui index 97486e2..304c3b4 100755 --- a/finalTimer/dependent.ui +++ b/finalTimer/dependent.ui @@ -1,208 +1,208 @@ - - - dependent - - - - 0 - 0 - 455 - 416 - - - - Dependent Timers - - - - - 330 - 160 - 71 - 31 - - - - Set - - - - - - 120 - 20 - 121 - 16 - - - - - 16 - - - - Main Timer - - - - - - 90 - 110 - 171 - 31 - - - - - 16 - - - - Dependent Timer - - - - - - 260 - 120 - 141 - 17 - - - - Do Not Reset - - - - - - 60 - 150 - 251 - 51 - - - - - - - - - - - - - - - - - - 300 - 300 - 101 - 41 - - - - About - - - - - - 50 - 230 - 311 - 51 - - - - - - - Count Up - - - - - - - Count Down - - - - - - - - - 60 - 50 - 251 - 51 - - - - - - - - - - - - - - - - - - 20 - 300 - 121 - 41 - - - - Start - - - - - - 160 - 300 - 121 - 41 - - - - Stop - - - - - - - pushStop - clicked() - dependent - stop() - - - 237 - 156 - - - 268 - 156 - - - - - - stop() - - + + + dependent + + + + 0 + 0 + 455 + 416 + + + + Dependent Timers + + + + + 330 + 160 + 71 + 31 + + + + Set + + + + + + 120 + 20 + 121 + 16 + + + + + 16 + + + + Main Timer + + + + + + 90 + 110 + 191 + 31 + + + + + 16 + + + + Dependent Timer + + + + + + 310 + 120 + 141 + 17 + + + + Do Not Reset + + + + + + 60 + 150 + 251 + 51 + + + + + + + + + + + + + + + + + + 300 + 300 + 101 + 41 + + + + About + + + + + + 50 + 230 + 311 + 51 + + + + + + + Count Up + + + + + + + Count Down + + + + + + + + + 60 + 50 + 251 + 51 + + + + + + + + + + + + + + + + + + 20 + 300 + 121 + 41 + + + + Start + + + + + + 160 + 300 + 121 + 41 + + + + Stop + + + + + + + pushStop + clicked() + dependent + stop() + + + 237 + 156 + + + 268 + 156 + + + + + + stop() + + diff --git a/finalTimer/mainwindow.ui b/finalTimer/mainwindow.ui index 740b541..8a053dd 100755 --- a/finalTimer/mainwindow.ui +++ b/finalTimer/mainwindow.ui @@ -1,125 +1,111 @@ - - - - MainWindow - - - - 0 - 0 - 400 - 400 - - - - - 400 - 400 - - - - Timer Program - - - - - - - - - - 30 - 0 - 150 - 60 - - - - Single Timer - - - - - - - - 10 - 80 - 200 - 60 - - - - One Main Timer -One Dependent Timer - - - - - - - - - 0 - 0 - 136 - 21 - - - - - - - - - TopToolBarArea - - - false - - - - - - - - - - - pushButton - clicked() - MainWindow - openSingle() - - - 300 - 300 - - - 96 - 146 - - - - - pushButton_2 - clicked() - MainWindow - openDependent() - - - 225 - 104 - - - 296 - 106 - - - - - - openSingle() - openDependent() - - + + + MainWindow + + + + 0 + 0 + 224 + 228 + + + + + 224 + 228 + + + + Timer Program + + + + + + 30 + 0 + 150 + 60 + + + + Single Timer + + + + + + 10 + 80 + 200 + 60 + + + + One Main Timer +One Dependent Timer + + + + + + + 0 + 0 + 224 + 27 + + + + + + TopToolBarArea + + + false + + + + + + + + + pushButton + clicked() + MainWindow + openSingle() + + + 300 + 300 + + + 96 + 146 + + + + + pushButton_2 + clicked() + MainWindow + openDependent() + + + 225 + 104 + + + 296 + 106 + + + + + + openSingle() + openDependent() + + From d5e9a0df7a8627a7faad68cf94c4e96b761a8fb6 Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 2 May 2012 23:51:17 -0400 Subject: [PATCH 06/14] Updated README to reflect current absence of make file that cleans or enters subdirectory --- README | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README b/README index fb5b87c..001c34d 100644 --- a/README +++ b/README @@ -5,8 +5,11 @@ they are not already on your system. To do this run this command from the termi sudo apt-get install libxtst-dev build-essential libqt4-dev qt4-qmake -In order to run the program you type qmake and then make from the command line. This should create an executable -called finalTimer. To execute the program type ./finalTimer +In order to run the program enter the finalTimer directory, run the command: +qmake +Once that finishes run the command +make +This should create an executable called finalTimer. To execute the program type ./finalTimer User instructions: @@ -14,5 +17,3 @@ User instructions: There are two buttons in the main window. The single timer button lauches a window that has a single count up or count down timer. There are two options to choose what will occur when the timer finishes. The dependent timer button launches a new timer that has dependencies. There is a About button for user instructions. - - From 87cc525f6a6a10d9aff3c35d3f7a431a3eeb61c7 Mon Sep 17 00:00:00 2001 From: Thomas Walton Date: Thu, 3 May 2012 00:08:35 -0400 Subject: [PATCH 07/14] Contributions --- CONTRIBUTIONS.thomasw4 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CONTRIBUTIONS.thomasw4 diff --git a/CONTRIBUTIONS.thomasw4 b/CONTRIBUTIONS.thomasw4 new file mode 100644 index 0000000..a229c86 --- /dev/null +++ b/CONTRIBUTIONS.thomasw4 @@ -0,0 +1,6 @@ + +I worked on some of the qt code and ui files. Made changes and updates to some of the source code. Usig github posed some problems for us, we often times +couldn't push or pull. We reverted to dropbox and email, to collaborate on the project. Most of my contribution is for the text based timer (console input and output) +and trying to link the gui to the console. As it is right now, the gui is working great, the console is working great, but still working on the interfacing between the two. +We have not pushed the console version to the repo yet. What we have now is working and in order to meet the deadline of a "working" submission, I chose to not push the +console version until later today. From 7761ba254890e2d9218d396c7ad39f90aa049dab Mon Sep 17 00:00:00 2001 From: tavispa Date: Thu, 3 May 2012 00:28:47 -0400 Subject: [PATCH 08/14] Added main directory Makefile with clean up (although clean: didn't work), had to rename directory --- Makefile | 14 +++ timerGUI/dependent.cpp | 171 ++++++++++++++++++++++++++++ timerGUI/dependent.h | 50 +++++++++ timerGUI/dependent.ui | 208 +++++++++++++++++++++++++++++++++++ timerGUI/finalTimer.pro | 24 ++++ timerGUI/finalTimer.pro.user | 167 ++++++++++++++++++++++++++++ timerGUI/main.cpp | 13 +++ timerGUI/mainwindow.cpp | 42 +++++++ timerGUI/mainwindow.h | 32 ++++++ timerGUI/mainwindow.ui | 111 +++++++++++++++++++ timerGUI/singletimer.cpp | 147 +++++++++++++++++++++++++ timerGUI/singletimer.h | 51 +++++++++ timerGUI/singletimer.ui | 194 ++++++++++++++++++++++++++++++++ timerGUI/ui_dependent.h | 171 ++++++++++++++++++++++++++++ timerGUI/ui_mainwindow.h | 86 +++++++++++++++ timerGUI/ui_singletimer.h | 162 +++++++++++++++++++++++++++ 16 files changed, 1643 insertions(+) create mode 100644 Makefile create mode 100755 timerGUI/dependent.cpp create mode 100755 timerGUI/dependent.h create mode 100755 timerGUI/dependent.ui create mode 100755 timerGUI/finalTimer.pro create mode 100755 timerGUI/finalTimer.pro.user create mode 100755 timerGUI/main.cpp create mode 100755 timerGUI/mainwindow.cpp create mode 100755 timerGUI/mainwindow.h create mode 100755 timerGUI/mainwindow.ui create mode 100755 timerGUI/singletimer.cpp create mode 100755 timerGUI/singletimer.h create mode 100755 timerGUI/singletimer.ui create mode 100644 timerGUI/ui_dependent.h create mode 100644 timerGUI/ui_mainwindow.h create mode 100644 timerGUI/ui_singletimer.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..37d1f0e --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +CXX_FLAGS := -O2 -DNDEBUG -Wall -g -march=core2 -std=c++11 +CXX := g++ +INSTALL_DIR := ./ +export CXX +export CXX_FLAGS + +.PHONY: finalTimer +finalTimer: + qmake timerGUI/finalTimer.pro -o timerGUI/Makefile + $(MAKE) -C timerGUI + rm ./timerGUI/moc* + rm ./timerGUI/*.o + rm ./timerGUI/Makefile + mv timerGUI/finalTimer $(INSTALL_DIR) diff --git a/timerGUI/dependent.cpp b/timerGUI/dependent.cpp new file mode 100755 index 0000000..b24ee41 --- /dev/null +++ b/timerGUI/dependent.cpp @@ -0,0 +1,171 @@ +#include "dependent.h" +#include "ui_dependent.h" + +dependent::dependent(QWidget *parent) : + QDialog(parent), + ui(new Ui::dependent) +{ + ui->setupUi(this); + mytimer = new QTimer(); + dep_h = 0; + dep_m = 0; + dep_s = 0; +} + +dependent::~dependent() +{ + delete ui; +} +/* +*on_pushStart_clicked +* On click event function for starting execution and connecting +* appropiate signals and slots. +*/ +void dependent::on_pushStart_clicked() +{ + + if(ui->radioUp->isChecked()){ + connect(mytimer, SIGNAL(timeout()), this, SLOT(secUp())); + connect(mytimer, SIGNAL(timeout()), this, SLOT(depSecUp())); + } + if(ui->radioDown->isChecked()){ + connect(mytimer, SIGNAL(timeout()), this, SLOT(secDown())); + connect(mytimer, SIGNAL(timeout()), this, SLOT(checkToConnect())); + } + mytimer->start(1000); +} + +/*stop +* Function to disconnect slots and signals when timers expire +* checks the main timer spin box values +*/ + +void dependent::stop() +{ + if(ui->spinBox_main_h->value() == 0 && ui->spinBox_main_m->value() == 0 && ui->spinBox_main_s->value() == 0){ + disconnect(mytimer, SIGNAL(timeout()), this, SLOT(secDown())); + } + +} + +/*secUp +* Updates the main timer spin boxes and resets the boxes +* as dependent timer counts up +*/ + +void dependent::secUp(){ + ui->spinBox_main_s->stepUp(); + if(ui->spinBox_main_s->value()==60){ + ui->spinBox_main_m->stepUp(); + if(ui->spinBox_main_m->value() == 60){ + ui->spinBox_main_h->stepUp(); + ui->spinBox_main_m->setValue(0); + } + ui->spinBox_main_s->setValue(0); + } +} + +/*secDown +* Updates the main timer spin boxes and reset as needed +* as dependent timer counts down +*/ + +void dependent::secDown(){ + ui->spinBox_main_s->stepDown(); + if(ui->spinBox_main_s->value() == 0){ + if(ui->spinBox_main_m->value() == 0 && ui->spinBox_main_h->value() > 0){ + ui->spinBox_main_h->stepDown(); + ui->spinBox_main_m->setValue(59); + } + else + ui->spinBox_main_m->stepDown(); + } + if(ui->spinBox_main_h->value() == 0 && ui->spinBox_main_m->value() == 0 && ui->spinBox_main_s->value() == 0){ + stop(); + } + else if(ui->spinBox_main_s->value() == 0) + ui->spinBox_main_s->setValue(59); +} + +/*on_pushSet_Clicked +* +*/ +void dependent::on_pushSet_clicked() +{ + dep_h = ui->spinBox_main_h->value(); + dep_m = ui->spinBox_main_m->value(); + dep_s = ui->spinBox_main_s->value(); + if(!ui->checkReset->isChecked()){ + ui->spinBox_main_h->setValue(0); + ui->spinBox_main_m->setValue(0); + ui->spinBox_main_s->setValue(0); + } +} +/*depSecUp +* +*/ +void dependent::depSecUp(){ + if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()){ + connect(mytimer, SIGNAL(timeout()), this, SLOT(depUpStart())); + } +} +/*depUpStart +* Starts the depenent timer up +*/ +void dependent::depUpStart(){ + ui->spinBox_dep_s->stepUp(); + if(ui->spinBox_dep_s->value()==60){ + ui->spinBox_dep_m->stepUp(); + if(ui->spinBox_dep_m->value() == 60){ + ui->spinBox_dep_h->stepUp(); + ui->spinBox_dep_m->setValue(0); + } + ui->spinBox_dep_s->setValue(0); + } +} + +/* +* Updates the dependent timer seconds spinbox +*/ +void dependent::depSecDown(){ + ui->spinBox_dep_s->stepDown(); + if(ui->spinBox_dep_s->value() == 0){ + if(ui->spinBox_dep_m->value() == 0 && ui->spinBox_dep_h->value() > 0){ + ui->spinBox_dep_h->stepDown(); + ui->spinBox_dep_m->setValue(59); + } + else + ui->spinBox_dep_m->stepDown(); + } + if(ui->spinBox_dep_h->value() == 0 && ui->spinBox_dep_m->value() == 0 && ui->spinBox_dep_s->value() == 0) + stop(); + else if(ui->spinBox_dep_s->value() == 0) + ui->spinBox_dep_s->setValue(59); +} + +/* +* +*/ + +void dependent::checkToConnect(){ + if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()-1) + connect(mytimer, SIGNAL(timeout()), this, SLOT(depSecDown())); +} + +/* +* Function disconnects the signal from the slot and stops countings +*/ +void dependent::on_pushStop_clicked() +{ + mytimer->disconnect(); + mytimer->stop(); +} + +/* +* Message box for user instructions +*/ +void dependent::on_pushAbout_clicked() +{ + QMessageBox::information(this, "How to use", + "Count Up Instructions:\nSet the main timer to when you want the dependent timer to start and click 'set'.\n You can change the dependent timer after this. For example, if you want to start the dependent timer at 5s, set the main timer, and then change the\ndependent timer input box to 5.\n Count Down Instructions:\nThe dependent timer can start when the main timer is 0:0:0 or you can set the dependent timer to start at specific time.\n Set the dependent timer per the Count Up instructions.\n You can then change the dependent timer.\n For example, set main timer to 5s, click set. Then\n change the dependent timer spin boxes to where you want to start."); +} diff --git a/timerGUI/dependent.h b/timerGUI/dependent.h new file mode 100755 index 0000000..b7e5bcc --- /dev/null +++ b/timerGUI/dependent.h @@ -0,0 +1,50 @@ +#ifndef DEPENDENT_H +#define DEPENDENT_H + +#include +#include +#include + +namespace Ui { + class dependent; +} + +class dependent : public QDialog +{ + Q_OBJECT + +public: + explicit dependent(QWidget *parent = 0); + ~dependent(); + +public slots: + void stop(); + + void secUp(); + void secDown(); + + void depSecUp(); + void depUpStart(); + + void depSecDown(); + + void checkToConnect(); + +private: + Ui::dependent *ui; + QTimer *mytimer; + int main_h; // main timer hours + int main_m; // main timer minutes + int main_s; // main timer seconds + int dep_h; // dependent timer hours + int dep_m; // dependent timer minutes + int dep_s; // dependent timer seconds + +private slots: + void on_pushAbout_clicked(); + void on_pushStop_clicked(); + void on_pushSet_clicked(); + void on_pushStart_clicked(); +}; + +#endif // DEPENDENT_H diff --git a/timerGUI/dependent.ui b/timerGUI/dependent.ui new file mode 100755 index 0000000..304c3b4 --- /dev/null +++ b/timerGUI/dependent.ui @@ -0,0 +1,208 @@ + + + dependent + + + + 0 + 0 + 455 + 416 + + + + Dependent Timers + + + + + 330 + 160 + 71 + 31 + + + + Set + + + + + + 120 + 20 + 121 + 16 + + + + + 16 + + + + Main Timer + + + + + + 90 + 110 + 191 + 31 + + + + + 16 + + + + Dependent Timer + + + + + + 310 + 120 + 141 + 17 + + + + Do Not Reset + + + + + + 60 + 150 + 251 + 51 + + + + + + + + + + + + + + + + + + 300 + 300 + 101 + 41 + + + + About + + + + + + 50 + 230 + 311 + 51 + + + + + + + Count Up + + + + + + + Count Down + + + + + + + + + 60 + 50 + 251 + 51 + + + + + + + + + + + + + + + + + + 20 + 300 + 121 + 41 + + + + Start + + + + + + 160 + 300 + 121 + 41 + + + + Stop + + + + + + + pushStop + clicked() + dependent + stop() + + + 237 + 156 + + + 268 + 156 + + + + + + stop() + + diff --git a/timerGUI/finalTimer.pro b/timerGUI/finalTimer.pro new file mode 100755 index 0000000..c1f7c01 --- /dev/null +++ b/timerGUI/finalTimer.pro @@ -0,0 +1,24 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-04-29T19:29:40 +# +#------------------------------------------------- + +QT += core gui + +TARGET = finalTimer +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp \ + singletimer.cpp \ + dependent.cpp + +HEADERS += mainwindow.h \ + singletimer.h \ + dependent.h + +FORMS += mainwindow.ui \ + singletimer.ui \ + dependent.ui diff --git a/timerGUI/finalTimer.pro.user b/timerGUI/finalTimer.pro.user new file mode 100755 index 0000000..65fce9f --- /dev/null +++ b/timerGUI/finalTimer.pro.user @@ -0,0 +1,167 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + 0 + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + false + + + Make + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop + 2 + 0 + true + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + false + + + Make + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop + 2 + 0 + true + + 2 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + No deployment + ProjectExplorer.DefaultDeployConfiguration + + 1 + + finalTimer + finalTimer + Qt4ProjectManager.Qt4RunConfiguration + 2 + + finalTimer.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {51d458ba-8523-45dd-b880-1e75999cdc84} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/timerGUI/main.cpp b/timerGUI/main.cpp new file mode 100755 index 0000000..c811da0 --- /dev/null +++ b/timerGUI/main.cpp @@ -0,0 +1,13 @@ +#include +#include "mainwindow.h" + +// Main Qt application start + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/timerGUI/mainwindow.cpp b/timerGUI/mainwindow.cpp new file mode 100755 index 0000000..e5ad455 --- /dev/null +++ b/timerGUI/mainwindow.cpp @@ -0,0 +1,42 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +//open a single timer window +void MainWindow::openSingle(){ + //open multiple timing windows and allow control to main + //I chose this since one of the ideas of the project was + //to have multiple timers available to someone + oneTimer = new singleTimer(this); + oneTimer->show(); + + //you would use these lines if you only wanted the user to have one window + //disables control leaving the opened window + //singleTimer oneTimer; + //oneTimer.setModal(true); + //oneTimer.exec(); +} + +//open a timing window with one dependent timer and one independent timer +void MainWindow::openDependent(){ + mainTimer = new dependent(); + mainTimer->show(); + /* + dependent mainTimer; + mainTimer.setModal(true); + mainTimer.exec(); + */ +} + diff --git a/timerGUI/mainwindow.h b/timerGUI/mainwindow.h new file mode 100755 index 0000000..734c6c0 --- /dev/null +++ b/timerGUI/mainwindow.h @@ -0,0 +1,32 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "singletimer.h" +#include "dependent.h" + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + + + //functions to open the individual timing windows +private slots: + void openSingle(); + void openDependent(); + +private: + Ui::MainWindow *ui; + singleTimer *oneTimer; + dependent *mainTimer; +}; + +#endif // MAINWINDOW_H diff --git a/timerGUI/mainwindow.ui b/timerGUI/mainwindow.ui new file mode 100755 index 0000000..8a053dd --- /dev/null +++ b/timerGUI/mainwindow.ui @@ -0,0 +1,111 @@ + + + MainWindow + + + + 0 + 0 + 224 + 228 + + + + + 224 + 228 + + + + Timer Program + + + + + + 30 + 0 + 150 + 60 + + + + Single Timer + + + + + + 10 + 80 + 200 + 60 + + + + One Main Timer +One Dependent Timer + + + + + + + 0 + 0 + 224 + 27 + + + + + + TopToolBarArea + + + false + + + + + + + + + pushButton + clicked() + MainWindow + openSingle() + + + 300 + 300 + + + 96 + 146 + + + + + pushButton_2 + clicked() + MainWindow + openDependent() + + + 225 + 104 + + + 296 + 106 + + + + + + openSingle() + openDependent() + + diff --git a/timerGUI/singletimer.cpp b/timerGUI/singletimer.cpp new file mode 100755 index 0000000..2485f9a --- /dev/null +++ b/timerGUI/singletimer.cpp @@ -0,0 +1,147 @@ +#include "singletimer.h" +#include "ui_singletimer.h" + + +singleTimer::singleTimer(QWidget *parent) : + QDialog(parent), + ui(new Ui::singleTimer) +{ + ui->setupUi(this); + //create timer pointer + mytimer = new QTimer(); +} + +singleTimer::~singleTimer() +{ + delete ui; +} + +/*countdownStart - + connects the signals from the timer to the second portion of the timing box + then connects the seconds to minutes, minutes to hours + starts the timer + if rollOver is checked, then it saves where the values will need to go back to +*/ +void singleTimer::countdownStart(){ + connect(mytimer, SIGNAL(timeout()), this, SLOT(subtractOne())); + connect(ui->spinBox_h, SIGNAL(valueChanged(int)), this, SLOT(setMValue())); + connect(ui->spinBox_m, SIGNAL(valueChanged(int)), this, SLOT(setSValue())); + if(ui->checkRollover->isChecked()){ + hour = ui->spinBox_h->value(); + min = ui->spinBox_m->value(); + sec = ui->spinBox_s->value(); + } + mytimer->start(1000); +} + + +/*subtractOne + + subtract one from the second box, then check to see if other boxes need to be subtracted from + and reset seconds to 59 (or minutes to 59) based on what happens in more significant places + + control what happens if check boxes are/aren't checked + + */ +void singleTimer::subtractOne(){ + ui->spinBox_s->stepDown(); + if(ui->spinBox_s->value() == 0){ + if(ui->spinBox_m->value()-1 == 0 && ui->spinBox_h->value()>0){ + ui->spinBox_h->stepDown(); + } + else + ui->spinBox_m->stepDown(); + } + if(ui->spinBox_h->value() == 0 && ui->spinBox_m->value() == 0 && ui->spinBox_s ->value() == 0){ + /* + if(ui->checkSound->isChecked()){ + //possible implementation + } + */ + + //display a message + if(ui->checkMessage->isChecked()){ + QMessageBox::information(this, "Timer Stop", "Countdown finished!"); + } + + //if it's not rolling over, stop the timer + if(!ui->checkRollover->isChecked()){ + stop(); + } + //if the timer doesn't stop, reset to the roll over values + else{ + ui->spinBox_h->setValue(hour); + ui->spinBox_m->setValue(min); + ui->spinBox_s->setValue(sec); + } + } +} + +//setMValue and setSValue set the spin boxes to 59 when they hit 0 and you get a carry from +//a more significant section +void singleTimer::setMValue(){ + ui->spinBox_m->setValue(59); +} + +void singleTimer::setSValue(){ + ui->spinBox_s->setValue(59); +} + + +/*countupStart + connects the spin boxes so they change as necessary when seconds hits 60, or minutes hits 60 + + */ +void singleTimer::countupStart(){ + connect(mytimer, SIGNAL(timeout()), this, SLOT(addOne())); + connect(ui->spinBox_h, SIGNAL(valueChanged(int)), this, SLOT(setMLow())); + connect(ui->spinBox_m, SIGNAL(valueChanged(int)), this, SLOT(setSLow())); +} + +//addOne +//add one to the seconds, if it hits 60, add one to minutes, if minutes hits 60, add one to hours, +//roll seconds/minutes back over to 0 +void singleTimer::addOne(){ + ui->spinBox_s->stepUp(); + if(ui->spinBox_s->value() == 60){ + ui->spinBox_m->stepUp(); + if(ui->spinBox_m->value() == 60){ + ui->spinBox_h->stepUp(); + } + } +} + +//setMLow and setSLow set minutes and seconds to 0 as needed +void singleTimer::setMLow(){ + ui->spinBox_m->setValue(0); +} + +void singleTimer::setSLow(){ + ui->spinBox_s->setValue(0); +} + + +//when the pushButton is clicked, determine if the timer is counting up or down, +//call those functions to connect signals +//start the timer +void singleTimer::on_pushStart_clicked() +{ + + if(ui->radioDown->isChecked()) + countdownStart(); + else if(ui->radioUp->isChecked()) + countupStart(); + mytimer->start(1000); +} + + +//stop +//stop the timer, and disconnect the signals +//if you don't disconnect the signals, everytime you click start it will add 1 to how much seconds is +//increased/decreased by (click it once, increases by 1, click it again, starts increasing by 2, then 3, etc) +void singleTimer::stop() +{ + mytimer->stop(); + disconnect(mytimer, SIGNAL(timeout()), this, SLOT(addOne())); + disconnect(mytimer, SIGNAL(timeout()), this, SLOT(subtractOne())); +} diff --git a/timerGUI/singletimer.h b/timerGUI/singletimer.h new file mode 100755 index 0000000..458d96c --- /dev/null +++ b/timerGUI/singletimer.h @@ -0,0 +1,51 @@ +#ifndef SINGLETIMER_H +#define SINGLETIMER_H + +#include +#include +#include + +namespace Ui { + class singleTimer; +} + +class singleTimer : public QDialog +{ + Q_OBJECT + +public: + explicit singleTimer(QWidget *parent = 0); + ~singleTimer(); + +//Everything above here is automatically created by QT +public slots: + //functions needed to countdown to work + void countdownStart(); + void subtractOne(); + void setMValue(); + void setSValue(); + + //functions needed for countup to work + void countupStart(); + void addOne(); + void setMLow(); + void setSLow(); + + //function to stop timer + void stop(); + +private: + Ui::singleTimer *ui; + QTimer *mytimer; + + //variables to store time in case of roll over + int hour; + int min; + int sec; + +private slots: + //you can do this with a different function but this can be created automatically + void on_pushStart_clicked(); +}; + +#endif // SINGLETIMER_H diff --git a/timerGUI/singletimer.ui b/timerGUI/singletimer.ui new file mode 100755 index 0000000..29582b8 --- /dev/null +++ b/timerGUI/singletimer.ui @@ -0,0 +1,194 @@ + + + singleTimer + + + + 0 + 0 + 619 + 367 + + + + Single Timer + + + + + 40 + 60 + 231 + 71 + + + + + + + + + + + + + + + + + + 360 + 150 + 201 + 31 + + + + + 12 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Bitstream Charter'; font-size:12pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt;">Count Down Options</span></p></body></html> + + + Qt::RichText + + + + + + 20 + 160 + 291 + 51 + + + + + + + Count Up + + + + + + + Count Down + + + + + + + + + 360 + 190 + 211 + 101 + + + + + + + Show Message + + + + + + + Rollover + + + + + + + + + 40 + 250 + 111 + 41 + + + + + 16 + + + + Start + + + + + + 190 + 250 + 111 + 41 + + + + + 16 + + + + Stop + + + + + + 90 + 20 + 141 + 23 + + + + + 16 + + + + Single Timer + + + + + + + pushStop + clicked() + singleTimer + stop() + + + 209 + 174 + + + 211 + 186 + + + + + + countupStart() + countdownStart() + start() + stop() + + diff --git a/timerGUI/ui_dependent.h b/timerGUI/ui_dependent.h new file mode 100644 index 0000000..2199423 --- /dev/null +++ b/timerGUI/ui_dependent.h @@ -0,0 +1,171 @@ +/******************************************************************************** +** Form generated from reading UI file 'dependent.ui' +** +** Created: Wed May 2 23:44:57 2012 +** by: Qt User Interface Compiler version 4.7.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_DEPENDENT_H +#define UI_DEPENDENT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_dependent +{ +public: + QPushButton *pushSet; + QLabel *label_2; + QLabel *label_3; + QCheckBox *checkReset; + QWidget *layoutWidget; + QHBoxLayout *horizontalLayout_4; + QSpinBox *spinBox_dep_h; + QSpinBox *spinBox_dep_m; + QSpinBox *spinBox_dep_s; + QPushButton *pushAbout; + QWidget *layoutWidget1; + QHBoxLayout *horizontalLayout_3; + QRadioButton *radioUp; + QRadioButton *radioDown; + QWidget *layoutWidget2; + QHBoxLayout *horizontalLayout; + QSpinBox *spinBox_main_h; + QSpinBox *spinBox_main_m; + QSpinBox *spinBox_main_s; + QPushButton *pushStart; + QPushButton *pushStop; + + void setupUi(QDialog *dependent) + { + if (dependent->objectName().isEmpty()) + dependent->setObjectName(QString::fromUtf8("dependent")); + dependent->resize(455, 416); + pushSet = new QPushButton(dependent); + pushSet->setObjectName(QString::fromUtf8("pushSet")); + pushSet->setGeometry(QRect(330, 160, 71, 31)); + label_2 = new QLabel(dependent); + label_2->setObjectName(QString::fromUtf8("label_2")); + label_2->setGeometry(QRect(120, 20, 121, 16)); + QFont font; + font.setPointSize(16); + label_2->setFont(font); + label_3 = new QLabel(dependent); + label_3->setObjectName(QString::fromUtf8("label_3")); + label_3->setGeometry(QRect(90, 110, 191, 31)); + label_3->setFont(font); + checkReset = new QCheckBox(dependent); + checkReset->setObjectName(QString::fromUtf8("checkReset")); + checkReset->setGeometry(QRect(310, 120, 141, 17)); + layoutWidget = new QWidget(dependent); + layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); + layoutWidget->setGeometry(QRect(60, 150, 251, 51)); + horizontalLayout_4 = new QHBoxLayout(layoutWidget); + horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4")); + horizontalLayout_4->setContentsMargins(0, 0, 0, 0); + spinBox_dep_h = new QSpinBox(layoutWidget); + spinBox_dep_h->setObjectName(QString::fromUtf8("spinBox_dep_h")); + + horizontalLayout_4->addWidget(spinBox_dep_h); + + spinBox_dep_m = new QSpinBox(layoutWidget); + spinBox_dep_m->setObjectName(QString::fromUtf8("spinBox_dep_m")); + + horizontalLayout_4->addWidget(spinBox_dep_m); + + spinBox_dep_s = new QSpinBox(layoutWidget); + spinBox_dep_s->setObjectName(QString::fromUtf8("spinBox_dep_s")); + + horizontalLayout_4->addWidget(spinBox_dep_s); + + pushAbout = new QPushButton(dependent); + pushAbout->setObjectName(QString::fromUtf8("pushAbout")); + pushAbout->setGeometry(QRect(300, 300, 101, 41)); + layoutWidget1 = new QWidget(dependent); + layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); + layoutWidget1->setGeometry(QRect(50, 230, 311, 51)); + horizontalLayout_3 = new QHBoxLayout(layoutWidget1); + horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); + horizontalLayout_3->setContentsMargins(0, 0, 0, 0); + radioUp = new QRadioButton(layoutWidget1); + radioUp->setObjectName(QString::fromUtf8("radioUp")); + + horizontalLayout_3->addWidget(radioUp); + + radioDown = new QRadioButton(layoutWidget1); + radioDown->setObjectName(QString::fromUtf8("radioDown")); + + horizontalLayout_3->addWidget(radioDown); + + layoutWidget2 = new QWidget(dependent); + layoutWidget2->setObjectName(QString::fromUtf8("layoutWidget2")); + layoutWidget2->setGeometry(QRect(60, 50, 251, 51)); + horizontalLayout = new QHBoxLayout(layoutWidget2); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + spinBox_main_h = new QSpinBox(layoutWidget2); + spinBox_main_h->setObjectName(QString::fromUtf8("spinBox_main_h")); + + horizontalLayout->addWidget(spinBox_main_h); + + spinBox_main_m = new QSpinBox(layoutWidget2); + spinBox_main_m->setObjectName(QString::fromUtf8("spinBox_main_m")); + + horizontalLayout->addWidget(spinBox_main_m); + + spinBox_main_s = new QSpinBox(layoutWidget2); + spinBox_main_s->setObjectName(QString::fromUtf8("spinBox_main_s")); + + horizontalLayout->addWidget(spinBox_main_s); + + pushStart = new QPushButton(dependent); + pushStart->setObjectName(QString::fromUtf8("pushStart")); + pushStart->setGeometry(QRect(20, 300, 121, 41)); + pushStop = new QPushButton(dependent); + pushStop->setObjectName(QString::fromUtf8("pushStop")); + pushStop->setGeometry(QRect(160, 300, 121, 41)); + + retranslateUi(dependent); + QObject::connect(pushStop, SIGNAL(clicked()), dependent, SLOT(stop())); + + QMetaObject::connectSlotsByName(dependent); + } // setupUi + + void retranslateUi(QDialog *dependent) + { + dependent->setWindowTitle(QApplication::translate("dependent", "Dependent Timers", 0, QApplication::UnicodeUTF8)); + pushSet->setText(QApplication::translate("dependent", "Set", 0, QApplication::UnicodeUTF8)); + label_2->setText(QApplication::translate("dependent", "Main Timer", 0, QApplication::UnicodeUTF8)); + label_3->setText(QApplication::translate("dependent", "Dependent Timer", 0, QApplication::UnicodeUTF8)); + checkReset->setText(QApplication::translate("dependent", "Do Not Reset", 0, QApplication::UnicodeUTF8)); + pushAbout->setText(QApplication::translate("dependent", "About", 0, QApplication::UnicodeUTF8)); + radioUp->setText(QApplication::translate("dependent", "Count Up", 0, QApplication::UnicodeUTF8)); + radioDown->setText(QApplication::translate("dependent", "Count Down", 0, QApplication::UnicodeUTF8)); + pushStart->setText(QApplication::translate("dependent", "Start", 0, QApplication::UnicodeUTF8)); + pushStop->setText(QApplication::translate("dependent", "Stop", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class dependent: public Ui_dependent {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_DEPENDENT_H diff --git a/timerGUI/ui_mainwindow.h b/timerGUI/ui_mainwindow.h new file mode 100644 index 0000000..5649c60 --- /dev/null +++ b/timerGUI/ui_mainwindow.h @@ -0,0 +1,86 @@ +/******************************************************************************** +** Form generated from reading UI file 'mainwindow.ui' +** +** Created: Wed May 2 23:44:57 2012 +** by: Qt User Interface Compiler version 4.7.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_MAINWINDOW_H +#define UI_MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_MainWindow +{ +public: + QWidget *centralWidget; + QPushButton *pushButton; + QPushButton *pushButton_2; + QMenuBar *menuBar; + QToolBar *mainToolBar; + QStatusBar *statusBar; + + void setupUi(QMainWindow *MainWindow) + { + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QString::fromUtf8("MainWindow")); + MainWindow->resize(224, 228); + MainWindow->setMaximumSize(QSize(224, 228)); + centralWidget = new QWidget(MainWindow); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + pushButton = new QPushButton(centralWidget); + pushButton->setObjectName(QString::fromUtf8("pushButton")); + pushButton->setGeometry(QRect(30, 0, 150, 60)); + pushButton_2 = new QPushButton(centralWidget); + pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); + pushButton_2->setGeometry(QRect(10, 80, 200, 60)); + MainWindow->setCentralWidget(centralWidget); + menuBar = new QMenuBar(MainWindow); + menuBar->setObjectName(QString::fromUtf8("menuBar")); + menuBar->setGeometry(QRect(0, 0, 224, 27)); + MainWindow->setMenuBar(menuBar); + mainToolBar = new QToolBar(MainWindow); + mainToolBar->setObjectName(QString::fromUtf8("mainToolBar")); + MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); + statusBar = new QStatusBar(MainWindow); + statusBar->setObjectName(QString::fromUtf8("statusBar")); + MainWindow->setStatusBar(statusBar); + + retranslateUi(MainWindow); + QObject::connect(pushButton, SIGNAL(clicked()), MainWindow, SLOT(openSingle())); + QObject::connect(pushButton_2, SIGNAL(clicked()), MainWindow, SLOT(openDependent())); + + QMetaObject::connectSlotsByName(MainWindow); + } // setupUi + + void retranslateUi(QMainWindow *MainWindow) + { + MainWindow->setWindowTitle(QApplication::translate("MainWindow", "Timer Program", 0, QApplication::UnicodeUTF8)); + pushButton->setText(QApplication::translate("MainWindow", "Single Timer", 0, QApplication::UnicodeUTF8)); + pushButton_2->setText(QApplication::translate("MainWindow", "One Main Timer\n" +"One Dependent Timer", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class MainWindow: public Ui_MainWindow {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_MAINWINDOW_H diff --git a/timerGUI/ui_singletimer.h b/timerGUI/ui_singletimer.h new file mode 100644 index 0000000..de82a47 --- /dev/null +++ b/timerGUI/ui_singletimer.h @@ -0,0 +1,162 @@ +/******************************************************************************** +** Form generated from reading UI file 'singletimer.ui' +** +** Created: Wed May 2 23:40:02 2012 +** by: Qt User Interface Compiler version 4.7.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_SINGLETIMER_H +#define UI_SINGLETIMER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_singleTimer +{ +public: + QWidget *horizontalLayoutWidget; + QHBoxLayout *horizontalLayout; + QSpinBox *spinBox_h; + QSpinBox *spinBox_m; + QSpinBox *spinBox_s; + QLabel *label; + QWidget *layoutWidget; + QHBoxLayout *horizontalLayout_2; + QRadioButton *radioDown; + QRadioButton *radioUp; + QWidget *layoutWidget1; + QVBoxLayout *verticalLayout; + QCheckBox *checkMessage; + QCheckBox *checkRollover; + QPushButton *pushStart; + QPushButton *pushStop; + QLabel *label_2; + + void setupUi(QDialog *singleTimer) + { + if (singleTimer->objectName().isEmpty()) + singleTimer->setObjectName(QString::fromUtf8("singleTimer")); + singleTimer->resize(619, 367); + horizontalLayoutWidget = new QWidget(singleTimer); + horizontalLayoutWidget->setObjectName(QString::fromUtf8("horizontalLayoutWidget")); + horizontalLayoutWidget->setGeometry(QRect(40, 60, 231, 71)); + horizontalLayout = new QHBoxLayout(horizontalLayoutWidget); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + spinBox_h = new QSpinBox(horizontalLayoutWidget); + spinBox_h->setObjectName(QString::fromUtf8("spinBox_h")); + + horizontalLayout->addWidget(spinBox_h); + + spinBox_m = new QSpinBox(horizontalLayoutWidget); + spinBox_m->setObjectName(QString::fromUtf8("spinBox_m")); + + horizontalLayout->addWidget(spinBox_m); + + spinBox_s = new QSpinBox(horizontalLayoutWidget); + spinBox_s->setObjectName(QString::fromUtf8("spinBox_s")); + + horizontalLayout->addWidget(spinBox_s); + + label = new QLabel(singleTimer); + label->setObjectName(QString::fromUtf8("label")); + label->setGeometry(QRect(360, 150, 201, 31)); + QFont font; + font.setPointSize(12); + label->setFont(font); + label->setTextFormat(Qt::RichText); + layoutWidget = new QWidget(singleTimer); + layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); + layoutWidget->setGeometry(QRect(20, 160, 291, 51)); + horizontalLayout_2 = new QHBoxLayout(layoutWidget); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + horizontalLayout_2->setContentsMargins(0, 0, 0, 0); + radioDown = new QRadioButton(layoutWidget); + radioDown->setObjectName(QString::fromUtf8("radioDown")); + + horizontalLayout_2->addWidget(radioDown); + + radioUp = new QRadioButton(layoutWidget); + radioUp->setObjectName(QString::fromUtf8("radioUp")); + + horizontalLayout_2->addWidget(radioUp); + + layoutWidget1 = new QWidget(singleTimer); + layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); + layoutWidget1->setGeometry(QRect(360, 190, 211, 101)); + verticalLayout = new QVBoxLayout(layoutWidget1); + verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + verticalLayout->setContentsMargins(0, 0, 0, 0); + checkMessage = new QCheckBox(layoutWidget1); + checkMessage->setObjectName(QString::fromUtf8("checkMessage")); + + verticalLayout->addWidget(checkMessage); + + checkRollover = new QCheckBox(layoutWidget1); + checkRollover->setObjectName(QString::fromUtf8("checkRollover")); + + verticalLayout->addWidget(checkRollover); + + pushStart = new QPushButton(singleTimer); + pushStart->setObjectName(QString::fromUtf8("pushStart")); + pushStart->setGeometry(QRect(40, 250, 111, 41)); + QFont font1; + font1.setPointSize(16); + pushStart->setFont(font1); + pushStop = new QPushButton(singleTimer); + pushStop->setObjectName(QString::fromUtf8("pushStop")); + pushStop->setGeometry(QRect(190, 250, 111, 41)); + pushStop->setFont(font1); + label_2 = new QLabel(singleTimer); + label_2->setObjectName(QString::fromUtf8("label_2")); + label_2->setGeometry(QRect(90, 20, 141, 23)); + label_2->setFont(font1); + + retranslateUi(singleTimer); + QObject::connect(pushStop, SIGNAL(clicked()), singleTimer, SLOT(stop())); + + QMetaObject::connectSlotsByName(singleTimer); + } // setupUi + + void retranslateUi(QDialog *singleTimer) + { + singleTimer->setWindowTitle(QApplication::translate("singleTimer", "Single Timer", 0, QApplication::UnicodeUTF8)); + label->setText(QApplication::translate("singleTimer", "\n" +"\n" +"

Count Down Options

", 0, QApplication::UnicodeUTF8)); + radioDown->setText(QApplication::translate("singleTimer", "Count Down", 0, QApplication::UnicodeUTF8)); + radioUp->setText(QApplication::translate("singleTimer", "Count Up", 0, QApplication::UnicodeUTF8)); + checkMessage->setText(QApplication::translate("singleTimer", "Show Message", 0, QApplication::UnicodeUTF8)); + checkRollover->setText(QApplication::translate("singleTimer", "Rollover", 0, QApplication::UnicodeUTF8)); + pushStart->setText(QApplication::translate("singleTimer", "Start", 0, QApplication::UnicodeUTF8)); + pushStop->setText(QApplication::translate("singleTimer", "Stop", 0, QApplication::UnicodeUTF8)); + label_2->setText(QApplication::translate("singleTimer", "Single Timer", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class singleTimer: public Ui_singleTimer {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_SINGLETIMER_H From 913dec9c40702a090d39fd6e35be3c5d470372df Mon Sep 17 00:00:00 2001 From: tavispa Date: Thu, 3 May 2012 00:31:58 -0400 Subject: [PATCH 09/14] Updated README --- README | 9 +- finalTimer/dependent.cpp | 171 --------------------------- finalTimer/dependent.h | 50 -------- finalTimer/dependent.ui | 208 --------------------------------- finalTimer/finalTimer.pro | 24 ---- finalTimer/finalTimer.pro.user | 113 ------------------ finalTimer/main.cpp | 13 --- finalTimer/mainwindow.cpp | 42 ------- finalTimer/mainwindow.h | 32 ----- finalTimer/mainwindow.ui | 111 ------------------ finalTimer/singletimer.cpp | 147 ----------------------- finalTimer/singletimer.h | 51 -------- finalTimer/singletimer.ui | 194 ------------------------------ 13 files changed, 5 insertions(+), 1160 deletions(-) delete mode 100755 finalTimer/dependent.cpp delete mode 100755 finalTimer/dependent.h delete mode 100755 finalTimer/dependent.ui delete mode 100755 finalTimer/finalTimer.pro delete mode 100755 finalTimer/finalTimer.pro.user delete mode 100755 finalTimer/main.cpp delete mode 100755 finalTimer/mainwindow.cpp delete mode 100755 finalTimer/mainwindow.h delete mode 100755 finalTimer/mainwindow.ui delete mode 100755 finalTimer/singletimer.cpp delete mode 100755 finalTimer/singletimer.h delete mode 100755 finalTimer/singletimer.ui diff --git a/README b/README index 001c34d..3301137 100644 --- a/README +++ b/README @@ -5,11 +5,12 @@ they are not already on your system. To do this run this command from the termi sudo apt-get install libxtst-dev build-essential libqt4-dev qt4-qmake -In order to run the program enter the finalTimer directory, run the command: -qmake -Once that finishes run the command +In order to create the executable for the main directory run make -This should create an executable called finalTimer. To execute the program type ./finalTimer + +the executable for the GUI will be called finalTimer. +Run +./finalTimer User instructions: diff --git a/finalTimer/dependent.cpp b/finalTimer/dependent.cpp deleted file mode 100755 index b24ee41..0000000 --- a/finalTimer/dependent.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "dependent.h" -#include "ui_dependent.h" - -dependent::dependent(QWidget *parent) : - QDialog(parent), - ui(new Ui::dependent) -{ - ui->setupUi(this); - mytimer = new QTimer(); - dep_h = 0; - dep_m = 0; - dep_s = 0; -} - -dependent::~dependent() -{ - delete ui; -} -/* -*on_pushStart_clicked -* On click event function for starting execution and connecting -* appropiate signals and slots. -*/ -void dependent::on_pushStart_clicked() -{ - - if(ui->radioUp->isChecked()){ - connect(mytimer, SIGNAL(timeout()), this, SLOT(secUp())); - connect(mytimer, SIGNAL(timeout()), this, SLOT(depSecUp())); - } - if(ui->radioDown->isChecked()){ - connect(mytimer, SIGNAL(timeout()), this, SLOT(secDown())); - connect(mytimer, SIGNAL(timeout()), this, SLOT(checkToConnect())); - } - mytimer->start(1000); -} - -/*stop -* Function to disconnect slots and signals when timers expire -* checks the main timer spin box values -*/ - -void dependent::stop() -{ - if(ui->spinBox_main_h->value() == 0 && ui->spinBox_main_m->value() == 0 && ui->spinBox_main_s->value() == 0){ - disconnect(mytimer, SIGNAL(timeout()), this, SLOT(secDown())); - } - -} - -/*secUp -* Updates the main timer spin boxes and resets the boxes -* as dependent timer counts up -*/ - -void dependent::secUp(){ - ui->spinBox_main_s->stepUp(); - if(ui->spinBox_main_s->value()==60){ - ui->spinBox_main_m->stepUp(); - if(ui->spinBox_main_m->value() == 60){ - ui->spinBox_main_h->stepUp(); - ui->spinBox_main_m->setValue(0); - } - ui->spinBox_main_s->setValue(0); - } -} - -/*secDown -* Updates the main timer spin boxes and reset as needed -* as dependent timer counts down -*/ - -void dependent::secDown(){ - ui->spinBox_main_s->stepDown(); - if(ui->spinBox_main_s->value() == 0){ - if(ui->spinBox_main_m->value() == 0 && ui->spinBox_main_h->value() > 0){ - ui->spinBox_main_h->stepDown(); - ui->spinBox_main_m->setValue(59); - } - else - ui->spinBox_main_m->stepDown(); - } - if(ui->spinBox_main_h->value() == 0 && ui->spinBox_main_m->value() == 0 && ui->spinBox_main_s->value() == 0){ - stop(); - } - else if(ui->spinBox_main_s->value() == 0) - ui->spinBox_main_s->setValue(59); -} - -/*on_pushSet_Clicked -* -*/ -void dependent::on_pushSet_clicked() -{ - dep_h = ui->spinBox_main_h->value(); - dep_m = ui->spinBox_main_m->value(); - dep_s = ui->spinBox_main_s->value(); - if(!ui->checkReset->isChecked()){ - ui->spinBox_main_h->setValue(0); - ui->spinBox_main_m->setValue(0); - ui->spinBox_main_s->setValue(0); - } -} -/*depSecUp -* -*/ -void dependent::depSecUp(){ - if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()){ - connect(mytimer, SIGNAL(timeout()), this, SLOT(depUpStart())); - } -} -/*depUpStart -* Starts the depenent timer up -*/ -void dependent::depUpStart(){ - ui->spinBox_dep_s->stepUp(); - if(ui->spinBox_dep_s->value()==60){ - ui->spinBox_dep_m->stepUp(); - if(ui->spinBox_dep_m->value() == 60){ - ui->spinBox_dep_h->stepUp(); - ui->spinBox_dep_m->setValue(0); - } - ui->spinBox_dep_s->setValue(0); - } -} - -/* -* Updates the dependent timer seconds spinbox -*/ -void dependent::depSecDown(){ - ui->spinBox_dep_s->stepDown(); - if(ui->spinBox_dep_s->value() == 0){ - if(ui->spinBox_dep_m->value() == 0 && ui->spinBox_dep_h->value() > 0){ - ui->spinBox_dep_h->stepDown(); - ui->spinBox_dep_m->setValue(59); - } - else - ui->spinBox_dep_m->stepDown(); - } - if(ui->spinBox_dep_h->value() == 0 && ui->spinBox_dep_m->value() == 0 && ui->spinBox_dep_s->value() == 0) - stop(); - else if(ui->spinBox_dep_s->value() == 0) - ui->spinBox_dep_s->setValue(59); -} - -/* -* -*/ - -void dependent::checkToConnect(){ - if(dep_h == ui->spinBox_main_h->value() && dep_m == ui->spinBox_main_m->value() && dep_s == ui->spinBox_main_s->value()-1) - connect(mytimer, SIGNAL(timeout()), this, SLOT(depSecDown())); -} - -/* -* Function disconnects the signal from the slot and stops countings -*/ -void dependent::on_pushStop_clicked() -{ - mytimer->disconnect(); - mytimer->stop(); -} - -/* -* Message box for user instructions -*/ -void dependent::on_pushAbout_clicked() -{ - QMessageBox::information(this, "How to use", - "Count Up Instructions:\nSet the main timer to when you want the dependent timer to start and click 'set'.\n You can change the dependent timer after this. For example, if you want to start the dependent timer at 5s, set the main timer, and then change the\ndependent timer input box to 5.\n Count Down Instructions:\nThe dependent timer can start when the main timer is 0:0:0 or you can set the dependent timer to start at specific time.\n Set the dependent timer per the Count Up instructions.\n You can then change the dependent timer.\n For example, set main timer to 5s, click set. Then\n change the dependent timer spin boxes to where you want to start."); -} diff --git a/finalTimer/dependent.h b/finalTimer/dependent.h deleted file mode 100755 index b7e5bcc..0000000 --- a/finalTimer/dependent.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef DEPENDENT_H -#define DEPENDENT_H - -#include -#include -#include - -namespace Ui { - class dependent; -} - -class dependent : public QDialog -{ - Q_OBJECT - -public: - explicit dependent(QWidget *parent = 0); - ~dependent(); - -public slots: - void stop(); - - void secUp(); - void secDown(); - - void depSecUp(); - void depUpStart(); - - void depSecDown(); - - void checkToConnect(); - -private: - Ui::dependent *ui; - QTimer *mytimer; - int main_h; // main timer hours - int main_m; // main timer minutes - int main_s; // main timer seconds - int dep_h; // dependent timer hours - int dep_m; // dependent timer minutes - int dep_s; // dependent timer seconds - -private slots: - void on_pushAbout_clicked(); - void on_pushStop_clicked(); - void on_pushSet_clicked(); - void on_pushStart_clicked(); -}; - -#endif // DEPENDENT_H diff --git a/finalTimer/dependent.ui b/finalTimer/dependent.ui deleted file mode 100755 index 304c3b4..0000000 --- a/finalTimer/dependent.ui +++ /dev/null @@ -1,208 +0,0 @@ - - - dependent - - - - 0 - 0 - 455 - 416 - - - - Dependent Timers - - - - - 330 - 160 - 71 - 31 - - - - Set - - - - - - 120 - 20 - 121 - 16 - - - - - 16 - - - - Main Timer - - - - - - 90 - 110 - 191 - 31 - - - - - 16 - - - - Dependent Timer - - - - - - 310 - 120 - 141 - 17 - - - - Do Not Reset - - - - - - 60 - 150 - 251 - 51 - - - - - - - - - - - - - - - - - - 300 - 300 - 101 - 41 - - - - About - - - - - - 50 - 230 - 311 - 51 - - - - - - - Count Up - - - - - - - Count Down - - - - - - - - - 60 - 50 - 251 - 51 - - - - - - - - - - - - - - - - - - 20 - 300 - 121 - 41 - - - - Start - - - - - - 160 - 300 - 121 - 41 - - - - Stop - - - - - - - pushStop - clicked() - dependent - stop() - - - 237 - 156 - - - 268 - 156 - - - - - - stop() - - diff --git a/finalTimer/finalTimer.pro b/finalTimer/finalTimer.pro deleted file mode 100755 index c1f7c01..0000000 --- a/finalTimer/finalTimer.pro +++ /dev/null @@ -1,24 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2012-04-29T19:29:40 -# -#------------------------------------------------- - -QT += core gui - -TARGET = finalTimer -TEMPLATE = app - - -SOURCES += main.cpp\ - mainwindow.cpp \ - singletimer.cpp \ - dependent.cpp - -HEADERS += mainwindow.h \ - singletimer.h \ - dependent.h - -FORMS += mainwindow.ui \ - singletimer.ui \ - dependent.ui diff --git a/finalTimer/finalTimer.pro.user b/finalTimer/finalTimer.pro.user deleted file mode 100755 index 666fc2b..0000000 --- a/finalTimer/finalTimer.pro.user +++ /dev/null @@ -1,113 +0,0 @@ - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - System - - - - ProjectExplorer.Project.Target.0 - - Desktop - Qt4ProjectManager.Target.DesktopTarget - 0 - 0 - - - qmake - QtProjectManager.QMakeBuildStep - - - - Make - Qt4ProjectManager.MakeStep - false - - - - 2 - - Make - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop - 2 - 2 - true - - - - qmake - QtProjectManager.QMakeBuildStep - - - - Make - Qt4ProjectManager.MakeStep - false - - - - 2 - - Make - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - C:/Users/Xepher/Desktop/Classes/Spring 2012/ECE2524/Project/finalTimer-build-desktop - 2 - 2 - true - - 2 - - finalTimer - Qt4ProjectManager.Qt4RunConfiguration - 2 - - finalTimer.pro - false - false - - false - false - - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 4 - - diff --git a/finalTimer/main.cpp b/finalTimer/main.cpp deleted file mode 100755 index c811da0..0000000 --- a/finalTimer/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "mainwindow.h" - -// Main Qt application start - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/finalTimer/mainwindow.cpp b/finalTimer/mainwindow.cpp deleted file mode 100755 index e5ad455..0000000 --- a/finalTimer/mainwindow.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -//open a single timer window -void MainWindow::openSingle(){ - //open multiple timing windows and allow control to main - //I chose this since one of the ideas of the project was - //to have multiple timers available to someone - oneTimer = new singleTimer(this); - oneTimer->show(); - - //you would use these lines if you only wanted the user to have one window - //disables control leaving the opened window - //singleTimer oneTimer; - //oneTimer.setModal(true); - //oneTimer.exec(); -} - -//open a timing window with one dependent timer and one independent timer -void MainWindow::openDependent(){ - mainTimer = new dependent(); - mainTimer->show(); - /* - dependent mainTimer; - mainTimer.setModal(true); - mainTimer.exec(); - */ -} - diff --git a/finalTimer/mainwindow.h b/finalTimer/mainwindow.h deleted file mode 100755 index 734c6c0..0000000 --- a/finalTimer/mainwindow.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include "singletimer.h" -#include "dependent.h" - -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - - - //functions to open the individual timing windows -private slots: - void openSingle(); - void openDependent(); - -private: - Ui::MainWindow *ui; - singleTimer *oneTimer; - dependent *mainTimer; -}; - -#endif // MAINWINDOW_H diff --git a/finalTimer/mainwindow.ui b/finalTimer/mainwindow.ui deleted file mode 100755 index 8a053dd..0000000 --- a/finalTimer/mainwindow.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 224 - 228 - - - - - 224 - 228 - - - - Timer Program - - - - - - 30 - 0 - 150 - 60 - - - - Single Timer - - - - - - 10 - 80 - 200 - 60 - - - - One Main Timer -One Dependent Timer - - - - - - - 0 - 0 - 224 - 27 - - - - - - TopToolBarArea - - - false - - - - - - - - - pushButton - clicked() - MainWindow - openSingle() - - - 300 - 300 - - - 96 - 146 - - - - - pushButton_2 - clicked() - MainWindow - openDependent() - - - 225 - 104 - - - 296 - 106 - - - - - - openSingle() - openDependent() - - diff --git a/finalTimer/singletimer.cpp b/finalTimer/singletimer.cpp deleted file mode 100755 index 2485f9a..0000000 --- a/finalTimer/singletimer.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "singletimer.h" -#include "ui_singletimer.h" - - -singleTimer::singleTimer(QWidget *parent) : - QDialog(parent), - ui(new Ui::singleTimer) -{ - ui->setupUi(this); - //create timer pointer - mytimer = new QTimer(); -} - -singleTimer::~singleTimer() -{ - delete ui; -} - -/*countdownStart - - connects the signals from the timer to the second portion of the timing box - then connects the seconds to minutes, minutes to hours - starts the timer - if rollOver is checked, then it saves where the values will need to go back to -*/ -void singleTimer::countdownStart(){ - connect(mytimer, SIGNAL(timeout()), this, SLOT(subtractOne())); - connect(ui->spinBox_h, SIGNAL(valueChanged(int)), this, SLOT(setMValue())); - connect(ui->spinBox_m, SIGNAL(valueChanged(int)), this, SLOT(setSValue())); - if(ui->checkRollover->isChecked()){ - hour = ui->spinBox_h->value(); - min = ui->spinBox_m->value(); - sec = ui->spinBox_s->value(); - } - mytimer->start(1000); -} - - -/*subtractOne - - subtract one from the second box, then check to see if other boxes need to be subtracted from - and reset seconds to 59 (or minutes to 59) based on what happens in more significant places - - control what happens if check boxes are/aren't checked - - */ -void singleTimer::subtractOne(){ - ui->spinBox_s->stepDown(); - if(ui->spinBox_s->value() == 0){ - if(ui->spinBox_m->value()-1 == 0 && ui->spinBox_h->value()>0){ - ui->spinBox_h->stepDown(); - } - else - ui->spinBox_m->stepDown(); - } - if(ui->spinBox_h->value() == 0 && ui->spinBox_m->value() == 0 && ui->spinBox_s ->value() == 0){ - /* - if(ui->checkSound->isChecked()){ - //possible implementation - } - */ - - //display a message - if(ui->checkMessage->isChecked()){ - QMessageBox::information(this, "Timer Stop", "Countdown finished!"); - } - - //if it's not rolling over, stop the timer - if(!ui->checkRollover->isChecked()){ - stop(); - } - //if the timer doesn't stop, reset to the roll over values - else{ - ui->spinBox_h->setValue(hour); - ui->spinBox_m->setValue(min); - ui->spinBox_s->setValue(sec); - } - } -} - -//setMValue and setSValue set the spin boxes to 59 when they hit 0 and you get a carry from -//a more significant section -void singleTimer::setMValue(){ - ui->spinBox_m->setValue(59); -} - -void singleTimer::setSValue(){ - ui->spinBox_s->setValue(59); -} - - -/*countupStart - connects the spin boxes so they change as necessary when seconds hits 60, or minutes hits 60 - - */ -void singleTimer::countupStart(){ - connect(mytimer, SIGNAL(timeout()), this, SLOT(addOne())); - connect(ui->spinBox_h, SIGNAL(valueChanged(int)), this, SLOT(setMLow())); - connect(ui->spinBox_m, SIGNAL(valueChanged(int)), this, SLOT(setSLow())); -} - -//addOne -//add one to the seconds, if it hits 60, add one to minutes, if minutes hits 60, add one to hours, -//roll seconds/minutes back over to 0 -void singleTimer::addOne(){ - ui->spinBox_s->stepUp(); - if(ui->spinBox_s->value() == 60){ - ui->spinBox_m->stepUp(); - if(ui->spinBox_m->value() == 60){ - ui->spinBox_h->stepUp(); - } - } -} - -//setMLow and setSLow set minutes and seconds to 0 as needed -void singleTimer::setMLow(){ - ui->spinBox_m->setValue(0); -} - -void singleTimer::setSLow(){ - ui->spinBox_s->setValue(0); -} - - -//when the pushButton is clicked, determine if the timer is counting up or down, -//call those functions to connect signals -//start the timer -void singleTimer::on_pushStart_clicked() -{ - - if(ui->radioDown->isChecked()) - countdownStart(); - else if(ui->radioUp->isChecked()) - countupStart(); - mytimer->start(1000); -} - - -//stop -//stop the timer, and disconnect the signals -//if you don't disconnect the signals, everytime you click start it will add 1 to how much seconds is -//increased/decreased by (click it once, increases by 1, click it again, starts increasing by 2, then 3, etc) -void singleTimer::stop() -{ - mytimer->stop(); - disconnect(mytimer, SIGNAL(timeout()), this, SLOT(addOne())); - disconnect(mytimer, SIGNAL(timeout()), this, SLOT(subtractOne())); -} diff --git a/finalTimer/singletimer.h b/finalTimer/singletimer.h deleted file mode 100755 index 458d96c..0000000 --- a/finalTimer/singletimer.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SINGLETIMER_H -#define SINGLETIMER_H - -#include -#include -#include - -namespace Ui { - class singleTimer; -} - -class singleTimer : public QDialog -{ - Q_OBJECT - -public: - explicit singleTimer(QWidget *parent = 0); - ~singleTimer(); - -//Everything above here is automatically created by QT -public slots: - //functions needed to countdown to work - void countdownStart(); - void subtractOne(); - void setMValue(); - void setSValue(); - - //functions needed for countup to work - void countupStart(); - void addOne(); - void setMLow(); - void setSLow(); - - //function to stop timer - void stop(); - -private: - Ui::singleTimer *ui; - QTimer *mytimer; - - //variables to store time in case of roll over - int hour; - int min; - int sec; - -private slots: - //you can do this with a different function but this can be created automatically - void on_pushStart_clicked(); -}; - -#endif // SINGLETIMER_H diff --git a/finalTimer/singletimer.ui b/finalTimer/singletimer.ui deleted file mode 100755 index f1a712e..0000000 --- a/finalTimer/singletimer.ui +++ /dev/null @@ -1,194 +0,0 @@ - - - singleTimer - - - - 0 - 0 - 619 - 367 - - - - Single Timer - - - - - 40 - 60 - 231 - 71 - - - - - - - - - - - - - - - - - - 360 - 150 - 201 - 31 - - - - - 12 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Bitstream Charter'; font-size:12pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt;">Count Down Options</span></p></body></html> - - - Qt::RichText - - - - - - 20 - 160 - 291 - 51 - - - - - - - Count Down - - - - - - - Count Up - - - - - - - - - 360 - 190 - 211 - 101 - - - - - - - Show Message - - - - - - - Rollover - - - - - - - - - 40 - 250 - 111 - 41 - - - - - 16 - - - - Start - - - - - - 190 - 250 - 111 - 41 - - - - - 16 - - - - Stop - - - - - - 90 - 20 - 141 - 23 - - - - - 16 - - - - Single Timer - - - - - - - pushStop - clicked() - singleTimer - stop() - - - 209 - 174 - - - 211 - 186 - - - - - - countupStart() - countdownStart() - start() - stop() - - From d06d0743b2bddca28cba955d8575c94bd81746a6 Mon Sep 17 00:00:00 2001 From: tavispa Date: Thu, 3 May 2012 11:08:54 -0400 Subject: [PATCH 10/14] Modified Makefile to separate rm command, updated README --- Makefile | 8 +++++--- README | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 37d1f0e..b548851 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,9 @@ export CXX_FLAGS finalTimer: qmake timerGUI/finalTimer.pro -o timerGUI/Makefile $(MAKE) -C timerGUI - rm ./timerGUI/moc* - rm ./timerGUI/*.o - rm ./timerGUI/Makefile mv timerGUI/finalTimer $(INSTALL_DIR) + +clean: + rm timerGUI/moc* + rm timerGUI/*.o + rm timerGUI/Makefile diff --git a/README b/README index 3301137..83596b6 100644 --- a/README +++ b/README @@ -12,6 +12,10 @@ the executable for the GUI will be called finalTimer. Run ./finalTimer +To clean the *.o, moc*, and Makefile from the timerGUI directory run + +make clean + User instructions: From af74faf2cbb773268e80565ea5b8eb96395fbe99 Mon Sep 17 00:00:00 2001 From: Thomas Walton Date: Sun, 6 May 2012 01:46:24 -0400 Subject: [PATCH 11/14] Console timer with gui interface files --- CONTRIBUTIONS.thomasw4 | 3 + Makefile | 12 ++- README | 45 +++++++-- dispatcher/Makefile | 9 ++ dispatcher/dispatcher.cpp | 96 ++++++++++++++++++++ dispatcher/timer.cpp | 186 ++++++++++++++++++++++++++++++++++++++ dispatcher/timer.h | 23 +++++ timerGUI/ui_dependent.h | 4 +- timerGUI/ui_mainwindow.h | 4 +- timerGUI/ui_singletimer.h | 18 ++-- 10 files changed, 377 insertions(+), 23 deletions(-) create mode 100644 dispatcher/Makefile create mode 100644 dispatcher/dispatcher.cpp create mode 100644 dispatcher/timer.cpp create mode 100644 dispatcher/timer.h diff --git a/CONTRIBUTIONS.thomasw4 b/CONTRIBUTIONS.thomasw4 index a229c86..79fb75e 100644 --- a/CONTRIBUTIONS.thomasw4 +++ b/CONTRIBUTIONS.thomasw4 @@ -4,3 +4,6 @@ couldn't push or pull. We reverted to dropbox and email, to collaborate on the p and trying to link the gui to the console. As it is right now, the gui is working great, the console is working great, but still working on the interfacing between the two. We have not pushed the console version to the repo yet. What we have now is working and in order to meet the deadline of a "working" submission, I chose to not push the console version until later today. + + +I have added the new files for the text timer. The gui timer is now executed via the commandline using various options diff --git a/Makefile b/Makefile index b548851..0c6cc71 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,22 @@ + CXX_FLAGS := -O2 -DNDEBUG -Wall -g -march=core2 -std=c++11 CXX := g++ INSTALL_DIR := ./ export CXX export CXX_FLAGS -.PHONY: finalTimer +all: finalTimer timer + finalTimer: qmake timerGUI/finalTimer.pro -o timerGUI/Makefile $(MAKE) -C timerGUI - mv timerGUI/finalTimer $(INSTALL_DIR) + #mv timerGUI/finalTimer $(INSTALL_DIR) + +timer: + $(MAKE) -C dispatcher + mv dispatcher/timer $(INSTALL_DIR) clean: - rm timerGUI/moc* rm timerGUI/*.o rm timerGUI/Makefile + rm timerGUI/moc* diff --git a/README b/README index 83596b6..44764a4 100644 --- a/README +++ b/README @@ -1,24 +1,55 @@ -A Timer application with two options. A single up/down timer or a dependent timer. +A Timer application with three options. + In order to properly compile this program in a linux environment you must install the qt4 libraries if they are not already on your system. To do this run this command from the terminal: sudo apt-get install libxtst-dev build-essential libqt4-dev qt4-qmake -In order to create the executable for the main directory run + +To create the executable for the main directory run: + make -the executable for the GUI will be called finalTimer. -Run -./finalTimer +The executable for the TIMER will be called timer. + -To clean the *.o, moc*, and Makefile from the timerGUI directory run +To clean the *.o, moc*, and Makefile from the timerGUI directory run: make clean -User instructions: +To Execute from command line: + +./timer [version option] [# of timers] + +version options: +1 - stand alone console timer (No GUI) +2 - stand alone GUI timer +3 - Timer that takes console input and outputs via GUI timer + +# of timers: +Number of timers needed (must be between 1 and 10) + + +Version 1 instructions: +User will be prompted to enter events and time for each event, the time must +be entered in the following format: + +HH:MM:SS + +User will be notified how long before the next event needs to be started and +notified again when to start that event + + +Version 2 instructions: There are two buttons in the main window. The single timer button lauches a window that has a single count up or count down timer. There are two options to choose what will occur when the timer finishes. The dependent timer button launches a new timer that has dependencies. There is a About button for user instructions. + + +Version 3: + +Still under construction. +------------------------------------------------------------------------------------- diff --git a/dispatcher/Makefile b/dispatcher/Makefile new file mode 100644 index 0000000..5afd3bc --- /dev/null +++ b/dispatcher/Makefile @@ -0,0 +1,9 @@ + +all: timer + +timer: dispatcher.cpp + g++ -std=c++0x -g -o timer timer.cpp dispatcher.cpp + + + + diff --git a/dispatcher/dispatcher.cpp b/dispatcher/dispatcher.cpp new file mode 100644 index 0000000..d0fd6b4 --- /dev/null +++ b/dispatcher/dispatcher.cpp @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "timer.h" + +using namespace std; + +int main(int argc, char *argv[]) +{ + if(argc == 1 || argc ==2) + { + cout << "There is a README for a reason" << endl; + cout << "READ IT!!" << endl; + return EXIT_FAILURE; + } + + int switchCase = atoi(argv[1]); + int numberOfTimers = atoi(argv[2]); + + checkCommandLine(numberOfTimers, switchCase); + + string event; + string time; // string representation of user inputted time + int timeNumber; // variable to store timer as an integer + + vector timeDifference; //Vector of user inputted times + + int times[numberOfTimers]; // array to hold times + string events[numberOfTimers]; // array to hold events + + + + + + + if(switchCase==2) + { + execv("timerGUI/finalTimer",NULL); + } + else if(switchCase == 1) + { + //Populate vectors with user input + for(int index = 0; index < numberOfTimers; index++) + { + cout << "Enter timed event: "; + getline (cin, event); + events[index] = event; + cout << "Enter time needed for " << events[index] << " : "; + getline(cin, time); + timeNumber = convertTime(time); + times[index] = timeNumber; + } + + descendSort(times, events, numberOfTimers); // put longest times at beginning of array + + timeDifference = getTimeDifference(times, numberOfTimers); // Load time difference into vector + timeDifference.push_back(times[numberOfTimers-1]); // push the least time to the back of the timerDifference vector + + cout << "------------------------------------------------------------------------" << endl; + cout << "The timer for " << events[0] << " has started" << endl; + cout << "In " << timeDifference.at(0) << " seconds, you need to start the " << events[1] << endl; + cout << endl; + + + + for(int x = 0; x < numberOfTimers -1; x++) + { + if(newTimer(timeDifference.at(x))) + { + execute(x, numberOfTimers, timeDifference, events); + } + } + + return EXIT_SUCCESS; + } + else + { + cout << "***********************************************" << endl; + cout << "This version is still under construction" << endl; + cout << "When completed it will take input from the user" << + " and excute the gui timer interface for the provided input" << endl; + cout << "***********************************************" << endl; + pid_t pId = fork(); + exit(0); + } +return 0; + + +} + + diff --git a/dispatcher/timer.cpp b/dispatcher/timer.cpp new file mode 100644 index 0000000..c66b906 --- /dev/null +++ b/dispatcher/timer.cpp @@ -0,0 +1,186 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "timer.h" + + + +using namespace std; + + +/* + * Converts input string to seconds + * @parm inputTime - string format of time + * @return (sec + min + hour) - total time converted to seconds + */ + +int convertTime(string inputTime) +{ + int sec; + int min; + int hour; + + string secString=inputTime.substr(6,2); + string minString=inputTime.substr(3,2); + string hourString=inputTime.substr(0,2); + + //convert string to int for seconds + stringstream secTime(secString); + secTime >> sec; + //convert string to int for minutes + stringstream minTime(minString); + minTime >> min; + min = min * 60; + //convert string to int for hours + stringstream hourTime(hourString); + hourTime >> hour; + hour = hour * 3600; + + return (sec + min + hour); + +} + + +/* + * Output of timer to console + * @param number - number of timers + * @param timers - number of timers input by user + * @param timeDifference - vector of time differentials + * @param events - array of events + * + */ +void execute(int number, int timers, vector timeDifference, string events[]) +{ + if(number < timers-1) + { + cout << "Time to start " << events[number+1] << endl; + } + if(number < timers-2) + { + + cout << "In " << timeDifference.at(number+1) << " seconds, you need to start the " << events[number+2] << endl; + cout << endl; + } + if(number == timers-2 ) + { + sleep(timeDifference.at(timers)); + + cout << "***************************************************************************" << endl; + cout << "Everything is completed" << endl; + } +} + +/* + * Sorts the inputed times - longest time at first element of array + * @param sortTime[] - array of user input times + * @param sortEvent[] - array of user input events + * @param size - number of user input timers + */ + +void descendSort(int sortTime[], string sortEvent[], int size) +{ + int tempTime = 0; + string tempEvent = ""; + for (int i=0; i < size; i++) + { + for (int j=0; j <= i; j++) + { + if( sortTime[j] < sortTime[i]) + { + tempTime = sortTime[j]; + tempEvent = sortEvent[j]; + + sortTime[j] = sortTime[i]; + sortEvent[j] = sortEvent[i]; + + sortTime[i] = tempTime; + sortEvent[i] = tempEvent; + } + + } + } +} + +/* + * Check the given command line arguments for proper usage + * @param numberOfTimer - number of user input timers needed + * @param argc - number of command line arguments + * @param switchCase - value of argv[1] - used for determine which version to execute + */ + + +void checkCommandLine(int numberOfTimers, int switchCase) +{ + if(switchCase < 1 || switchCase > 3) + { + cout << "To use this application: Enter ./timer [timer option] [# of timers]" << endl; + cout << "-------------------------------------------------------------------" << endl; + cout << endl; + cout << "Timer 0ptions" << endl; + cout << "------------- " << endl; + cout << "1 - console timer" << endl; + cout << "2 - GUI timer" << endl; + cout << "3 - console input and GUI output" << endl; + exit(EXIT_FAILURE); + } + if(numberOfTimers > 10 || numberOfTimers < 1) + { + cout << "You can not use more than 10 timers on this system" << endl; + cout << "Please enter a number between 1 and 10 " << endl; + exit(EXIT_FAILURE); + } + +} + +/* + * Calculate the time difference between input timer values + * @param eventTimes[] - array of user input events + * @param size - number of user input timers + * @return delayTime - vector of times to delay. + */ + +vector getTimeDifference(int eventTimes[], int size) +{ + vector delayTime; + + if(size == 1) + { + delayTime.push_back(eventTimes[0]); + return delayTime; + } + else + { + for(int i = 0; i < size ; i ++) + { + delayTime.push_back(eventTimes[i] - eventTimes[i+1]); + } + + return delayTime; + } +} + +/* + * Simple function to sleep for given amount of time + * @param time - amount of time to sleep in seconds + * @return - 1 when sleep completes executing + */ +int newTimer(int time) +{ + int count = 0; + while(1) + { + sleep(1); + count ++; + if(count == time) + { + return 1; + } + } +} + diff --git a/dispatcher/timer.h b/dispatcher/timer.h new file mode 100644 index 0000000..c488f0c --- /dev/null +++ b/dispatcher/timer.h @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + + + + +using namespace std; + +int convertTime(string inputTime); +void execute(int number, int timers, vector timeDifference, string events[]); +void descendSort(int sortTime[], string sortEvent[], int size); +void checkCommandLine(int numberOfTimers, int switchCase); +vector getTimeDifference(int eventTimes[], int size); +int newTimer(int time); + + diff --git a/timerGUI/ui_dependent.h b/timerGUI/ui_dependent.h index 2199423..67bd73a 100644 --- a/timerGUI/ui_dependent.h +++ b/timerGUI/ui_dependent.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'dependent.ui' ** -** Created: Wed May 2 23:44:57 2012 -** by: Qt User Interface Compiler version 4.7.2 +** Created: Sun May 6 01:43:24 2012 +** by: Qt User Interface Compiler version 4.7.4 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/timerGUI/ui_mainwindow.h b/timerGUI/ui_mainwindow.h index 5649c60..f16cf4d 100644 --- a/timerGUI/ui_mainwindow.h +++ b/timerGUI/ui_mainwindow.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'mainwindow.ui' ** -** Created: Wed May 2 23:44:57 2012 -** by: Qt User Interface Compiler version 4.7.2 +** Created: Sun May 6 01:43:24 2012 +** by: Qt User Interface Compiler version 4.7.4 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/timerGUI/ui_singletimer.h b/timerGUI/ui_singletimer.h index de82a47..4129ed4 100644 --- a/timerGUI/ui_singletimer.h +++ b/timerGUI/ui_singletimer.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'singletimer.ui' ** -** Created: Wed May 2 23:40:02 2012 -** by: Qt User Interface Compiler version 4.7.2 +** Created: Sun May 6 01:43:24 2012 +** by: Qt User Interface Compiler version 4.7.4 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -38,8 +38,8 @@ class Ui_singleTimer QLabel *label; QWidget *layoutWidget; QHBoxLayout *horizontalLayout_2; - QRadioButton *radioDown; QRadioButton *radioUp; + QRadioButton *radioDown; QWidget *layoutWidget1; QVBoxLayout *verticalLayout; QCheckBox *checkMessage; @@ -87,16 +87,16 @@ class Ui_singleTimer horizontalLayout_2 = new QHBoxLayout(layoutWidget); horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); horizontalLayout_2->setContentsMargins(0, 0, 0, 0); - radioDown = new QRadioButton(layoutWidget); - radioDown->setObjectName(QString::fromUtf8("radioDown")); - - horizontalLayout_2->addWidget(radioDown); - radioUp = new QRadioButton(layoutWidget); radioUp->setObjectName(QString::fromUtf8("radioUp")); horizontalLayout_2->addWidget(radioUp); + radioDown = new QRadioButton(layoutWidget); + radioDown->setObjectName(QString::fromUtf8("radioDown")); + + horizontalLayout_2->addWidget(radioDown); + layoutWidget1 = new QWidget(singleTimer); layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); layoutWidget1->setGeometry(QRect(360, 190, 211, 101)); @@ -142,8 +142,8 @@ class Ui_singleTimer "p, li { white-space: pre-wrap; }\n" "\n" "

Count Down Options

", 0, QApplication::UnicodeUTF8)); - radioDown->setText(QApplication::translate("singleTimer", "Count Down", 0, QApplication::UnicodeUTF8)); radioUp->setText(QApplication::translate("singleTimer", "Count Up", 0, QApplication::UnicodeUTF8)); + radioDown->setText(QApplication::translate("singleTimer", "Count Down", 0, QApplication::UnicodeUTF8)); checkMessage->setText(QApplication::translate("singleTimer", "Show Message", 0, QApplication::UnicodeUTF8)); checkRollover->setText(QApplication::translate("singleTimer", "Rollover", 0, QApplication::UnicodeUTF8)); pushStart->setText(QApplication::translate("singleTimer", "Start", 0, QApplication::UnicodeUTF8)); From 9754bb42e967979f17db2c32cc627c8d18d7f536 Mon Sep 17 00:00:00 2001 From: tavispa Date: Sun, 6 May 2012 22:41:58 -0400 Subject: [PATCH 12/14] Updated README message --- dispatcher/dispatcher.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dispatcher/dispatcher.cpp b/dispatcher/dispatcher.cpp index d0fd6b4..8c69c3e 100644 --- a/dispatcher/dispatcher.cpp +++ b/dispatcher/dispatcher.cpp @@ -14,8 +14,9 @@ int main(int argc, char *argv[]) { if(argc == 1 || argc ==2) { - cout << "There is a README for a reason" << endl; - cout << "READ IT!!" << endl; + cout << "You must include the type of timer and the number of timers" << endl; + cout << "eg. ./timer 2 1" << endl; + cout << "See README for further documentation." << endl; return EXIT_FAILURE; } From be4280a57908a7b98d31c154554f65053874c573 Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 9 May 2012 13:56:16 -0400 Subject: [PATCH 13/14] Updated README for clarity with timer 1 --- README | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README b/README index 44764a4..f849c45 100644 --- a/README +++ b/README @@ -33,6 +33,9 @@ Number of timers needed (must be between 1 and 10) Version 1 instructions: +NOTE:If you do not enter the time in the correct format, you will get a basic_string error. + + User will be prompted to enter events and time for each event, the time must be entered in the following format: @@ -41,6 +44,22 @@ HH:MM:SS User will be notified how long before the next event needs to be started and notified again when to start that event +If you use multiple timers, enter the events beginning at the LAST event: +For example, You want to cook 3 items, meat, potatoes, and corn. +Corn takes 10 seconds, potatoes takes 20 seconds, and meat takes 1 minute. +Run this command: +./timer 1 3 + +You will be prompted to 'enter timed event' and 'enter time needed.' Do this as follows: +Enter timed event: corn +Enter time needed for corn: 00:00:10 +Enter timed event: potatoes +Enter time needed for potatoes: 00:00:20 +Enter timed event: meat +Enter time needed for meat: 00:01:00 + + + Version 2 instructions: From 17648a5f85f63af4bf8c06c63b2b118f50978c6c Mon Sep 17 00:00:00 2001 From: tavispa Date: Wed, 9 May 2012 14:01:21 -0400 Subject: [PATCH 14/14] Updated CONTRIBUTIONS.tavispa file --- CONTRIBUTIONS.tavispa | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTIONS.tavispa b/CONTRIBUTIONS.tavispa index 15033fc..3645d5b 100644 --- a/CONTRIBUTIONS.tavispa +++ b/CONTRIBUTIONS.tavispa @@ -3,3 +3,5 @@ I also attempted to manage the repo but we had some problems with it where we co dropbox instead. I wrote prototype code in C and Qt's C++ to demonstrate the single timer application. I wrote the code for the single timer application and made the decisions on the GUI architecture, and decided on its limitations for the scope of this project. + +I also tried to update the README as feedback was received.