void tst_QFormLayout::spacing() { //TODO: confirm spacing behavior QWidget *w = new QWidget; CustomLayoutStyle *style = new CustomLayoutStyle; style->hspacing = 5; style->vspacing = 10; w->setStyle(style); QFormLayout *fl = new QFormLayout(w); QCOMPARE(style->hspacing, fl->horizontalSpacing()); QCOMPARE(style->vspacing, fl->verticalSpacing()); //QCOMPARE(fl->spacing(), -1); fl->setVerticalSpacing(5); QCOMPARE(5, fl->horizontalSpacing()); QCOMPARE(5, fl->verticalSpacing()); //QCOMPARE(fl->spacing(), 5); fl->setVerticalSpacing(-1); QCOMPARE(style->hspacing, fl->horizontalSpacing()); QCOMPARE(style->vspacing, fl->verticalSpacing()); style->hspacing = 5; style->vspacing = 5; //QCOMPARE(fl->spacing(), 5); fl->setHorizontalSpacing(20); //QCOMPARE(fl->spacing(), -1); style->vspacing = 20; QCOMPARE(fl->horizontalSpacing(), 20); QCOMPARE(fl->verticalSpacing(), 20); //QCOMPARE(fl->spacing(), 20); fl->setHorizontalSpacing(-1); //QCOMPARE(fl->spacing(), -1); style->hspacing = 20; //QCOMPARE(fl->spacing(), 20); // Do not assert if spacings are negative (QTBUG-34731) style->vspacing = -1; style->hspacing = -1; QLabel *label = new QLabel(tr("Asserts")); QCheckBox *checkBox = new QCheckBox(tr("Yes")); fl->setWidget(0, QFormLayout::LabelRole, label); fl->setWidget(1, QFormLayout::FieldRole, checkBox); w->resize(200, 100); w->show(); QVERIFY(QTest::qWaitForWindowExposed(w)); delete w; delete style; }
QWidget* AutoImportWindow::setupInputFolderContainer() { GroupContainer* container = new GroupContainer(); container->setTitle("Import Folder"); QFormLayout* layout = new QFormLayout; layout->setHorizontalSpacing(10); layout->setVerticalSpacing(0); layout->setRowWrapPolicy(QFormLayout::DontWrapRows); layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop); layout->setLabelAlignment(Qt::AlignLeft); BrowserWidget* filesDirBrowser_ = new BrowserWidget(BrowserWidget::BrowseType::DIRECTORY); ParametersConfiguration* conf = projectData.projectParameterData(); QString importImagesPath = conf->getValue("import_dir"); filesDirBrowser_->setPath(importImagesPath); setupWatcherPaths(); connect(filesDirBrowser_, &BrowserWidget::pathChanged, [ = ] (const QString & value){ conf->set("import_dir", value); setupWatcherPaths(); analyzeImport(); }); layout->addRow(filesDirBrowser_); QLabel* introLabel = new QLabel(introText()); introLabel->setWordWrap(true); QPalette pal = introLabel->palette(); pal.setColor(QPalette::WindowText, Qt::darkGray); introLabel->setPalette(pal); layout->addRow(introLabel); QCheckBox* restartCheck = new QCheckBox("Import new images in the import folder on start"); restartCheck->setChecked(ProjectPreferences().importRestartCheck()); connect(restartCheck, &QCheckBox::toggled, [ = ] (bool check){ ProjectPreferences().setImportRestartCheck(check); }); layout->addRow(restartCheck); layout->addRow(continuous); deleteCheck = new QCheckBox("DELETE the original images in import folder after importing them"); deleteCheck->setChecked(ProjectPreferences().importDeleteCheck()); deleteLabel_->setVisible(deleteCheck->isChecked()); connect(deleteCheck, &QCheckBox::toggled, [ = ] (bool check){ ProjectPreferences().setImportDeleteCheck(check); deleteLabel_->setVisible(check); }); layout->addRow(deleteCheck); container->setContainerLayout(layout); return container; }
void QmitkMultiLabelSegmentationPreferencePage::CreateQtControl(QWidget* parent) { m_Initializing = true; berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); m_SegmentationPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.views.multilabelsegmentation"); m_MainControl = new QWidget(parent); QVBoxLayout* displayOptionsLayout = new QVBoxLayout; m_RadioOutline = new QRadioButton( "Draw as outline", m_MainControl); displayOptionsLayout->addWidget( m_RadioOutline ); m_RadioOverlay = new QRadioButton( "Draw as transparent overlay", m_MainControl); displayOptionsLayout->addWidget( m_RadioOverlay ); QFormLayout *formLayout = new QFormLayout; formLayout->setHorizontalSpacing(8); formLayout->setVerticalSpacing(24); formLayout->addRow( "2D display", displayOptionsLayout ); m_VolumeRenderingCheckBox = new QCheckBox( "Show as volume rendering", m_MainControl ); formLayout->addRow( "3D display", m_VolumeRenderingCheckBox ); connect( m_VolumeRenderingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnVolumeRenderingCheckboxChecked(int)) ); QFormLayout* surfaceLayout = new QFormLayout; surfaceLayout->setSpacing(8); m_SmoothingSpinBox = new QDoubleSpinBox(m_MainControl); m_SmoothingSpinBox->setMinimum(0.0); m_SmoothingSpinBox->setSingleStep(0.5); m_SmoothingSpinBox->setValue(0.1); m_SmoothingSpinBox->setToolTip("The Smoothing value is used as Sigma for a gaussian blur."); surfaceLayout->addRow("Smoothing value (mm)", m_SmoothingSpinBox); m_DecimationSpinBox = new QDoubleSpinBox(m_MainControl); m_DecimationSpinBox->setMinimum(0.0); m_DecimationSpinBox->setMaximum(0.99); m_DecimationSpinBox->setSingleStep(0.1); m_DecimationSpinBox->setValue(0.5); m_DecimationSpinBox->setToolTip("Valid range is [0, 1). High values increase decimation, especially when very close to 1. A value of 0 disables decimation."); surfaceLayout->addRow("Decimation rate", m_DecimationSpinBox); m_SelectionModeCheckBox = new QCheckBox("Enable auto-selection mode", m_MainControl); m_SelectionModeCheckBox->setToolTip("If checked the segmentation plugin ensures that only one segmentation and the according greyvalue image are visible at one time."); formLayout->addRow("Data node selection mode",m_SelectionModeCheckBox); formLayout->addRow("Smoothed surface creation", surfaceLayout); m_MainControl->setLayout(formLayout); this->Update(); m_Initializing = false; }
void tst_QFormLayout::spacing() { //TODO: confirm spacing behavior QWidget *w = new QWidget; CustomLayoutStyle *style = new CustomLayoutStyle; style->hspacing = 5; style->vspacing = 10; w->setStyle(style); QFormLayout *fl = new QFormLayout(w); QCOMPARE(style->hspacing, fl->horizontalSpacing()); QCOMPARE(style->vspacing, fl->verticalSpacing()); //QCOMPARE(fl->spacing(), -1); fl->setVerticalSpacing(5); QCOMPARE(5, fl->horizontalSpacing()); QCOMPARE(5, fl->verticalSpacing()); //QCOMPARE(fl->spacing(), 5); fl->setVerticalSpacing(-1); QCOMPARE(style->hspacing, fl->horizontalSpacing()); QCOMPARE(style->vspacing, fl->verticalSpacing()); style->hspacing = 5; style->vspacing = 5; //QCOMPARE(fl->spacing(), 5); fl->setHorizontalSpacing(20); //QCOMPARE(fl->spacing(), -1); style->vspacing = 20; QCOMPARE(fl->horizontalSpacing(), 20); QCOMPARE(fl->verticalSpacing(), 20); //QCOMPARE(fl->spacing(), 20); fl->setHorizontalSpacing(-1); //QCOMPARE(fl->spacing(), -1); style->hspacing = 20; //QCOMPARE(fl->spacing(), 20); delete w; delete style; }
PropertyMultiValueWidget::PropertyMultiValueWidget(PartProperty* prop, QWidget* parent, QObject* keyEventFilter) : QWidget(parent), cat(prop->getPartCategory()), prop(prop), state(Enabled), flags(0) { PartProperty::Type type = prop->getType(); flags_t flags = prop->getFlags(); QVBoxLayout* topLayout = new QVBoxLayout(this); setLayout(topLayout); QSplitter* splitter = new QSplitter(Qt::Horizontal, this); topLayout->addWidget(splitter); QWidget* listContWidget = new QWidget(splitter); splitter->addWidget(listContWidget); QVBoxLayout* listContLayout = new QVBoxLayout(listContWidget); listContWidget->setLayout(listContLayout); listWidget = new QListWidget(listContWidget); listWidget->installEventFilter(keyEventFilter); connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(currentItemChanged(QListWidgetItem*, QListWidgetItem*))); listContLayout->addWidget(listWidget); QWidget* buttonWidget = new QWidget(listContWidget); listContLayout->addWidget(buttonWidget); QHBoxLayout* buttonLayout = new QHBoxLayout(buttonWidget); buttonWidget->setLayout(buttonLayout); buttonLayout->addStretch(1); listAddButton = new QPushButton("", buttonWidget); listAddButton->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/list-add.png"))); connect(listAddButton, SIGNAL(clicked()), this, SLOT(addRequested())); buttonLayout->addWidget(listAddButton); listRemoveButton = new QPushButton("", buttonWidget); listRemoveButton->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/list-remove.png"))); connect(listRemoveButton, SIGNAL(clicked()), this, SLOT(removeRequested())); buttonLayout->addWidget(listRemoveButton); buttonLayout->addStretch(1); QWidget* detailWidget = new QWidget(splitter); splitter->addWidget(detailWidget); QVBoxLayout* detailLayout = new QVBoxLayout(detailWidget); detailWidget->setLayout(detailLayout); QWidget* detailFormWidget = new QWidget(detailWidget); detailLayout->addWidget(detailFormWidget); QFormLayout* detailFormLayout = new QFormLayout(detailFormWidget); detailFormLayout->setSizeConstraint(QFormLayout::SetMinimumSize); detailFormLayout->setHorizontalSpacing(20); detailFormLayout->setVerticalSpacing(10); detailFormWidget->setLayout(detailFormLayout); if (type != PartProperty::PartLink) { if (type == PartProperty::Boolean) { boolBox = new QCheckBox(prop->getUserReadableName(), detailFormWidget); boolBox->installEventFilter(keyEventFilter); connect(boolBox, SIGNAL(toggled(bool)), this, SLOT(boolFieldToggled(bool))); detailFormLayout->addRow(boolBox); } else if (type == PartProperty::File) {
AttachCoreDialog::AttachCoreDialog(QWidget *parent) : QDialog(parent), d(new AttachCoreDialogPrivate) { setWindowTitle(tr("Load Core File")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this); d->kitChooser->populate(); d->selectRemoteCoreButton = new QPushButton(tr("Browse..."), this); d->remoteCoreFileName = new QLineEdit(this); d->forceLocalCheckBox = new QCheckBox(this); d->forceLocalLabel = new QLabel(this); d->forceLocalLabel->setText(tr("Use local core file:")); d->forceLocalLabel->setBuddy(d->forceLocalCheckBox); d->localCoreFileName = new PathChooser(this); d->localCoreFileName->setExpectedKind(PathChooser::File); d->localCoreFileName->setPromptDialogTitle(tr("Select Core File")); d->localExecFileName = new PathChooser(this); d->localExecFileName->setExpectedKind(PathChooser::File); d->localExecFileName->setPromptDialogTitle(tr("Select Executable")); d->overrideStartScriptFileName = new PathChooser(this); d->overrideStartScriptFileName->setExpectedKind(PathChooser::File); d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script")); d->buttonBox = new QDialogButtonBox(this); d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); d->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); QHBoxLayout *coreLayout = new QHBoxLayout; coreLayout->addWidget(d->localCoreFileName); coreLayout->addWidget(d->remoteCoreFileName); coreLayout->addWidget(d->selectRemoteCoreButton); QFormLayout *formLayout = new QFormLayout; formLayout->setContentsMargins(0, 0, 0, 0); formLayout->setHorizontalSpacing(6); formLayout->setVerticalSpacing(6); formLayout->addRow(tr("Kit:"), d->kitChooser); formLayout->addRow(tr("&Executable:"), d->localExecFileName); formLayout->addRow(d->forceLocalLabel, d->forceLocalCheckBox); formLayout->addRow(tr("Core file:"), coreLayout); formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName); QFrame *line = new QFrame(this); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); formLayout->addRow(d->buttonBox); QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->addLayout(formLayout); vboxLayout->addStretch(); vboxLayout->addWidget(line); vboxLayout->addWidget(d->buttonBox); }
QWidget* ProcessingManager::setupQueueContainer() { queueModel_ = new ProcessingModel(this); connect(&projectData, &ProjectData::toBeAddedToProcessingQueue, queueModel_, &ProcessingModel::addProcesses); QFormLayout* layout = new QFormLayout; layout->setHorizontalSpacing(10); layout->setVerticalSpacing(2); layout->setRowWrapPolicy(QFormLayout::DontWrapRows); layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop); layout->setLabelAlignment(Qt::AlignLeft); int numberOfThreads = QThread::idealThreadCount(); if(numberOfThreads < 1) numberOfThreads = 1; processesBox_ = new QSpinBox; processesBox_->setFrame(false); processesBox_->setMinimum(1); processesBox_->setMaximum(numberOfThreads); processesBox_->setValue(ProjectPreferences().processJobs()); connect(processesBox_, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int value){ ProjectPreferences().setProcessJobs(value); }); layout->addRow("Number of jobs to run in parallel", processesBox_); QLabel* introLabel = new QLabel("The maximum number of threads on your system is: " + QString::number(numberOfThreads)); introLabel->setWordWrap(true); QPalette pal = introLabel->palette(); pal.setColor(QPalette::WindowText, Qt::darkGray); introLabel->setPalette(pal); layout->addRow(introLabel); GroupContainer* jobcontainer = new GroupContainer; jobcontainer->setTitle("Concurrency Selection"); jobcontainer->setContainerLayout(layout); QToolButton* addSelectedButton = getButton("add_queue", "Add Images", "Add selected images from the project library to the processing queue"); connect(addSelectedButton, &GraphicalButton::clicked, [=]() { projectData.addSelectedToQueue(); }); QToolButton* clearSelectedButton = getButton("remove_highlighted", "Clear Selected", "Remove highlighted images from the processing queue"); connect(clearSelectedButton, &GraphicalButton::clicked, [=]() { while(!queueView_->selectionModel()->selectedIndexes().isEmpty()) { QModelIndex i = queueView_->selectionModel()->selectedIndexes().first(); if(!i.parent().isValid()) { queueModel_->removeRow(i.row()); } } setQueueCount(queueModel_->rowCount()); }); QToolButton* clearAllButton = getButton("remove_all", "Clear All", "Remove all images from queue"); connect(clearAllButton, &GraphicalButton::clicked, queueModel_, &ProcessingModel::clearAll); QToolButton* prioritizeButton = getButton("prioritize_highlighted", "Prioritize", "Prioritize the processing of highlighted images"); connect(prioritizeButton, &GraphicalButton::clicked, [=]() { for(QModelIndex i : queueView_->selectionModel()->selectedRows(0)) { if(!i.parent().isValid()) { queueModel_->insertRow(0, queueModel_->takeRow(i.row())); } } }); QHBoxLayout* buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(0); buttonLayout->addWidget(addSelectedButton, 0); buttonLayout->addStretch(1); buttonLayout->addWidget(prioritizeButton, 0); buttonLayout->addWidget(clearAllButton, 0); buttonLayout->addWidget(clearSelectedButton, 0); queueView_ = new QTreeView(this); queueView_->setAttribute(Qt::WA_MacShowFocusRect, 0); queueView_->setModel(queueModel_); queueView_->setSelectionMode(QAbstractItemView::ExtendedSelection); queueView_->setSortingEnabled(true); queueView_->setAllColumnsShowFocus(true); queueView_->setAlternatingRowColors(true); queueView_->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); queueView_->setHeaderHidden(true); BlockContainer* queueContainer = new BlockContainer("Images in queue", queueView_); QVBoxLayout *queueLayout = new QVBoxLayout; queueLayout->setMargin(10); queueLayout->setSpacing(10); queueLayout->addLayout(buttonLayout, 0); queueLayout->addWidget(queueContainer, 1); GroupContainer* container = new GroupContainer; container->setTitle("Processing Queue"); container->setContainerLayout(queueLayout); QVBoxLayout* mainLayout = new QVBoxLayout(); mainLayout->setMargin(0); mainLayout->setSpacing(10); mainLayout->addStretch(0); mainLayout->addWidget(jobcontainer, 0); mainLayout->addWidget(container, 1); QWidget* mainContainer = new QWidget; mainContainer->setLayout(mainLayout); mainContainer->setMaximumWidth(500); return mainContainer; }