Krita Source Code Documentation
Loading...
Searching...
No Matches
KisDlgConfigureCumulativeUndo.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
9#include <klocalizedstring.h>
10#include <lager/state.hpp>
11#include <QFormLayout>
12#include <QVBoxLayout>
13#include <QCheckBox>
14#include <QLabel>
17
20
21#include "kis_config.h"
22
24{
26 : data(_data)
27 , model(data)
28 {
29 }
30
31 lager::state<KisCumulativeUndoData, lager::automatic_tag> data;
33};
34
36 int undoLimit,
37 QWidget *parent)
38 : KoDialog(parent)
39 , m_d(new Private(data))
40{
41 using namespace KisWidgetConnectionUtils;
42
44
45 QWidget *page = new QWidget(this);
46
47 QVBoxLayout *vboxLayout = new QVBoxLayout(page);
48
49 QFormLayout *form = new QFormLayout();
50 vboxLayout->addLayout(form);
51
52 QDoubleSpinBox *dblMergeTimeout = new KisDoubleParseSpinBox(page);
53 dblMergeTimeout->setToolTip(
54 i18nc("@info:tooltip",
55 "The amount of time during which the strokes will "
56 "be kept unmerged. When a stroke becomes old enough, "
57 "Krita will try to merge it"));
58 dblMergeTimeout->setRange(3, 600);
59 dblMergeTimeout->setSuffix(i18nc("suffix for \"seconds\"", " sec"));
60 form->addRow(i18n("Wait before merging strokes:"), dblMergeTimeout);
61
62 connectControl(dblMergeTimeout, &m_d->model, "mergeTimeout");
63
64 QSpinBox *intExcludeFromMerge = new KisIntParseSpinBox();
65 intExcludeFromMerge->setToolTip(
66 i18nc("@info:tooltip",
67 "The number of last strokes that Krita will not merge "
68 "(even if they are old enough)"));
69 intExcludeFromMerge->setRange(1, undoLimit > 0 ? undoLimit : 1000);
70 form->addRow(i18n("Exclude last strokes from merge:"), intExcludeFromMerge);
71
72 connectControl(intExcludeFromMerge, &m_d->model, "excludeFromMerge");
73
74 QDoubleSpinBox *dblMaxGroupSeparation = new KisDoubleParseSpinBox();
75 dblMaxGroupSeparation->setToolTip(
76 i18nc("@info:tooltip",
77 "If two strokes have short time interval (delay) between "
78 "each other, then they will be considered as belonging to "
79 "the same group and merged"));
80 dblMaxGroupSeparation->setRange(0.3, 60);
81 dblMaxGroupSeparation->setSuffix(i18nc("suffix for \"seconds\"", " sec"));
82 form->addRow(i18n("Max interval of grouped strokes:"), dblMaxGroupSeparation);
83
84 connectControl(dblMaxGroupSeparation, &m_d->model, "maxGroupSeparation");
85
86 QDoubleSpinBox *dblMaxGroupDuration = new KisDoubleParseSpinBox();
87 dblMaxGroupDuration->setToolTip(
88 i18nc("@info:tooltip",
89 "Maximum allowed duration of the group after the merge. "
90 "If the group is going to be longer than this limit in "
91 "the result of the merge, this merge will not happen."));
92 dblMaxGroupDuration->setRange(0.3, 600.0);
93 dblMaxGroupDuration->setSuffix(i18nc("suffix for \"seconds\"", " sec"));
94 form->addRow(i18n("Max group duration:"), dblMaxGroupDuration);
95
96 connectControl(dblMaxGroupDuration, &m_d->model, "maxGroupDuration");
97
98 vboxLayout->addItem(new QSpacerItem(20, 20));
99
100 QLabel *help = new QLabel(
101 i18n("Cumulative Undo allows Krita to merge undo actions "
102 "and make undo history cleaner. Krita will still keep "
103 "a few latest actions unmerged according to "
104 "\"Wait before merging strokes\" and \"Exclude last strokes from merge\" "
105 "options. Whenever an action gets outdated using "
106 "the time limit and this action is not excluded using "
107 "\"Exclude last strokes from merge\", Krita will try "
108 " to merge this action into a group. The groups are "
109 "formed using \"Max group strokes delay\" and "
110 "\"Max group duration\" options."),
111 page);
112 help->setWordWrap(true);
113 help->setAlignment(Qt::AlignJustify);
114 vboxLayout->addWidget(help);
115
116 vboxLayout->addItem(new QSpacerItem(20, 20));
117
118 setMainWidget(page);
119
120 connect(this, SIGNAL(defaultClicked()), SLOT(slotDefaultClicked()));
121}
122
126
131
133{
134 const KisConfig cfg(true);
135 m_d->data.set(KisCumulativeUndoData());
136}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisCumulativeUndoData cumulativeUndoData() const
KisDlgConfigureCumulativeUndo(const KisCumulativeUndoData &data, int undoLimit, QWidget *parent=0)
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
The KisIntParseSpinBox class is a cleverer SpinBox, able to parse arithmetic expressions.
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
void defaultClicked()
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Default
Show Default button.
Definition KoDialog.h:126
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
lager::state< KisCumulativeUndoData, lager::automatic_tag > data