Skip to content

Commit

Permalink
re #10772 merge conflict resolution
Browse files Browse the repository at this point in the history
Merge branch 'feature/10772_OptOut_usage_stats' into develop

Conflicts:
	Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui
  • Loading branch information
NickDraper committed Dec 16, 2014
2 parents 60a4873 + 656e5a3 commit 07fcbd2
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 251 deletions.
41 changes: 41 additions & 0 deletions Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp
Expand Up @@ -4,6 +4,7 @@
#include "MantidQtAPI/ManageUserDirectories.h"

#include <QDesktopServices>
#include <QMessageBox>
#include <QSettings>
#include <QUrl>

Expand Down Expand Up @@ -36,6 +37,7 @@ void FirstTimeSetup::initLayout()
connect(m_uiForm.clbPythonInMantid, SIGNAL(clicked()), this, SLOT(openPythonInMantid()));
connect(m_uiForm.clbExtendingMantid, SIGNAL(clicked()), this, SLOT(openExtendingMantid()));

//set first use
QSettings settings;
settings.beginGroup("Mantid/FirstUse");
const bool doNotShowUntilNextRelease = settings.value("DoNotShowUntilNextRelease", 0).toInt();
Expand All @@ -55,12 +57,21 @@ void FirstTimeSetup::initLayout()
m_uiForm.cbFacility->setCurrentIndex(m_uiForm.cbFacility->findText(
QString::fromStdString(facility)));

//set instrument
std::string instrument = config.getString("default.instrument", true);
m_uiForm.cbInstrument->updateInstrumentOnSelection(false);
m_uiForm.cbInstrument->setCurrentIndex(m_uiForm.cbInstrument->findText(
QString::fromStdString(instrument)));
connect(m_uiForm.cbFacility, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(facilitySelected(const QString &)));

//set chkAllowUsageData
std::string isUsageReportEnabled = config.getString("usagereports.enabled", "1");
if (isUsageReportEnabled == "0")
{
m_uiForm.chkAllowUsageData->setChecked(false);
}
connect(m_uiForm.chkAllowUsageData, SIGNAL(stateChanged (int)), this, SLOT(allowUsageDataStateChanged(int)));

QString stlyeName = QApplication::style()->metaObject()->className();
if(stlyeName!="QWindowsVistaStyle")
{
Expand All @@ -69,6 +80,7 @@ void FirstTimeSetup::initLayout()
ss += "\n"
"QDialog#FirstTimeSetup QCommandLinkButton {"
" background-color: rgba(255, 255, 255, 0);"
" border-radius: 15px;"
"}"
"\n"
"QDialog#FirstTimeSetup QCommandLinkButton:hover {"
Expand All @@ -84,6 +96,7 @@ void FirstTimeSetup::confirm()
std::string filename = config.getUserFilename();
config.setString("default.facility", m_uiForm.cbFacility->currentText().toStdString());
config.setString("default.instrument", m_uiForm.cbInstrument->currentText().toStdString());
config.setString("usagereports.enabled", (m_uiForm.chkAllowUsageData->isChecked()? "1" : "0"));
config.saveConfig(filename);

QSettings settings;
Expand All @@ -102,6 +115,34 @@ void FirstTimeSetup::cancel()
this->close();
}

void FirstTimeSetup::allowUsageDataStateChanged(int checkedState)
{
if (checkedState == Qt::Unchecked)
{
QMessageBox msgBox(this);
msgBox.setWindowTitle("Mantid: Report Usage Data ");
msgBox.setText("Are you sure you want to disable reporting usage data?");
msgBox.setInformativeText("All usage data is anonymous and untraceable.\n"
"We use the usage data to inform the future development of Mantid.\n"
"If you click \"Yes\" aspects you need risk being deprecated in "
"future versions if we think they are not used.\n\n"
"Are you sure you still want to disable reporting usage data?\n"
"Please click \"No\".");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setEscapeButton(QMessageBox::No);
msgBox.setIcon(QMessageBox::Question);

int ret = msgBox.exec();
if ((ret == QMessageBox::No) || (ret == QMessageBox::NoButton))
{
// No was clicked, or no button was clicked
// set the checkbox back to checked
m_uiForm.chkAllowUsageData->setCheckState(Qt::Checked);
}
}
}

void FirstTimeSetup::facilitySelected(const QString & facility)
{
m_uiForm.cbInstrument->fillWithInstrumentsFromFacility(facility);
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.h
Expand Up @@ -23,6 +23,7 @@ class FirstTimeSetup : public QDialog
private slots:
void confirm();
void cancel();
void allowUsageDataStateChanged(int);

void openReleaseNotes();
void openSampleDatasets();
Expand Down

0 comments on commit 07fcbd2

Please sign in to comment.