Mantid
Loading...
Searching...
No Matches
SyncedCheckboxes.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9
10namespace MantidQt {
11namespace API {
12
13//----------------------------------------------------------------------------------------------
20SyncedCheckboxes::SyncedCheckboxes(QAction *menu, QAbstractButton *button, bool checked)
21 : m_menu(menu), m_button(button) {
22 m_menu->setCheckable(true);
23 m_button->setCheckable(true);
24 m_menu->setChecked(checked);
25 m_button->setChecked(checked);
26 // Now connect each signal to this object
27 connect(m_menu, SIGNAL(toggled(bool)), this, SLOT(on_menu_toggled(bool)));
28 connect(m_button, SIGNAL(toggled(bool)), this, SLOT(on_button_toggled(bool)));
29}
30
31//----------------------------------------------------------------------------------------------
35//----------------------------------------------------------------------------------------------
41 // Set both GUI elements
42 m_button->blockSignals(true);
43 m_button->setChecked(val);
44 m_button->blockSignals(false);
45 m_menu->blockSignals(true);
46 m_menu->setChecked(val);
47 m_menu->blockSignals(false);
48 // Re-transmit the signal
49 emit toggled(val);
50}
51
52//----------------------------------------------------------------------------------------------
58 m_menu->setEnabled(val);
59 m_button->setEnabled(val);
60}
61
62//----------------------------------------------------------------------------------------------
68 m_menu->setVisible(val);
69 m_button->setVisible(val);
70}
71
72//----------------------------------------------------------------------------------------------
75 // Adjust the state of the other
76 m_button->blockSignals(true);
77 m_button->setChecked(val);
78 m_button->blockSignals(false);
79 // Re-transmit the signal
80 emit toggled(val);
81}
82
83//----------------------------------------------------------------------------------------------
86 // Adjust the state of the other
87 m_menu->blockSignals(true);
88 m_menu->setChecked(val);
89 m_menu->blockSignals(false);
90 // Re-transmit the signal
91 emit toggled(val);
92}
93
94} // namespace API
95} // namespace MantidQt
void on_button_toggled(bool)
Slot called when the button is toggled.
void toggled(bool)
Signal emitted when the check box is toggled.
void toggle(bool val)
Destructor.
void setVisible(bool val)
Set the visibility of both the menu and the checkboxes.
SyncedCheckboxes(QAction *menu, QAbstractButton *button, bool checked=false)
Constructor that links a menu and a button.
void on_menu_toggled(bool)
Slot called when the menu is toggled.
void setEnabled(bool val)
Enable or disable both the menu and the checkboxes.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...