CleanupSettings::CleanupSettings(QWidget *parent) : QWidget(parent), m_attached(false) { QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setMargin(1); // NOTE: This works to show the 1-pix black border, // because this is a QWidget (not QFrame) heir... setLayout(vLayout); // Tabs Container // Used to deal with styled background and other stuff TabBarContainter *tabBarContainer = new TabBarContainter(this); QHBoxLayout *hLayout = new QHBoxLayout(tabBarContainer); hLayout->setMargin(0); hLayout->setAlignment(Qt::AlignLeft); hLayout->addSpacing(6); vLayout->addWidget(tabBarContainer); // Tabs Bar DVGui::TabBar *tabBar = new DVGui::TabBar(this); hLayout->addWidget(tabBar); tabBar->addSimpleTab(tr("Cleanup")); tabBar->addSimpleTab(tr("Processing")); tabBar->addSimpleTab(tr("Camera")); tabBar->setDrawBase(false); // Splitter QSplitter *split = new QSplitter(Qt::Vertical, this); split->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); vLayout->addWidget(split); // Stacked Widget QStackedWidget *stackedWidget = new QStackedWidget(split); stackedWidget->setMinimumWidth(300); //stackedWidget->setMinimumHeight(250); split->addWidget(stackedWidget); split->setStretchFactor(0, 1); // Cleanup Tab QScrollArea *scrollArea = new QScrollArea(stackedWidget); stackedWidget->addWidget(scrollArea); scrollArea->setWidgetResizable(true); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_cleanupTab = new CleanupTab; scrollArea->setWidget(m_cleanupTab); // Processing Tab scrollArea = new QScrollArea(stackedWidget); stackedWidget->addWidget(scrollArea); scrollArea->setWidgetResizable(true); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_processingTab = new ProcessingTab; scrollArea->setWidget(m_processingTab); // Camera Tab scrollArea = new QScrollArea(stackedWidget); stackedWidget->addWidget(scrollArea); scrollArea->setWidgetResizable(true); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_cameraTab = new CameraTab; scrollArea->setWidget(m_cameraTab); m_cameraTab->setCameraPresetListFile(ToonzFolder::getReslistPath(true)); // Swatch m_swatch = new CleanupSwatch(split, 200, 150); split->addWidget(m_swatch); // ToolBar QWidget *toolBarWidget = new QWidget(this); vLayout->addWidget(toolBarWidget); toolBarWidget->setFixedHeight(22); QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget); toolBarWidget->setLayout(toolBarLayout); toolBarLayout->setMargin(0); toolBarLayout->setSpacing(0); QToolBar *leftToolBar = new QToolBar(toolBarWidget); toolBarLayout->addWidget(leftToolBar, 0, Qt::AlignLeft); leftToolBar->setFixedWidth(110); m_swatchAct = new QAction(createQIconOnOffPNG("preview", true), tr("Toggle Swatch Preview"), this); m_swatchAct->setCheckable(true); leftToolBar->addAction(m_swatchAct); leftToolBar->addSeparator(); m_opacityAct = new QAction(createQIconOnOffPNG("opacitycheck", true), tr("Toggle Opacity Check"), this); m_opacityAct->setCheckable(true); leftToolBar->addAction(m_opacityAct); QToolBar *spacingToolBar1 = new QToolBar(toolBarWidget); toolBarLayout->addWidget(spacingToolBar1, 1); spacingToolBar1->setMinimumHeight(22); QToolBar *rightToolBar = new QToolBar(toolBarWidget); toolBarLayout->addWidget(rightToolBar, 0, Qt::AlignRight); rightToolBar->setFixedWidth(110); QAction *saveAct = new QAction(createQIconOnOffPNG("save", false), tr("Save Settings"), this); rightToolBar->addAction(saveAct); QAction *loadAct = new QAction(createQIconOnOffPNG("load", false), tr("Load Settings"), this); rightToolBar->addAction(loadAct); rightToolBar->addSeparator(); QAction *resetAct = new QAction(createQIconOnOffPNG("resetsize", false), tr("Reset Settings"), this); rightToolBar->addAction(resetAct); // Model-related stuff CleanupSettingsModel *model = CleanupSettingsModel::instance(); m_backupParams.assign(model->getCurrentParameters(), false); // Connections QAction *opacityCheckCmd = CommandManager::instance()->getAction(MI_OpacityCheck); assert(opacityCheckCmd); bool ret = true; ret = ret && connect(tabBar, SIGNAL(currentChanged(int)), stackedWidget, SLOT(setCurrentIndex(int))); ret = ret && connect(m_swatchAct, SIGNAL(toggled(bool)), SLOT(enableSwatch(bool))); ret = ret && connect(m_opacityAct, SIGNAL(triggered(bool)), opacityCheckCmd, SLOT(trigger())); ret = ret && connect(saveAct, SIGNAL(triggered()), model, SLOT(promptSave())); ret = ret && connect(loadAct, SIGNAL(triggered()), model, SLOT(promptLoad())); ret = ret && connect(resetAct, SIGNAL(triggered()), this, SLOT(onRestoreSceneSettings())); assert(ret); }
void interface::CreateWidgets(){ QString name, type, title, wight, image, id, act; xmlItem childItem; xmlItem md = xml.find(xml_root,md_metadata); xmlItem ifTabs = xml.find(xml_root,md_tabs); xmlItem itActions = xml.find(xml_root,md_actions); currentTab = 0; int idTab = 0; int idVal = 0; while (!ifTabs.isNull()){ name = xml.attr(ifTabs,mda_name); type = xml.attr(ifTabs,mda_type); title = xml.attr(ifTabs,mda_title); QGridLayout *l = new QGridLayout(this); QTabWidget *root = new QTabWidget; l->addWidget(root); connect(root,SIGNAL(currentChanged(int)),this,SLOT(on_clicked_tab(int))); //—оздаем вкладки разделов childItem = xml.find(ifTabs,md_tab); while (!childItem.isNull()){ name = xml.attr(childItem,mda_name); type = xml.attr(childItem,mda_type); title = xml.attr(childItem,mda_title); image = xml.attr(childItem,mda_image); QWidget *Tab = UIload.createWidget(type,root,name); Tab->setObjectName(name); QIcon ic(":/"+image); root->setIconSize(QSize(50,50)); root->addTab(Tab,ic,title); QHBoxLayout *vb = new QHBoxLayout(Tab); QStackedWidget *stWidget = new QStackedWidget(); listWindow.insert(idTab,stWidget); idTab++; //idVal = 0; // —оздаем левое меню xmlItem childrenItem = xml.find(childItem,md_left_menu,0); while (!childrenItem.isNull() && childrenItem.nodeName() == md_left_menu){ name = xml.attr(childrenItem,mda_name); type = xml.attr(childrenItem,mda_type); title = xml.attr(childrenItem,mda_title); wight = xml.attr(childrenItem,mda_width); iisTaskPanel *tskPanel = new iisTaskPanel(Tab); if (!wight.isEmpty()) tskPanel->setMinimumWidth(wight.toInt()); vb->addWidget(tskPanel,0); vb->setAlignment(tskPanel,Qt::AlignLeft); // √руппы меню tskPanel->layout()->setAlignment(Qt::AlignTop); xmlItem xmlGr = xml.find(childrenItem,md_group); while (!xmlGr.isNull()){ name = xml.attr(xmlGr,mda_name); type = xml.attr(xmlGr,mda_type); title = xml.attr(xmlGr,mda_title); //QGroupBox *Gr = new QGroupBox(name,prev); iisTaskBox *Gr = new iisTaskBox(title); tskPanel->addWidget(Gr); Gr->setObjectName(name); //Ёлементы меню xmlItem xmlValue = xml.find(xmlGr,md_value); while (!xmlValue.isNull()){ name = xml.attr(xmlValue,mda_name); id = xml.attr(xmlValue,mda_id); title = xml.attr(xmlValue,mda_title); act = xml.sText(xmlValue,md_comaction); iisIconLabel *val = new iisIconLabel(title); val->setObjectName(name); connect(val,SIGNAL(clicked()),this,SLOT(on_clicked_item())); Gr->addIconLabel(val); list.insert(val,idVal); xmlItem iact = xml.findId(itActions,"",act); xmlItem iObj, iFrm; if (!iact.isNull()){ QString idObj = xml.sText(iact,md_objectid); xmlItem tmp = xml.firstChild(md); while (!tmp.isNull()){ iObj = xml.findId(tmp,"",idObj); tmp = xml.nextSibling(tmp); if (!iObj.isNull()) break; } } if (!iObj.isNull()){ QString idFrm = xml.sText(iact,md_formid); iObj = xml.find(iObj,md_forms); iFrm = xml.findId(iObj,"",idFrm); // —оздаем форму QWidget *form =eng->OpenForm(iFrm); if (form){ stWidget->insertWidget(idVal,form); idVal++; } } xmlValue = xml.nextSibling(xmlValue); } xmlGr = xml.nextSibling(xmlGr); } childrenItem = xml.nextSibling(childrenItem); } // ѕрава¤ панель childrenItem = xml.find(childItem,md_panel); while (!childrenItem.isNull()){ name = xml.attr(childrenItem,mda_name); type = xml.attr(childrenItem,mda_type); title = xml.attr(childrenItem,mda_title); wight = xml.attr(childrenItem,mda_width); if (!wight.isEmpty()) stWidget->setMinimumWidth(wight.toInt()); stWidget->setObjectName(name); stWidget->setFrameStyle(1); stWidget->setFrameShadow(QFrame::Raised); vb->addWidget(stWidget,2); childrenItem = xml.nextSibling(childrenItem); } childItem = xml.nextSibling(childItem); } ifTabs = xml.nextSibling(ifTabs); } }