void ChannelRenderArea::resizeEvent(QResizeEvent *event) { /* Quick hack to prevent compiler warning. */ event = event; /* Quick hack to force a redraw upon resize. */ generatePainterPath(); }
void MainWindow::setupDockWidgets(void) { int i; QString s; QColor color; /* TODO: Do not create new dockWidgets if we already have them. */ /* TODO: Kill any old dockWidgets before creating new ones? */ for (i = 0; i < getNumChannels(); ++i) { widgets[i] = new QWidget(this); gridLayouts[i] = new QGridLayout(widgets[i]); lineEdits[i] = new QLineEdit(this); lineEdits[i]->setMaximumWidth(150); lineEdits[i]->setText(s.sprintf("Channel %d", i)); /* Use random colors for the channel names for now. */ QPalette p = QPalette(QApplication::palette()); color = QColor(2 + qrand() * 16); p.setColor(QPalette::Base, color); lineEdits[i]->setPalette(p); gridLayouts[i]->addWidget(lineEdits[i], i, 1); channelRenderAreas[i] = new ChannelRenderArea(this); channelRenderAreas[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); channelRenderAreas[i]->setChannelNumber(i); channelRenderAreas[i]->setChannelColor(color); gridLayouts[i]->addWidget(channelRenderAreas[i], i, 2); dockWidgets[i] = new QDockWidget(this); dockWidgets[i]->setAllowedAreas(Qt::RightDockWidgetArea); dockWidgets[i]->setFeatures( QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetVerticalTitleBar); dockWidgets[i]->setWidget(widgets[i]); addDockWidget(Qt::RightDockWidgetArea, dockWidgets[i]); /* Update labels upon changes. */ QObject::connect(channelRenderAreas[i], SIGNAL(sampleStartChanged(QString)), ui->labelSampleStart, SLOT(setText(QString))); QObject::connect(channelRenderAreas[i], SIGNAL(sampleEndChanged(QString)), ui->labelSampleEnd, SLOT(setText(QString))); QObject::connect(channelRenderAreas[i], SIGNAL(zoomFactorChanged(QString)), ui->labelZoomFactor, SLOT(setText(QString))); /* Redraw channels upon changes. */ QObject::connect(channelRenderAreas[i], SIGNAL(sampleStartChanged(QString)), channelRenderAreas[i], SLOT(generatePainterPath())); QObject::connect(channelRenderAreas[i], SIGNAL(sampleEndChanged(QString)), channelRenderAreas[i], SLOT(generatePainterPath())); QObject::connect(channelRenderAreas[i], SIGNAL(zoomFactorChanged(QString)), channelRenderAreas[i], SLOT(generatePainterPath())); // dockWidgets[i]->show(); #if 0 /* If the user renames a channel, adapt the dock title. */ QObject::connect(lineEdits[i], SIGNAL(textChanged(QString)), dockWidgets[i], SLOT(setWindowTitle(QString))); #endif } }
void MainWindow::setupDockWidgets(void) { /* TODO: Do not create new dockWidgets if we already have them. */ /* TODO: Kill any old dockWidgets before creating new ones? */ for (int i = 0; i < getNumChannels(); ++i) { channelForms[i] = new ChannelForm(this); channelForms[i]->setChannelNumber(i); dockWidgets[i] = new QDockWidget(this); dockWidgets[i]->setAllowedAreas(Qt::BottomDockWidgetArea); QDockWidget::DockWidgetFeatures f; f = QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable; if (configChannelTitleBarLayout == DOCK_VERTICAL) f |= QDockWidget::DockWidgetVerticalTitleBar; dockWidgets[i]->setFeatures(f); dockWidgets[i]->setWidget(channelForms[i]); addDockWidget(Qt::BottomDockWidgetArea, dockWidgets[i], Qt::Vertical); /* Update labels upon changes. */ QObject::connect(channelForms[i], SIGNAL(sampleStartChanged(QString)), ui->labelSampleStart, SLOT(setText(QString))); QObject::connect(channelForms[i], SIGNAL(sampleEndChanged(QString)), ui->labelSampleEnd, SLOT(setText(QString))); QObject::connect(channelForms[i], SIGNAL(scaleFactorChanged(QString)), ui->labelScaleFactor, SLOT(setText(QString))); /* Redraw channels upon changes. */ QObject::connect(channelForms[i], SIGNAL(sampleStartChanged(QString)), channelForms[i], SLOT(generatePainterPath())); QObject::connect(channelForms[i], SIGNAL(sampleEndChanged(QString)), channelForms[i], SLOT(generatePainterPath())); QObject::connect(channelForms[i], SIGNAL(scaleFactorChanged(QString)), channelForms[i], SLOT(generatePainterPath())); // dockWidgets[i]->show(); #if 0 /* If the user renames a channel, adapt the dock title. */ QObject::connect(lineEdits[i], SIGNAL(textChanged(QString)), dockWidgets[i], SLOT(setWindowTitle(QString))); #endif } /* For now, display only one scrollbar which scrolls all channels. */ QDockWidget* scrollWidget = new QDockWidget(this); scrollWidget->setAllowedAreas(Qt::BottomDockWidgetArea); horizontalScrollBar = new QScrollBar(this); horizontalScrollBar->setOrientation(Qt::Horizontal); QDockWidget::DockWidgetFeatures f; if (configChannelTitleBarLayout == DOCK_VERTICAL) f |= QDockWidget::DockWidgetVerticalTitleBar; scrollWidget->setFeatures(f); scrollWidget->setWidget(horizontalScrollBar); addDockWidget(Qt::BottomDockWidgetArea, scrollWidget, Qt::Vertical); for (int i = 0; i < getNumChannels(); ++i) { /* The scrollbar scrolls all channels. */ connect(horizontalScrollBar, SIGNAL(valueChanged(int)), channelForms[i], SLOT(setScrollBarValue(int))); } }