| 731 | } |
| 732 | |
| 733 | void |
| 734 | PreferencesPanel::createGui() |
| 735 | { |
| 736 | //setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 737 | |
| 738 | setWindowFlags(Qt::Window); |
| 739 | setWindowTitle( tr("Preferences") ); |
| 740 | _imp->mainLayout = new QVBoxLayout(this); |
| 741 | |
| 742 | _imp->splitter = new Splitter(Qt::Horizontal, this); |
| 743 | |
| 744 | _imp->tree = new QTreeWidget(_imp->splitter); |
| 745 | _imp->tree->setSelectionMode(QAbstractItemView::SingleSelection); |
| 746 | _imp->tree->setColumnCount(1); |
| 747 | _imp->tree->setAttribute(Qt::WA_MacShowFocusRect, 0); |
| 748 | _imp->tree->header()->close(); |
| 749 | QObject::connect( _imp->tree, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChanged()) ); |
| 750 | |
| 751 | initializeKnobs(); |
| 752 | |
| 753 | _imp->splitter->addWidget(_imp->tree); |
| 754 | |
| 755 | |
| 756 | int maxLength = 0; |
| 757 | QFontMetrics fm = fontMetrics(); |
| 758 | QGridLayout* pluginsFrameLayout = 0; |
| 759 | QTreeWidgetItem* uiTabTreeItem = 0; |
| 760 | for (std::size_t i = 0; i < _imp->tabs.size(); ++i) { |
| 761 | KnobPagePtr pageKnob = _imp->tabs[i].page.lock()->pageKnob.lock(); |
| 762 | if (pageKnob->getName() == "plugins") { |
| 763 | pluginsFrameLayout = _imp->tabs[i].page.lock()->gridLayout; |
| 764 | } else if (pageKnob->getName() == "userInterfacePage") { |
| 765 | uiTabTreeItem = _imp->tabs[i].treeItem; |
| 766 | } |
| 767 | QString label = QString::fromUtf8( pageKnob->getLabel().c_str() ); |
| 768 | #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) |
| 769 | int w = fm.horizontalAdvance(label); |
| 770 | #else |
| 771 | int w = fm.width(label); |
| 772 | #endif |
| 773 | maxLength = std::max(w, maxLength); |
| 774 | } |
| 775 | assert(pluginsFrameLayout); |
| 776 | assert(uiTabTreeItem); |
| 777 | _imp->tree->setFixedWidth(maxLength + 100); |
| 778 | |
| 779 | _imp->buttonBox = new DialogButtonBox(Qt::Horizontal); |
| 780 | _imp->restoreDefaultsB = new Button( tr("Restore Defaults") ); |
| 781 | _imp->restoreDefaultsB->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Restore default values for all preferences."), NATRON_NAMESPACE::WhiteSpaceNormal) ); |
| 782 | |
| 783 | _imp->prefsHelp = new Button( tr("Help") ); |
| 784 | _imp->prefsHelp->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Display help for preferences in an external browser."), NATRON_NAMESPACE::WhiteSpaceNormal) ); |
| 785 | |
| 786 | _imp->cancelB = new Button( tr("Discard") ); |
| 787 | _imp->cancelB->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Cancel changes that were not saved and close the window."), NATRON_NAMESPACE::WhiteSpaceNormal) ); |
| 788 | _imp->okB = new Button( tr("Save") ); |
| 789 | _imp->okB->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Save changes on disk and close the window."), NATRON_NAMESPACE::WhiteSpaceNormal) ); |
| 790 | _imp->buttonBox->addButton(_imp->restoreDefaultsB, QDialogButtonBox::ResetRole); |
nothing calls this directly
no test coverage detected