File indexing completed on 2024-12-22 04:13:14
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Emmet O 'Neill <emmetoneill.pdx@gmail.com> 0003 * SPDX-FileCopyrightText: 2020 Eoin O 'Neill <eoinoneill1991@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_transport_controls.h" 0009 0010 #include <QHBoxLayout> 0011 #include <QToolButton> 0012 0013 #include "kis_debug.h" 0014 #include "kis_icon.h" 0015 #include "klocalizedstring.h" 0016 0017 0018 KisTransportControls::KisTransportControls(QWidget* parent) 0019 : QWidget(parent) 0020 { 0021 QHBoxLayout* layout = new QHBoxLayout(this); 0022 layout->setContentsMargins(0,0,0,0); 0023 layout->setSpacing(0); 0024 0025 buttonSkipBack = new QToolButton(this); 0026 buttonSkipBack->setIcon(KisIconUtils::loadIcon("prevkeyframe")); 0027 buttonSkipBack->setToolTip(i18n("Skip Back")); 0028 buttonSkipBack->setIconSize(QSize(22, 22)); 0029 buttonSkipBack->setFocusPolicy(Qt::NoFocus); 0030 buttonSkipBack->setAutoRaise(true); 0031 layout->addWidget(buttonSkipBack); 0032 connect(buttonSkipBack, SIGNAL(released()), this, SIGNAL(skipBack())); 0033 0034 buttonBack = new QToolButton(this); 0035 buttonBack->setIcon(KisIconUtils::loadIcon("prevframe")); 0036 buttonBack->setToolTip(i18n("Back")); 0037 buttonBack->setIconSize(QSize(22, 22)); 0038 buttonBack->setFocusPolicy(Qt::NoFocus); 0039 buttonBack->setAutoRaise(true); 0040 layout->addWidget(buttonBack); 0041 connect(buttonBack, SIGNAL(released()), this, SIGNAL(back())); 0042 0043 buttonStop = new QToolButton(this); 0044 buttonStop->setIcon(KisIconUtils::loadIcon("animation_stop")); 0045 buttonStop->setToolTip(i18n("Stop")); 0046 buttonStop->setIconSize(QSize(22, 22)); 0047 buttonStop->setFocusPolicy(Qt::NoFocus); 0048 buttonStop->setAutoRaise(true); 0049 layout->addWidget(buttonStop); 0050 connect(buttonStop, SIGNAL(released()), this, SIGNAL(stop())); 0051 0052 buttonPlayPause = new QToolButton(this); 0053 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_play")); 0054 buttonPlayPause->setToolTip(i18n("Play/Pause")); 0055 buttonPlayPause->setIconSize(QSize(22, 22)); 0056 buttonPlayPause->setFocusPolicy(Qt::NoFocus); 0057 buttonPlayPause->setAutoRaise(true); 0058 layout->addWidget(buttonPlayPause); 0059 connect(buttonPlayPause, SIGNAL(released()), this, SIGNAL(playPause())); 0060 0061 buttonForward = new QToolButton(this); 0062 buttonForward->setIcon(KisIconUtils::loadIcon("nextframe")); 0063 buttonForward->setToolTip(i18n("Forward")); 0064 buttonForward->setIconSize(QSize(22, 22)); 0065 buttonForward->setFocusPolicy(Qt::NoFocus); 0066 buttonForward->setAutoRaise(true); 0067 layout->addWidget(buttonForward); 0068 connect(buttonForward, SIGNAL(released()), this, SIGNAL(forward())); 0069 0070 buttonSkipForward = new QToolButton(this); 0071 buttonSkipForward->setIcon(KisIconUtils::loadIcon("nextkeyframe")); 0072 buttonSkipForward->setToolTip(i18n("Skip Forward")); 0073 buttonSkipForward->setIconSize(QSize(22, 22)); 0074 buttonSkipForward->setFocusPolicy(Qt::NoFocus); 0075 buttonSkipForward->setAutoRaise(true); 0076 layout->addWidget(buttonSkipForward); 0077 connect(buttonSkipForward, SIGNAL(released()), this, SIGNAL(skipForward())); 0078 0079 showStateButtons(true); 0080 showSeekButtons(true); 0081 showSkipButtons(false); 0082 0083 setFocusPolicy(Qt::ClickFocus); 0084 } 0085 0086 KisTransportControls::~KisTransportControls() 0087 { 0088 } 0089 0090 QSize KisTransportControls::sizeHint() const 0091 { 0092 return QSize(32, 32); 0093 } 0094 0095 void KisTransportControls::setPlaying(bool playing) 0096 { 0097 if (playing) { 0098 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_pause")); 0099 } else { 0100 buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_play")); 0101 } 0102 } 0103 0104 void KisTransportControls::showStateButtons(bool show) 0105 { 0106 if (show) { 0107 buttonPlayPause->show(); 0108 buttonStop->show(); 0109 } else { 0110 buttonPlayPause->hide(); 0111 buttonStop->hide(); 0112 } 0113 } 0114 0115 void KisTransportControls::showSeekButtons(bool show) 0116 { 0117 if (show) { 0118 buttonBack->show(); 0119 buttonForward->show(); 0120 } else { 0121 buttonBack->hide(); 0122 buttonForward->hide(); 0123 } 0124 } 0125 0126 void KisTransportControls::showSkipButtons(bool show) 0127 { 0128 if (show) { 0129 buttonSkipBack->show(); 0130 buttonSkipForward->show(); 0131 } else { 0132 buttonSkipBack->hide(); 0133 buttonSkipForward->hide(); 0134 } 0135 }