cutter/src/dialogs/preferences/GraphOptionsWidget.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

#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"
2019-03-16 12:41:45 +00:00
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog *dialog)
: QDialog(dialog),
2018-03-21 20:32:32 +00:00
ui(new Ui::GraphOptionsWidget)
{
ui->setupUi(this);
updateOptionsFromVars();
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
}
GraphOptionsWidget::~GraphOptionsWidget() {}
void GraphOptionsWidget::updateOptionsFromVars()
{
qhelpers::setCheckedWithoutSignals(ui->graphOffsetCheckBox, Config()->getConfigBool("graph.offset"));
ui->maxColsSpinBox->blockSignals(true);
ui->maxColsSpinBox->setValue(Config()->getGraphBlockMaxChars());
ui->maxColsSpinBox->blockSignals(false);
}
void GraphOptionsWidget::triggerOptionsChanged()
{
disconnect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
Core()->triggerGraphOptionsChanged();
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
}
void GraphOptionsWidget::on_maxColsSpinBox_valueChanged(int value)
{
Config()->setGraphBlockMaxChars(value);
triggerOptionsChanged();
}
void GraphOptionsWidget::on_graphOffsetCheckBox_toggled(bool checked)
{
Config()->setConfig("graph.offset", checked);
triggerOptionsChanged();
}