Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "MantidQtAPI/AlgorithmRunner.h"
#include "MantidQtAPI/HelpWindow.h"
#include "MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h"
#include "MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h"
using namespace Mantid::API;
using namespace MantidQt::CustomInterfaces;
#include <boost/lexical_cast.hpp>
#include <QCheckBox>
#include <QCloseEvent>
#include <QMessageBox>
#include <QSettings>
namespace MantidQt {
namespace CustomInterfaces {
// Add this class to the list of specialised dialogs in this namespace
DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI)
/**
* Default constructor.
*
* @param parent Parent window (most likely the Mantid main app window).
*/
EnggDiffractionViewQtGUI::EnggDiffractionViewQtGUI(QWidget *parent)
: UserSubWindow(parent), IEnggDiffractionView(), m_presenter(NULL) {}
EnggDiffractionViewQtGUI::~EnggDiffractionViewQtGUI() {}
void EnggDiffractionViewQtGUI::initLayout() {
// setup container ui
m_ui.setupUi(this);
// add tab contents and set up their ui's
QWidget *wCalib = new QWidget(m_ui.tabMain);
m_uiTabCalib.setupUi(wCalib);
m_ui.tabMain->addTab(wCalib, QString("Calibration"));
QWidget *wSettings = new QWidget(m_ui.tabMain);
m_uiTabSettings.setupUi(wSettings);
m_ui.tabMain->addTab(wSettings, QString("Setup"));
readSettings();
// basic UI setup
doSetupTabCalib();
doSetupTabSettings();
// presenter that knows how to handle a IEnggDiffractionView should take care
// of all the logic
// note that the view needs to know the concrete presenter
m_presenter.reset(new EnggDiffractionPresenter(this));
// it will know what compute resources and tools we have available:
// This view doesn't even know the names of compute resources, etc.
m_presenter->notify(IEnggDiffractionPresenter::Start);
}
void EnggDiffractionViewQtGUI::doSetupTabCalib() {}
void EnggDiffractionViewQtGUI::doSetupTabSettings() {}
void EnggDiffractionViewQtGUI::readSettings() {}
void EnggDiffractionViewQtGUI::saveSettings() const {}
void EnggDiffractionViewQtGUI::userWarning(const std::string &err,
const std::string &description) {
QMessageBox::warning(this, QString::fromStdString(err),
QString::fromStdString(description), QMessageBox::Ok,
QMessageBox::Ok);
}
void EnggDiffractionViewQtGUI::userError(const std::string &err,
const std::string &description) {
QMessageBox::critical(this, QString::fromStdString(err),
QString::fromStdString(description), QMessageBox::Ok,
QMessageBox::Ok);
}
std::string EnggDiffractionViewQtGUI::getRBNumber() const {
return "not available";
}
void EnggDiffractionViewQtGUI::loadCalibrationClicked() {}
void EnggDiffractionViewQtGUI::closeEvent(QCloseEvent *event) {
int answer = QMessageBox::AcceptRole;
QMessageBox msgBox;
msgBox.setWindowTitle("Close the engineering diffraction interface");
// with something like this, we'd have layout issues:
// msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
// msgBox.setDefaultButton(QMessageBox::Yes);
msgBox.setIconPixmap(QPixmap(":/win/unknown.png"));
QCheckBox confirmCheckBox("Always ask for confirmation", &msgBox);
confirmCheckBox.setCheckState(Qt::Checked);
msgBox.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
msgBox.layout()->addWidget(&confirmCheckBox);
QPushButton *bYes = msgBox.addButton("Yes", QMessageBox::YesRole);
bYes->setIcon(style()->standardIcon(QStyle::SP_DialogYesButton));
QPushButton *bNo = msgBox.addButton("No", QMessageBox::NoRole);
bNo->setIcon(style()->standardIcon(QStyle::SP_DialogNoButton));
msgBox.setDefaultButton(bNo);
msgBox.setText("You are about to close this interface");
msgBox.setInformativeText("Are you sure?");
answer = msgBox.exec();
if (answer == QMessageBox::AcceptRole) {
m_presenter->notify(IEnggDiffractionPresenter::ShutDown);
event->accept();
} else {
event->ignore();
}
}
void EnggDiffractionViewQtGUI::openHelpWin() {
MantidQt::API::HelpWindow::showCustomInterface(
NULL, QString("Engineering_Diffraction"));
}
} // namespace CustomInterfaces
} // namespace MantidQt