2017-12-19 16:13:44 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QFontDialog>
|
|
|
|
|
|
|
|
#include "GraphOptionsWidget.h"
|
|
|
|
#include "ui_GraphOptionsWidget.h"
|
|
|
|
|
|
|
|
#include "PreferencesDialog.h"
|
|
|
|
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Helpers.h"
|
|
|
|
#include "common/Configuration.h"
|
2017-12-19 16:13:44 +00:00
|
|
|
|
2019-03-16 12:41:45 +00:00
|
|
|
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog *dialog)
|
2021-01-24 14:50:13 +00:00
|
|
|
: QDialog(dialog), ui(new Ui::GraphOptionsWidget)
|
2017-12-19 16:13:44 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2020-03-09 20:59:03 +00:00
|
|
|
ui->checkTransparent->setChecked(Config()->getBitmapTransparentState());
|
2020-11-29 14:41:13 +00:00
|
|
|
ui->blockEntryCheckBox->setChecked(Config()->getGraphBlockEntryOffset());
|
2021-12-05 08:53:45 +00:00
|
|
|
ui->graphPreviewCheckBox->setChecked(Config()->getGraphPreview());
|
2021-01-24 14:50:13 +00:00
|
|
|
ui->bitmapGraphScale->setValue(Config()->getBitmapExportScaleFactor() * 100.0);
|
2017-12-19 16:13:44 +00:00
|
|
|
updateOptionsFromVars();
|
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
connect<void (QDoubleSpinBox::*)(double)>(ui->bitmapGraphScale, (&QDoubleSpinBox::valueChanged),
|
|
|
|
this,
|
|
|
|
&GraphOptionsWidget::bitmapGraphScaleValueChanged);
|
|
|
|
connect(ui->checkTransparent, &QCheckBox::stateChanged, this,
|
|
|
|
&GraphOptionsWidget::checkTransparentStateChanged);
|
|
|
|
connect(ui->blockEntryCheckBox, &QCheckBox::stateChanged, this,
|
|
|
|
&GraphOptionsWidget::checkGraphBlockEntryOffsetChanged);
|
|
|
|
|
|
|
|
connect(Core(), &CutterCore::graphOptionsChanged, this,
|
|
|
|
&GraphOptionsWidget::updateOptionsFromVars);
|
|
|
|
QSpinBox *graphSpacingWidgets[] = { ui->horizontalEdgeSpacing, ui->horizontalBlockSpacing,
|
|
|
|
ui->verticalEdgeSpacing, ui->verticalBlockSpacing };
|
|
|
|
for (auto widget : graphSpacingWidgets) {
|
|
|
|
connect<void (QSpinBox::*)(int)>(widget, &QSpinBox::valueChanged, this,
|
|
|
|
&GraphOptionsWidget::layoutSpacingChanged);
|
2020-06-16 10:43:45 +00:00
|
|
|
}
|
2017-12-19 16:13:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphOptionsWidget::~GraphOptionsWidget() {}
|
|
|
|
|
|
|
|
void GraphOptionsWidget::updateOptionsFromVars()
|
|
|
|
{
|
2021-01-24 14:50:13 +00:00
|
|
|
qhelpers::setCheckedWithoutSignals(ui->graphOffsetCheckBox,
|
|
|
|
Config()->getConfigBool("graph.offset"));
|
2017-12-19 16:13:44 +00:00
|
|
|
ui->maxColsSpinBox->blockSignals(true);
|
|
|
|
ui->maxColsSpinBox->setValue(Config()->getGraphBlockMaxChars());
|
|
|
|
ui->maxColsSpinBox->blockSignals(false);
|
2020-12-19 14:04:48 +00:00
|
|
|
ui->minFontSizeSpinBox->blockSignals(true);
|
|
|
|
ui->minFontSizeSpinBox->setValue(Config()->getGraphMinFontSize());
|
|
|
|
ui->minFontSizeSpinBox->blockSignals(false);
|
2020-07-03 17:09:37 +00:00
|
|
|
auto blockSpacing = Config()->getGraphBlockSpacing();
|
|
|
|
ui->horizontalBlockSpacing->setValue(blockSpacing.x());
|
|
|
|
ui->verticalBlockSpacing->setValue(blockSpacing.y());
|
|
|
|
auto edgeSpacing = Config()->getGraphEdgeSpacing();
|
|
|
|
ui->horizontalEdgeSpacing->setValue(edgeSpacing.x());
|
|
|
|
ui->verticalEdgeSpacing->setValue(edgeSpacing.y());
|
2017-12-19 16:13:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphOptionsWidget::triggerOptionsChanged()
|
|
|
|
{
|
2021-01-24 14:50:13 +00:00
|
|
|
disconnect(Core(), &CutterCore::graphOptionsChanged, this,
|
|
|
|
&GraphOptionsWidget::updateOptionsFromVars);
|
2017-12-19 16:13:44 +00:00
|
|
|
Core()->triggerGraphOptionsChanged();
|
2021-01-24 14:50:13 +00:00
|
|
|
connect(Core(), &CutterCore::graphOptionsChanged, this,
|
|
|
|
&GraphOptionsWidget::updateOptionsFromVars);
|
2017-12-19 16:13:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphOptionsWidget::on_maxColsSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
Config()->setGraphBlockMaxChars(value);
|
|
|
|
triggerOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2020-12-19 14:04:48 +00:00
|
|
|
void GraphOptionsWidget::on_minFontSizeSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
Config()->setGraphMinFontSize(value);
|
|
|
|
triggerOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-08-12 16:20:16 +00:00
|
|
|
void GraphOptionsWidget::on_graphOffsetCheckBox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
Config()->setConfig("graph.offset", checked);
|
2020-06-11 16:43:32 +00:00
|
|
|
emit Core()->asmOptionsChanged();
|
2018-08-12 16:20:16 +00:00
|
|
|
triggerOptionsChanged();
|
|
|
|
}
|
2020-03-09 20:59:03 +00:00
|
|
|
|
2022-03-30 08:41:37 +00:00
|
|
|
void GraphOptionsWidget::on_graphPreviewCheckBox_toggled(bool checked)
|
2021-12-05 08:53:45 +00:00
|
|
|
{
|
|
|
|
Config()->setGraphPreview(checked);
|
|
|
|
triggerOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2020-03-09 20:59:03 +00:00
|
|
|
void GraphOptionsWidget::checkTransparentStateChanged(int checked)
|
|
|
|
{
|
|
|
|
Config()->setBitmapTransparentState(checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphOptionsWidget::bitmapGraphScaleValueChanged(double value)
|
|
|
|
{
|
2021-01-24 14:50:13 +00:00
|
|
|
double value_decimal = value / (double)100.0;
|
2020-03-09 20:59:03 +00:00
|
|
|
Config()->setBitmapExportScaleFactor(value_decimal);
|
|
|
|
}
|
|
|
|
|
2020-06-16 10:43:45 +00:00
|
|
|
void GraphOptionsWidget::layoutSpacingChanged()
|
|
|
|
{
|
2021-01-24 14:50:13 +00:00
|
|
|
QPoint blockSpacing { ui->horizontalBlockSpacing->value(), ui->verticalBlockSpacing->value() };
|
|
|
|
QPoint edgeSpacing { ui->horizontalEdgeSpacing->value(), ui->verticalEdgeSpacing->value() };
|
2020-06-16 10:43:45 +00:00
|
|
|
Config()->setGraphSpacing(blockSpacing, edgeSpacing);
|
|
|
|
triggerOptionsChanged();
|
|
|
|
}
|
|
|
|
|
2020-11-29 14:41:13 +00:00
|
|
|
void GraphOptionsWidget::checkGraphBlockEntryOffsetChanged(bool checked)
|
|
|
|
{
|
|
|
|
Config()->setGraphBlockEntryOffset(checked);
|
|
|
|
triggerOptionsChanged();
|
2020-12-19 14:04:48 +00:00
|
|
|
}
|