Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_transport_controls.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Emmet O 'Neill <emmetoneill.pdx@gmail.com>
3 * SPDX-FileCopyrightText: 2020 Eoin O 'Neill <eoinoneill1991@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9
10#include <QHBoxLayout>
11#include <QToolButton>
12
13#include "kis_debug.h"
14#include "kis_icon.h"
15#include "klocalizedstring.h"
16
17
19 : QWidget(parent)
20{
21 QHBoxLayout* layout = new QHBoxLayout(this);
22 layout->setContentsMargins(0,0,0,0);
23 layout->setSpacing(0);
24
25 buttonSkipBack = new QToolButton(this);
26 buttonSkipBack->setIcon(KisIconUtils::loadIcon("prevkeyframe"));
27 buttonSkipBack->setToolTip(i18n("Skip Back"));
28 buttonSkipBack->setIconSize(QSize(22, 22));
29 buttonSkipBack->setFocusPolicy(Qt::NoFocus);
30 buttonSkipBack->setAutoRaise(true);
31 layout->addWidget(buttonSkipBack);
32 connect(buttonSkipBack, SIGNAL(released()), this, SIGNAL(skipBack()));
33
34 buttonBack = new QToolButton(this);
35 buttonBack->setIcon(KisIconUtils::loadIcon("prevframe"));
36 buttonBack->setToolTip(i18n("Back"));
37 buttonBack->setIconSize(QSize(22, 22));
38 buttonBack->setFocusPolicy(Qt::NoFocus);
39 buttonBack->setAutoRaise(true);
40 layout->addWidget(buttonBack);
41 connect(buttonBack, SIGNAL(released()), this, SIGNAL(back()));
42
43 buttonStop = new QToolButton(this);
44 buttonStop->setIcon(KisIconUtils::loadIcon("animation_stop"));
45 buttonStop->setToolTip(i18n("Stop"));
46 buttonStop->setIconSize(QSize(22, 22));
47 buttonStop->setFocusPolicy(Qt::NoFocus);
48 buttonStop->setAutoRaise(true);
49 layout->addWidget(buttonStop);
50 connect(buttonStop, SIGNAL(released()), this, SIGNAL(stop()));
51
52 buttonPlayPause = new QToolButton(this);
53 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_play"));
54 buttonPlayPause->setToolTip(i18n("Play/Pause"));
55 buttonPlayPause->setIconSize(QSize(22, 22));
56 buttonPlayPause->setFocusPolicy(Qt::NoFocus);
57 buttonPlayPause->setAutoRaise(true);
58 layout->addWidget(buttonPlayPause);
59 connect(buttonPlayPause, SIGNAL(released()), this, SIGNAL(playPause()));
60
61 buttonForward = new QToolButton(this);
62 buttonForward->setIcon(KisIconUtils::loadIcon("nextframe"));
63 buttonForward->setToolTip(i18n("Forward"));
64 buttonForward->setIconSize(QSize(22, 22));
65 buttonForward->setFocusPolicy(Qt::NoFocus);
66 buttonForward->setAutoRaise(true);
67 layout->addWidget(buttonForward);
68 connect(buttonForward, SIGNAL(released()), this, SIGNAL(forward()));
69
70 buttonSkipForward = new QToolButton(this);
71 buttonSkipForward->setIcon(KisIconUtils::loadIcon("nextkeyframe"));
72 buttonSkipForward->setToolTip(i18n("Skip Forward"));
73 buttonSkipForward->setIconSize(QSize(22, 22));
74 buttonSkipForward->setFocusPolicy(Qt::NoFocus);
75 buttonSkipForward->setAutoRaise(true);
76 layout->addWidget(buttonSkipForward);
77 connect(buttonSkipForward, SIGNAL(released()), this, SIGNAL(skipForward()));
78
79 showStateButtons(true);
80 showSeekButtons(true);
81 showSkipButtons(false);
82
83 setFocusPolicy(Qt::ClickFocus);
84}
85
89
91{
92 return QSize(32, 32);
93}
94
96{
97 if (playing) {
98 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_pause"));
99 } else {
100 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_play"));
101 }
102}
103
105{
106 if (show) {
107 buttonPlayPause->show();
108 buttonStop->show();
109 } else {
110 buttonPlayPause->hide();
111 buttonStop->hide();
112 }
113}
114
116{
117 if (show) {
118 buttonBack->show();
119 buttonForward->show();
120 } else {
121 buttonBack->hide();
122 buttonForward->hide();
123 }
124}
125
127{
128 if (show) {
129 buttonSkipBack->show();
130 buttonSkipForward->show();
131 } else {
132 buttonSkipBack->hide();
133 buttonSkipForward->hide();
134 }
135}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisTransportControls(QWidget *parent=nullptr)
QSize sizeHint() const override
void setPlaying(bool playing)
setPlaying flips the icon on the play/pause button. When playing, the button will show a pause icon....
QIcon loadIcon(const QString &name)