| 372 | }; |
| 373 | |
| 374 | PyPanel::PyPanel(const QString& scriptName, |
| 375 | const QString& label, |
| 376 | bool useUserParameters, |
| 377 | GuiApp* app) |
| 378 | : QWidget( app->getGui() ) |
| 379 | , UserParamHolder() |
| 380 | , PanelWidget( this, app->getGui() ) |
| 381 | , _imp( new PyPanelPrivate() ) |
| 382 | { |
| 383 | setLabel( label.toStdString() ); |
| 384 | |
| 385 | |
| 386 | int idx = 1; |
| 387 | std::string name = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( scriptName.toStdString() ); |
| 388 | PanelWidget* existing = 0; |
| 389 | existing = getGui()->findExistingTab(name); |
| 390 | while (existing) { |
| 391 | std::stringstream ss; |
| 392 | ss << name << idx; |
| 393 | existing = getGui()->findExistingTab( ss.str() ); |
| 394 | if (!existing) { |
| 395 | name = ss.str(); |
| 396 | } |
| 397 | ++idx; |
| 398 | } |
| 399 | |
| 400 | setScriptName(name); |
| 401 | getGui()->registerTab(this, this); |
| 402 | |
| 403 | |
| 404 | if (useUserParameters) { |
| 405 | _imp->holder = new DialogParamHolder( QString::fromUtf8( name.c_str() ), getGui()->getApp(), this ); |
| 406 | setHolder(_imp->holder); |
| 407 | _imp->holder->initializeKnobsPublic(); |
| 408 | _imp->mainLayout = new QVBoxLayout(this); |
| 409 | _imp->mainLayout->setContentsMargins(0, 0, 0, 0); |
| 410 | |
| 411 | _imp->centerContainer = new QWidget(this); |
| 412 | _imp->centerLayout = new QVBoxLayout(_imp->centerContainer); |
| 413 | _imp->centerLayout->setContentsMargins(0, 0, 0, 0); |
| 414 | |
| 415 | _imp->panel = new DockablePanel(getGui(), |
| 416 | _imp->holder, |
| 417 | _imp->mainLayout, |
| 418 | DockablePanel::eHeaderModeNoHeader, |
| 419 | false, |
| 420 | QUndoStackPtr(), |
| 421 | QString(), QString(), |
| 422 | _imp->centerContainer); |
| 423 | _imp->panel->turnOffPages(); |
| 424 | _imp->centerLayout->insertWidget(0, _imp->panel); |
| 425 | |
| 426 | _imp->mainLayout->addWidget(_imp->centerContainer); |
| 427 | _imp->mainLayout->addStretch(); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | PyPanel::~PyPanel() |
no test coverage detected