1 /**
2 * UGENE - Integrated Bioinformatics Tools.
3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4 * http://ugene.net
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 #include "TreeOptionsWidget.h"
23
24 #include <QColorDialog>
25 #include <QLineEdit>
26 #include <QMainWindow>
27 #include <QProxyStyle>
28 #include <QStyleFactory>
29 #include <QTextEdit>
30
31 #include <U2Algorithm/MSADistanceAlgorithmRegistry.h>
32
33 #include <U2Core/AppContext.h>
34 #include <U2Core/MultipleSequenceAlignmentObject.h>
35 #include <U2Core/Theme.h>
36 #include <U2Core/U2SafePoints.h>
37
38 #include <U2Gui/ShowHideSubgroupWidget.h>
39 #include <U2Gui/U2WidgetStateStorage.h>
40
41 #include <U2View/MSAEditor.h>
42
43 #include "ov_msa/phy_tree/MSAEditorMultiTreeViewer.h"
44 #include "ov_msa/phy_tree/MSAEditorTreeViewer.h"
45 #include "ov_msa/phy_tree/MsaEditorTreeTabArea.h"
46 #include "ov_phyltree/TreeViewer.h"
47 #include "phyltree/TreeSettingsDialog.h"
48
49 namespace U2 {
50
51 const static QString SHOW_FONT_OPTIONS_LINK("show_font_options_link");
52 const static QString SHOW_PEN_OPTIONS_LINK("show_pen_options_link");
53
initLayout(QWidget * w)54 static inline QVBoxLayout *initLayout(QWidget *w) {
55 QVBoxLayout *layout = new QVBoxLayout;
56 layout->setContentsMargins(0, 0, 0, 0);
57 layout->setSpacing(5);
58
59 w->setLayout(layout);
60 return layout;
61 }
62
TreeOptionsWidget(MSAEditor * msaEditor,const TreeOpWidgetViewSettings & viewSettings)63 TreeOptionsWidget::TreeOptionsWidget(MSAEditor *msaEditor, const TreeOpWidgetViewSettings &viewSettings)
64 : editor(msaEditor), treeViewer(nullptr), viewSettings(viewSettings), showFontSettings(false), showPenSettings(false),
65 savableTab(this, GObjectViewUtils::findViewByName(msaEditor->getName())), isUpdating(false) {
66 SAFE_POINT(nullptr != editor, QString("Invalid parameter were passed into constructor TreeOptionsWidget"), );
67
68 contentWidget = new QWidget();
69 setupUi(contentWidget);
70
71 initColorButtonsStyle();
72 createGroups();
73 savableTab.disableSavingForWidgets(getSaveDisabledWidgets());
74 U2WidgetStateStorage::restoreWidgetState(savableTab);
75 sl_selectionChanged();
76 }
77
TreeOptionsWidget(TreeViewer * tree,const TreeOpWidgetViewSettings & viewSettings)78 TreeOptionsWidget::TreeOptionsWidget(TreeViewer *tree, const TreeOpWidgetViewSettings &viewSettings)
79 : editor(nullptr), treeViewer(tree->getTreeViewerUI()), viewSettings(viewSettings), showFontSettings(false), showPenSettings(false),
80 savableTab(this, GObjectViewUtils::findViewByName(tree->getName())), isUpdating(false) {
81 SAFE_POINT(nullptr != treeViewer, QString("Invalid parameter were passed into constructor TreeOptionsWidget"), );
82
83 contentWidget = new QWidget();
84 setupUi(contentWidget);
85
86 initColorButtonsStyle();
87 createGroups();
88 savableTab.disableSavingForWidgets(getSaveDisabledWidgets());
89 U2WidgetStateStorage::restoreWidgetState(savableTab);
90 sl_selectionChanged();
91 }
92
~TreeOptionsWidget()93 TreeOptionsWidget::~TreeOptionsWidget() {
94 emit saveViewSettings(getViewSettings());
95 delete contentWidget;
96 }
97
initColorButtonsStyle()98 void TreeOptionsWidget::initColorButtonsStyle() {
99 QStyle *buttonStyle = new QProxyStyle(QStyleFactory::create("fusion"));
100 buttonStyle->setParent(this);
101 labelsColorButton->setStyle(buttonStyle);
102 branchesColorButton->setStyle(buttonStyle);
103 }
104
getViewSettings()105 const TreeOpWidgetViewSettings &TreeOptionsWidget::getViewSettings() {
106 viewSettings.showFontSettings = showFontSettings;
107 viewSettings.showPenSettings = showPenSettings;
108 return viewSettings;
109 }
110
createGroups()111 void TreeOptionsWidget::createGroups() {
112 QVBoxLayout *mainLayout = initLayout(this);
113 mainLayout->setSpacing(0);
114
115 auto generalOpGroup = new ShowHideSubgroupWidget("TREE_GENERAL_OP", tr("General"), treeLayoutWidget, true);
116 mainLayout->addWidget(generalOpGroup);
117
118 auto labelsOpGroup = new ShowHideSubgroupWidget("TREE_LABELS_OP", tr("Labels"), labelsGroup, true);
119 mainLayout->addWidget(labelsOpGroup);
120
121 auto scalebarOpGroup = new ShowHideSubgroupWidget("SCALEBAR_OP", tr("Scale Bar"), scalebarGroup, true);
122 mainLayout->addWidget(scalebarOpGroup);
123
124 auto branchesOpGroup = new ShowHideSubgroupWidget("TREE_BRANCHES_OP", tr("Branches"), branchesGroup, true);
125 mainLayout->addWidget(branchesOpGroup);
126
127 initializeOptionsMap();
128 updateAllWidgets();
129 connectSlots();
130 }
131
updateAllWidgets()132 void TreeOptionsWidget::updateAllWidgets() {
133 showFontSettings = viewSettings.showFontSettings;
134 showPenSettings = viewSettings.showPenSettings;
135 createGeneralSettingsWidgets();
136
137 QString fontLabel = showFontSettings ? tr("Hide font settings") : tr("Show font settings");
138 updateShowFontOpLabel(fontLabel);
139 QString penLabel = showPenSettings ? tr("Hide pen settings") : tr("Show pen settings");
140 updateShowPenOpLabel(penLabel);
141 fontSettingsWidget->setVisible(viewSettings.showFontSettings);
142 penGroup->setVisible(viewSettings.showPenSettings);
143
144 QMap<TreeViewOption, QVariant> settings = getTreeViewer()->getSettings();
145 const QList<TreeViewOption> keyList = settings.keys();
146 for (const TreeViewOption &option : qAsConst(keyList)) {
147 sl_onOptionChanged(option, settings[option]);
148 }
149 if (!settings[SHOW_NODE_LABELS].toBool()) {
150 showNodeLabelsCheck->setEnabled(false);
151 }
152 }
153
sl_onOptionChanged(TreeViewOption option,const QVariant & value)154 void TreeOptionsWidget::sl_onOptionChanged(TreeViewOption option, const QVariant &value) {
155 if (option == SHOW_LABELS) {
156 alignLabelsCheck->setEnabled(value.toBool());
157 }
158 if (option == LABEL_COLOR || option == LABEL_FONT_TYPE || option == LABEL_FONT_SIZE ||
159 option == LABEL_FONT_BOLD || option == LABEL_FONT_ITALIC || option == LABEL_FONT_UNDERLINE) {
160 updateFormatSettings();
161 return;
162 }
163 if (option == BRANCH_COLOR) {
164 updateButtonColor(branchesColorButton, qvariant_cast<QColor>(value));
165 return;
166 }
167 updateRelations(option, value);
168
169 QString objectName = optionsMap.key(option);
170 if (objectName.isEmpty()) {
171 return;
172 }
173 isUpdating = true;
174 savableTab.setChildValue(objectName, value);
175 isUpdating = false;
176 }
177
sl_selectionChanged()178 void TreeOptionsWidget::sl_selectionChanged() {
179 const QSignalBlocker fontSizeBlocker(fontSizeSpinBox);
180 const QSignalBlocker fontComboBlocker(fontComboBox);
181
182 fontComboBox->setCurrentFont(qvariant_cast<QFont>(getTreeViewer()->getOptionValue(LABEL_FONT_TYPE)));
183 fontSizeSpinBox->setValue(getTreeViewer()->getOptionValue(LABEL_FONT_SIZE).toInt());
184 boldAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_BOLD).toBool());
185 italicAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_ITALIC).toBool());
186 underlineAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_UNDERLINE).toBool());
187 updateButtonColor(labelsColorButton, qvariant_cast<QColor>(getTreeViewer()->getOptionValue(LABEL_COLOR)));
188 }
189
getSaveDisabledWidgets() const190 QStringList TreeOptionsWidget::getSaveDisabledWidgets() const {
191 return QStringList()
192 << fontComboBox->objectName()
193 << fontSizeSpinBox->objectName()
194 << boldAttrButton->objectName()
195 << italicAttrButton->objectName()
196 << underlineAttrButton->objectName()
197 << labelsColorButton->objectName();
198 }
199
initializeOptionsMap()200 void TreeOptionsWidget::initializeOptionsMap() {
201 // Scalebar settings widgets
202 optionsMap[scaleSpinBox->objectName()] = SCALEBAR_RANGE;
203 optionsMap[scaleFontSizeSpinBox->objectName()] = SCALEBAR_FONT_SIZE;
204 optionsMap[lineWidthSpinBox->objectName()] = SCALEBAR_LINE_WIDTH;
205
206 optionsMap[showNamesCheck->objectName()] = SHOW_LABELS;
207 optionsMap[showDistancesCheck->objectName()] = SHOW_DISTANCES;
208 optionsMap[alignLabelsCheck->objectName()] = ALIGN_LABELS;
209 optionsMap[showNodeLabelsCheck->objectName()] = SHOW_NODE_LABELS;
210
211 optionsMap[lineWeightSpinBox->objectName()] = BRANCH_THICKNESS;
212
213 optionsMap[heightSlider->objectName()] = HEIGHT_COEF;
214 optionsMap[widthSlider->objectName()] = WIDTH_COEF;
215
216 optionsMap[treeViewCombo->objectName()] = BRANCHES_TRANSFORMATION_TYPE;
217 optionsMap[layoutCombo->objectName()] = TREE_LAYOUT;
218 }
219
connectSlots()220 void TreeOptionsWidget::connectSlots() {
221 // Show more options labels
222 connect(lblPenSettings, SIGNAL(linkActivated(const QString &)), SLOT(sl_onLblLinkActivated(const QString &)));
223 connect(lblFontSettings, SIGNAL(linkActivated(const QString &)), SLOT(sl_onLblLinkActivated(const QString &)));
224
225 // General settings widgets
226 connect(treeViewCombo, SIGNAL(currentIndexChanged(int)), SLOT(sl_valueChanged()));
227 connect(layoutCombo, SIGNAL(currentIndexChanged(int)), SLOT(sl_valueChanged()));
228
229 connect(getTreeViewer(), SIGNAL(si_optionChanged(TreeViewOption, const QVariant &)), SLOT(sl_onOptionChanged(TreeViewOption, const QVariant &)));
230
231 // Labels settings widgets
232 connect(showNamesCheck, SIGNAL(stateChanged(int)), SLOT(sl_valueChanged()));
233 connect(showDistancesCheck, SIGNAL(stateChanged(int)), SLOT(sl_valueChanged()));
234 connect(alignLabelsCheck, SIGNAL(stateChanged(int)), SLOT(sl_valueChanged()));
235 connect(showNodeLabelsCheck, SIGNAL(stateChanged(int)), SLOT(sl_valueChanged()));
236
237 // Labels format widgets
238 connect(labelsColorButton, SIGNAL(clicked()), SLOT(sl_labelsColorButton()));
239 connect(boldAttrButton, SIGNAL(clicked(bool)), SLOT(sl_fontBoldChanged()));
240 connect(italicAttrButton, SIGNAL(clicked(bool)), SLOT(sl_fontItalicChanged()));
241 connect(underlineAttrButton, SIGNAL(clicked(bool)), SLOT(sl_fontUnderlineChanged()));
242 connect(fontSizeSpinBox, SIGNAL(valueChanged(int)), SLOT(sl_fontSizeChanged()));
243 connect(fontComboBox, SIGNAL(currentFontChanged(const QFont &)), SLOT(sl_fontTypeChanged()));
244
245 // Scalebar settings widgets
246 connect(scaleSpinBox, SIGNAL(valueChanged(double)), SLOT(sl_valueChanged()));
247 connect(scaleFontSizeSpinBox, SIGNAL(valueChanged(int)), SLOT(sl_valueChanged()));
248 connect(lineWidthSpinBox, SIGNAL(valueChanged(int)), SLOT(sl_valueChanged()));
249
250 // Branches settings widgets
251 connect(widthSlider, SIGNAL(valueChanged(int)), SLOT(sl_valueChanged()));
252 connect(heightSlider, SIGNAL(valueChanged(int)), SLOT(sl_valueChanged()));
253
254 connect(branchesColorButton, SIGNAL(clicked()), SLOT(sl_branchesColorButton()));
255 connect(lineWeightSpinBox, SIGNAL(valueChanged(int)), SLOT(sl_valueChanged()));
256
257 connect(getTreeViewer(), SIGNAL(si_updateBranch()), SLOT(sl_selectionChanged()));
258 }
259
sl_valueChanged()260 void TreeOptionsWidget::sl_valueChanged() {
261 QWidget *inputWidget = qobject_cast<QWidget *>(sender());
262 SAFE_POINT(inputWidget != nullptr, "Null sender in slot", );
263
264 QVariant newValue = savableTab.getChildValue(inputWidget->objectName());
265 TreeViewOption option = optionsMap[inputWidget->objectName()];
266 if (option == SHOW_LABELS) {
267 alignLabelsCheck->setEnabled(newValue.toBool());
268 }
269 updateRelations(option, newValue);
270
271 CHECK(!isUpdating, );
272 getTreeViewer()->changeOption(option, newValue);
273 }
274
createGeneralSettingsWidgets()275 void TreeOptionsWidget::createGeneralSettingsWidgets() {
276 layoutCombo->addItems(QStringList()
277 << tr("Rectangular")
278 << tr("Circular")
279 << tr("Unrooted"));
280
281 treeViewCombo->addItem(TreeSettingsDialog::getDefaultTreeModeText());
282 treeViewCombo->addItem(TreeSettingsDialog::getPhylogramTreeModeText());
283 treeViewCombo->addItem(TreeSettingsDialog::getCladogramTreeModeText());
284 }
285
updateFormatSettings()286 void TreeOptionsWidget::updateFormatSettings() {
287 // Update labels format settings widgets
288 QColor curColor = qvariant_cast<QColor>(getTreeViewer()->getOptionValue(LABEL_COLOR));
289 updateButtonColor(labelsColorButton, curColor);
290
291 QFont curFont = qvariant_cast<QFont>(getTreeViewer()->getOptionValue(LABEL_FONT_TYPE));
292 fontComboBox->setCurrentFont(curFont);
293
294 fontSizeSpinBox->setValue(getTreeViewer()->getOptionValue(LABEL_FONT_SIZE).toInt());
295 boldAttrButton->setCheckable(true);
296 italicAttrButton->setCheckable(true);
297 underlineAttrButton->setCheckable(true);
298
299 boldAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_BOLD).toBool());
300 italicAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_ITALIC).toBool());
301 underlineAttrButton->setChecked(getTreeViewer()->getOptionValue(LABEL_FONT_UNDERLINE).toBool());
302 }
303
getTreeViewer() const304 TreeViewerUI *TreeOptionsWidget::getTreeViewer() const {
305 SAFE_POINT(editor != nullptr || treeViewer != nullptr, QString("Invalid parameter in constructor TreeOptionsWidget"), nullptr);
306 return treeViewer != nullptr ? treeViewer : editor->getUI()->getCurrentTree()->getTreeViewerUI();
307 }
308
sl_fontTypeChanged()309 void TreeOptionsWidget::sl_fontTypeChanged() {
310 getTreeViewer()->changeOption(LABEL_FONT_TYPE, fontComboBox->currentFont());
311 }
312
sl_fontSizeChanged()313 void TreeOptionsWidget::sl_fontSizeChanged() {
314 getTreeViewer()->changeOption(LABEL_FONT_SIZE, fontSizeSpinBox->value());
315 }
316
sl_fontBoldChanged()317 void TreeOptionsWidget::sl_fontBoldChanged() {
318 getTreeViewer()->changeOption(LABEL_FONT_BOLD, boldAttrButton->isChecked());
319 }
320
sl_fontItalicChanged()321 void TreeOptionsWidget::sl_fontItalicChanged() {
322 getTreeViewer()->changeOption(LABEL_FONT_ITALIC, italicAttrButton->isChecked());
323 }
324
sl_fontUnderlineChanged()325 void TreeOptionsWidget::sl_fontUnderlineChanged() {
326 getTreeViewer()->changeOption(LABEL_FONT_UNDERLINE, underlineAttrButton->isChecked());
327 }
328
sl_labelsColorButton()329 void TreeOptionsWidget::sl_labelsColorButton() {
330 QColor curColor = qvariant_cast<QColor>(getTreeViewer()->getOptionValue(LABEL_COLOR));
331 QColor newColor = QColorDialog::getColor(curColor, AppContext::getMainWindow()->getQMainWindow());
332 if (newColor.isValid()) {
333 updateButtonColor(labelsColorButton, newColor);
334 getTreeViewer()->changeOption(LABEL_COLOR, newColor);
335 }
336 }
337
sl_branchesColorButton()338 void TreeOptionsWidget::sl_branchesColorButton() {
339 QColor curColor = qvariant_cast<QColor>(getTreeViewer()->getOptionValue(BRANCH_COLOR));
340 QColor newColor = QColorDialog::getColor(curColor, AppContext::getMainWindow()->getQMainWindow());
341 if (newColor.isValid()) {
342 updateButtonColor(branchesColorButton, newColor);
343 getTreeViewer()->changeOption(BRANCH_COLOR, newColor);
344 }
345 }
346
sl_onLblLinkActivated(const QString & link)347 void TreeOptionsWidget::sl_onLblLinkActivated(const QString &link) {
348 if (link == SHOW_FONT_OPTIONS_LINK) {
349 showFontSettings = !showFontSettings;
350 QString labelText = showFontSettings ? tr("Hide font settings") : tr("Show font settings");
351 updateShowFontOpLabel(labelText);
352 fontSettingsWidget->setVisible(showFontSettings);
353 } else if (link == SHOW_PEN_OPTIONS_LINK) {
354 showPenSettings = !showPenSettings;
355 QString labelText = showPenSettings ? tr("Hide pen settings") : tr("Show pen settings");
356 updateShowPenOpLabel(labelText);
357 penGroup->setVisible(showPenSettings);
358 }
359 }
360
updateButtonColor(QPushButton * button,const QColor & newColor)361 void TreeOptionsWidget::updateButtonColor(QPushButton *button, const QColor &newColor) {
362 QPalette palette = button->palette();
363 palette.setColor(button->backgroundRole(), newColor);
364 button->setPalette(palette);
365 }
366
updateShowFontOpLabel(QString newText)367 void TreeOptionsWidget::updateShowFontOpLabel(QString newText) {
368 newText = QString("<a href=\"%1\" style=\"color: %2\">")
369 .arg(SHOW_FONT_OPTIONS_LINK)
370 .arg(Theme::linkColorLabelStr()) +
371 newText + QString("</a>");
372
373 lblFontSettings->setText(newText);
374 lblFontSettings->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
375 }
376
updateShowPenOpLabel(QString newText)377 void TreeOptionsWidget::updateShowPenOpLabel(QString newText) {
378 newText = QString("<a href=\"%1\" style=\"color: %2\">").arg(SHOW_PEN_OPTIONS_LINK).arg(Theme::linkColorLabelStr()) + newText + QString("</a>");
379
380 lblPenSettings->setText(newText);
381 lblPenSettings->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
382 }
383
updateRelations(TreeViewOption option,QVariant newValue)384 void TreeOptionsWidget::updateRelations(TreeViewOption option, QVariant newValue) {
385 if (option == BRANCHES_TRANSFORMATION_TYPE) {
386 TREE_TYPE type = static_cast<TREE_TYPE>(newValue.toUInt());
387 scalebarGroup->setEnabled(type == PHYLOGRAM);
388 } else if (option == TREE_LAYOUT) {
389 TreeLayout layout = static_cast<TreeLayout>(newValue.toUInt());
390 heightSlider->setEnabled(layout == RECTANGULAR_LAYOUT);
391 lblHeightSlider->setEnabled(layout == RECTANGULAR_LAYOUT);
392 }
393 }
394
AddTreeWidget(MSAEditor * msaEditor)395 AddTreeWidget::AddTreeWidget(MSAEditor *msaEditor)
396 : editor(msaEditor), openTreeButton(nullptr), buildTreeButton(nullptr), addTreeHint(nullptr) {
397 setObjectName("AddTreeWidget");
398 QVBoxLayout *mainLayout = initLayout(this);
399 mainLayout->setSpacing(0);
400
401 addTreeHint = new QLabel(tr("There are no displayed trees so settings are hidden."), this);
402 addTreeHint->setWordWrap(true);
403
404 mainLayout->addWidget(addTreeHint);
405
406 auto buttonLayout = new QHBoxLayout();
407 buttonLayout->setContentsMargins(0, 5, 0, 0);
408
409 openTreeButton = new QPushButton(QIcon(":ugene/images/advanced_open.png"), tr("Open tree"), this);
410 openTreeButton->setFixedWidth(102);
411 openTreeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
412 buttonLayout->addWidget(openTreeButton);
413 openTreeButton->setObjectName("OpenTreeButton");
414
415 auto horizontalSpacer = new QSpacerItem(50, 20, QSizePolicy::Maximum, QSizePolicy::Minimum);
416 buttonLayout->addSpacerItem(horizontalSpacer);
417
418 buildTreeButton = new QPushButton(QIcon(":core/images/phylip.png"), tr("Build tree"), this);
419 buildTreeButton->setFixedWidth(102);
420 buttonLayout->addWidget(buildTreeButton);
421 buildTreeButton->setObjectName("BuildTreeButton");
422
423 MultipleSequenceAlignmentObject *maObj = editor->getMaObject();
424 buildTreeButton->setDisabled(editor->getNumSequences() < 2 || maObj->isStateLocked());
425
426 mainLayout->addLayout(buttonLayout);
427
428 connect(openTreeButton, SIGNAL(clicked()), SLOT(sl_onOpenTreeTriggered()));
429 connect(buildTreeButton, SIGNAL(clicked()), SLOT(sl_onBuildTreeTriggered()));
430 connect(maObj, SIGNAL(si_lockedStateChanged()), SLOT(sl_updateBuildTreeButtonState()));
431 connect(maObj, SIGNAL(si_alignmentChanged(const MultipleAlignment &, const MaModificationInfo &)), SLOT(sl_updateBuildTreeButtonState()));
432 }
433
sl_onOpenTreeTriggered()434 void AddTreeWidget::sl_onOpenTreeTriggered() {
435 editor->getTreeManager()->openTreeFromFile();
436 }
437
sl_onBuildTreeTriggered()438 void AddTreeWidget::sl_onBuildTreeTriggered() {
439 editor->getTreeManager()->buildTreeWithDialog();
440 }
441
sl_updateBuildTreeButtonState()442 void AddTreeWidget::sl_updateBuildTreeButtonState() {
443 buildTreeButton->setDisabled(editor->getNumSequences() < 2 || editor->getMaObject()->isStateLocked());
444 }
445
TreeOptionsSavableWidget(QWidget * wrappedWidget,MWMDIWindow * contextWindow)446 TreeOptionsSavableWidget::TreeOptionsSavableWidget(QWidget *wrappedWidget, MWMDIWindow *contextWindow /*= nullptr*/)
447 : U2SavableWidget(wrappedWidget, contextWindow) {
448 }
449
~TreeOptionsSavableWidget()450 TreeOptionsSavableWidget::~TreeOptionsSavableWidget() {
451 U2WidgetStateStorage::saveWidgetState(*this);
452 widgetStateSaved = true;
453 }
454
disableSavingForWidgets(const QStringList & s)455 void TreeOptionsSavableWidget::disableSavingForWidgets(const QStringList &s) {
456 widgetsNotToSave.append(s);
457 }
458
childCanBeSaved(QWidget * child) const459 bool TreeOptionsSavableWidget::childCanBeSaved(QWidget *child) const {
460 if (widgetsNotToSave.contains(child->objectName())) {
461 return false;
462 } else {
463 return U2SavableWidget::childCanBeSaved(child);
464 }
465 }
466
467 } // namespace U2
468