FreqView::FreqView(int viewID_, QWidget *parent) : ViewWidget(viewID_, parent) { View *view = gdata->view; //setCaption("Frequency View"); Q3BoxLayout *mainLayout = new Q3VBoxLayout(this); mainLayout->setResizeMode(QLayout::SetNoConstraint); //QBoxLayout *topLayout = new QVBoxLayout(mainLayout); //QBoxLayout *rightLayout = new QVBoxLayout(mainLayout); //QBoxLayout *bottomLayout = new QHBoxLayout(mainLayout); QSplitter *splitter = new QSplitter(Qt::Vertical, this); QWidget *topWidget = new QWidget(splitter); //topSplitter->setOpaqueResize(true); Q3BoxLayout *topLayout = new Q3HBoxLayout(topWidget); Q3BoxLayout *topLeftLayout = new Q3VBoxLayout(topLayout); timeAxis = new TimeAxis(topWidget, gdata->leftTime(), gdata->rightTime(), true); timeAxis->setWhatsThis("The time in seconds"); topLeftLayout->addWidget(timeAxis); /* Q3Grid *freqFrame = new Q3Grid(1, topWidget); freqFrame->setFrameStyle(Q3Frame::WinPanel | Q3Frame::Sunken); //freqDrawWidget = new FreqDrawWidget(freqFrame); //freqDrawWidget->setFocusPolicy(Qt::NoFocus); freqWidgetGL = new FreqWidgetGL(freqFrame); freqWidgetGL->setFocusPolicy(Qt::NoFocus); topLeftLayout->addWidget(freqFrame); */ QFrame *freqFrame = new QFrame; freqFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); QVBoxLayout *freqFrameLayout = new QVBoxLayout; freqWidgetGL = new FreqWidgetGL(NULL); freqWidgetGL->setWhatsThis("The line represents the musical pitch of the sound. A higher pitch moves up, with note names shown at the left, with octave numbers. " "The black vertical line shows the current time. This line's position can be moved. " "Pitch-lines are drawn connected only because they change a small amount over a small time step. " "Note: This may cause semi-tone note changes appear to be joined. Clicking the background and dragging moves the view. " "Clicking a pitch-line selects it. Mouse-Wheel scrolls. Shift-Mouse-Wheel zooms"); //freqWidgetGL = new FreqDrawWidget(NULL); freqFrameLayout->addWidget(freqWidgetGL); freqFrameLayout->setMargin(0); freqFrameLayout->setSpacing(0); freqFrame->setLayout(freqFrameLayout); topLeftLayout->addWidget(freqFrame); //Q3BoxLayout *topRightLayout = new Q3VBoxLayout(topLayout); QVBoxLayout *topRightLayout = new QVBoxLayout(); freqWheelY = new QwtWheel(topWidget); freqWheelY->setOrientation(Qt::Vertical); freqWheelY->setWheelWidth(14); freqWheelY->setRange(1.6, 5.0, 0.001, 1); //freqWheelY->setValue(3.2); //view->setZoomFactorY(3.2); freqWheelY->setValue(view->logZoomY()); QToolTip::add(freqWheelY, "Zoom pitch contour view vertically"); topRightLayout->addSpacing(20); topRightLayout->addWidget(freqWheelY, 0); //Create the vertical scrollbar //vScrollBar = new MyScrollBar(0, toInt((view->topNote()-view->viewHeight())*view->stepY()), 20, toInt(view->viewHeight()*view->stepY()), toInt(view->viewBottom()*view->stepY()), Qt::Vertical, this); //vScrollBar = new MyScrollBar(0, gdata->topNote()-view->viewHeight(), 20, view->viewHeight(), view->viewBottom(), 20, Qt::Vertical, this); freqScrollBar = new MyScrollBar(0, gdata->topPitch()-view->viewHeight(), 0.5, view->viewHeight(), 0, 20, Qt::Vertical, topWidget); freqScrollBar->setValue(gdata->topPitch()-view->viewHeight()-view->viewBottom()); topRightLayout->addWidget(freqScrollBar, 4); topLayout->addLayout(topRightLayout); /* QPushButton *buttonPlusY = new QPushButton("+", topSplitter); buttonPlusY->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); buttonPlusY->setFixedSize(15, 15); QToolTip::add(buttonPlusY, "Zoom in vertically"); QPushButton *buttonMinusY = new QPushButton("-", topSplitter); buttonMinusY->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); buttonMinusY->setFixedSize(15, 15); QToolTip::add(buttonMinusY, "Zoom out vertically"); */ //------------bottom half------------------ QWidget *bottomWidget = new QWidget(splitter); Q3BoxLayout *bottomLayout = new Q3VBoxLayout(bottomWidget); Q3BoxLayout *bottomTopLayout = new Q3HBoxLayout(bottomLayout); /* Q3Grid *amplitudeFrame = new Q3Grid(1, bottomWidget); amplitudeFrame->setFrameStyle(Q3Frame::WinPanel | Q3Frame::Sunken); amplitudeWidget = new AmplitudeWidget(amplitudeFrame); bottomTopLayout->addWidget(amplitudeFrame); */ QFrame *amplitudeFrame = new QFrame; amplitudeFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); QVBoxLayout *amplitudeFrameLayout = new QVBoxLayout; amplitudeWidget = new AmplitudeWidget(NULL); amplitudeWidget->setWhatsThis("Shows the volume (or other parameters) at time lined up with the pitch above. Note: You can move the lines to change some thresholds."); amplitudeFrameLayout->addWidget(amplitudeWidget); amplitudeFrameLayout->setMargin(0); amplitudeFrameLayout->setSpacing(0); amplitudeFrame->setLayout(amplitudeFrameLayout); bottomTopLayout->addWidget(amplitudeFrame); Q3BoxLayout *bottomTopRightLayout = new Q3VBoxLayout(bottomTopLayout); amplitudeWheelY = new QwtWheel(bottomWidget); amplitudeWheelY->setOrientation(Qt::Vertical); amplitudeWheelY->setWheelWidth(14); //amplitudeWheelY->setRange(30, 150, 0.1, 1); amplitudeWheelY->setRange(0.2, 1.00, 0.01, 1); amplitudeWheelY->setValue(amplitudeWidget->range()); QToolTip::add(amplitudeWheelY, "Zoom pitch contour view vertically"); bottomTopRightLayout->addWidget(amplitudeWheelY, 0); //Create the vertical scrollbar //amplitudeScrollBar = new MyScrollBar(0, 150, 20, 80, 0, 20, Qt::Vertical, bottomWidget); amplitudeScrollBar = new MyScrollBar(0.0, 1.0-amplitudeWidget->range(), 0.20, amplitudeWidget->range(), 0, 20, Qt::Vertical, bottomWidget); bottomTopRightLayout->addWidget(amplitudeScrollBar, 4); Q3BoxLayout *bottomBottomLayout = new Q3HBoxLayout(bottomLayout); /* QSpinBox *thresholdSpinBox = new QSpinBox(50, 100, 1, bottomWidget, "thresholdSpinBox"); thresholdSpinBox->setSuffix("%"); thresholdSpinBox->setFocusPolicy(Qt::NoFocus); thresholdSpinBox->setValue(gdata->getActiveIntThreshold()); QToolTip::add(thresholdSpinBox, "Threshold used in choosing the octave"); connect(thresholdSpinBox, SIGNAL(valueChanged(int)), gdata, SLOT(resetActiveIntThreshold(int))); //connect(thresholdSpinBox, SIGNAL(valueChanged(int)), freqDrawWidget, SLOT(update())); connect(thresholdSpinBox, SIGNAL(valueChanged(int)), freqWidgetGL, SLOT(update())); connect(gdata, SIGNAL(activeIntThresholdChanged(int)), thresholdSpinBox, SLOT(setValue(int))); */ QComboBox *amplitudeModeComboBox = new QComboBox(bottomWidget, "amplitudeTypeModeBox"); //static const char* amplitudeModeItems[] = { "RMS (Log)", "Peak Amplitude (Log)", "Peak Correlation", "Purity", "Changeness", 0 }; //amplitudeModeComboBox->insertStrList(amplitudeModeItems); //amplitudeModeComboBox->insertStrList(amp_mode_names, NUM_AMP_MODES); amplitudeModeComboBox->setWhatsThis("Select different algorithm parameters to view in the bottom pannel"); int j; QStringList s; for(j=0; j<NUM_AMP_MODES; j++) s << amp_mode_names[j]; amplitudeModeComboBox->addItems(s); connect(amplitudeModeComboBox, SIGNAL(activated(int)), gdata, SLOT(setAmplitudeMode(int))); connect(amplitudeModeComboBox, SIGNAL(activated(int)), amplitudeWidget, SLOT(update())); QComboBox *pitchContourModeComboBox = new QComboBox(bottomWidget, "pitchContourModeComboBox"); pitchContourModeComboBox->setWhatsThis("Select whether the Pitch Contour line fades in/out with clarity/loudness of the sound or is a solid dark line"); //static const char* pitchContourModeItems[] = { "Clarity fading", "Note grouping", 0 }; //pitchContourModeComboBox->insertStrList(pitchContourModeItems); s.clear(); s << "Clarity fading" << "Note grouping"; pitchContourModeComboBox->addItems(s); connect(pitchContourModeComboBox, SIGNAL(activated(int)), gdata, SLOT(setPitchContourMode(int))); //connect(pitchContourModeComboBox, SIGNAL(activated(int)), freqDrawWidget, SLOT(update())); connect(pitchContourModeComboBox, SIGNAL(activated(int)), freqWidgetGL, SLOT(update())); freqWheelX = new QwtWheel(bottomWidget); freqWheelX->setOrientation(Qt::Horizontal); freqWheelX->setWheelWidth(16); freqWheelX->setRange(0.5, 9.0, 0.001, 1); freqWheelX->setValue(2.0); QToolTip::add(freqWheelX, "Zoom horizontally"); bottomBottomLayout->addStretch(2); //bottomBottomLayout->addWidget(thresholdSpinBox, 0); //bottomBottomLayout->addStretch(2); bottomBottomLayout->addWidget(amplitudeModeComboBox, 0); bottomBottomLayout->addStretch(2); bottomBottomLayout->addWidget(pitchContourModeComboBox, 0); bottomBottomLayout->addStretch(2); bottomBottomLayout->addWidget(freqWheelX, 1); bottomBottomLayout->addSpacing(16); //Create the horizontal scrollbar and +/- buttons //hScrollBar = new MyScrollBar(gdata->leftTime(), gdata->rightTime(), 0.1, view->viewWidth(), view->currentTime(), 10000, Qt::Horizontal, this); /* QPushButton *buttonPlusX = new QPushButton("+", this); buttonPlusX->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); buttonPlusX->setFixedSize(15, 15); QToolTip::add(buttonPlusX, "Zoom in horizontal"); QPushButton *buttonMinusX = new QPushButton("-", this); buttonMinusX->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); buttonMinusX->setFixedSize(15, 15); QToolTip::add(buttonMinusX, "Zoom out horizontal"); */ //Create the resize grip. The thing in the bottom right hand corner QSizeGrip *sizeGrip = new QSizeGrip(bottomWidget); sizeGrip->setFixedSize(15, 15); //sizeGrip->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum, false)); sizeGrip->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, false)); bottomBottomLayout->addWidget(sizeGrip); //Actually add all the widgets into the widget layout //topLayout->addWidget(timeAxis); mainLayout->addWidget(splitter); //rightLayout->addWidget(buttonMinusY); //rightLayout->addWidget(buttonPlusY); //rightLayout->addWidget(vScrollBar); //bottomLayout->addWidget(buttonMinusX); //bottomLayout->addWidget(buttonPlusX); //mainLayout->addWidget(sizeGrip, 1, 1); //Setup all the signals and slots //vertical connect(freqScrollBar, SIGNAL(sliderMoved(double)), view, SLOT(changeViewY(double))); connect(freqScrollBar, SIGNAL(sliderMoved(double)), view, SLOT(doSlowUpdate())); connect(view, SIGNAL(viewBottomChanged(double)), freqScrollBar, SLOT(setValue(double))); /* connect(view, SIGNAL(scrollableYChanged(double)), freqScrollBar, SLOT(setMaxValue(double))); connect(view, SIGNAL(viewHeightChanged(double)), freqScrollBar, SLOT(setPageStep(double))); */ connect(freqWheelY, SIGNAL(valueChanged(double)), view, SLOT(setZoomFactorY(double))); connect(view, SIGNAL(logZoomYChanged(double)), freqWheelY, SLOT(setValue(double))); //connect(view, SIGNAL(logZoomYChanged(double)), freqDrawWidget, SLOT(update())); //horizontal connect(freqWheelX, SIGNAL(valueChanged(double)), view, SLOT(setZoomFactorX(double))); connect(view, SIGNAL(logZoomXChanged(double)), freqWheelX, SLOT(setValue(double))); //connect(view, SIGNAL(logZoomXChanged(double)), view, SLOT(doSlowUpdate())); //connect(buttonPlusX, SIGNAL(clicked()), view, SLOT(viewZoomInX())); //connect(buttonMinusX, SIGNAL(clicked()), view, SLOT(viewZoomOutX())); connect(amplitudeWheelY, SIGNAL(valueChanged(double)), amplitudeWidget, SLOT(setRange(double))); //connect(amplitudeWidget, SIGNAL(dBRangeChanged(double)), amplitudeScrollBar, SLOT(setPageStep(double))); connect(amplitudeWheelY, SIGNAL(valueChanged(double)), amplitudeWidget, SLOT(update())); connect(amplitudeScrollBar, SIGNAL(sliderMoved(double)), amplitudeWidget, SLOT(setOffset(double))); connect(amplitudeScrollBar, SIGNAL(sliderMoved(double)), amplitudeWidget, SLOT(update())); connect(amplitudeWidget, SIGNAL(rangeChanged(double)), this, SLOT(setAmplitudeZoom(double))); connect(amplitudeWidget, SIGNAL(rangeChanged(double)), amplitudeWheelY, SLOT(setValue(double))); connect(amplitudeWidget, SIGNAL(offsetChanged(double)), amplitudeScrollBar, SLOT(setValue(double))); /* connect(hScrollBar, SIGNAL(valueChanged(double)), view, SLOT(setCurrentTime(double))); connect(hScrollBar, SIGNAL(sliderMoved(double)), gdata, SLOT(updateActiveChunkTime(double))); connect(gdata, SIGNAL(leftTimeChanged(double)), hScrollBar, SLOT(setMinValue(double))); connect(gdata, SIGNAL(rightTimeChanged(double)), hScrollBar, SLOT(setMaxValue(double))); connect(view, SIGNAL(currentTimeChanged(double)), hScrollBar, SLOT(setValue(double))); connect(view, SIGNAL(viewWidthChanged(double)), hScrollBar, SLOT(setPageStep(double))); */ //make the widgets get updated when the view changes //connect(gdata->view, SIGNAL(onSlowUpdate(double)), freqDrawWidget, SLOT(update())); connect(gdata->view, SIGNAL(onSlowUpdate(double)), freqWidgetGL, SLOT(update())); //connect(gdata->view, SIGNAL(onSlowUpdate(double)), amplitudeWidget, SLOT(update())); connect(gdata->view, SIGNAL(onSlowUpdate(double)), amplitudeWidget, SLOT(update())); //connect(gdata->view, SIGNAL(onSlowUpdate(double)), timeAxis, SLOT(update())); connect(gdata->view, SIGNAL(onSlowUpdate(double)), timeAxis, SLOT(update())); connect(gdata->view, SIGNAL(timeViewRangeChanged(double, double)), timeAxis, SLOT(setRange(double, double))); }
void GPConfigDlg::appendWidget(QWidget* parent, CameraWidget* widget) { QWidget* newParent = parent; CameraWidgetType widget_type; const char* widget_name; const char* widget_info; const char* widget_label; float widget_value_float; int widget_value_int; const char* widget_value_string; gp_widget_get_type(widget, &widget_type); gp_widget_get_label(widget, &widget_label); gp_widget_get_info(widget, &widget_info); gp_widget_get_name(widget, &widget_name); // gphoto2 doesn't seem to have any standard for i18n QString whats_this = QString::fromLocal8Bit(widget_info); // Add this widget to parent switch (widget_type) { case GP_WIDGET_WINDOW: { setCaption(widget_label); break; } case GP_WIDGET_SECTION: { if (!d->tabWidget) { d->tabWidget = new QTabWidget(parent); parent->layout()->addWidget(d->tabWidget); } QWidget* tab = new QWidget(d->tabWidget); // widgets are to be aligned vertically in the tab QVBoxLayout* tabLayout = new QVBoxLayout(tab, marginHint(), spacingHint()); d->tabWidget->insertTab(tab, widget_label); KVBox* tabContainer = new KVBox(tab); tabContainer->setSpacing(spacingHint()); tabLayout->addWidget(tabContainer); newParent = tabContainer; tabLayout->addStretch(); break; } case GP_WIDGET_TEXT: { gp_widget_get_value(widget, &widget_value_string); Q3Grid* grid = new Q3Grid(2, Qt::Horizontal, parent); parent->layout()->addWidget(grid); grid->setSpacing(spacingHint()); new QLabel(QString::fromLocal8Bit(widget_label) + ':', grid); QLineEdit* lineEdit = new QLineEdit(widget_value_string, grid); d->wmap.insert(widget, lineEdit); if (!whats_this.isEmpty()) { grid->setWhatsThis(whats_this); } break; } case GP_WIDGET_RANGE: { float widget_low; float widget_high; float widget_increment; gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment); gp_widget_get_value(widget, &widget_value_float); Q3GroupBox* groupBox = new Q3GroupBox(1, Qt::Horizontal, widget_label, parent); parent->layout()->addWidget(groupBox); QSlider* slider = new QSlider( (int)widget_low, (int)widget_high, (int)widget_increment, (int)widget_value_float, Qt::Horizontal, groupBox); d->wmap.insert(widget, slider); if (!whats_this.isEmpty()) { groupBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_TOGGLE: { gp_widget_get_value(widget, &widget_value_int); QCheckBox* checkBox = new QCheckBox(widget_label, parent); parent->layout()->addWidget(checkBox); checkBox->setChecked(widget_value_int); d->wmap.insert(widget, checkBox); if (!whats_this.isEmpty()) { checkBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_RADIO: { gp_widget_get_value(widget, &widget_value_string); int count = gp_widget_count_choices(widget); // for less than 5 options, align them horizontally Q3ButtonGroup* buttonGroup; if (count > 4) { buttonGroup = new Q3VButtonGroup(widget_label, parent); } else { buttonGroup = new Q3HButtonGroup(widget_label, parent); } parent->layout()->addWidget(buttonGroup); for (int i = 0; i < count; ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); new QRadioButton(widget_choice, buttonGroup); if (!strcmp(widget_value_string, widget_choice)) { buttonGroup->setButton(i); } } d->wmap.insert(widget, buttonGroup); if (!whats_this.isEmpty()) { buttonGroup->setWhatsThis(whats_this); } break; } case GP_WIDGET_MENU: { gp_widget_get_value(widget, &widget_value_string); QComboBox* comboBox = new KComboBox(parent); parent->layout()->addWidget(comboBox); comboBox->clear(); for (int i = 0; i < gp_widget_count_choices(widget); ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); comboBox->insertItem(widget_choice); if (!strcmp(widget_value_string, widget_choice)) { comboBox->setCurrentItem(i); } } d->wmap.insert(widget, comboBox); if (!whats_this.isEmpty()) { comboBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_BUTTON: { // TODO // I can't see a way of implementing this. Since there is // no way of telling which button sent you a signal, we // can't map to the appropriate widget->callback QLabel* label = new QLabel(i18n("Button (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } case GP_WIDGET_DATE: { // TODO QLabel* label = new QLabel(i18n("Date (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } default: return; } // Append all this widgets children for (int i = 0; i < gp_widget_count_children(widget); ++i) { CameraWidget* widget_child; gp_widget_get_child(widget, i, &widget_child); appendWidget(newParent, widget_child); } // Things that must be done after all children were added /* switch (widget_type) { case GP_WIDGET_SECTION: { tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); break; } } */ }