MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / getOrCreatePage

Method getOrCreatePage

Gui/KnobGuiContainerHelper.cpp:216–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216KnobPageGuiPtr
217KnobGuiContainerHelper::getOrCreatePage(const KnobPagePtr& page)
218{
219
220 if (!page || page->getIsToolBar()) {
221 return KnobPageGuiPtr();
222 }
223 if ( !isPagingEnabled() && (_imp->pages.size() > 0) ) {
224 return _imp->pages.begin()->second;
225 }
226
227 // If the page is already created, return it
228 assert(page);
229 PagesMap::iterator found = _imp->pages.find(page);
230 if ( found != _imp->pages.end() ) {
231 return found->second;
232 }
233
234
235 QWidget* newTab;
236 QWidget* layoutContainer;
237
238 // The widget parent of the page
239 QWidget* pagesContainer = getPagesContainer();
240 assert(pagesContainer);
241
242 // Check If the page main widget should be a scrollarea
243 if ( useScrollAreaForTabs() ) {
244 QScrollArea* sa = new QScrollArea(pagesContainer);
245 layoutContainer = new QWidget(sa);
246 layoutContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
247 sa->setWidgetResizable(true);
248 sa->setWidget(layoutContainer);
249 newTab = sa;
250 } else {
251 // Otherwise let the derived class create the main widget
252 newTab = createPageMainWidget(pagesContainer);
253 layoutContainer = newTab;
254 }
255
256 // The container layout is always a grid layout
257 QGridLayout *tabLayout = new QGridLayout(layoutContainer);
258 tabLayout->setObjectName( QString::fromUtf8("formLayout") );
259 layoutContainer->setLayout(tabLayout);
260 tabLayout->setColumnStretch(1, 1);
261 tabLayout->setSpacing( TO_DPIY(NATRON_FORM_LAYOUT_LINES_SPACING) );
262
263 // Create the page gui
264 KnobPageGuiPtr pageGui = std::make_shared<KnobPageGui>();
265 pageGui->currentRow = 0;
266 pageGui->tab = newTab;
267 pageGui->pageKnob = page;
268 pageGui->groupAsTab = 0;
269 pageGui->gridLayout = tabLayout;
270
271 KnobSignalSlotHandlerPtr handler = page->getSignalSlotHandler();
272 QObject::connect( handler.get(), SIGNAL(labelChanged()), _imp->signals.get(), SLOT(onPageLabelChangedInternally()) );
273 QObject::connect( handler.get(), SIGNAL(secretChanged()), _imp->signals.get(), SLOT(onPageSecretnessChanged()) );

Callers

nothing calls this directly

Calls 10

getIsToolBarMethod · 0.80
setWidgetMethod · 0.80
getHintToolTipMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getMethod · 0.45
setToolTipMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected