1#include "PomodoroConfigDlg.h"
2#include "ui_PomodoroConfigDlg.h"
3
4#include <GitBase.h>
5#include <GitQlientSettings.h>
6#include <GitQlientStyles.h>
7
8PomodoroConfigDlg::PomodoroConfigDlg(const QSharedPointer<GitBase> &git, QWidget *parent)
9 : QDialog(parent)
10 , ui(new Ui::PomodoroConfigDlg)
11 , mGit(git)
12{
13 ui->setupUi(this);
14
15 connect(ui->pomodoroDur, &QSlider::valueChanged, this,
16 [this](int value) { ui->pomodoroDurLabel->setText(QString::number(value)); });
17 connect(ui->breakDur, &QSlider::valueChanged, this,
18 [this](int value) { ui->pomodoroBreakDurLabel->setText(QString::number(value)); });
19 connect(ui->longBreakDur, &QSlider::valueChanged, this,
20 [this](int value) { ui->pomodoroLongBreakLabel->setText(QString::number(value)); });
21
22 GitQlientSettings settings(mGit->getGitDir());
23 ui->cbAlarmSound->setChecked(settings.localValue("Pomodoro/Alarm", false).toBool());
24 ui->cbStopResets->setChecked(settings.localValue("Pomodoro/StopResets", true).toBool());
25 ui->pomodoroDur->setValue(settings.localValue("Pomodoro/Duration", 25).toInt());
26 ui->breakDur->setValue(settings.localValue("Pomodoro/Break", 5).toInt());
27 ui->longBreakDur->setValue(settings.localValue("Pomodoro/LongBreak", 15).toInt());
28 ui->sbLongBreakCount->setValue(settings.localValue("Pomodoro/LongBreakTrigger", 4).toInt());
29
30 setStyleSheet(GitQlientStyles::getInstance()->getStyles());
31}
32
33PomodoroConfigDlg::~PomodoroConfigDlg()
34{
35 delete ui;
36}
37
38void PomodoroConfigDlg::accept()
39{
40 GitQlientSettings settings(mGit->getGitDir());
41 settings.setLocalValue("Pomodoro/Alarm", ui->cbAlarmSound->isChecked());
42 settings.setLocalValue("Pomodoro/StopResets", ui->cbStopResets->isChecked());
43 settings.setLocalValue("Pomodoro/Duration", ui->pomodoroDur->value());
44 settings.setLocalValue("Pomodoro/Break", ui->breakDur->value());
45 settings.setLocalValue("Pomodoro/LongBreak", ui->longBreakDur->value());
46 settings.setLocalValue("Pomodoro/LongBreakTrigger", ui->sbLongBreakCount->value());
47
48 QDialog::accept();
49}
50