17#include "onionskinwidget.h"
18#include "ui_onionskin.h"
20#include "preferencemanager.h"
22#include "flowlayout.h"
25OnionSkinWidget::OnionSkinWidget(
QWidget *parent) :
31 clearFocusOnFinished(ui->onionPrevFramesNumBox);
32 clearFocusOnFinished(ui->onionNextFramesNumBox);
33 clearFocusOnFinished(ui->onionMinOpacityBox);
34 clearFocusOnFinished(ui->onionMaxOpacityBox);
37OnionSkinWidget::~OnionSkinWidget()
42void OnionSkinWidget::initUI()
52 ui->opacityGroup->layout()->removeWidget(ui->minOpacityGroup);
53 ui->opacityGroup->layout()->removeWidget(ui->maxOpacityGroup);
54 opacityLayout->
addWidget(ui->minOpacityGroup);
55 opacityLayout->
addWidget(ui->maxOpacityGroup);
56 delete ui->opacityGroup->layout();
57 ui->opacityGroup->setLayout(opacityLayout);
61 ui->scrollAreaWidgetContents->layout()->setSpacing(8);
65 "QToolButton { border: 0px; } "
67 "subcontrol-origin: padding;"
69 "padding: 2px 2px 0px 0px;"
70 "background: transparent;"
73 "subcontrol-origin: margin;"
77 "QToolButton:pressed{ border: 1px solid #FFADAD; border-radius: 2px; background-color: #D5D5D5; }"
78 "QToolButton:checked{ border: 1px solid #ADADAD; border-radius: 2px; background-color: #D5D5D5; }";
83void OnionSkinWidget::makeConnections()
86 connect(ui->onionMaxOpacityBox, spinBoxChanged,
this, &OnionSkinWidget::onionMaxOpacityChange);
87 connect(ui->onionMinOpacityBox, spinBoxChanged,
this, &OnionSkinWidget::onionMinOpacityChange);
88 connect(ui->onionPrevFramesNumBox, spinBoxChanged,
this, &OnionSkinWidget::onionPrevFramesNumChange);
89 connect(ui->onionNextFramesNumBox, spinBoxChanged,
this, &OnionSkinWidget::onionNextFramesNumChange);
100 connect(prefs, &PreferenceManager::optionChanged,
this, &OnionSkinWidget::updateUI);
104void OnionSkinWidget::updateUI()
108 ui->prevFramesGroup->setChecked(prefs->isOn(SETTING::PREV_ONION));
109 ui->nextFramesGroup->setChecked(prefs->isOn(SETTING::NEXT_ONION));
112 ui->onionBlueButton->setChecked(prefs->isOn(SETTING::ONION_BLUE));
115 ui->onionRedButton->setChecked(prefs->isOn(SETTING::ONION_RED));
117 ui->onionMaxOpacityBox->setValue(prefs->getInt(SETTING::ONION_MAX_OPACITY));
118 ui->onionMinOpacityBox->setValue(prefs->getInt(SETTING::ONION_MIN_OPACITY));
119 ui->onionPrevFramesNumBox->setValue(prefs->getInt(SETTING::ONION_PREV_FRAMES_NUM));
120 ui->onionNextFramesNumBox->setValue(prefs->getInt(SETTING::ONION_NEXT_FRAMES_NUM));
123 ui->onionSkinMode->setChecked(prefs->getString(SETTING::ONION_TYPE) ==
"absolute");
126 ui->onionWhilePlayback->setChecked(prefs->getInt(SETTING::ONION_WHILE_PLAYBACK));
130void OnionSkinWidget::prevFramesGroupClicked(
bool isOn)
133 prefs->set(SETTING::PREV_ONION, isOn);
136void OnionSkinWidget::nextFramesGroupClicked(
bool isOn)
139 prefs->set(SETTING::NEXT_ONION, isOn);
142void OnionSkinWidget::onionRedButtonClicked(
bool isOn)
145 prefs->set(SETTING::ONION_RED, isOn);
148void OnionSkinWidget::onionBlueButtonClicked(
bool isOn)
151 prefs->set(SETTING::ONION_BLUE, isOn);
154void OnionSkinWidget::onionMaxOpacityChange(
int value)
157 prefs->set(SETTING::ONION_MAX_OPACITY, value);
160void OnionSkinWidget::onionMinOpacityChange(
int value)
163 prefs->set(SETTING::ONION_MIN_OPACITY, value);
166void OnionSkinWidget::onionPrevFramesNumChange(
int value)
169 prefs->set(SETTING::ONION_PREV_FRAMES_NUM, value);
172void OnionSkinWidget::onionNextFramesNumChange(
int value)
175 prefs->set(SETTING::ONION_NEXT_FRAMES_NUM, value);
178void OnionSkinWidget::onionSkinModeChange(
int value)
183 prefs->set(SETTING::ONION_TYPE,
QString(
"absolute"));
187 prefs->set(SETTING::ONION_TYPE,
QString(
"relative"));
191void OnionSkinWidget::playbackStateChanged(
int value)
194 prefs->set(SETTING::ONION_WHILE_PLAYBACK, value);
void stateChanged(int state)
void clicked(bool checked)
bool setAlignment(QWidget *w, Qt::Alignment alignment)
void setContentsMargins(int left, int top, int right, int bottom)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)