int main(int argc, char **argv) { QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); QWidget *container = QWidget::createWindowContainer(graph); QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("Interpolation")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Mode")); QRadioButton *InitPlotModelRB = new QRadioButton(widget); InitPlotModelRB->setText(QStringLiteral("Initial plot")); InitPlotModelRB->setChecked(false); QRadioButton *InterpModelRB = new QRadioButton(widget); InterpModelRB->setText(QStringLiteral("Interpolating plot")); InterpModelRB->setChecked(false); QRadioButton *InitInterpModelRB = new QRadioButton(widget); InitInterpModelRB->setText(QStringLiteral("Initial and Interpolating plots")); InitInterpModelRB->setChecked(false); QRadioButton *ResidModelRB = new QRadioButton(widget); ResidModelRB->setText(QStringLiteral("Residual norm plot")); ResidModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; modelVBox->addWidget(InitPlotModelRB); modelVBox->addWidget(InterpModelRB); modelVBox->addWidget(InitInterpModelRB); modelVBox->addWidget(ResidModelRB); modelGroupBox->setLayout(modelVBox); QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget); axisMinSliderX->setMinimum(0); axisMinSliderX->setTickInterval(1); axisMinSliderX->setEnabled(true); QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget); axisMaxSliderX->setMinimum(1); axisMaxSliderX->setTickInterval(1); axisMaxSliderX->setEnabled(true); QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget); axisMinSliderZ->setMinimum(0); axisMinSliderZ->setTickInterval(1); axisMinSliderZ->setEnabled(true); QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget); axisMaxSliderZ->setMinimum(1); axisMaxSliderZ->setTickInterval(1); axisMaxSliderZ->setEnabled(true); QLabel *countN = new QLabel(widget); QLabel *countM = new QLabel(widget); vLayout->addWidget(modelGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Column range"))); vLayout->addWidget(axisMinSliderX); vLayout->addWidget(axisMaxSliderX); vLayout->addWidget(new QLabel(QStringLiteral("Row range"))); vLayout->addWidget(axisMinSliderZ); vLayout->addWidget(axisMaxSliderZ); vLayout->addWidget(new QLabel(QStringLiteral("Points at X axis"))); vLayout->addWidget(countN); vLayout->addWidget(new QLabel(QStringLiteral("Points at Z axis"))); vLayout->addWidget(countM); vLayout->addWidget(new QLabel(QStringLiteral("Press 1 to change the plot\n" "Press 2 to increase number of points at X axis\n" "Press 3 to decrease number of points at X axis\n" "Press 4 to increase number of points at Z axis\n" "Press 5 to decrease number of points at Z axis"))); widget->show(); SurfaceGraph *modifier = new SurfaceGraph(graph); modifier->key1 = new QShortcut(widget); modifier->key1->setKey(Qt::Key_1); QObject::connect(modifier->key1, SIGNAL(activated()), modifier, SLOT(slotShortcut1())); modifier->key2 = new QShortcut(widget); modifier->key2->setKey(Qt::Key_2); QObject::connect(modifier->key2, SIGNAL(activated()), modifier, SLOT(slotShortcut2())); modifier->key3 = new QShortcut(widget); modifier->key3->setKey(Qt::Key_3); QObject::connect(modifier->key3, SIGNAL(activated()), modifier, SLOT(slotShortcut3())); modifier->key4 = new QShortcut(widget); modifier->key4->setKey(Qt::Key_4); QObject::connect(modifier->key4, SIGNAL(activated()), modifier, SLOT(slotShortcut4())); modifier->key5 = new QShortcut(widget); modifier->key5->setKey(Qt::Key_5); QObject::connect(modifier->key5, SIGNAL(activated()), modifier, SLOT(slotShortcut5())); QObject::connect(InitPlotModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitPlotModel); QObject::connect(InterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInterpModel); QObject::connect(InitInterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitInterpModel); QObject::connect(ResidModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableResidModel); QObject::connect(axisMinSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMin); QObject::connect(axisMaxSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMax); QObject::connect(axisMinSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMin); QObject::connect(axisMaxSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMax); modifier->setAxisMinSliderX(axisMinSliderX); modifier->setAxisMaxSliderX(axisMaxSliderX); modifier->setAxisMinSliderZ(axisMinSliderZ); modifier->setAxisMaxSliderZ(axisMaxSliderZ); InitPlotModelRB->setChecked(true); modifier->setCount(countN, countM); modifier->setMode(InitPlotModelRB, InterpModelRB, InitInterpModelRB, ResidModelRB); return app.exec(); }
// scale and adjust the upper slider group void TriangleDensityWidget::resetSliders(double norm) { TriangleList triangles = triangleScene->triangles(); int n = 0; foreach (Triangle* t, triangles) { QSlider* sl = sliders[n]; QLabel* la = slider_names[n]; sl->blockSignals(true); sl->setSliderPosition((int)( t->xform()->density / norm * 1000. )); sl->blockSignals(false); sl->setVisible(true); la->setVisible(true); sl->setToolTip(triangleScene->getInfoLabel(t)); if (genome_ptr->final_xform_enable && genome_ptr->final_xform_index == n) { sl->setEnabled(false); la->setEnabled(false); } else { sl->setEnabled(true); la->setEnabled(true); } n++; }
QWidget* createWidgets(BasePropertyWidget* parent) { m_slider = new QSlider(parent); m_slider->setOrientation(Qt::Horizontal); m_slider->setEnabled(!parent->readOnly()); QObject::connect(m_slider, &QSlider::valueChanged, parent, &BasePropertyWidget::setWidgetDirty); auto rangeMeta = parent->property()->getMeta<meta::RangeWithStep<value_type>>(); float minVal = 0, maxVal = 100, step = 1; if (rangeMeta) { minVal = rangeMeta->min; maxVal = rangeMeta->max; step = rangeMeta->step; } m_scale = 1 / step; m_offset = -minVal * m_scale; float range = maxVal - minVal; int intRange = static_cast<int>(range * m_scale); m_slider->setMinimum(0); m_slider->setMaximum(intRange); return m_slider; }
void MediaView::startPlaying() { // qDebug() << __PRETTY_FUNCTION__; if (stopped) return; if (!downloadItem) { skip(); return; } if (downloadItem->offset() == 0) { currentVideoSize = downloadItem->bytesTotal(); // qDebug() << "currentVideoSize" << currentVideoSize; } // go! QString source = downloadItem->currentFilename(); qDebug() << "Playing" << source << QFile::exists(source); #ifdef APP_PHONON mediaObject->setCurrentSource(QUrl::fromLocalFile(source)); mediaObject->play(); #endif #ifdef APP_PHONON_SEEK MainWindow::instance()->getSeekSlider()->setEnabled(false); #else QSlider *slider = MainWindow::instance()->getSlider(); slider->setEnabled(true); #endif }
void AbstractCameraManager::on_propertyCheckbox_changed(int state) { if( selectedItem == NULL ) return; CameraProperty* prop = reinterpret_cast<CameraProperty*>( sender()->property("CameraProperty").value<quintptr>() ); qDebug() << sender() << prop->getName().c_str(); prop->setAuto(state == Qt::Checked); cameraTree_recursiveSetProperty(selectedItem, prop); //(de)activate slider if( prop->getType() == CameraManager::AUTOTRIGGER ) return; QSlider* slider = reinterpret_cast<QSlider*>( sender()->property("TreeWidgetSlider").value<quintptr>() ); qDebug() << "Qslider" << slider; if(state != Qt::Checked) { slider->setEnabled(true); slider->setValue(prop->getValueToSlider()); } else { slider->setEnabled(false); } }
void MediaView::stop() { stopped = true; while (!history.isEmpty()) { VideoSource *videoSource = history.takeFirst(); if (!videoSource->parent()) delete videoSource; } playlistModel->abortSearch(); videoAreaWidget->clear(); videoAreaWidget->update(); errorTimer->stop(); playlistView->selectionModel()->clearSelection(); if (downloadItem) { downloadItem->stop(); delete downloadItem; downloadItem = 0; currentVideoSize = 0; } The::globalActions()->value("refine-search")->setChecked(false); updateSubscriptionAction(0, false); #ifdef APP_ACTIVATION demoTimer->stop(); #endif foreach (QAction *action, currentVideoActions) action->setEnabled(false); QAction *a = The::globalActions()->value("download"); a->setEnabled(false); a->setVisible(false); #ifdef APP_PHONON mediaObject->stop(); #endif currentVideoId.clear(); #ifndef APP_PHONON_SEEK QSlider *slider = MainWindow::instance()->getSlider(); slider->setEnabled(false); slider->setValue(0); #else Phonon::SeekSlider *slider = MainWindow::instance()->getSeekSlider(); #endif if (snapshotSettings) { delete snapshotSettings; snapshotSettings = 0; } }
void AbstractCameraManager::updateProperties() { AbstractCamera* selected = selectedCamera; if( selected == NULL ) return ; for( int i = propertiesList.topLevelItemCount()-1; i>=0; i--) { QTreeWidgetItem* item = propertiesList.topLevelItem(i); QCheckBox* checkBox = qobject_cast<QCheckBox*>( propertiesList.itemWidget(item, Ui::PropertyAuto) ); CameraManager::CameraProperty * prop = reinterpret_cast<CameraManager::CameraProperty*>( checkBox->property("CameraProperty").value<quintptr>() ); QSlider* slider = reinterpret_cast<QSlider*>( checkBox->property("TreeWidgetSlider").value<quintptr>() ); //qDebug() << "updating:" << prop->getName().c_str(); selected->updateProperty(prop); item->setText(Ui::PropertyValue, prop->formatValue() ); checkBox->setChecked(prop->getAuto()); if( prop->getType() == CameraManager::AUTOTRIGGER ) continue; slider->setValue(prop->getValueToSlider()); slider->setEnabled(!prop->getAuto()); } }
void GNURadioGui::displaySettings() { int oldIndex = 0; oldIndex = ui->cboDevices->currentIndex(); ui->cboDevices->clear(); QString oldArgs = ui->txtDeviceArgs->text(); osmosdr::devices_t devices = osmosdr::device::find(); for ( uint i = 0; i < devices.size(); i++ ) { osmosdr::device_t dev = devices[i]; QString label; if ( dev.count( "label" ) ) { label = QString(dev[ "label" ].c_str()); dev.erase("label"); } QPair< QString, QString > pair(label, dev.to_string().c_str()); m_devs.append(pair); ui->cboDevices->addItem(label); } if ( ui->cboDevices->count() && oldIndex >= 0 ) { if ( oldIndex > ui->cboDevices->count() - 1 ) oldIndex = 0; ui->cboDevices->setCurrentIndex(oldIndex); if ( oldArgs.length() == 0 ) ui->txtDeviceArgs->setText( m_devs[oldIndex].second ); } if ( oldArgs.length() ) ui->txtDeviceArgs->setText( oldArgs ); ui->centerFrequency->setValueRange(7, unsigned(m_freqMin / 1000.0), unsigned(m_freqMax / 1000.0)); ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000); ui->sldFreqCorr->setRange(-100, +100); ui->sldFreqCorr->setValue( m_freqCorr ); ui->lblFreqCorr->setText(tr("%1").arg(ui->sldFreqCorr->value())); m_gainControls.clear(); QVBoxLayout *layoutGains = ui->verticalLayoutGains; QLayoutItem *layoutItem; while ( ( layoutItem = layoutGains->takeAt( 0 ) ) != NULL ) { QLayout *layout = layoutItem->layout(); if ( !layout ) continue; while ( ( layoutItem = layout->takeAt( 0 ) ) != NULL ) { delete layoutItem->widget(); delete layoutItem; } delete layout; } for ( uint i = 0; i < m_namedGains.size(); i++ ) { std::pair< QString, std::vector<double> > pair = m_namedGains[i]; QHBoxLayout *layout = new QHBoxLayout(); QLabel *gainName = new QLabel( pair.first + " Gain" ); QSlider *gainSlider = new QSlider(Qt::Horizontal); QLabel *gainLabel = new QLabel("0"); gainLabel->setMinimumWidth(30); gainLabel->setAlignment(Qt::AlignHCenter | Qt::AlignHCenter); QPair< QSlider*, QLabel* > pair2( gainSlider, gainLabel ); m_gainControls.push_back( pair2 ); connect(gainSlider, SIGNAL(valueChanged(int)), this, SLOT(on_sldGain_valueChanged(int))); layout->addWidget(gainName); layout->addWidget(gainSlider); layout->addWidget(gainLabel); layoutGains->addLayout(layout); std::vector<double> gain_values = pair.second; if ( gain_values.size() ) { gainSlider->setRange(0, gain_values.size() - 1); gainSlider->setValue(gain_values.size() / 4); gainSlider->setEnabled(true); } else { gainSlider->setEnabled(false); } } oldIndex = ui->cboSampleRate->currentIndex(); ui->cboSampleRate->clear(); for ( uint i = 0; i < m_sampRates.size(); i++ ) ui->cboSampleRate->addItem( QString::number(m_sampRates[i] / 1e6) ); if ( oldIndex > ui->cboSampleRate->count() - 1 ) oldIndex = 0; if ( ui->cboSampleRate->count() && oldIndex >= 0 ) ui->cboSampleRate->setCurrentIndex(oldIndex); if ( ui->cboSampleRate->count() ) { ui->cboSampleRate->setEnabled(true); } else { ui->cboSampleRate->setEnabled(false); } oldIndex = ui->cboAntennas->currentIndex(); ui->cboAntennas->clear(); if ( m_antennas.size() ) { for ( uint i = 0; i < m_antennas.size(); i++ ) ui->cboAntennas->addItem( m_antennas[i] ); if ( oldIndex > ui->cboAntennas->count() - 1 ) oldIndex = 0; if ( ui->cboAntennas->count() && oldIndex >= 0 ) ui->cboAntennas->setCurrentIndex(oldIndex); ui->cboAntennas->setEnabled(true); } else { ui->cboAntennas->setEnabled(false); } oldIndex = ui->cboDCOffset->currentIndex(); ui->cboDCOffset->clear(); if ( m_dcoffs.size() ) { for ( uint i = 0; i < m_dcoffs.size(); i++ ) ui->cboDCOffset->addItem( m_dcoffs[i] ); if ( ui->cboDCOffset->count() && oldIndex >= 0 ) ui->cboDCOffset->setCurrentIndex(oldIndex); ui->cboDCOffset->setEnabled(true); } else { ui->cboDCOffset->setEnabled(false); } oldIndex = ui->cboIQBalance->currentIndex(); ui->cboIQBalance->clear(); if ( m_iqbals.size() ) { for ( uint i = 0; i < m_iqbals.size(); i++ ) ui->cboIQBalance->addItem( m_iqbals[i] ); if ( ui->cboIQBalance->count() && oldIndex >= 0 ) ui->cboIQBalance->setCurrentIndex(oldIndex); ui->cboIQBalance->setEnabled(true); } else { ui->cboIQBalance->setEnabled(false); } oldIndex = ui->cboBandwidth->currentIndex(); ui->cboBandwidth->clear(); for ( uint i = 0; i < m_bandwidths.size(); i++ ) if ( 0.0 == m_bandwidths[i] ) ui->cboBandwidth->addItem( "Auto" ); else ui->cboBandwidth->addItem( QString::number(m_bandwidths[i] / 1e6) ); if ( oldIndex > ui->cboBandwidth->count() - 1 ) oldIndex = 0; if ( ui->cboBandwidth->count() && oldIndex >= 0 ) ui->cboBandwidth->setCurrentIndex(oldIndex); if ( ui->cboBandwidth->count() ) { ui->cboBandwidth->setEnabled(true); } else { ui->cboBandwidth->setEnabled(false); } }
int main(int argc, char **argv) { //! [0] QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); return -1; } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); //! [1] QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); //! [1] widget->setWindowTitle(QStringLiteral("Surface example")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Model")); QRadioButton *sqrtSinModelRB = new QRadioButton(widget); sqrtSinModelRB->setText(QStringLiteral("Sqrt && Sin")); sqrtSinModelRB->setChecked(false); QRadioButton *heightMapModelRB = new QRadioButton(widget); heightMapModelRB->setText(QStringLiteral("Height Map")); heightMapModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; modelVBox->addWidget(sqrtSinModelRB); modelVBox->addWidget(heightMapModelRB); modelGroupBox->setLayout(modelVBox); QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode")); QRadioButton *modeNoneRB = new QRadioButton(widget); modeNoneRB->setText(QStringLiteral("No selection")); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(widget); modeItemRB->setText(QStringLiteral("Item")); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(widget); modeSliceRowRB->setText(QStringLiteral("Row Slice")); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(widget); modeSliceColumnRB->setText(QStringLiteral("Column Slice")); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; selectionVBox->addWidget(modeNoneRB); selectionVBox->addWidget(modeItemRB); selectionVBox->addWidget(modeSliceRowRB); selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget); axisMinSliderX->setMinimum(0); axisMinSliderX->setTickInterval(1); axisMinSliderX->setEnabled(true); QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget); axisMaxSliderX->setMinimum(1); axisMaxSliderX->setTickInterval(1); axisMaxSliderX->setEnabled(true); QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget); axisMinSliderZ->setMinimum(0); axisMinSliderZ->setTickInterval(1); axisMinSliderZ->setEnabled(true); QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget); axisMaxSliderZ->setMinimum(1); axisMaxSliderZ->setTickInterval(1); axisMaxSliderZ->setEnabled(true); QComboBox *themeList = new QComboBox(widget); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient")); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.0, Qt::black); grBtoY.setColorAt(0.67, Qt::blue); grBtoY.setColorAt(0.33, Qt::red); grBtoY.setColorAt(0.0, Qt::yellow); QPixmap pm(24, 100); QPainter pmp(&pm); pmp.setBrush(QBrush(grBtoY)); pmp.setPen(Qt::NoPen); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientBtoYPB = new QPushButton(widget); gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(24, 100)); QLinearGradient grGtoR(0, 0, 1, 100); grGtoR.setColorAt(1.0, Qt::darkGreen); grGtoR.setColorAt(0.5, Qt::yellow); grGtoR.setColorAt(0.2, Qt::red); grGtoR.setColorAt(0.0, Qt::darkRed); pmp.setBrush(QBrush(grGtoR)); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientGtoRPB = new QPushButton(widget); gradientGtoRPB->setIcon(QIcon(pm)); gradientGtoRPB->setIconSize(QSize(24, 100)); QHBoxLayout *colorHBox = new QHBoxLayout; colorHBox->addWidget(gradientBtoYPB); colorHBox->addWidget(gradientGtoRPB); colorGroupBox->setLayout(colorHBox); vLayout->addWidget(modelGroupBox); vLayout->addWidget(selectionGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Column range"))); vLayout->addWidget(axisMinSliderX); vLayout->addWidget(axisMaxSliderX); vLayout->addWidget(new QLabel(QStringLiteral("Row range"))); vLayout->addWidget(axisMinSliderZ); vLayout->addWidget(axisMaxSliderZ); vLayout->addWidget(new QLabel(QStringLiteral("Theme"))); vLayout->addWidget(themeList); vLayout->addWidget(colorGroupBox); widget->show(); SurfaceGraph *modifier = new SurfaceGraph(graph); QObject::connect(heightMapModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableHeightMapModel); QObject::connect(sqrtSinModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableSqrtSinModel); QObject::connect(modeNoneRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeNone); QObject::connect(modeItemRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeItem); QObject::connect(modeSliceRowRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeSliceRow); QObject::connect(modeSliceColumnRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeSliceColumn); QObject::connect(axisMinSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMin); QObject::connect(axisMaxSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMax); QObject::connect(axisMinSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMin); QObject::connect(axisMaxSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMax); QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeTheme(int))); QObject::connect(gradientBtoYPB, &QPushButton::pressed, modifier, &SurfaceGraph::setBlackToYellowGradient); QObject::connect(gradientGtoRPB, &QPushButton::pressed, modifier, &SurfaceGraph::setGreenToRedGradient); modifier->setAxisMinSliderX(axisMinSliderX); modifier->setAxisMaxSliderX(axisMaxSliderX); modifier->setAxisMinSliderZ(axisMinSliderZ); modifier->setAxisMaxSliderZ(axisMaxSliderZ); sqrtSinModelRB->setChecked(true); modeItemRB->setChecked(true); themeList->setCurrentIndex(2); return app.exec(); }
scannerwindow::scannerwindow(QList<int> parameters, QMainWindow *parent, bool load, QTextStream* stream): QObject(parent) { this->parameters=parameters; widget = new QWidget(); widget->setAttribute(Qt::WA_DeleteOnClose); graph = new Q3DSurface(); container = QWidget::createWindowContainer(graph, widget); container->setAttribute(Qt::WA_AcceptTouchEvents); widget->setGeometry( QStyle::alignedRect( Qt::LeftToRight, Qt::AlignTop, widget->size(), qApp->desktop()->availableGeometry() ) ); bitmapForward=new QCustomPlot(widget); bitmapBackward=new QCustomPlot(widget); bitmapCombined=new QCustomPlot(widget); bitmapForward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapCombined->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapForward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapCombined->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); initializeBitmapForward(bitmapForward); initializeBitmapBackward(bitmapBackward); initializeBitmapCombined(bitmapCombined); if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 3, screenSize.height()/4)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); bitmapBackward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapForward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapCombined->setMinimumSize(screenSize.width()/4, screenSize.height()/4); QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); QSplitter *hSplitterMain = new QSplitter(); QSplitter *vSplitterRight = new QSplitter(); hLayout->setSizeConstraint(QBoxLayout::SizeConstraint::SetMinimumSize); vSplitterRight->addWidget(bitmapForward); vSplitterRight->addWidget(bitmapBackward); vSplitterRight->addWidget(bitmapCombined); vSplitterRight->setOrientation(Qt::Orientation::Vertical); vSplitterRight->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); hSplitterMain->setOrientation(Qt::Orientation::Horizontal); hSplitterMain->addWidget(container); hSplitterMain->addWidget(vSplitterRight); hSplitterMain->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); vSplitterRight->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); hLayout->addWidget(hSplitterMain); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("AFM Scan")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Scan")); if(!load){ AFM_Scan_3D_RB = new QPushButton(widget); AFM_Scan_3D_RB->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); AFM_Scan_3D_RB->setText(QStringLiteral("Start Scan")); AFM_Scan_3D_RB->setCheckable(true); AFM_Scan_3D_RB->setChecked(false); } SaveSurface = new QPushButton(widget); SaveSurface->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); SaveSurface->setText(QStringLiteral("Save Data")); BitmapView = new QPushButton(widget); BitmapView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); BitmapView->setText(QStringLiteral("Save BMP")); QVBoxLayout *modelVBox = new QVBoxLayout; if(!load){ modelVBox->addWidget(AFM_Scan_3D_RB); } modelVBox->addWidget(BitmapView); modelVBox->addWidget(SaveSurface); modelGroupBox->setLayout(modelVBox); QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode")); selectionGroupBox->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); QCheckBox *piezoMove = new QCheckBox(widget); piezoMove->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); piezoMove->setText(QStringLiteral("Piezo")); piezoMove->setChecked(true); modelVBox->addWidget(piezoMove); QRadioButton *modeNoneRB = new QRadioButton(widget); modeNoneRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeNoneRB->setText(QStringLiteral("No selection")); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(widget); modeItemRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeItemRB->setText(QStringLiteral("Item")); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(widget); modeSliceRowRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceRowRB->setText(QStringLiteral("Row Slice")); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(widget); modeSliceColumnRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceColumnRB->setText(QStringLiteral("Column Slice")); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; selectionVBox->addWidget(modeNoneRB); selectionVBox->addWidget(modeItemRB); selectionVBox->addWidget(modeSliceRowRB); selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); QSlider *axisCameraSliderZ = new QSlider(Qt::Horizontal, widget); axisCameraSliderZ->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderZ->setMinimum(0); axisCameraSliderZ->setMaximum(179); axisCameraSliderZ->setTickInterval(1); axisCameraSliderZ->setEnabled(true); QSlider *axisCameraSliderY = new QSlider(Qt::Horizontal, widget); axisCameraSliderY->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderY->setMinimum(0); axisCameraSliderY->setMaximum(180); axisCameraSliderY->setTickInterval(0); axisCameraSliderY->setEnabled(true); QComboBox *themeList = new QComboBox(widget); themeList->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient")); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.0, Qt::black); grBtoY.setColorAt(0.67, Qt::blue); grBtoY.setColorAt(0.33, Qt::red); grBtoY.setColorAt(0.0, Qt::yellow); QPixmap pm(24, 100); QPainter pmp(&pm); pmp.setBrush(QBrush(grBtoY)); pmp.setPen(Qt::NoPen); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientBtoYPB = new QPushButton(widget); gradientBtoYPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(24, 100)); QLinearGradient grGtoR(0, 0, 1, 100); grGtoR.setColorAt(1.0, Qt::darkGreen); grGtoR.setColorAt(0.5, Qt::yellow); grGtoR.setColorAt(0.2, Qt::red); grGtoR.setColorAt(0.0, Qt::darkRed); pmp.setBrush(QBrush(grGtoR)); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientGtoRPB = new QPushButton(widget); gradientGtoRPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientGtoRPB->setIcon(QIcon(pm)); gradientGtoRPB->setIconSize(QSize(24, 100)); QHBoxLayout *colorHBox = new QHBoxLayout; colorHBox->addWidget(gradientBtoYPB); colorHBox->addWidget(gradientGtoRPB); colorGroupBox->setLayout(colorHBox); vLayout->addWidget(modelGroupBox); vLayout->addWidget(selectionGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Camera Position"))); vLayout->addWidget(axisCameraSliderZ); vLayout->addWidget(axisCameraSliderY); vLayout->addWidget(new QLabel(QStringLiteral("Theme"))); vLayout->addWidget(themeList); vLayout->addWidget(colorGroupBox); widget->show(); modifier= new SurfaceGraph(graph, widget,parameters); if(!load){ QObject::connect(parent, SIGNAL(plotDataReceived(QList <QByteArray>)), modifier, SLOT(dataHandler(QList <QByteArray>))); QObject::connect(AFM_Scan_3D_RB, SIGNAL (toggled(bool)), this, SLOT(AFMButtonHandler(bool))); QObject::connect(this, SIGNAL (AFMStart()), modifier, SLOT (enableAFMModel())); QObject::connect(this, SIGNAL (AFMDone()), parent, SLOT (sendDone())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT (sendGo())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT(sendReady()));}
void MediaView::activeRowChanged(int row) { if (stopped) return; errorTimer->stop(); #ifdef APP_PHONON mediaObject->stop(); #endif if (downloadItem) { downloadItem->stop(); delete downloadItem; downloadItem = 0; currentVideoSize = 0; } Video *video = playlistModel->videoAt(row); if (!video) return; videoAreaWidget->showLoading(video); connect(video, SIGNAL(gotStreamUrl(QUrl)), SLOT(gotStreamUrl(QUrl)), Qt::UniqueConnection); connect(video, SIGNAL(errorStreamUrl(QString)), SLOT(skip()), Qt::UniqueConnection); video->loadStreamUrl(); // video title in titlebar MainWindow::instance()->setWindowTitle(video->title() + " - " + Constants::NAME); // ensure active item is visible if (row != -1) { QModelIndex index = playlistModel->index(row, 0, QModelIndex()); playlistView->scrollTo(index, QAbstractItemView::EnsureVisible); } // enable/disable actions The::globalActions()->value("download")->setEnabled( DownloadManager::instance()->itemForVideo(video) == 0); The::globalActions()->value("previous")->setEnabled(row > 0); The::globalActions()->value("stopafterthis")->setEnabled(true); The::globalActions()->value("related-videos")->setEnabled(true); bool enableDownload = video->license() == Video::LicenseCC; #ifdef APP_ACTIVATION enableDownload = enableDownload || Activation::instance().isLegacy(); #endif #ifdef APP_DOWNLOADS enableDownload = true; #endif QAction *a = The::globalActions()->value("download"); a->setEnabled(enableDownload); a->setVisible(enableDownload); updateSubscriptionAction(video, YTChannel::isSubscribed(video->channelId())); foreach (QAction *action, currentVideoActions) action->setEnabled(true); #ifndef APP_PHONON_SEEK QSlider *slider = MainWindow::instance()->getSlider(); slider->setEnabled(false); slider->setValue(0); #endif if (snapshotSettings) { delete snapshotSettings; snapshotSettings = 0; MainWindow::instance()->adjustStatusBarVisibility(); } // see you in gotStreamUrl... }
int main(int argc, char **argv) { //! [0] QApplication app(argc, argv); Q3DScatter *graph = new Q3DScatter(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("A Galaxy")); QSlider *radiusGalaxySlider = new QSlider(Qt::Horizontal, widget); radiusGalaxySlider->setMinimum(1000); radiusGalaxySlider->setMaximum(40000); radiusGalaxySlider->setValue(15000); radiusGalaxySlider->setEnabled(true); QSlider *radiusCoreSlider = new QSlider(Qt::Horizontal, widget); radiusCoreSlider->setMinimum(1000); radiusCoreSlider->setMaximum(30000); radiusCoreSlider->setValue(4000); radiusCoreSlider->setEnabled(true); QSlider *angleOffsetSlider = new QSlider(Qt::Horizontal, widget); angleOffsetSlider->setMinimum(10); angleOffsetSlider->setMaximum(70); angleOffsetSlider->setValue(40); angleOffsetSlider->setEnabled(true); QSlider *eccentricityInnerSlider = new QSlider(Qt::Horizontal, widget); eccentricityInnerSlider->setMinimum(10); eccentricityInnerSlider->setMaximum(200); eccentricityInnerSlider->setValue(90); eccentricityInnerSlider->setEnabled(true); QSlider *eccentricityOuterSlider = new QSlider(Qt::Horizontal, widget); eccentricityOuterSlider->setMinimum(10); eccentricityOuterSlider->setMaximum(200); eccentricityOuterSlider->setValue(90); eccentricityOuterSlider->setEnabled(true); QCheckBox *staticCheckBox = new QCheckBox(widget); staticCheckBox->setText(QStringLiteral("Static")); staticCheckBox->setChecked(false); QCheckBox *starsCheckBox = new QCheckBox(widget); starsCheckBox->setText(QStringLiteral("Stars")); starsCheckBox->setChecked(true); QCheckBox *dustCheckBox = new QCheckBox(widget); dustCheckBox->setText(QStringLiteral("Dust")); dustCheckBox->setChecked(true); QCheckBox *H2CheckBox = new QCheckBox(widget); H2CheckBox->setText(QStringLiteral("H2")); H2CheckBox->setChecked(true); QPushButton *resetButton = new QPushButton(widget); resetButton->setText(QStringLiteral("Reset values")); QCheckBox *filteredCheckBox = new QCheckBox(widget); filteredCheckBox->setText(QStringLiteral("Filtered")); filteredCheckBox->setChecked(false); QLabel *fpsLabel = new QLabel(QStringLiteral("")); vLayout->addWidget(new QLabel(QStringLiteral("Galaxy radius"))); vLayout->addWidget(radiusGalaxySlider); vLayout->addWidget(new QLabel(QStringLiteral("Core radius"))); vLayout->addWidget(radiusCoreSlider); vLayout->addWidget(new QLabel(QStringLiteral("Angle offset"))); vLayout->addWidget(angleOffsetSlider); vLayout->addWidget(new QLabel(QStringLiteral("Eccentricity inner"))); vLayout->addWidget(eccentricityInnerSlider); vLayout->addWidget(new QLabel(QStringLiteral("Eccentricity outer"))); vLayout->addWidget(eccentricityOuterSlider); vLayout->addWidget(staticCheckBox); vLayout->addWidget(starsCheckBox); vLayout->addWidget(dustCheckBox); vLayout->addWidget(H2CheckBox); vLayout->addWidget(resetButton); vLayout->addWidget(filteredCheckBox); vLayout->addWidget(fpsLabel); GalaxyData *modifier = new GalaxyData(graph); QObject::connect(radiusGalaxySlider, &QSlider::valueChanged, modifier, &GalaxyData::radiusGalaxyChanged); QObject::connect(radiusCoreSlider, &QSlider::valueChanged, modifier, &GalaxyData::radiusCoreChanged); QObject::connect(angleOffsetSlider, &QSlider::valueChanged, modifier, &GalaxyData::angleOffsetChanged); QObject::connect(eccentricityInnerSlider, &QSlider::valueChanged, modifier, &GalaxyData::eccentricityInnerChanged); QObject::connect(eccentricityOuterSlider, &QSlider::valueChanged, modifier, &GalaxyData::eccentricityOuterChanged); QObject::connect(resetButton, &QPushButton::clicked, modifier, &GalaxyData::resetValues); QObject::connect(filteredCheckBox, &QCheckBox::stateChanged, modifier, &GalaxyData::setFilteredEnabled); QObject::connect(staticCheckBox, &QCheckBox::stateChanged, modifier, &GalaxyData::setStaticEnabled); QObject::connect(starsCheckBox, &QCheckBox::stateChanged, modifier, &GalaxyData::setStarsVisible); QObject::connect(dustCheckBox, &QCheckBox::stateChanged, modifier, &GalaxyData::setDustVisible); QObject::connect(H2CheckBox, &QCheckBox::stateChanged, modifier, &GalaxyData::setH2Visible); modifier->setSliders(radiusGalaxySlider, radiusCoreSlider, angleOffsetSlider, eccentricityInnerSlider, eccentricityOuterSlider); modifier->setFpsLabel(fpsLabel); widget->show(); return app.exec(); }