Skip to content

Commit c0a62ab

Browse files
authored
Merge pull request #38119 from mantidproject/new_qt_connection_syntax_inelastic_interfaces
Update Qt connection syntax in Inelastic Interfaces
2 parents 10c753c + 7ec465a commit c0a62ab

26 files changed

+319
-320
lines changed

qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ void BayesFitting::initLayout() {
3333
// Connect each tab to the actions available in this GUI
3434
std::map<unsigned int, BayesFittingTab *>::iterator iter;
3535
for (iter = m_bayesTabs.begin(); iter != m_bayesTabs.end(); ++iter) {
36-
connect(iter->second, SIGNAL(showMessageBox(const std::string &)), this, SLOT(showMessageBox(const std::string &)));
36+
connect(iter->second, &BayesFittingTab::showMessageBox, this, &BayesFitting::showMessageBox);
3737
}
3838

3939
loadSettings();
4040

41-
connect(m_uiForm.pbSettings, SIGNAL(clicked()), this, SLOT(settings()));
42-
connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(help()));
43-
connect(m_uiForm.pbManageDirs, SIGNAL(clicked()), this, SLOT(manageUserDirectories()));
41+
connect(m_uiForm.pbSettings, &QPushButton::clicked, this, &BayesFitting::settings);
42+
connect(m_uiForm.pbHelp, &QPushButton::clicked, this, &BayesFitting::help);
43+
connect(m_uiForm.pbManageDirs, &QPushButton::clicked, this, &BayesFitting::manageUserDirectories);
4444

4545
InelasticInterface::initLayout();
4646
}

qt/scientific_interfaces/Inelastic/BayesFitting/BayesFittingTab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace MantidQt::CustomInterfaces {
1111
BayesFittingTab::BayesFittingTab(QWidget *parent) : InelasticTab(parent), m_propTree(new QtTreePropertyBrowser()) {
1212
m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac);
1313

14-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
14+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &BayesFittingTab::updateProperties);
1515
}
1616

1717
BayesFittingTab::~BayesFittingTab() { m_propTree->unsetFactoryForManager(m_dblManager); }

qt/scientific_interfaces/Inelastic/BayesFitting/Quasi.cpp

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,33 @@ Quasi::Quasi(QWidget *parent) : BayesFittingTab(parent), m_previewSpec(0) {
3838

3939
// Create range selector
4040
auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("QuasiERange");
41-
connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double)));
42-
connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double)));
41+
connect(eRangeSelector, &MantidWidgets::RangeSelector::minValueChanged, this, &Quasi::minValueChanged);
42+
connect(eRangeSelector, &MantidWidgets::RangeSelector::maxValueChanged, this, &Quasi::maxValueChanged);
4343

4444
setupFitOptions();
4545
setupPropertyBrowser();
4646
setupPlotOptions();
4747

4848
// Connect optional form elements with enabling checkboxes
49-
connect(m_uiForm.chkFixWidth, SIGNAL(toggled(bool)), m_uiForm.mwFixWidthDat, SLOT(setEnabled(bool)));
50-
connect(m_uiForm.chkUseResNorm, SIGNAL(toggled(bool)), m_uiForm.dsResNorm, SLOT(setEnabled(bool)));
51-
49+
connect(m_uiForm.chkFixWidth, &QCheckBox::toggled, m_uiForm.mwFixWidthDat, &FileFinderWidget::setEnabled);
50+
connect(m_uiForm.chkUseResNorm, &QCheckBox::toggled, m_uiForm.dsResNorm, &DataSelector::setEnabled);
5251
// Connect the data selector for the sample to the mini plot
53-
connect(m_uiForm.dsSample, SIGNAL(dataReady(const QString &)), this, SLOT(handleSampleInputReady(const QString &)));
54-
connect(m_uiForm.dsSample, SIGNAL(filesAutoLoaded()), this, SLOT(enableView()));
52+
connect(m_uiForm.dsSample, &DataSelector::dataReady, this, &Quasi::handleSampleInputReady);
53+
connect(m_uiForm.dsSample, &DataSelector::filesAutoLoaded, [=] { this->enableView(); });
5554

56-
connect(m_uiForm.dsResolution, SIGNAL(dataReady(const QString &)), this,
57-
SLOT(handleResolutionInputReady(const QString &)));
58-
connect(m_uiForm.dsResolution, SIGNAL(filesAutoLoaded()), this, SLOT(enableView()));
55+
connect(m_uiForm.dsResolution, &DataSelector::dataReady, this, &Quasi::handleResolutionInputReady);
56+
connect(m_uiForm.dsResolution, &DataSelector::filesAutoLoaded, [=] { this->enableView(); });
5957

6058
// Connect the program selector to its handler
61-
connect(m_uiForm.cbProgram, SIGNAL(currentIndexChanged(int)), this, SLOT(handleProgramChange(int)));
62-
59+
connect(m_uiForm.cbProgram, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
60+
&Quasi::handleProgramChange);
6361
// Connect preview spectrum spinner to handler
64-
connect(m_uiForm.spPreviewSpectrum, SIGNAL(valueChanged(int)), this, SLOT(previewSpecChanged(int)));
65-
62+
connect(m_uiForm.spPreviewSpectrum, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
63+
&Quasi::previewSpecChanged);
6664
// Plot current preview
67-
connect(m_uiForm.pbPlotPreview, SIGNAL(clicked()), this, SLOT(plotCurrentPreview()));
68-
69-
connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked()));
70-
connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked()));
65+
connect(m_uiForm.pbPlotPreview, &QPushButton::clicked, this, &Quasi::plotCurrentPreview);
66+
connect(m_uiForm.pbSave, &QPushButton::clicked, this, &Quasi::saveClicked);
67+
connect(m_uiForm.pbPlot, &QPushButton::clicked, this, &Quasi::plotClicked);
7168

7269
// Allows empty workspace selector when initially selected
7370
m_uiForm.dsSample->isOptional(true);
@@ -351,8 +348,7 @@ void Quasi::handleRun() {
351348

352349
m_QuasiAlg = runAlg;
353350
m_batchAlgoRunner->addAlgorithm(runAlg);
354-
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmComplete(bool)));
355-
351+
connect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &Quasi::algorithmComplete);
356352
m_batchAlgoRunner->executeBatchAsync();
357353
}
358354

@@ -496,10 +492,9 @@ void Quasi::handleResolutionInputReady(const QString &wsName) {
496492
* @param min :: The new value of the lower guide
497493
*/
498494
void Quasi::minValueChanged(double min) {
499-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
500-
SLOT(updateProperties(QtProperty *, double)));
495+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
501496
m_dblManager->setValue(m_properties["EMin"], min);
502-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
497+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
503498
}
504499

505500
/**
@@ -508,10 +503,9 @@ void Quasi::minValueChanged(double min) {
508503
* @param max :: The new value of the upper guide
509504
*/
510505
void Quasi::maxValueChanged(double max) {
511-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
512-
SLOT(updateProperties(QtProperty *, double)));
506+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
513507
m_dblManager->setValue(m_properties["EMax"], max);
514-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
508+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
515509
}
516510

517511
/**
@@ -523,16 +517,15 @@ void Quasi::maxValueChanged(double max) {
523517
void Quasi::updateProperties(QtProperty *prop, double val) {
524518
auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("QuasiERange");
525519

526-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
527-
SLOT(updateProperties(QtProperty *, double)));
520+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
528521

529522
if (prop == m_properties["EMin"]) {
530523
setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
531524
} else if (prop == m_properties["EMax"]) {
532525
setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
533526
}
534527

535-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
528+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Quasi::updateProperties);
536529
}
537530

538531
/**

qt/scientific_interfaces/Inelastic/BayesFitting/ResNorm.cpp

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ ResNorm::ResNorm(QWidget *parent) : BayesFittingTab(parent), m_previewSpec(0) {
3131

3232
// Create range selector
3333
auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("ResNormERange");
34-
connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double)));
35-
connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double)));
36-
34+
connect(eRangeSelector, &MantidWidgets::RangeSelector::minValueChanged, this, &ResNorm::minValueChanged);
35+
connect(eRangeSelector, &MantidWidgets::RangeSelector::maxValueChanged, this, &ResNorm::maxValueChanged);
3736
// Add the properties browser to the ui form
3837
m_uiForm.treeSpace->addWidget(m_propTree);
3938

@@ -49,20 +48,17 @@ ResNorm::ResNorm(QWidget *parent) : BayesFittingTab(parent), m_previewSpec(0) {
4948
formatTreeWidget(m_propTree, m_properties);
5049

5150
// Connect data selector to handler method
52-
connect(m_uiForm.dsVanadium, SIGNAL(dataReady(const QString &)), this,
53-
SLOT(handleVanadiumInputReady(const QString &)));
54-
connect(m_uiForm.dsResolution, SIGNAL(dataReady(const QString &)), this,
55-
SLOT(handleResolutionInputReady(const QString &)));
51+
connect(m_uiForm.dsVanadium, &DataSelector::dataReady, this, &ResNorm::handleVanadiumInputReady);
52+
connect(m_uiForm.dsResolution, &DataSelector::dataReady, this, &ResNorm::handleResolutionInputReady);
5653

5754
// Connect the preview spectrum selector
58-
connect(m_uiForm.spPreviewSpectrum, SIGNAL(valueChanged(int)), this, SLOT(previewSpecChanged(int)));
59-
60-
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(handleAlgorithmComplete(bool)));
61-
55+
connect(m_uiForm.spPreviewSpectrum, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
56+
&ResNorm::previewSpecChanged);
57+
connect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &ResNorm::handleAlgorithmComplete);
6258
// Post Plot and Save
63-
connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked()));
64-
connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked()));
65-
connect(m_uiForm.pbPlotCurrent, SIGNAL(clicked()), this, SLOT(plotCurrentPreview()));
59+
connect(m_uiForm.pbSave, &QPushButton::clicked, this, &ResNorm::saveClicked);
60+
connect(m_uiForm.pbPlot, &QPushButton::clicked, this, &ResNorm::plotClicked);
61+
connect(m_uiForm.pbPlotCurrent, &QPushButton::clicked, this, &ResNorm::plotCurrentPreview);
6662

6763
// Allows empty workspace selector when initially selected
6864
m_uiForm.dsVanadium->isOptional(true);
@@ -308,10 +304,9 @@ void ResNorm::handleResolutionInputReady(const QString &filename) {
308304
* @param min :: The new value of the lower guide
309305
*/
310306
void ResNorm::minValueChanged(double min) {
311-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
312-
SLOT(updateProperties(QtProperty *, double)));
307+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
313308
m_dblManager->setValue(m_properties["EMin"], min);
314-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
309+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
315310
}
316311

317312
/**
@@ -320,10 +315,9 @@ void ResNorm::minValueChanged(double min) {
320315
* @param max :: The new value of the upper guide
321316
*/
322317
void ResNorm::maxValueChanged(double max) {
323-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
324-
SLOT(updateProperties(QtProperty *, double)));
318+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
325319
m_dblManager->setValue(m_properties["EMax"], max);
326-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
320+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
327321
}
328322

329323
/**
@@ -335,16 +329,14 @@ void ResNorm::maxValueChanged(double max) {
335329
void ResNorm::updateProperties(QtProperty *prop, double val) {
336330
auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("ResNormERange");
337331

338-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
339-
SLOT(updateProperties(QtProperty *, double)));
332+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
340333

341334
if (prop == m_properties["EMin"]) {
342335
setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
343336
} else if (prop == m_properties["EMax"]) {
344337
setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
345338
}
346-
347-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
339+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &ResNorm::updateProperties);
348340
}
349341

350342
/**

qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ Stretch::Stretch(QWidget *parent) : BayesFittingTab(parent), m_previewSpec(0), m
3535

3636
// Create range selector
3737
auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("StretchERange");
38-
connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double)));
39-
connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double)));
40-
38+
connect(eRangeSelector, &MantidWidgets::RangeSelector::minValueChanged, this, &Stretch::minValueChanged);
39+
connect(eRangeSelector, &MantidWidgets::RangeSelector::maxValueChanged, this, &Stretch::maxValueChanged);
4140
setupFitOptions();
4241
setupPropertyBrowser();
4342
setupPlotOptions();
4443

4544
// Connect the data selector for the sample to the mini plot
46-
connect(m_uiForm.dsSample, SIGNAL(dataReady(const QString &)), this, SLOT(handleSampleInputReady(const QString &)));
47-
connect(m_uiForm.chkSequentialFit, SIGNAL(toggled(bool)), m_uiForm.cbPlot, SLOT(setEnabled(bool)));
45+
connect(m_uiForm.dsSample, &DataSelector::dataReady, this, &Stretch::handleSampleInputReady);
46+
connect(m_uiForm.chkSequentialFit, &QCheckBox::toggled, m_uiForm.cbPlot, &QComboBox::setEnabled);
4847
// Connect preview spectrum spinner to handler
49-
connect(m_uiForm.spPreviewSpectrum, SIGNAL(valueChanged(int)), this, SLOT(previewSpecChanged(int)));
48+
connect(m_uiForm.spPreviewSpectrum, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
49+
&Stretch::previewSpecChanged);
5050
m_uiForm.spPreviewSpectrum->setMaximum(0);
5151

5252
// Connect the plot and save push buttons
53-
connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotWorkspaces()));
54-
connect(m_uiForm.pbPlotContour, SIGNAL(clicked()), this, SLOT(plotContourClicked()));
55-
connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveWorkspaces()));
56-
connect(m_uiForm.pbPlotPreview, SIGNAL(clicked()), this, SLOT(plotCurrentPreview()));
53+
connect(m_uiForm.pbPlot, &QPushButton::clicked, this, &Stretch::plotWorkspaces);
54+
connect(m_uiForm.pbPlotContour, &QPushButton::clicked, this, &Stretch::plotContourClicked);
55+
connect(m_uiForm.pbSave, &QPushButton::clicked, this, &Stretch::saveWorkspaces);
56+
connect(m_uiForm.pbPlotPreview, &QPushButton::clicked, this, &Stretch::plotCurrentPreview);
5757

5858
// Allows empty workspace selector when initially selected
5959
m_uiForm.dsSample->isOptional(true);
@@ -138,15 +138,15 @@ void Stretch::handleRun() {
138138
}
139139

140140
m_batchAlgoRunner->addAlgorithm(stretch);
141-
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmComplete(bool)));
141+
connect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &Stretch::algorithmComplete);
142142
m_batchAlgoRunner->executeBatchAsync();
143143
}
144144

145145
/**
146146
* Handles the saving and plotting of workspaces after execution
147147
*/
148148
void Stretch::algorithmComplete(const bool &error) {
149-
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmComplete(bool)));
149+
disconnect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &Stretch::algorithmComplete);
150150

151151
m_runPresenter->setRunEnabled(true);
152152
setPlotResultEnabled(!error);
@@ -413,10 +413,9 @@ void Stretch::plotCurrentPreview() {
413413
* @param min :: The new value of the lower guide
414414
*/
415415
void Stretch::minValueChanged(double min) {
416-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
417-
SLOT(updateProperties(QtProperty *, double)));
416+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
418417
m_dblManager->setValue(m_properties["EMin"], min);
419-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
418+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
420419
}
421420

422421
/**
@@ -425,10 +424,9 @@ void Stretch::minValueChanged(double min) {
425424
* @param max :: The new value of the upper guide
426425
*/
427426
void Stretch::maxValueChanged(double max) {
428-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
429-
SLOT(updateProperties(QtProperty *, double)));
427+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
430428
m_dblManager->setValue(m_properties["EMax"], max);
431-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
429+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
432430
}
433431

434432
/**
@@ -440,16 +438,15 @@ void Stretch::maxValueChanged(double max) {
440438
void Stretch::updateProperties(QtProperty *prop, double val) {
441439
auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("StretchERange");
442440

443-
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
444-
SLOT(updateProperties(QtProperty *, double)));
441+
disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
445442

446443
if (prop == m_properties["EMin"]) {
447444
setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
448445
} else if (prop == m_properties["EMax"]) {
449446
setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val);
450447
}
451448

452-
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
449+
connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties);
453450
}
454451

455452
void Stretch::setPlotResultEnabled(bool enabled) {

0 commit comments

Comments
 (0)