From 83d6989d51fb2dd1e4ecf81cff97c6942f121198 Mon Sep 17 00:00:00 2001 From: "Sean C. Rhea" Date: Tue, 13 May 2008 16:15:22 +0000 Subject: [PATCH] from Justin: more .pro file patches for Windows, plus ToolsDialog --- src/MainWindow.cpp | 13 +++++- src/MainWindow.h | 1 + src/ToolsDialog.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++ src/ToolsDialog.h | 43 ++++++++++++++++++++ src/src.pro | 22 +++++----- 5 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 src/ToolsDialog.cpp create mode 100644 src/ToolsDialog.h diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index e057e0dea..4c01d58a2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -42,6 +42,7 @@ #include #include "DatePickerDialog.h" +#include "ToolsDialog.h" #define FOLDER_TYPE 0 #define RIDE_TYPE 1 @@ -377,9 +378,12 @@ MainWindow::MainWindow(const QDir &home) : SLOT (importTCX())); rideMenu->addAction(tr("Find &best intervals..."), this, SLOT(findBestIntervals()), tr ("Ctrl+B")); - QMenu *optionsMenu = menuBar()->addMenu(tr("&Options")); + QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools")); optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions()), tr("Ctrl+O")); + optionsMenu->addAction(tr("&Tools..."), this, + SLOT(showTools()), tr("Ctrl+T")); + QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("&About GoldenCheetah"), this, SLOT(aboutDialog())); @@ -1069,3 +1073,10 @@ MainWindow::notesChanged() currentNotesChanged = true; } +void MainWindow::showTools() +{ + ToolsDialog *td = new ToolsDialog(); + td->exec(); + +} + diff --git a/src/MainWindow.h b/src/MainWindow.h index cc643aad8..36cb7899e 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -70,6 +70,7 @@ class MainWindow : public QMainWindow void notesChanged(); void saveNotes(); void showOptions(); + void showTools(); protected: diff --git a/src/ToolsDialog.cpp b/src/ToolsDialog.cpp new file mode 100644 index 000000000..25e4a9491 --- /dev/null +++ b/src/ToolsDialog.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2007 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "ToolsDialog.h" +#include + +void ToolsDialog::setupUi(QDialog *ToolsDialog) +{ + if (ToolsDialog->objectName().isEmpty()) + ToolsDialog->setObjectName(QString::fromUtf8("ToolsDialog")); + ToolsDialog->setWindowModality(Qt::WindowModal); + ToolsDialog->setAcceptDrops(false); + ToolsDialog->setModal(true); + + QGridLayout *mainGrid = new QGridLayout(this); // a 2 x n grid + lblBest3Min = new QLabel("Your Best 3 Minutes:", this); + lblBest3Min->setFrameStyle(QFrame::Panel | QFrame::Sunken); + txtBest3Min = new QLineEdit(this); + txtBest3Min->setInputMask("999"); + lblBest20Min = new QLabel("Your Best 20 Minutes:", this); + lblBest20Min->setFrameStyle(QFrame::Panel | QFrame::Sunken); + txtBest20Min = new QLineEdit(this); + txtBest20Min->setInputMask("999"); + lblCP = new QLabel(this); + lblCP->setFrameStyle(QFrame::Panel | QFrame::Sunken); + lblCP->setText(QString("Critical Power:")); + txtCP = new QLineEdit(this); + txtCP->setEnabled(false); + + btnOK = new QPushButton(this); + btnCalculate = new QPushButton(this); + mainGrid->addWidget(lblBest3Min, 0, 0); + mainGrid->addWidget(lblBest3Min, 0, 0); + mainGrid->addWidget(txtBest3Min, 0, 1); + + mainGrid->addWidget(lblBest20Min, 1, 0); + mainGrid->addWidget(txtBest20Min, 1, 1); + + mainGrid->addWidget(lblCP, 2, 0); + mainGrid->addWidget(txtCP, 2, 1); + + mainGrid->addWidget(btnCalculate, 3, 0); + mainGrid->addWidget(btnOK, 3, 1); + + + + + ToolsDialog->setWindowTitle( + QApplication::translate("ToolsDialog", "Critical Power Calculator", 0, + QApplication::UnicodeUTF8)); + + btnOK->setText( + QApplication::translate("ToolsDialog", "OK", 0, + QApplication::UnicodeUTF8)); + btnCalculate->setText( + QApplication::translate("ToolsDialog", "Calculate", 0, + QApplication::UnicodeUTF8)); + + connect(btnOK, SIGNAL(clicked()), this, SLOT(on_btnOK_clicked())); + connect(btnCalculate, SIGNAL(clicked()), this, SLOT(on_btnCalculate_clicked())); + + Q_UNUSED(ToolsDialog); +} + +ToolsDialog::ToolsDialog(QWidget *parent) + : QDialog(parent) +{ + setupUi(this); +} + +void ToolsDialog::on_btnOK_clicked() +{ + accept(); +} + +void ToolsDialog::on_btnCalculate_clicked() +{ + int CP = (txtBest20Min->text().toInt() * 20 * 60 - (txtBest3Min->text().toInt() * 3 * 60)) / (20 * 60 - 3 * 60); + QString strCP; + txtCP->setText(strCP.setNum(CP)); + +} + diff --git a/src/ToolsDialog.h b/src/ToolsDialog.h new file mode 100644 index 000000000..d711742f5 --- /dev/null +++ b/src/ToolsDialog.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +class ToolsDialog : public QDialog +{ + Q_OBJECT + + public: + ToolsDialog(QWidget *parent = 0); + QLabel *lblBest3Min; + QLineEdit *txtBest3Min; + QHBoxLayout *hboxLayout1; + QLabel *lblBest20Min; + QPushButton *btnCalculate; + QLineEdit *txtBest20Min; + QPushButton *btnOK; + QLabel *lblCP; + QLineEdit *txtCP; + void setupUi(QDialog*); + + private slots: + void on_btnOK_clicked(); + void on_btnCalculate_clicked(); +}; + diff --git a/src/src.pro b/src/src.pro index 7b63e1f0f..6bd494951 100644 --- a/src/src.pro +++ b/src/src.pro @@ -7,27 +7,27 @@ CONFIG += static debug QT += xml LIBS += /usr/local/qwt/lib/libqwt.a LIBS += -lm -lz -lftd2xx +QMAKE_CXXFLAGS = -DGC_BUILD_DATE="`date +'\"%a_%b_%d,_%Y\"'`" +RC_FILE = images/gc.icns + macx { LIBS += -framework Carbon } -macx || unix { - HEADERS += Serial.h - SOURCES += Serial.cpp - QMAKE_CXXFLAGS = -DGC_BUILD_DATE="`date +'\"%a_%b_%d,_%Y\"'`" - RC_FILE = images/gc.icns -} - -win32 { +win32 { + HEADERS -= Serial.h + HEADERS -= Serial.cpp LIBS = ..\lib\libregex.a \ C:\qwt-5.1.0\lib\libqwtd5.a \ -lws2_32 \ C:\ftdi\libftd2xx.a QMAKE_LFLAGS = -Wl,--enable-runtime-pseudo-reloc \ -Wl,--script,i386pe.x-no-rdata - QMAKE_CXXFLAGS = -fdata-sections - INCLUDEPATH += C:\qwt-5.1.0\include \ + QMAKE_CXXFLAGS += -fdata-sections + INCLUDEPATH += C:\qwt-5.1.0\include\ C:\boost + RC_FILE -= images/gc.icns + } HEADERS += \ @@ -56,6 +56,7 @@ HEADERS += \ LogTimeScaleEngine.h \ Pages.h \ PowerTap.h \ + ToolsDialog.h \ Zones.h \ cpint.h \ srm.h @@ -89,6 +90,7 @@ SOURCES += \ LogTimeScaleEngine.cpp \ Pages.cpp \ PowerTap.cpp \ + ToolsDialog.cpp \ Zones.cpp \ main.cpp \ srm.cpp