foreach(QWidget *i, d_widgets){ LegendWidget *l = qobject_cast<LegendWidget *>(i); if (!l){ QRect r = operateOn(i->geometry()); i->setGeometry(r); FrameWidget *f = qobject_cast<FrameWidget *>(i); if (f) f->updateCoordinates(); continue; } QRect new_rect = operateOn(l->geometry()); l->move(new_rect.topLeft()); if (!l->text().isEmpty()){ QFont f = l->font(); f.setPointSize(f.pointSize() * new_rect.width() * new_rect.height()/(l->rect().width() * l->rect().height())); l->setFont(f); l->plot()->notifyFontChange(f); } }
void EnrichmentDialog::setWidget(QWidget *w) { if (!w || !d_app) return; d_widget = w; FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget); if (fw){ #ifndef QT_MAC_USE_COCOA if (d_plot) d_plot->deselectMarker(); #endif frameBox->blockSignals(true); frameBox->setCurrentIndex(fw->frameStyle()); frameBox->blockSignals(false); frameColorBtn->blockSignals(true); frameColorBtn->setColor(fw->frameColor()); frameColorBtn->blockSignals(false); boxFrameLineStyle->blockSignals(true); boxFrameLineStyle->setStyle(fw->framePen().style()); boxFrameLineStyle->blockSignals(false); boxFrameWidth->blockSignals(true); if (d_widget_type == Ellipse) boxFrameWidth->setValue(fw->framePen().widthF()); else boxFrameWidth->setValue(fw->framePen().width()); boxFrameWidth->blockSignals(false); unitBox->setCurrentIndex(d_app->d_frame_geometry_unit); attachToBox->setCurrentIndex((int)fw->attachPolicy()); displayCoordinates(d_app->d_frame_geometry_unit); } else { unitBox->setCurrentIndex(FrameWidget::Pixel); displayCoordinates(FrameWidget::Pixel); } if (d_widget_type == Text){ LegendWidget *l = qobject_cast<LegendWidget *>(d_widget); if (l){ setText(textEditBox, l->text()); textFont = l->font(); QFont fnt = textFont; fnt.setPointSize(QFont().pointSize() + 2); textEditBox->setFont(fnt); textColorBtn->blockSignals(true); textColorBtn->setColor(l->textColor()); textColorBtn->blockSignals(false); QColor bc = l->backgroundColor(); boxBackgroundTransparency->blockSignals(true); boxBackgroundTransparency->setValue(100*bc.alphaF()); boxBackgroundTransparency->blockSignals(false); transparencySlider->blockSignals(true); transparencySlider->setValue(boxBackgroundTransparency->value()); transparencySlider->blockSignals(false); textBackgroundBtn->blockSignals(true); textBackgroundBtn->setEnabled(bc.alpha()); bc.setAlpha(255); textBackgroundBtn->setColor(bc); textBackgroundBtn->blockSignals(false); boxTextAngle->blockSignals(true); boxTextAngle->setValue(l->angle()); boxTextAngle->blockSignals(false); autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled()); texOutputBox->setChecked(l->hasTeXOutput()); updateButtons(); } } else if (d_widget_type == Tex){ TexWidget *tw = qobject_cast<TexWidget *>(d_widget); if (tw){ setText(equationEditor, tw->formula()); outputLabel->setPixmap(tw->pixmap()); bestSizeButton->show(); } return; } else if (d_widget_type == Image){ ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i){ imagePathBox->setText(i->fileName()); boxSaveImagesInternally->blockSignals(true); boxSaveImagesInternally->setChecked(i->saveInternally()); boxSaveImagesInternally->blockSignals(false); bestSizeButton->show(); } } else if (d_widget_type == Frame || d_widget_type == Ellipse){ QColor bc = fw->backgroundColor(); boxTransparency->blockSignals(true); boxTransparency->setValue(100.0*bc.alphaF()); boxTransparency->blockSignals(false); fillTransparencySlider->blockSignals(true); fillTransparencySlider->setValue(boxTransparency->value()); fillTransparencySlider->blockSignals(false); bc.setAlpha(255); backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(bc); backgroundColorBtn->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(fw->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(fw->brush().color()); patternColorBtn->blockSignals(false); } }
void EnrichmentDialog::setWidget(QWidget *w) { if (!w) return; ApplicationWindow *app = (ApplicationWindow *)parent(); if (!app) return; d_widget = w; FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget); if (fw){ frameBox->blockSignals(true); frameBox->setCurrentIndex(fw->frameStyle()); frameBox->blockSignals(false); frameColorBtn->blockSignals(true); frameColorBtn->setColor(fw->frameColor()); frameColorBtn->blockSignals(false); boxFrameLineStyle->blockSignals(true); boxFrameLineStyle->setStyle(fw->framePen().style()); boxFrameLineStyle->blockSignals(false); boxFrameWidth->blockSignals(true); if (d_widget_type == Ellipse) boxFrameWidth->setValue(fw->framePen().widthF()); else boxFrameWidth->setValue(fw->framePen().width()); boxFrameWidth->blockSignals(false); unitBox->setCurrentIndex(app->d_frame_geometry_unit); attachToBox->setCurrentIndex((int)fw->attachPolicy()); displayCoordinates(app->d_frame_geometry_unit); } else { unitBox->setCurrentIndex(FrameWidget::Pixel); displayCoordinates(FrameWidget::Pixel); } if (d_widget_type == Text){ LegendWidget *l = qobject_cast<LegendWidget *>(d_widget); if (l){ setText(textEditBox, l->text()); textFont = l->font(); QFont fnt = textFont; fnt.setPointSize(QFont().pointSize() + 2); textEditBox->setFont(fnt); textColorBtn->blockSignals(true); textColorBtn->setColor(l->textColor()); textColorBtn->blockSignals(false); QColor bc = l->backgroundColor(); boxBackgroundTransparency->blockSignals(true); boxBackgroundTransparency->setValue(bc.alpha()); boxBackgroundTransparency->blockSignals(false); textBackgroundBtn->blockSignals(true); textBackgroundBtn->setEnabled(bc.alpha()); textBackgroundBtn->setColor(bc); textBackgroundBtn->blockSignals(false); boxTextAngle->blockSignals(true); boxTextAngle->setValue(l->angle()); boxTextAngle->blockSignals(false); autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled()); texOutputBox->setChecked(l->hasTeXOutput()); } } else if (d_widget_type == Tex){ TexWidget *tw = qobject_cast<TexWidget *>(d_widget); if (tw){ setText(equationEditor, tw->formula()); outputLabel->setPixmap(tw->pixmap()); bestSizeButton->show(); } return; } else if (d_widget_type == Image){ ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i){ imagePathBox->setText(i->fileName()); boxSaveImagesInternally->blockSignals(true); boxSaveImagesInternally->setChecked(i->saveInternally()); boxSaveImagesInternally->blockSignals(false); } } else if (d_widget_type == Frame){ RectangleWidget *r = qobject_cast<RectangleWidget *>(d_widget); if (r){ backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(r->backgroundColor()); backgroundColorBtn->blockSignals(false); boxTransparency->blockSignals(true); boxTransparency->setValue(r->backgroundColor().alpha()); boxTransparency->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(r->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(r->brush().color()); patternColorBtn->blockSignals(false); } } else if (d_widget_type == Ellipse){ EllipseWidget *r = qobject_cast<EllipseWidget *>(d_widget); if (r){ backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(r->backgroundColor()); backgroundColorBtn->blockSignals(false); boxTransparency->blockSignals(true); boxTransparency->setValue(r->backgroundColor().alpha()); boxTransparency->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(r->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(r->brush().color()); patternColorBtn->blockSignals(false); } } }