diff --git a/DataTracker.pro b/DataTracker.pro index b305b10..ca19843 100644 --- a/DataTracker.pro +++ b/DataTracker.pro @@ -19,8 +19,8 @@ TEST_FEATURES = 1 VERSION_MAJOR = 0 -VERSION_MINOR = 7 -VERSION_BUILD = 3 +VERSION_MINOR = 8 +VERSION_BUILD = 0 DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\ "VERSION_MINOR=$$VERSION_MINOR"\ diff --git a/main.cpp b/main.cpp index 2ad1f4a..0832623 100644 --- a/main.cpp +++ b/main.cpp @@ -39,7 +39,6 @@ int main(int argc, char *argv[]) qRegisterMetaType("ParseTypes::ParseAction"); QSettings settings; - settings.beginGroup(QLatin1String("DTProgramSettings")); bool displayDark = settings.value(QLatin1String("displayDark"), false).toBool(); settings.endGroup(); diff --git a/recordingwindow.cpp b/recordingwindow.cpp index 4dc5710..fc9f17b 100644 --- a/recordingwindow.cpp +++ b/recordingwindow.cpp @@ -35,7 +35,7 @@ RecordingWindow::RecordingWindow(QWidget *parent) : QDialog(parent), ui(new Ui:: installEventFilter(this); setWindowTitle(tr("Session Recording Window")); - Qt::WindowFlags windowFlags = 0; + Qt::WindowFlags windowFlags = nullptr; windowFlags |= Qt::WindowMaximizeButtonHint; windowFlags |= Qt::WindowMinimizeButtonHint; windowFlags |= Qt::WindowCloseButtonHint; diff --git a/sessionwindow.h b/sessionwindow.h index ed985a8..22c1da6 100644 --- a/sessionwindow.h +++ b/sessionwindow.h @@ -48,7 +48,7 @@ class SessionWindow : public QDialog Q_OBJECT public: - explicit SessionWindow(QString mCurrentWorkingDirectory, QWidget *parent = 0); + explicit SessionWindow(QString mCurrentWorkingDirectory, QWidget *parent = nullptr); ~SessionWindow(); private slots: diff --git a/sessionwindow.ui b/sessionwindow.ui index 6349ca9..dd9a5a0 100644 --- a/sessionwindow.ui +++ b/sessionwindow.ui @@ -1396,6 +1396,9 @@ + + false + 0 @@ -1409,8 +1412,11 @@ + + false + - + Sync functionality disabled. diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 8232305..ae16fb8 100644 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -41,6 +41,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) : WindowTools::SetDialogFixedDisplay(this); } +/** + * @brief SettingsDialog::SetPrimarySaveLocation + * @param location + */ +void SettingsDialog::SetPrimarySaveLocation(QString location) +{ + primarySaveLocation = location; + ui->editPrimarySaveLocation->setText(location); +} + /** * @brief SettingsDialog::SetSaveLocation * @param location @@ -120,6 +130,15 @@ void SettingsDialog::SetAutoUpdateCheck(bool value) ui->checkBoxAutoUpdate->setChecked(value); } +/** + * @brief SettingsDialog::GetPrimarySaveLocation + * @return + */ +QString SettingsDialog::GetPrimarySaveLocation() +{ + return ui->editPrimarySaveLocation->text(); +} + /** * @brief SettingsDialog::GetSaveLocation * @return @@ -193,6 +212,7 @@ SettingsDialog::~SettingsDialog() */ void SettingsDialog::on_pushButton_clicked() { + primarySaveLocation = GetPrimarySaveLocation(); alternateSaveLocation = GetSaveLocation(); spreadsheetOutput = GetSpreadsheetOption(); displayPlots = GetDisplayOption(); @@ -201,8 +221,13 @@ void SettingsDialog::on_pushButton_clicked() autoMigrate = GetAutoMigrate(); autoUpdate = GetAutoUpdate(); - QDir mDir(alternateSaveLocation); + QDir mDir(primarySaveLocation); + if (mDir.exists()) + { + FileTools::CheckAndPrepDirectory("DataTracker3", mDir.absolutePath()); + } + mDir = QDir(alternateSaveLocation); if (mDir.exists()) { FileTools::CheckAndPrepDirectory("DataTracker3", mDir.absolutePath()); @@ -256,3 +281,49 @@ void SettingsDialog::on_setSaveLocation_clicked() ui->editSaveLocation->setText(mLocation); } } + +void SettingsDialog::on_setPrimarySaveLocation_clicked() +{ + QString mLocation; + + if (ui->editPrimarySaveLocation->text().length() == 0) + { +#ifdef _WIN32 + mLocation = QFileDialog::getExistingDirectory (this, + tr("Pick Primary Save Location"), + QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0], + QFileDialog::ShowDirsOnly); +#elif TARGET_OS_MAC + mLocation = QFileDialog::getExistingDirectory (this, + tr("Pick Primary Save Location"), + QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0], + QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog); +#endif + } + else + { +#ifdef _WIN32 + mLocation = QFileDialog::getExistingDirectory (this, + tr("Pick Primary Save Location"), + ui->editPrimarySaveLocation->text(), + QFileDialog::ShowDirsOnly); +#elif TARGET_OS_MAC + mLocation = QFileDialog::getExistingDirectory (this, + tr("Pick Primary Save Location"), + ui->editPrimarySaveLocation->text(), + QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog); +#endif + } + + // Remove the trailing location, if added + if (mLocation.contains("DataTracker3", Qt::CaseInsensitive)) + { + mLocation = mLocation.replace("DataTracker3", ""); + } + + QDir mPotentialDir(mLocation); + if (mLocation.length() !=0 && mPotentialDir.exists()) + { + ui->editPrimarySaveLocation->setText(mLocation); + } +} diff --git a/settingsdialog.h b/settingsdialog.h index c3cc6b2..8ad96d4 100644 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -35,8 +35,9 @@ class SettingsDialog : public QDialog Q_OBJECT public: - explicit SettingsDialog(QWidget *parent = 0); + explicit SettingsDialog(QWidget *parent = nullptr); + QString primarySaveLocation; QString alternateSaveLocation; bool spreadsheetOutput = true; bool displayPlots = false; @@ -45,6 +46,7 @@ class SettingsDialog : public QDialog bool autoMigrate = false; bool autoUpdate = true; + void SetPrimarySaveLocation(QString location); void SetSaveLocation(QString location); void SetSpreadsheetOption(bool value); void SetDisplayOption(bool value); @@ -53,6 +55,7 @@ class SettingsDialog : public QDialog void SetAutoMigrate(bool value); void SetAutoUpdateCheck(bool value); + QString GetPrimarySaveLocation(); QString GetSaveLocation(); bool GetSpreadsheetOption(); bool GetDisplayOption(); @@ -66,6 +69,7 @@ class SettingsDialog : public QDialog private slots: void on_pushButton_clicked(); void on_setSaveLocation_clicked(); + void on_setPrimarySaveLocation_clicked(); private: Ui::SettingsDialog *ui; diff --git a/settingsdialog.ui b/settingsdialog.ui index 5665816..7b9e11a 100644 --- a/settingsdialog.ui +++ b/settingsdialog.ui @@ -48,15 +48,15 @@ - QLayout::SetNoConstraint + QLayout::SetFixedSize QFormLayout::ExpandingFieldsGrow - 13 + 10 - + @@ -69,7 +69,52 @@ - + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Qt::NoFocus + + + true + + + + + + + + 0 + 0 + + + + Set + + + + + + @@ -82,7 +127,7 @@ - + @@ -105,7 +150,7 @@ - + @@ -118,7 +163,7 @@ - + @@ -131,8 +176,11 @@ - + + + false + 0 @@ -144,10 +192,10 @@ - + - true + false @@ -160,7 +208,7 @@ - + @@ -173,7 +221,7 @@ - + @@ -186,14 +234,14 @@ - + Automate File Migrations: - + false @@ -203,16 +251,30 @@ - - + + + + Check for Updates: + + + + + + + + + + + + - 5 + 6 QLayout::SetDefaultConstraint - + 0 @@ -234,7 +296,7 @@ - + 0 @@ -248,17 +310,16 @@ - - - - Check for Updates: + + + + + 0 + 0 + - - - - - + Primary Save Location: diff --git a/startwindow.cpp b/startwindow.cpp index 373b6fe..3fe3d47 100644 --- a/startwindow.cpp +++ b/startwindow.cpp @@ -41,23 +41,25 @@ StartWindow::StartWindow(QWidget *parent) : QSettings settings(QSettings::UserScope, QLatin1String("Data Tracker")); - folderTitle = "DataTracker3"; setWindowTitle(QString(tr("Data Tracker")) + " v" + QString("%1.%2.%3").arg(VERSION_MAJOR).arg(VERSION_MINOR).arg(VERSION_BUILD)); - if (FileTools::CheckAndPrepDirectory(folderTitle)) + folderTitle = "DataTracker3"; + + LoadSettings(); + + if (primarySaveLocation != nullptr && QDir(primarySaveLocation).exists()) { + workingDirectory = FileTools::pathAppend(primarySaveLocation, folderTitle); + } + else if (FileTools::CheckAndPrepDirectory(folderTitle)) { workingDirectory = FileTools::pathAppend(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0], folderTitle); } - LoadSettings(); - +/** + * Stubbed out this functionality for now, collisions are an issue + * if (QDir(backupSaveLocation).exists()) { - /* - * - * Disable for now - * - * migraterThread = new QThread(); migrater = new FileMigrater(workingDirectory, backupSaveLocation, folderTitle); migrater->moveToThread(migraterThread); @@ -69,8 +71,10 @@ StartWindow::StartWindow(QWidget *parent) : migraterThread->wait(); migrater->startWork(); - */ } + * + * + */ statusBar()->setSizeGripEnabled(false); @@ -200,11 +204,12 @@ StartWindow::~StartWindow() /** Save Settings * @brief StartWindow::SaveSettings */ -void StartWindow::SaveSettings(QString savedLocation, bool plots, bool dark, bool sheets, bool reli, bool migrate, bool updateCheck) +void StartWindow::SaveSettings(QString primaryLocation, QString savedLocation, bool plots, bool dark, bool sheets, bool reli, bool migrate, bool updateCheck) { QSettings settings; settings.beginGroup(QLatin1String("DTProgramSettings")); + settings.setValue(QLatin1String("primarySaveLocation"), primaryLocation); settings.setValue(QLatin1String("alternateSaveLocation"), savedLocation); settings.setValue(QLatin1String("displayPlots"), plots); settings.setValue(QLatin1String("displayDark"), dark); @@ -221,7 +226,8 @@ void StartWindow::SaveSettings(QString savedLocation, bool plots, bool dark, boo */ void StartWindow::closeEvent(QCloseEvent *) { - SaveSettings(backupSaveLocation, + SaveSettings(primarySaveLocation, + backupSaveLocation, displayPlots, displayDark, outputSheets, @@ -238,6 +244,7 @@ void StartWindow::LoadSettings() QSettings settings; settings.beginGroup(QLatin1String("DTProgramSettings")); + primarySaveLocation = settings.value(QLatin1String("primarySaveLocation"), "").toString(); backupSaveLocation = settings.value(QLatin1String("alternateSaveLocation"), "").toString(); displayPlots = settings.value(QLatin1String("displayPlots"), false).toBool(); displayDark = settings.value(QLatin1String("displayDark"), false).toBool(); @@ -271,6 +278,7 @@ void StartWindow::on_actionCalculate_Reliability_triggered() */ void StartWindow::on_actionSettings_2_triggered() { + settingsDialog.SetPrimarySaveLocation(primarySaveLocation); settingsDialog.SetSaveLocation(backupSaveLocation); settingsDialog.SetSpreadsheetOption(outputSheets); settingsDialog.SetDisplayOption(displayPlots); @@ -283,12 +291,13 @@ void StartWindow::on_actionSettings_2_triggered() if (displayDark != settingsDialog.GetThemeDark() || autoUpdateCheck != settingsDialog.GetAutoUpdate()) { - QMessageBox::information(NULL, + QMessageBox::information(nullptr, tr("Settings Updated"), tr("Restart for changes to take effect."), QMessageBox::Ok); } + primarySaveLocation = settingsDialog.GetPrimarySaveLocation(); backupSaveLocation = settingsDialog.GetSaveLocation(); outputSheets = settingsDialog.GetSpreadsheetOption(); displayPlots = settingsDialog.GetDisplayOption(); @@ -297,7 +306,8 @@ void StartWindow::on_actionSettings_2_triggered() autoMigrate = settingsDialog.GetAutoMigrate(); autoUpdateCheck = settingsDialog.GetAutoUpdate(); - SaveSettings(backupSaveLocation, + SaveSettings(primarySaveLocation, + backupSaveLocation, displayPlots, displayDark, outputSheets, @@ -449,6 +459,9 @@ void StartWindow::on_actionSequential_Analyses_triggered() sequenceDialog->exec(); } +/** + * @brief StartWindow::on_actionCondition_Sequential_Analysis_triggered + */ void StartWindow::on_actionCondition_Sequential_Analysis_triggered() { sequenceConditionDialog = new SequentialConditionAnalysisDialog(workingDirectory, this); @@ -502,9 +515,6 @@ void StartWindow::on_actionAbout_triggered() */ void StartWindow::on_buttonStart_clicked() { - if (FileTools::CheckAndPrepDirectory(folderTitle)) - { - sessionWindow = new SessionWindow(workingDirectory, this); - sessionWindow->exec(); - } + sessionWindow = new SessionWindow(workingDirectory, this); + sessionWindow->exec(); } diff --git a/startwindow.h b/startwindow.h index 4c76c1b..b205fc2 100644 --- a/startwindow.h +++ b/startwindow.h @@ -55,10 +55,10 @@ class StartWindow : public QMainWindow Q_OBJECT public: - explicit StartWindow(QWidget *parent = 0); + explicit StartWindow(QWidget *parent = nullptr); ~StartWindow(); - void SaveSettings(QString savedLocation, bool plots, bool dark, bool sheets, bool reli, bool migrate, bool updateCheck); + void SaveSettings(QString primaryLocation, QString savedLocation, bool plots, bool dark, bool sheets, bool reli, bool migrate, bool updateCheck); void LoadSettings(); private slots: @@ -106,6 +106,7 @@ private slots: bool foundFolder = false; QString workingDirectory; + QString primarySaveLocation; QString backupSaveLocation; bool displayPlots; bool displayDark;