Krita Source Code Documentation
Loading...
Searching...
No Matches
KisUndoView.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2010 Matus Talcik <matus.talcik@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6/****************************************************************************
7**
8** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
9** All rights reserved.
10** Contact: Nokia Corporation (qt-info@nokia.com)
11**
12** This file is part of the QtGui module of the Qt Toolkit.
13**
14** $QT_BEGIN_LICENSE:LGPL$
15** No Commercial Usage
16** This file contains pre-release code and may not be distributed.
17** You may use this file in accordance with the terms and conditions
18** contained in the Technology Preview License Agreement accompanying
19** this package.
20**
21** GNU Lesser General Public License Usage
22** Alternatively, this file may be used under the terms of the GNU Lesser
23** General Public License version 2.1 as published by the Free Software
24** Foundation and appearing in the file LICENSE.LGPL included in the
25** packaging of this file. Please review the following information to
26** ensure the GNU Lesser General Public License version 2.1 requirements
27** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
28**
29** In addition, as a special exception, Nokia gives you certain additional
30** rights. These rights are described in the Nokia Qt LGPL Exception
31** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
32**
33** If you have questions regarding the use of this file, please contact
34** Nokia at qt-info@nokia.com.
35**
36**
37**
38**
39**
40**
41**
42**
43** $QT_END_LICENSE$
44**
45****************************************************************************/
46#include <kundo2qstack.h>
47#include "KisUndoView.h"
48#include "KisUndoModel.h"
49
50#ifndef QT_NO_UNDOVIEW
51
52#include <kundo2group.h>
53#include <QAbstractItemModel>
54#include <QPointer>
55#include <QIcon>
56#include <QSpinBox>
57#include <QDoubleSpinBox>
58#include <QWidgetAction>
59#include <QGridLayout>
60#include <kis_config.h>
61#include <KisKineticScroller.h>
62
65
86{
87public:
89
90#ifndef QT_NO_UNDOGROUP
92#endif
95
96 void init(KisUndoView* view);
97};
98
100{
101 q = view;
102 model = new KisUndoModel(q);
103 model->setDevicePixelRatio(view->devicePixelRatioF());
104 q->setModel(model);
105 q->setSelectionModel(model->selectionModel());
106}
107
113 : QListView(parent)
114 , d(new KisUndoViewPrivate)
115{
116 d->init(this);
117
118 QScroller *scroller = KisKineticScroller::createPreconfiguredScroller(this);
119 if (scroller) {
120 connect(scroller, SIGNAL(stateChanged(QScroller::State)),
121 this, SLOT(slotScrollerStateChanged(QScroller::State)));
122 }
123}
124
130 : KisUndoView(parent)
131{
133}
134
135#ifndef QT_NO_UNDOGROUP
136
143KisUndoView::KisUndoView(KUndo2Group *group, QWidget *parent)
144 : KisUndoView(parent)
145{
147}
148
149#endif // QT_NO_UNDOGROUP
150
156{
157 delete d;
158
159}
160
169{
170
171 return d->model->stack();
172}
173
184{
185
186#ifndef QT_NO_UNDOGROUP
187 setGroup(0);
188#endif
190}
191
192#ifndef QT_NO_UNDOGROUP
193
204{
205
206
207 if (d->group == group)
208 return;
209
210 if (d->group != 0) {
211 disconnect(d->group, SIGNAL(activeStackChanged(KUndo2QStack*)),
212 d->model, SLOT(setStack(KUndo2QStack*)));
213 }
214
215 d->group = group;
216
217 if (d->group != 0) {
218 connect(d->group, SIGNAL(activeStackChanged(KUndo2QStack*)),
219 d->model, SLOT(setStack(KUndo2QStack*)));
220 d->model->setStack(d->group->activeStack());
221 } else {
222 d->model->setStack(0);
223 }
224}
225
235{
236
237 return d->group;
238}
239
240#endif // QT_NO_UNDOGROUP
241
251void KisUndoView::setEmptyLabel(const QString &label)
252{
253
254 d->model->setEmptyLabel(label);
255}
256
258{
259
260 return d->model->emptyLabel();
261}
262
273void KisUndoView::setCleanIcon(const QIcon &icon)
274{
275
276 d->model->setCleanIcon(icon);
277
278}
279
281{
282
283 return d->model->cleanIcon();
284}
285
287 d->model->setCanvas(canvas);
288}
289
290#endif // QT_NO_UNDOVIEW
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KUndo2Group class is a group of KUndo2QStack objects.
Definition kundo2group.h:57
The KUndo2QStack class is a stack of KUndo2Command objects.
KUndo2QStack * stack() const
QIcon cleanIcon() const
void setDevicePixelRatio(qreal devicePixelRatio)
QItemSelectionModel * selectionModel() const
void setCleanIcon(const QIcon &icon)
void setEmptyLabel(const QString &label)
QString emptyLabel() const
void setCanvas(KisCanvas2 *canvas)
void setStack(KUndo2QStack *stack)
KisUndoView * q
QPointer< KUndo2Group > group
KisUndoModel * model
void init(KisUndoView *view)
The KisUndoView class displays the contents of a KUndo2QStack.
Definition KisUndoView.h:66
void setEmptyLabel(const QString &label)
KisUndoView(QWidget *parent=0)
KUndo2QStack * stack() const
QString emptyLabel
the label used for the empty state.
Definition KisUndoView.h:68
void setCleanIcon(const QIcon &icon)
void setCanvas(KisCanvas2 *canvas)
KisUndoViewPrivate *const d
void slotScrollerStateChanged(QScroller::State state)
Definition KisUndoView.h:98
KUndo2Group * group() const
void setStack(KUndo2QStack *stack)
void setGroup(KUndo2Group *group)
QIcon cleanIcon
the icon used to represent the clean state.
Definition KisUndoView.h:69
~KisUndoView() override
KRITAWIDGETUTILS_EXPORT QScroller * createPreconfiguredScroller(QAbstractScrollArea *target)