1 /*
2 * Copyright (C) 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "DlgConfigureHistoryDock.h"
21
22 #include <QFormLayout>
23 #include <QCheckBox>
24 #include <QLabel>
25 #include <kis_double_parse_spin_box.h>
26 #include <kis_int_parse_spin_box.h>
27
DlgConfigureHistoryDock(KisUndoView * view,KUndo2QStack * stack,QWidget * parent)28 DlgConfigureHistoryDock::DlgConfigureHistoryDock(KisUndoView *view, KUndo2QStack *stack, QWidget *parent)
29 : KoDialog(parent)
30 , m_stack(stack)
31 {
32 setButtons(KoDialog::Close);
33
34 QWidget *page = new QWidget(this);
35
36 QFormLayout *form = new QFormLayout(page);
37 QCheckBox *chkCumulative = new QCheckBox(i18n("Enable Cumulative Undo"), page);
38 chkCumulative->setChecked(stack->useCumulativeUndoRedo());
39 connect(chkCumulative, SIGNAL(toggled(bool)), view, SLOT(toggleCumulativeUndoRedo()));
40
41 form->addRow(chkCumulative, new QWidget(page));
42
43 QLabel *l = new QLabel(i18n("Start merging time"), page);
44 QDoubleSpinBox *s = new KisDoubleParseSpinBox(page);
45 s->setToolTip(i18nc("@info:tooltip", "The amount of time after a merged stroke before merging again"));
46 s->setRange(3,10);
47 s->setValue(m_stack->timeT1());
48 form->addRow(l, s);
49 s->setEnabled(chkCumulative->isChecked());
50 connect(chkCumulative, SIGNAL(toggled(bool)), s, SLOT(setEnabled(bool)));
51 connect(s, SIGNAL(valueChanged(double)), view, SLOT(setStackT1(double)));
52
53 QLabel *l1 = new QLabel(i18n("Group time"));
54 QDoubleSpinBox *s1 = new KisDoubleParseSpinBox();
55 s1->setToolTip(i18nc("@info:tooltip", "The amount of time every stroke should be apart from its previous stroke to be classified in one group"));
56 s1->setRange(0.3,s->value());
57 s1->setValue(m_stack->timeT2());
58 form->addRow(l1, s1);
59 s1->setEnabled(chkCumulative->isChecked());
60 connect(chkCumulative, SIGNAL(toggled(bool)), s1, SLOT(setEnabled(bool)));
61 connect(s1, SIGNAL(valueChanged(double)), view, SLOT(setStackT2(double)));
62
63 QLabel *l2 = new QLabel(i18n("Split Strokes"));
64 QSpinBox *s2 = new KisIntParseSpinBox();
65 s2->setToolTip(i18nc("@info:tooltip", "The number of last strokes which Krita should store separately"));
66 s2->setRange(1,m_stack->undoLimit());
67 s2->setValue(m_stack->strokesN());
68 form->addRow(l2, s2);
69 s2->setEnabled(chkCumulative->isChecked());
70 connect(chkCumulative, SIGNAL(toggled(bool)), s2, SLOT(setEnabled(bool)));
71 connect(s2,SIGNAL(valueChanged(int)),SLOT(view(int)));
72
73 setMainWidget(page);
74 }
75