diff --git a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp index 7d0ebf7d284a63b65d55b458d04dcb81143b86fb..ee54e7748c767b16a8efedae9e4e4d886d46b9cb 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp @@ -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); diff --git a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.h b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.h index 52e7af4405720b63491ba7e175dba5ffd8dde1bd..f7e4798415bd9c85edfc983b3efc84d65c3e2694 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.h +++ b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.h @@ -23,6 +23,7 @@ private: private slots: void confirm(); void cancel(); + void allowUsageDataStateChanged(int); void openReleaseNotes(); void openSampleDatasets(); diff --git a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui index f943ab0623797d52f6a756c1d0d6a20e4e8f5e3f..4d91147407e6c5d66194b44d4a9ba91ca0af0f6b 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui +++ b/Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui @@ -40,23 +40,29 @@ <string notr="true">QDialog#FirstTimeSetup{background-image: url(:/First_use_Background.png);} </string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>2</number> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="leftMargin"> + <number>6</number> </property> <property name="topMargin"> - <number>125</number> + <number>135</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>6</number> </property> <item> <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> - <number>17</number> + <number>23</number> </property> <property name="spacing"> <number>0</number> </property> - <item row="1" column="1"> - <widget class="QCommandLinkButton" name="clbReleaseNotes"> + <item row="7" column="0"> + <widget class="QCommandLinkButton" name="clbExtendingMantid"> <property name="font"> <font> <family>Segoe UI</family> @@ -69,15 +75,14 @@ <enum>Qt::LeftToRight</enum> </property> <property name="styleSheet"> - <string notr="true">color: rgb(0, 128, 0); -color: rgb(0, 0, 0);</string> + <string notr="true">color: rgb(0, 0, 0);</string> </property> <property name="text"> - <string>Release Notes</string> + <string>Extending Mantid with Python</string> </property> <property name="icon"> <iconset resource="../../../Images/images.qrc"> - <normaloff>:/Icons/Notepad-Bloc-notes-icon-32x32.png</normaloff>:/Icons/Notepad-Bloc-notes-icon-32x32.png</iconset> + <normaloff>:/Icons/Plugin-Python-icon-32x32.png</normaloff>:/Icons/Plugin-Python-icon-32x32.png</iconset> </property> <property name="iconSize"> <size> @@ -90,25 +95,41 @@ color: rgb(0, 0, 0);</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLabel" name="lblVersion"> + <item row="6" column="0"> + <widget class="QCommandLinkButton" name="clbPythonInMantid"> <property name="font"> <font> <family>Segoe UI</family> - <pointsize>24</pointsize> + <pointsize>18</pointsize> <weight>75</weight> <bold>true</bold> </font> </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> <property name="styleSheet"> - <string notr="true">color: rgb(0, 105, 0);</string> + <string notr="true">color: rgb(0, 0, 0);</string> </property> <property name="text"> - <string>Version </string> + <string>Python in Mantid</string> + </property> + <property name="icon"> + <iconset resource="../../../Images/images.qrc"> + <normaloff>:/win/running_process.png</normaloff>:/win/running_process.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="checkable"> + <bool>false</bool> </property> </widget> </item> - <item row="2" column="0"> + <item row="5" column="0"> <widget class="QCommandLinkButton" name="clbPythonIntroduction"> <property name="font"> <font> @@ -142,7 +163,7 @@ color: rgb(0, 0, 0);</string> </property> </widget> </item> - <item row="1" column="0"> + <item row="4" column="0"> <widget class="QCommandLinkButton" name="clbMantidIntroduction"> <property name="font"> <font> @@ -194,42 +215,26 @@ color: rgb(0, 0, 0);</string> </property> </widget> </item> - <item row="2" column="1"> - <widget class="QCommandLinkButton" name="clbSampleDatasets"> + <item row="0" column="1"> + <widget class="QLabel" name="lblVersion"> <property name="font"> <font> <family>Segoe UI</family> - <pointsize>18</pointsize> + <pointsize>24</pointsize> <weight>75</weight> <bold>true</bold> </font> </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> <property name="styleSheet"> - <string notr="true"/> + <string notr="true">color: rgb(0, 105, 0);</string> </property> <property name="text"> - <string>Sample Datasets</string> - </property> - <property name="icon"> - <iconset resource="../../../Images/images.qrc"> - <normaloff>:/Icons/download-icon-32x32.png</normaloff>:/Icons/download-icon-32x32.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="checkable"> - <bool>false</bool> + <string>Version </string> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QCommandLinkButton" name="clbPythonInMantid"> + <item row="4" column="1"> + <widget class="QCommandLinkButton" name="clbReleaseNotes"> <property name="font"> <font> <family>Segoe UI</family> @@ -242,14 +247,15 @@ color: rgb(0, 0, 0);</string> <enum>Qt::LeftToRight</enum> </property> <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> + <string notr="true">color: rgb(0, 128, 0); +color: rgb(0, 0, 0);</string> </property> <property name="text"> - <string>Python in Mantid</string> + <string>Release Notes</string> </property> <property name="icon"> <iconset resource="../../../Images/images.qrc"> - <normaloff>:/win/running_process.png</normaloff>:/win/running_process.png</iconset> + <normaloff>:/Icons/Notepad-Bloc-notes-icon-32x32.png</normaloff>:/Icons/Notepad-Bloc-notes-icon-32x32.png</iconset> </property> <property name="iconSize"> <size> @@ -262,8 +268,8 @@ color: rgb(0, 0, 0);</string> </property> </widget> </item> - <item row="4" column="0"> - <widget class="QCommandLinkButton" name="clbExtendingMantid"> + <item row="5" column="1"> + <widget class="QCommandLinkButton" name="clbSampleDatasets"> <property name="font"> <font> <family>Segoe UI</family> @@ -276,14 +282,14 @@ color: rgb(0, 0, 0);</string> <enum>Qt::LeftToRight</enum> </property> <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> + <string notr="true"/> </property> <property name="text"> - <string>Extending Mantid with Python</string> + <string>Sample Datasets</string> </property> <property name="icon"> <iconset resource="../../../Images/images.qrc"> - <normaloff>:/Icons/Plugin-Python-icon-32x32.png</normaloff>:/Icons/Plugin-Python-icon-32x32.png</iconset> + <normaloff>:/Icons/download-icon-32x32.png</normaloff>:/Icons/download-icon-32x32.png</iconset> </property> <property name="iconSize"> <size> @@ -314,33 +320,57 @@ color: rgb(0, 0, 0);</string> <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QLabel" name="lbUpdate"> - <property name="minimumSize"> - <size> - <width>540</width> - <height>0</height> - </size> - </property> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>You can revisit this dialog by selecting "First Time Setup" on the Help menu.</string> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lbUpdate"> + <property name="minimumSize"> + <size> + <width>540</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>You can revisit this dialog by selecting "First Time Setup" on the Help menu.</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="chkDoNotShowUntilNextRelease"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>Do not show again until next release</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> </item> <item> <spacer name="horizontalSpacer_2"> @@ -356,177 +386,185 @@ color: rgb(0, 0, 0);</string> </spacer> </item> <item> - <widget class="QGroupBox" name="grpPersonalSetup"> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="styleSheet"> - <string notr="true">QGroupBox { + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="grpPersonalSetup"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">QGroupBox { border: 2px solid green; border-radius: 5px; } </string> - </property> - <property name="title"> - <string>Personal Setup</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <property name="topMargin"> - <number>18</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>Default Facility</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="cbFacility"> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>Default Instrument</string> + </property> + <property name="title"> + <string>Personal Setup</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="MantidQt::MantidWidgets::InstrumentSelector" name="cbInstrument"> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> + <property name="topMargin"> + <number>18</number> </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="lbMUD"> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> + <property name="bottomMargin"> + <number>6</number> </property> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>Set local data directories</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="pbMUD"> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>Manage User Directories</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="chkDoNotShowUntilNextRelease"> - <property name="font"> - <font> - <family>Segoe UI</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="styleSheet"> - <string notr="true">color: rgb(0, 0, 0);</string> - </property> - <property name="text"> - <string>Do not show again until next release</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>13</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pbCancel"> - <property name="text"> - <string>ASK ME NEXT TIME</string> - </property> - <property name="default"> - <bool>false</bool> - </property> - <property name="flat"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pbConfirm"> - <property name="text"> - <string>SET</string> - </property> - <property name="default"> - <bool>false</bool> - </property> - </widget> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>Default Facility</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="cbFacility"> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>Default Instrument</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="MantidQt::MantidWidgets::InstrumentSelector" name="cbInstrument"> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="lbMUD"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>Set local data directories</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="pbMUD"> + <property name="styleSheet"> + <string notr="true">color: rgb(0, 0, 0);</string> + </property> + <property name="text"> + <string>Manage User Directories</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="chkAllowUsageData"> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="lblAllowUsageData"> + <property name="font"> + <font> + <family>Segoe UI</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Report usage data</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>13</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbCancel"> + <property name="text"> + <string>ASK ME NEXT TIME</string> + </property> + <property name="default"> + <bool>false</bool> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbConfirm"> + <property name="text"> + <string>SET</string> + </property> + <property name="default"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> </item> </layout> </item>