void SubToolBar::initSaveLabel() { //save to... QList<ToolButton*> toolBtnList; ToolButton* saveDesktopBtn = new ToolButton(); saveDesktopBtn->setFixedSize(SAVEBTN_SIZE); saveDesktopBtn->setObjectName("SaveToDesktop"); saveDesktopBtn->setTips(tr("Save to desktop")); toolBtnList.append(saveDesktopBtn); ToolButton* savePicBtn = new ToolButton(); savePicBtn->setFixedSize(SAVEBTN_SIZE); savePicBtn->setObjectName("SaveToPictureDir"); savePicBtn->setTips(tr("Autosave")); toolBtnList.append(savePicBtn); ToolButton* saveSpecificDirBtn = new ToolButton(); saveSpecificDirBtn->setFixedSize(SAVEBTN_SIZE); saveSpecificDirBtn->setObjectName("SaveToSpecificDir"); saveSpecificDirBtn->setTips(tr("Save to specified folder")); toolBtnList.append(saveSpecificDirBtn); ToolButton* saveClipboardBtn = new ToolButton(); saveClipboardBtn->setFixedSize(SAVEBTN_SIZE); saveClipboardBtn->setObjectName("SaveToClipboard"); saveClipboardBtn->setTips(tr("Copy to clipboard")); toolBtnList.append(saveClipboardBtn); ToolButton* saveAutoClipboardBtn = new ToolButton(); saveAutoClipboardBtn->setObjectName("SaveToAutoClipboard"); saveAutoClipboardBtn->setTips(tr("Autosave and copy to clipboard")); toolBtnList.append(saveAutoClipboardBtn); QLabel* lowQualityText = new QLabel(); lowQualityText->setObjectName("LowQualityLabel"); lowQualityText->setText(tr("Low")); QSlider* saveQualitySlider = new QSlider(Qt::Horizontal); saveQualitySlider->setFixedWidth(58); saveQualitySlider->setMinimum(50); saveQualitySlider->setMaximum(100); saveQualitySlider->setPageStep(1); saveQualitySlider->setSliderPosition(100); setSaveQualityIndex(saveQualitySlider->value()); connect(saveQualitySlider, &QSlider::valueChanged, this, &SubToolBar::setSaveQualityIndex); QLabel* highQualityText = new QLabel(); highQualityText->setObjectName("HighQualityLabel"); highQualityText->setText(tr("High")); m_saveLabel = new QLabel(this); QHBoxLayout* saveLayout = new QHBoxLayout(); saveLayout->setMargin(0); saveLayout->setSpacing(0); saveLayout->addSpacing(1); foreach (ToolButton* btn, toolBtnList) { saveLayout->addWidget(btn); // saveLayout->addSpacing(1); connect(btn, &ToolButton::clicked, this, [=]{ qDebug() << "saveButtonList:" << toolBtnList.indexOf(btn); setSaveOption(toolBtnList.indexOf(btn)); }); connect(btn, &ToolButton::onEnter, this, [=]{ emit showSaveTip(btn->getTips()); }); connect(btn, &ToolButton::onExist, this, [=]{ emit hideSaveTip(); }); }
NLMGUI2D::NLMGUI2D() { viewOrig = createView(); viewOrig->set2DMode(); //viewOrig->set3DMode(); // Create a 3D view //View* view = createView(); view = createView(); //view->set3DMode(); view->set2DMode(); //enableFullscreen(); // Import image ImageFileImporter::pointer importer = ImageFileImporter::New(); importer->setFilename(std::string(FAST_TEST_DATA_DIR) + "/US-2D.jpg"); //importer->setFilename(std::string(FAST_TEST_DATA_DIR) + "/US-1-2D.png"); // Smooth images nlmSmoothing = NonLocalMeans::New(); nlmSmoothing->setInputConnection(importer->getOutputPort()); nlmSmoothing->setSigma(0.65f); nlmSmoothing->setGroupSize(5); nlmSmoothing->setWindowSize(11); nlmSmoothing->setDenoiseStrength(0.300); nlmSmoothing->setK(1); nlmSmoothing->setEuclid(1); nlmSmoothing->enableRuntimeMeasurements(); //mSmoothing = GaussianSmoothingFilter::New(); //mSmoothing->setInputConnection(importer->getOutputPort()); //mSmoothing->setStandardDeviation(1); // Set up surface extraction //mSurfaceExtraction = SurfaceExtraction::New(); //mSurfaceExtraction->setInputConnection(nlmSmoothing->getOutputPort()); //mSurfaceExtraction->setThreshold(100); // Set up rendering renderer = ImageRenderer::New(); //ImageRenderer::pointer renderer = ImageRenderer::New(); renderer->addInputConnection(nlmSmoothing->getOutputPort()); //MeshRenderer::pointer renderer = MeshRenderer::New(); //renderer->addInputConnection(mSurfaceExtraction->getOutputPort()); view->addRenderer(renderer); rendererOrig = ImageRenderer::New(); rendererOrig->addInputConnection(importer->getOutputPort()); viewOrig->addRenderer(rendererOrig); // Create and add GUI elements // First create the menu layout QVBoxLayout* menuLayout = new QVBoxLayout; // Menu items should be aligned to the top menuLayout->setAlignment(Qt::AlignTop); // Title label QLabel* title = new QLabel; title->setText("Menu"); QFont font; font.setPointSize(28); title->setFont(font); menuLayout->addWidget(title); // Quit button QPushButton* quitButton = new QPushButton; quitButton->setText("Quit"); quitButton->setFixedWidth(200); menuLayout->addWidget(quitButton); // Connect the clicked signal of the quit button to the stop method for the window QObject::connect(quitButton, &QPushButton::clicked, boost::bind(&Window::stop, this)); // Smoothing parameter label //mSmoothingLabel = new QLabel; //mSmoothingLabel->setText("DenoiseStrength: 300"); //menuLayout->addWidget(mSmoothingLabel); nlmStrengthLabel = new QLabel; std::string text1 = "Denoise Strength: " + boost::lexical_cast<std::string>(0.3) + " "; nlmStrengthLabel->setText(text1.c_str()); menuLayout->addWidget(nlmStrengthLabel); // Smoothing parameter slider QSlider* slider = new QSlider(Qt::Horizontal); slider->setMinimum(10); slider->setMaximum(3000); slider->setValue(300); slider->setFixedWidth(300); menuLayout->addWidget(slider); // Connect the value changed signal of the slider to the updateSmoothingParameter method QObject::connect(slider, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateDenoiseParameter, this, _1)); // Threshold label //mThresholdLabel = new QLabel; //mThresholdLabel->setText("Threshold: 100 HU"); //menuLayout->addWidget(mThresholdLabel); nlmSigmaLabel = new QLabel; std::string text2 = "Sigma: " + boost::lexical_cast<std::string>(0.65) + " "; nlmSigmaLabel->setText(text2.c_str()); menuLayout->addWidget(nlmSigmaLabel); // Sigma slider QSlider* slider2 = new QSlider(Qt::Horizontal); slider2->setMinimum(10); slider2->setMaximum(3000); slider2->setValue(650); slider2->setFixedWidth(300); menuLayout->addWidget(slider2); // Connect the value changed signal of the slider to the updateSigma method QObject::connect(slider2, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateSigma, this, _1)); //GroupSize Label + Slider nlmGroupSizeLabel = new QLabel; std::string text3 = "Group Size: " + boost::lexical_cast<std::string>(3) + " "; nlmGroupSizeLabel->setText(text3.c_str()); menuLayout->addWidget(nlmGroupSizeLabel); QSlider* slider3 = new QSlider(Qt::Horizontal); slider3->setMinimum(3); slider3->setMaximum(30); slider3->setValue(3); slider3->setFixedWidth(300); menuLayout->addWidget(slider3); QObject::connect(slider3, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateGroupSize, this, _1)); //WindowSize Label + Slider nlmWindowSizeLabel = new QLabel; std::string text4 = "Window Size: " + boost::lexical_cast<std::string>(5) + " "; nlmWindowSizeLabel->setText(text4.c_str()); menuLayout->addWidget(nlmWindowSizeLabel); QSlider* slider4 = new QSlider(Qt::Horizontal); slider4->setMinimum(5); slider4->setMaximum(100); slider4->setValue(5); slider4->setFixedWidth(300); menuLayout->addWidget(slider4); QObject::connect(slider4, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateWindowSize, this, _1)); //K Label + Slider nlmKLabel = new QLabel; std::string text5 = "K Version: " + boost::lexical_cast<std::string>(0) + " "; nlmKLabel->setText(text5.c_str()); menuLayout->addWidget(nlmKLabel); QSlider* slider5 = new QSlider(Qt::Horizontal); slider5->setMinimum(0); slider5->setMaximum(5); slider5->setValue(0); slider5->setFixedWidth(300); menuLayout->addWidget(slider5); QObject::connect(slider5, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateK, this, _1)); nlmELabel = new QLabel; std::string text7 = "Euclid Version: " + boost::lexical_cast<std::string>(0) + " "; nlmELabel->setText(text7.c_str()); menuLayout->addWidget(nlmELabel); QSlider* slider6 = new QSlider(Qt::Horizontal); slider6->setMinimum(0); slider6->setMaximum(2); slider6->setValue(0); slider6->setFixedWidth(300); menuLayout->addWidget(slider6); QObject::connect(slider6, &QSlider::valueChanged, boost::bind(&NLMGUI2D::updateE, this, _1)); timerLabel = new QLabel; std::string text6 = "Kernal time: -- ms" ; timerLabel->setText(text6.c_str()); menuLayout->addWidget(timerLabel); // Add menu and view to main layout QHBoxLayout* layout = new QHBoxLayout; layout->addLayout(menuLayout); layout->addWidget(viewOrig); layout->addWidget(view); mWidget->setLayout(layout); }
void TimeLine::initUI() { Q_ASSERT(editor() != nullptr); setWindowTitle(tr("Timeline")); QWidget* timeLineContent = new QWidget(this); mLayerList = new TimeLineCells(this, editor(), TIMELINE_CELL_TYPE::Layers); mTracks = new TimeLineCells(this, editor(), TIMELINE_CELL_TYPE::Tracks); mHScrollbar = new QScrollBar(Qt::Horizontal); mVScrollbar = new QScrollBar(Qt::Vertical); mVScrollbar->setMinimum(0); mVScrollbar->setMaximum(1); mVScrollbar->setPageStep(1); QWidget* leftWidget = new QWidget(); leftWidget->setMinimumWidth(120); QWidget* rightWidget = new QWidget(); QWidget* leftToolBar = new QWidget(); leftToolBar->setFixedHeight(30); QWidget* rightToolBar = new QWidget(); rightToolBar->setFixedHeight(30); // --- left widget --- // --------- layer buttons --------- QToolBar* layerButtons = new QToolBar(this); QLabel* layerLabel = new QLabel(tr("Layers:")); layerLabel->setIndent(5); QToolButton* addLayerButton = new QToolButton(this); addLayerButton->setIcon(QIcon(":icons/add.png")); addLayerButton->setToolTip(tr("Add Layer")); addLayerButton->setFixedSize(24, 24); QToolButton* removeLayerButton = new QToolButton(this); removeLayerButton->setIcon(QIcon(":icons/remove.png")); removeLayerButton->setToolTip(tr("Remove Layer")); removeLayerButton->setFixedSize(24, 24); layerButtons->addWidget(layerLabel); layerButtons->addWidget(addLayerButton); layerButtons->addWidget(removeLayerButton); layerButtons->setFixedHeight(30); QHBoxLayout* leftToolBarLayout = new QHBoxLayout(); leftToolBarLayout->setMargin(0); leftToolBarLayout->addWidget(layerButtons); leftToolBar->setLayout(leftToolBarLayout); QAction* newBitmapLayerAct = new QAction(QIcon(":icons/layer-bitmap.png"), tr("New Bitmap Layer"), this); QAction* newVectorLayerAct = new QAction(QIcon(":icons/layer-vector.png"), tr("New Vector Layer"), this); QAction* newSoundLayerAct = new QAction(QIcon(":icons/layer-sound.png"), tr("New Sound Layer"), this); QAction* newCameraLayerAct = new QAction(QIcon(":icons/layer-camera.png"), tr("New Camera Layer"), this); QMenu* layerMenu = new QMenu(tr("&Layer", "Timeline add-layer menu"), this); layerMenu->addAction(newBitmapLayerAct); layerMenu->addAction(newVectorLayerAct); layerMenu->addAction(newSoundLayerAct); layerMenu->addAction(newCameraLayerAct); addLayerButton->setMenu(layerMenu); addLayerButton->setPopupMode(QToolButton::InstantPopup); QGridLayout* leftLayout = new QGridLayout(); leftLayout->addWidget(leftToolBar, 0, 0); leftLayout->addWidget(mLayerList, 1, 0); leftLayout->setMargin(0); leftLayout->setSpacing(0); leftWidget->setLayout(leftLayout); // --- right widget --- // --------- key buttons --------- QToolBar* timelineButtons = new QToolBar(this); QLabel* keyLabel = new QLabel(tr("Keys:")); keyLabel->setIndent(5); QToolButton* addKeyButton = new QToolButton(this); addKeyButton->setIcon(QIcon(":icons/add.png")); addKeyButton->setToolTip(tr("Add Frame")); addKeyButton->setFixedSize(24, 24); QToolButton* removeKeyButton = new QToolButton(this); removeKeyButton->setIcon(QIcon(":icons/remove.png")); removeKeyButton->setToolTip(tr("Remove Frame")); removeKeyButton->setFixedSize(24, 24); QToolButton* duplicateKeyButton = new QToolButton(this); duplicateKeyButton->setIcon(QIcon(":icons/controls/duplicate.png")); duplicateKeyButton->setToolTip(tr("Duplicate Frame")); duplicateKeyButton->setFixedSize(24, 24); QLabel* zoomLabel = new QLabel(tr("Zoom:")); zoomLabel->setIndent(5); QSlider* zoomSlider = new QSlider(this); zoomSlider->setRange(4, 40); zoomSlider->setFixedWidth(74); zoomSlider->setValue(mTracks->getFrameSize()); zoomSlider->setToolTip(tr("Adjust frame width")); zoomSlider->setOrientation(Qt::Horizontal); QLabel* onionLabel = new QLabel(tr("Onion skin:")); QToolButton* onionTypeButton = new QToolButton(this); onionTypeButton->setIcon(QIcon(":icons/onion_type.png")); onionTypeButton->setToolTip(tr("Toggle match keyframes")); onionTypeButton->setFixedSize(24, 24); timelineButtons->addWidget(keyLabel); timelineButtons->addWidget(addKeyButton); timelineButtons->addWidget(removeKeyButton); timelineButtons->addWidget(duplicateKeyButton); timelineButtons->addSeparator(); timelineButtons->addWidget(zoomLabel); timelineButtons->addWidget(zoomSlider); timelineButtons->addSeparator(); timelineButtons->addWidget(onionLabel); timelineButtons->addWidget(onionTypeButton); timelineButtons->addSeparator(); timelineButtons->setFixedHeight(30); // --------- Time controls --------- mTimeControls = new TimeControls(this); mTimeControls->setEditor(editor()); mTimeControls->initUI(); mTimeControls->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); updateLength(); QHBoxLayout* rightToolBarLayout = new QHBoxLayout(); rightToolBarLayout->addWidget(timelineButtons); rightToolBarLayout->setAlignment(Qt::AlignLeft); rightToolBarLayout->addWidget(mTimeControls); rightToolBarLayout->setMargin(0); rightToolBarLayout->setSpacing(0); rightToolBar->setLayout(rightToolBarLayout); QGridLayout* rightLayout = new QGridLayout(); rightLayout->addWidget(rightToolBar, 0, 0); rightLayout->addWidget(mTracks, 1, 0); rightLayout->setMargin(0); rightLayout->setSpacing(0); rightWidget->setLayout(rightLayout); // --- Splitter --- QSplitter* splitter = new QSplitter(this); splitter->addWidget(leftWidget); splitter->addWidget(rightWidget); splitter->setSizes(QList<int>() << 100 << 600); QGridLayout* lay = new QGridLayout(); lay->addWidget(splitter, 0, 0); lay->addWidget(mVScrollbar, 0, 1); lay->addWidget(mHScrollbar, 1, 0); lay->setMargin(0); lay->setSpacing(0); timeLineContent->setLayout(lay); setWidget(timeLineContent); setWindowFlags(Qt::WindowStaysOnTopHint); connect(mHScrollbar, &QScrollBar::valueChanged, mTracks, &TimeLineCells::hScrollChange); connect(mTracks, &TimeLineCells::offsetChanged, mHScrollbar, &QScrollBar::setValue); connect(mVScrollbar, &QScrollBar::valueChanged, mTracks, &TimeLineCells::vScrollChange); connect(mVScrollbar, &QScrollBar::valueChanged, mLayerList, &TimeLineCells::vScrollChange); connect(splitter, &QSplitter::splitterMoved, this, &TimeLine::updateLength); connect(addKeyButton, &QToolButton::clicked, this, &TimeLine::addKeyClick); connect(removeKeyButton, &QToolButton::clicked, this, &TimeLine::removeKeyClick); connect(duplicateKeyButton, &QToolButton::clicked, this, &TimeLine::duplicateKeyClick); connect(zoomSlider, &QSlider::valueChanged, mTracks, &TimeLineCells::setFrameSize); connect(onionTypeButton, &QToolButton::clicked, this, &TimeLine::toogleAbsoluteOnionClick); connect(mTimeControls, &TimeControls::soundToggled, this, &TimeLine::soundClick); connect(mTimeControls, &TimeControls::fpsChanged, this, &TimeLine::fpsChanged); connect(mTimeControls, &TimeControls::fpsChanged, this, &TimeLine::updateLength); connect(mTimeControls, &TimeControls::playButtonTriggered, this, &TimeLine::playButtonTriggered); connect(newBitmapLayerAct, &QAction::triggered, this, &TimeLine::newBitmapLayer); connect(newVectorLayerAct, &QAction::triggered, this, &TimeLine::newVectorLayer); connect(newSoundLayerAct, &QAction::triggered, this, &TimeLine::newSoundLayer); connect(newCameraLayerAct, &QAction::triggered, this, &TimeLine::newCameraLayer); connect(removeLayerButton, &QPushButton::clicked, this, &TimeLine::deleteCurrentLayer); connect(mLayerList, &TimeLineCells::mouseMovedY, mLayerList, &TimeLineCells::setMouseMoveY); connect(mLayerList, &TimeLineCells::mouseMovedY, mTracks, &TimeLineCells::setMouseMoveY); connect(mTracks, &TimeLineCells::lengthChanged, this, &TimeLine::updateLength); connect(editor(), &Editor::currentFrameChanged, this, &TimeLine::updateFrame); LayerManager* layer = editor()->layers(); connect(layer, &LayerManager::layerCountChanged, this, &TimeLine::updateLayerNumber); scrubbing = false; }
void VPiano::initExtraControllers() { QWidget *w = NULL; QCheckBox *chkbox = NULL; Knob *knob = NULL; QSpinBox *spin = NULL; QSlider *slider = NULL; QToolButton *button = NULL; foreach(const QString& s, m_extraControls) { QString lbl; int control = 0; int type = 0; int minValue = 0; int maxValue = 127; int defValue = 0; int value = 0; int size = 100; QString fileName; ExtraControl::decodeString( s, lbl, control, type, minValue, maxValue, defValue, size, fileName ); if (m_ctlState[m_channel].contains(control)) value = m_ctlState[m_channel][control]; else value = defValue; switch(type) { case 0: chkbox = new QCheckBox(this); if (dlgPreferences()->getStyledWidgets()) { chkbox->setStyle(m_dialStyle); } chkbox->setProperty(MIDICTLONVALUE, maxValue); chkbox->setProperty(MIDICTLOFFVALUE, minValue); chkbox->setChecked(bool(value)); connect(chkbox, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool))); w = chkbox; break; case 1: knob = new Knob(this); knob->setFixedSize(32, 32); knob->setStyle(dlgPreferences()->getStyledWidgets()? m_dialStyle : NULL); knob->setMinimum(minValue); knob->setMaximum(maxValue); knob->setValue(value); knob->setToolTip(QString::number(value)); knob->setDefaultValue(defValue); knob->setDialMode(Knob::LinearMode); connect(knob, SIGNAL(sliderMoved(int)), SLOT(slotExtraController(int))); w = knob; break; case 2: spin = new QSpinBox(this); spin->setMinimum(minValue); spin->setMaximum(maxValue); spin->setValue(value); connect(spin, SIGNAL(valueChanged(int)), SLOT(slotExtraController(int))); w = spin; break; case 3: slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); slider->setFixedWidth(size); slider->setMinimum(minValue); slider->setMaximum(maxValue); slider->setToolTip(QString::number(value)); slider->setValue(value); connect(slider, SIGNAL(sliderMoved(int)), SLOT(slotExtraController(int))); w = slider; break; case 4: button = new QToolButton(this); button->setText(lbl); button->setProperty(MIDICTLONVALUE, maxValue); button->setProperty(MIDICTLOFFVALUE, minValue); connect(button, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool))); w = button; break; case 5: control = 255; button = new QToolButton(this); button->setText(lbl); button->setProperty(SYSEXFILENAME, fileName); button->setProperty(SYSEXFILEDATA, readSysexDataFile(fileName)); connect(button, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool))); w = button; break; default: w = NULL; } if (w != NULL) { if (!lbl.isEmpty() && type < 4) { QLabel *qlbl = new QLabel(lbl, this); qlbl->setMargin(TOOLBARLABELMARGIN); ui.toolBarExtra->addWidget(qlbl); //connect(qlbl, SIGNAL(destroyed(QObject*)), SLOT(slotDebugDestroyed(QObject*))); } w->setProperty(MIDICTLNUMBER, control); w->setFocusPolicy(Qt::NoFocus); ui.toolBarExtra->addWidget(w); //connect(w, SIGNAL(destroyed(QObject*)), SLOT(slotDebugDestroyed(QObject*))); } }