Skip to content
Snippets Groups Projects
Commit 861f0081 authored by Nick Draper's avatar Nick Draper
Browse files

re #10772 add opt out with confirmation to first use dialog

parent 71f4af60
No related merge requests found
......@@ -4,6 +4,7 @@
#include "MantidQtAPI/ManageUserDirectories.h"
#include <QDesktopServices>
#include <QMessageBox>
#include <QSettings>
#include <QUrl>
......@@ -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();
......@@ -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")
{
......@@ -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 {"
......@@ -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;
......@@ -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);
......
......@@ -23,6 +23,7 @@ private:
private slots:
void confirm();
void cancel();
void allowUsageDataStateChanged(int);
void openReleaseNotes();
void openSampleDatasets();
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment