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 +
8
9namespace MantidQt {
10namespace API {
11
12//----------------------------------------------------------------------------------------------
19SyncedCheckboxes::SyncedCheckboxes(QAction *menu, QAbstractButton *button, bool checked)
20 : m_menu(menu), m_button(button) {
21 m_menu->setCheckable(true);
22 m_button->setCheckable(true);
23 m_menu->setChecked(checked);
24 m_button->setChecked(checked);
25 // Now connect each signal to this object
26 connect(m_menu, SIGNAL(toggled(bool)), this, SLOT(on_menu_toggled(bool)));
27 connect(m_button, SIGNAL(toggled(bool)), this, SLOT(on_button_toggled(bool)));
28}
29
30//----------------------------------------------------------------------------------------------
34//----------------------------------------------------------------------------------------------
40 // Set both GUI elements
41 m_button->blockSignals(true);
42 m_button->setChecked(val);
43 m_button->blockSignals(false);
44 m_menu->blockSignals(true);
45 m_menu->setChecked(val);
46 m_menu->blockSignals(false);
47 // Re-transmit the signal
48 emit toggled(val);
49}
50
51//----------------------------------------------------------------------------------------------
57 m_menu->setEnabled(val);
58 m_button->setEnabled(val);
59}
60
61//----------------------------------------------------------------------------------------------
67 m_menu->setVisible(val);
68 m_button->setVisible(val);
69}
70
71//----------------------------------------------------------------------------------------------
74 // Adjust the state of the other
75 m_button->blockSignals(true);
76 m_button->setChecked(val);
77 m_button->blockSignals(false);
78 // Re-transmit the signal
79 emit toggled(val);
80}
81
82//----------------------------------------------------------------------------------------------
85 // Adjust the state of the other
86 m_menu->blockSignals(true);
87 m_menu->setChecked(val);
88 m_menu->blockSignals(false);
89 // Re-transmit the signal
90 emit toggled(val);
91}
92
93} // namespace API
94} // 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...