<commit_before>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <settingscontrollergui.h>
#include <iostream>

#include <QMessageBox>
#include <QCloseEvent>
#include <QUrl>
#include <QDesktopServices>
#include <QDateTime>
#include <QFileDialog>

using namespace MNEANONYMIZE;

MainWindow::MainWindow(MNEANONYMIZE::SettingsControllerGui *c)
: m_bOptionsVisibility(false)
, m_pUi(new Ui::MainWindow)
, m_pController(c)
{
    m_pUi->setupUi(this);
    setDefautlStateUi();
    setDefaultStateExtraInfo();
    setupConnections();
}

MainWindow::~MainWindow()
{
    delete m_pUi;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
    if(confirmClose())
    {
        event->accept();
    } else {
        event->ignore();
    }
}

bool MainWindow::confirmClose()
{
    return true;
//    const QMessageBox::StandardButton ret
//            = QMessageBox::warning(this, tr("Application"),
//                                   tr("Are you sure you want to exit?\n"),
//                                   QMessageBox::Yes | QMessageBox::Cancel);
//    switch (ret) {
//    case QMessageBox::Yes:
//        return true;
//    case QMessageBox::Cancel:
//        return false;
//    default:
//        break;
//    }
//    return false;
}

void MainWindow::setDefautlStateUi()
{
    this->setWindowTitle(qApp->organizationName() + " ~ " + qApp->applicationName() + " ~ " + qApp->applicationVersion());

    resize(666,222);

    if(m_bOptionsVisibility)
    {
        m_pUi->checkBoxShowOptions->setCheckState(Qt::Checked);
    } else {
        m_pUi->checkBoxShowOptions->setCheckState(Qt::Unchecked);
    }

    m_pUi->frameOptionsAndExtraInfo->setVisible(m_bOptionsVisibility);
    m_pUi->pushButtonReadData->setVisible(m_bOptionsVisibility);
    m_pUi->spinBoxMeasurementDateOffset->setEnabled(false);
    m_pUi->spinBoxBirthdayDateOffset->setEnabled(false);
    m_pUi->spinBoxMeasurementDateOffset->setValue(0);
    m_pUi->spinBoxBirthdayDateOffset->setValue(0);

    m_pUi->comboBoxSubjectSexExtra->addItems(QStringList() << "Unknown" << "Male" << "Female");
    m_pUi->comboBoxSubjectSexExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectSexExtra->setEditable(false);

    m_pUi->comboBoxSubjectHandExtra->addItems(QStringList() << "Unknown" << "Right" << "Left");
    m_pUi->comboBoxSubjectHandExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectHandExtra->setEditable(false);

    m_pUi->lineEditIdFileVersionExtra->setReadOnly(true);
    m_pUi->lineEditIdMACAddressExtra->setReadOnly(true);
    m_pUi->dateTimeIdMeasurementDateExtra->setReadOnly(true);

    m_pUi->dateTimeFileMeasurementDateExtra->setReadOnly(true);

    m_pUi->lineEditFileExperimenterExtra->setReadOnly(true);
    m_pUi->plainTextFileCommentExtra->setReadOnly(true);

    m_pUi->spinBoxSubjectIDExtra->setReadOnly(true);
    m_pUi->lineEditSubjectFirstNameExtra->setReadOnly(true);
    m_pUi->lineEditSubjectMiddleNameExtra->setReadOnly(true);
    m_pUi->lineEditSubjectLastNameExtra->setReadOnly(true);
    m_pUi->dateEditSubjectBirthdayExtra->setReadOnly(true);
    m_pUi->doubleSpinBoxSubjectWeightExtra->setReadOnly(true);
    m_pUi->doubleSpinBoxSubjectHeightExtra->setReadOnly(true);
    m_pUi->lineEditSubjectCommentExtra->setReadOnly(true);
    m_pUi->lineEditSubjectHisIdExtra->setReadOnly(true);

    m_pUi->labelSubjectMriDataFoundExtra->setVisible(false);

    m_pUi->spinBoxProjectIDExtra->setReadOnly(true);
    m_pUi->lineEditProjectAimExtra->setReadOnly(true);
    m_pUi->lineEditProjectNameExtra->setReadOnly(true);
    m_pUi->lineEditProjectPersonsExtra->setReadOnly(true);
    m_pUi->plainTextEditProjectCommentExtra->setReadOnly(true);

    m_pUi->lineEditMNEEnvironmentWorkingDirExtra->setReadOnly(true);
    m_pUi->lineEditMNEEnvironmentCommandExtra->setReadOnly(true);

    //tooltips
    m_pUi->checkBoxShowOptions->setToolTip("Show the options menu.");
    m_pUi->checkBoxBruteMode->setToolTip("Advanced anonymization. Anonymize also weight, height and some other fields. See Help.");
    m_pUi->labelMeasDate->setToolTip("Specify the measurement date.");
    m_pUi->dateTimeMeasurementDate->setToolTip("Specify the measurement date.");
    m_pUi->checkBoxMeasurementDateOffset->setToolTip("Specify number of days to subtract to the measurement.");
    m_pUi->spinBoxMeasurementDateOffset->setToolTip("Specify number of days to subtract to the measurement.");

    m_pUi->labelSubjectBirthday->setToolTip("Specify the subject’s birthday.");
    m_pUi->dateTimeBirthdayDate->setToolTip("Specify the subject’s birthday.");
    m_pUi->checkBoxBirthdayDateOffset->setToolTip("Specify a number of to subtract from the subject's birthday.");
    m_pUi->spinBoxBirthdayDateOffset->setToolTip("Specify a number of to subtract from the subject's birthday.");

    m_pUi->labelSubjectHisId->setToolTip("Specify the Subject’s ID within the Hospital system.");
    m_pUi->lineEditSubjectHisId->setToolTip("Specify the Subject’s ID within the Hospital system.");
    m_pUi->checkBoxMNEEnvironment->setToolTip("Make information related to MNE Toolbox also anonymized.");

    m_pUi->moreInfoButton->setToolTip("See the MNE-CPP project's web for this application.");
    m_pUi->pushButtonAnonymizeFile->setToolTip("Anonymize the input file.");
    m_pUi->labelInFile->setToolTip("File to anonymize");
    m_pUi->lineEditInFile->setToolTip("File to anonymize.");
    m_pUi->openInFileWindowButton->setToolTip("Select a file to anonymize.");
    m_pUi->labelOutFile->setToolTip("Output anonymized file. By default a \"_anonymized\" suffix is added to the name of the input file.");
    m_pUi->lineEditOutFile->setToolTip("Output anonymized file. By default a \"_anonymized\" suffix is added to the name of the input file.");
    m_pUi->openOutFileWindowButton->setToolTip("Select a folder or a file where to save the output anonymized fif file.");

    m_pUi->lineEditIdFileVersionExtra->setToolTip("This value is not modified. It is shown for completion.");
    m_pUi->lineEditIdMACAddressExtra->setToolTip("MAC address of the main acquisition system. Substitution value: 00:00:00:00:00:00:00:00");
    m_pUi->dateTimeIdMeasurementDateExtra->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->dateTimeFileMeasurementDateExtra->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->lineEditFileExperimenterExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->plainTextFileCommentExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->spinBoxSubjectIDExtra->setToolTip("Default substitution value: 0");
    m_pUi->lineEditSubjectFirstNameExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditSubjectMiddleNameExtra->setToolTip("Default substitution value: mne-cpp");
    m_pUi->lineEditSubjectLastNameExtra->setToolTip("Default substitution value: mne_anonyze");
    m_pUi->dateTimeBirthdayDate->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->spinBoxBirthdayDateOffset->setToolTip("Default substitution value: 0");
    m_pUi->lineEditSubjectCommentExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->comboBoxSubjectSexExtra->setToolTip("Default substitution value: unknown");
    m_pUi->comboBoxSubjectHandExtra->setToolTip("Default substitution value: unknown");
    m_pUi->doubleSpinBoxSubjectWeightExtra->setToolTip("Default substitution value: 0.0");
    m_pUi->doubleSpinBoxSubjectHeightExtra->setToolTip("Default substitution value: 0.0");
    m_pUi->lineEditSubjectHisIdExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->spinBoxProjectIDExtra->setToolTip("Default substitution value: 0");
    m_pUi->lineEditProjectNameExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditProjectAimExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditProjectPersonsExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->plainTextEditProjectCommentExtra->setToolTip("Default substitution value: mne_anonymize");
}

void MainWindow::setDefaultStateExtraInfo()
{
    m_pUi->lineEditIdFileVersionExtra->clear();
    m_pUi->lineEditIdMACAddressExtra->clear();
    m_pUi->dateTimeIdMeasurementDateExtra->clear();

    m_pUi->dateTimeFileMeasurementDateExtra->clear();

    m_pUi->lineEditFileExperimenterExtra->clear();
    m_pUi->plainTextFileCommentExtra->clear();

    m_pUi->spinBoxSubjectIDExtra->clear();
    m_pUi->lineEditSubjectFirstNameExtra->clear();
    m_pUi->lineEditSubjectMiddleNameExtra->clear();
    m_pUi->lineEditSubjectLastNameExtra->clear();
    m_pUi->dateEditSubjectBirthdayExtra->clear();

    m_pUi->comboBoxSubjectSexExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectHandExtra->setCurrentIndex(0);
    m_pUi->doubleSpinBoxSubjectWeightExtra->clear();
    m_pUi->doubleSpinBoxSubjectHeightExtra->clear();
    m_pUi->lineEditSubjectCommentExtra->clear();
    m_pUi->lineEditSubjectHisIdExtra->clear();<commit_msg>add tooltips to mne environment placeholders<commit_after>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <settingscontrollergui.h>
#include <iostream>

#include <QMessageBox>
#include <QCloseEvent>
#include <QUrl>
#include <QDesktopServices>
#include <QDateTime>
#include <QFileDialog>

using namespace MNEANONYMIZE;

MainWindow::MainWindow(MNEANONYMIZE::SettingsControllerGui *c)
: m_bOptionsVisibility(false)
, m_pUi(new Ui::MainWindow)
, m_pController(c)
{
    m_pUi->setupUi(this);
    setDefautlStateUi();
    setDefaultStateExtraInfo();
    setupConnections();
}

MainWindow::~MainWindow()
{
    delete m_pUi;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
    if(confirmClose())
    {
        event->accept();
    } else {
        event->ignore();
    }
}

bool MainWindow::confirmClose()
{
    return true;
//    const QMessageBox::StandardButton ret
//            = QMessageBox::warning(this, tr("Application"),
//                                   tr("Are you sure you want to exit?\n"),
//                                   QMessageBox::Yes | QMessageBox::Cancel);
//    switch (ret) {
//    case QMessageBox::Yes:
//        return true;
//    case QMessageBox::Cancel:
//        return false;
//    default:
//        break;
//    }
//    return false;
}

void MainWindow::setDefautlStateUi()
{
    this->setWindowTitle(qApp->organizationName() + " ~ " + qApp->applicationName() + " ~ " + qApp->applicationVersion());

    resize(666,222);

    if(m_bOptionsVisibility)
    {
        m_pUi->checkBoxShowOptions->setCheckState(Qt::Checked);
    } else {
        m_pUi->checkBoxShowOptions->setCheckState(Qt::Unchecked);
    }

    m_pUi->frameOptionsAndExtraInfo->setVisible(m_bOptionsVisibility);
    m_pUi->pushButtonReadData->setVisible(m_bOptionsVisibility);
    m_pUi->spinBoxMeasurementDateOffset->setEnabled(false);
    m_pUi->spinBoxBirthdayDateOffset->setEnabled(false);
    m_pUi->spinBoxMeasurementDateOffset->setValue(0);
    m_pUi->spinBoxBirthdayDateOffset->setValue(0);

    m_pUi->comboBoxSubjectSexExtra->addItems(QStringList() << "Unknown" << "Male" << "Female");
    m_pUi->comboBoxSubjectSexExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectSexExtra->setEditable(false);

    m_pUi->comboBoxSubjectHandExtra->addItems(QStringList() << "Unknown" << "Right" << "Left");
    m_pUi->comboBoxSubjectHandExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectHandExtra->setEditable(false);

    m_pUi->lineEditIdFileVersionExtra->setReadOnly(true);
    m_pUi->lineEditIdMACAddressExtra->setReadOnly(true);
    m_pUi->dateTimeIdMeasurementDateExtra->setReadOnly(true);

    m_pUi->dateTimeFileMeasurementDateExtra->setReadOnly(true);

    m_pUi->lineEditFileExperimenterExtra->setReadOnly(true);
    m_pUi->plainTextFileCommentExtra->setReadOnly(true);

    m_pUi->spinBoxSubjectIDExtra->setReadOnly(true);
    m_pUi->lineEditSubjectFirstNameExtra->setReadOnly(true);
    m_pUi->lineEditSubjectMiddleNameExtra->setReadOnly(true);
    m_pUi->lineEditSubjectLastNameExtra->setReadOnly(true);
    m_pUi->dateEditSubjectBirthdayExtra->setReadOnly(true);
    m_pUi->doubleSpinBoxSubjectWeightExtra->setReadOnly(true);
    m_pUi->doubleSpinBoxSubjectHeightExtra->setReadOnly(true);
    m_pUi->lineEditSubjectCommentExtra->setReadOnly(true);
    m_pUi->lineEditSubjectHisIdExtra->setReadOnly(true);

    m_pUi->labelSubjectMriDataFoundExtra->setVisible(false);

    m_pUi->spinBoxProjectIDExtra->setReadOnly(true);
    m_pUi->lineEditProjectAimExtra->setReadOnly(true);
    m_pUi->lineEditProjectNameExtra->setReadOnly(true);
    m_pUi->lineEditProjectPersonsExtra->setReadOnly(true);
    m_pUi->plainTextEditProjectCommentExtra->setReadOnly(true);

    m_pUi->lineEditMNEEnvironmentWorkingDirExtra->setReadOnly(true);
    m_pUi->lineEditMNEEnvironmentCommandExtra->setReadOnly(true);

    //tooltips
    m_pUi->checkBoxShowOptions->setToolTip("Show the options menu.");
    m_pUi->checkBoxBruteMode->setToolTip("Advanced anonymization. Anonymize also weight, height and some other fields. See Help.");
    m_pUi->labelMeasDate->setToolTip("Specify the measurement date.");
    m_pUi->dateTimeMeasurementDate->setToolTip("Specify the measurement date.");
    m_pUi->checkBoxMeasurementDateOffset->setToolTip("Specify number of days to subtract to the measurement.");
    m_pUi->spinBoxMeasurementDateOffset->setToolTip("Specify number of days to subtract to the measurement.");

    m_pUi->labelSubjectBirthday->setToolTip("Specify the subject’s birthday.");
    m_pUi->dateTimeBirthdayDate->setToolTip("Specify the subject’s birthday.");
    m_pUi->checkBoxBirthdayDateOffset->setToolTip("Specify a number of to subtract from the subject's birthday.");
    m_pUi->spinBoxBirthdayDateOffset->setToolTip("Specify a number of to subtract from the subject's birthday.");

    m_pUi->labelSubjectHisId->setToolTip("Specify the Subject’s ID within the Hospital system.");
    m_pUi->lineEditSubjectHisId->setToolTip("Specify the Subject’s ID within the Hospital system.");
    m_pUi->checkBoxMNEEnvironment->setToolTip("Make information related to MNE Toolbox also anonymized.");

    m_pUi->moreInfoButton->setToolTip("See the MNE-CPP project's web for this application.");
    m_pUi->pushButtonAnonymizeFile->setToolTip("Anonymize the input file.");
    m_pUi->labelInFile->setToolTip("File to anonymize");
    m_pUi->lineEditInFile->setToolTip("File to anonymize.");
    m_pUi->openInFileWindowButton->setToolTip("Select a file to anonymize.");
    m_pUi->labelOutFile->setToolTip("Output anonymized file. By default a \"_anonymized\" suffix is added to the name of the input file.");
    m_pUi->lineEditOutFile->setToolTip("Output anonymized file. By default a \"_anonymized\" suffix is added to the name of the input file.");
    m_pUi->openOutFileWindowButton->setToolTip("Select a folder or a file where to save the output anonymized fif file.");

    m_pUi->lineEditIdFileVersionExtra->setToolTip("This value is not modified. It is shown for completion.");
    m_pUi->lineEditIdMACAddressExtra->setToolTip("MAC address of the main acquisition system. Substitution value: 00:00:00:00:00:00:00:00");
    m_pUi->dateTimeIdMeasurementDateExtra->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->dateTimeFileMeasurementDateExtra->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->lineEditFileExperimenterExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->plainTextFileCommentExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->spinBoxSubjectIDExtra->setToolTip("Default substitution value: 0");
    m_pUi->lineEditSubjectFirstNameExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditSubjectMiddleNameExtra->setToolTip("Default substitution value: mne-cpp");
    m_pUi->lineEditSubjectLastNameExtra->setToolTip("Default substitution value: mne_anonyze");
    m_pUi->dateTimeBirthdayDate->setToolTip("Default substitution value: 01/01/2000 00:01:01");
    m_pUi->spinBoxBirthdayDateOffset->setToolTip("Default substitution value: 0");
    m_pUi->lineEditSubjectCommentExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->comboBoxSubjectSexExtra->setToolTip("Default substitution value: unknown");
    m_pUi->comboBoxSubjectHandExtra->setToolTip("Default substitution value: unknown");
    m_pUi->doubleSpinBoxSubjectWeightExtra->setToolTip("Default substitution value: 0.0");
    m_pUi->doubleSpinBoxSubjectHeightExtra->setToolTip("Default substitution value: 0.0");
    m_pUi->lineEditSubjectHisIdExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->spinBoxProjectIDExtra->setToolTip("Default substitution value: 0");
    m_pUi->lineEditProjectNameExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditProjectAimExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->lineEditProjectPersonsExtra->setToolTip("Default substitution value: mne_anonymize");
    m_pUi->plainTextEditProjectCommentExtra->setToolTip("Default substitution value: mne_anonymize");

    m_pUi->lineEditMNEEnvironmentCommandExtra->setToolTip("Command used to modify the fif file with the MNE toolbox.");
    m_pUi->lineEditMNEEnvironmentWorkingDirExtra->setToolTip("Working directory within MNE toolbox.");
}

void MainWindow::setDefaultStateExtraInfo()
{
    m_pUi->lineEditIdFileVersionExtra->clear();
    m_pUi->lineEditIdMACAddressExtra->clear();
    m_pUi->dateTimeIdMeasurementDateExtra->clear();

    m_pUi->dateTimeFileMeasurementDateExtra->clear();

    m_pUi->lineEditFileExperimenterExtra->clear();
    m_pUi->plainTextFileCommentExtra->clear();

    m_pUi->spinBoxSubjectIDExtra->clear();
    m_pUi->lineEditSubjectFirstNameExtra->clear();
    m_pUi->lineEditSubjectMiddleNameExtra->clear();
    m_pUi->lineEditSubjectLastNameExtra->clear();
    m_pUi->dateEditSubjectBirthdayExtra->clear();

    m_pUi->comboBoxSubjectSexExtra->setCurrentIndex(0);
    m_pUi->comboBoxSubjectHandExtra->setCurrentIndex(0);
    m_pUi->doubleSpinBoxSubjectWeightExtra->clear();
    m_pUi->doubleSpinBoxSubjectHeightExtra->clear();
    m_pUi->lineEditSubjectCommentExtra->clear();
    m_pUi->lineEditSubjectHisIdExtra->clear();
{'fraction_non_alphanumeric': 0.12418408205803302, 'fraction_numerical': 0.00844715045801108, 'mean_word_length': 5.509103891467333, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 429, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6069946', 'n_tokens_mistral': 5912, 'n_tokens_neox': 5678, 'n_words': 856}