Skip to content

Commit aabddc3

Browse files
authored
Merge branch 'openscad:master' into master
2 parents 24467ea + f7b679c commit aabddc3

File tree

7 files changed

+184
-406
lines changed

7 files changed

+184
-406
lines changed

src/gui/Animate.cc

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ Animate::Animate(QWidget *parent) : QWidget(parent)
2828
const auto scrollMargins = scrollAreaWidgetContents->layout()->contentsMargins();
2929
const auto parameterMargins = groupBoxParameter->layout()->contentsMargins();
3030
initMinWidth = width + margins.left() + margins.right() + scrollMargins.left() + scrollMargins.right()
31-
+parameterMargins.left() + parameterMargins.right();
31+
+ parameterMargins.left() + parameterMargins.right();
3232
}
3333

3434
void Animate::initGUI()
3535
{
36-
this->animStep = 0;
37-
this->animNumSteps = 0;
36+
this->animStep = 0;
37+
this->animNumSteps = 0;
3838
this->animTVal = 0.0;
39-
this->animDumping = false;
39+
this->animDumping = false;
4040
this->animDumpStartStep = 0;
4141

4242
this->iconRun = QIcon::fromTheme("chokusen-animate-play");
4343
this->iconPause = QIcon::fromTheme("chokusen-animate-pause");
4444
this->iconDisabled = QIcon::fromTheme("chokusen-animate-disabled");
4545

46-
animateTimer = new QTimer(this);
47-
connect(animateTimer, SIGNAL(timeout()), this, SLOT(incrementTVal()));
46+
animateTimer = new QTimer(this);
47+
connect(animateTimer, SIGNAL(timeout()), this, SLOT(incrementTVal()));
4848

4949
connect(this->e_tval, SIGNAL(textChanged(QString)), this, SLOT(updatedAnimTval()));
5050
connect(this->e_fps, SIGNAL(textChanged(QString)), this, SLOT(updatedAnimFpsAndAnimSteps()));
@@ -72,9 +72,9 @@ void Animate::connectAction(QAction *action, QPushButton *button)
7272

7373
void Animate::updatedAnimTval()
7474
{
75-
double t = this->e_tval->text().toDouble(&this->tOK);
75+
double t = this->e_tval->text().toDouble(&this->tOK);
7676
// Clamp t to 0-1
77-
if (this->tOK) {
77+
if (this->tOK) {
7878
t = t < 0 ? 0.0 : ((t > 1.0) ? 1.0 : t);
7979
} else {
8080
t = 0.0;
@@ -88,23 +88,23 @@ void Animate::updatedAnimTval()
8888

8989
void Animate::updatedAnimFpsAndAnimSteps()
9090
{
91-
animateTimer->stop();
91+
animateTimer->stop();
9292

9393
int numsteps = this->e_fsteps->text().toInt(&this->steps_ok);
9494
if (this->steps_ok) {
95-
this->animNumSteps = numsteps;
95+
this->animNumSteps = numsteps;
9696
} else {
97-
this->animNumSteps = 0;
97+
this->animNumSteps = 0;
9898
}
9999
this->animDumping = false;
100100

101101
double fps = this->e_fps->text().toDouble(&this->fpsOK);
102102
animateTimer->stop();
103103
if (this->fpsOK && fps > 0 && this->animNumSteps > 0) {
104-
this->animStep = int(this->animTVal * this->animNumSteps) % this->animNumSteps;
105-
animateTimer->setSingleShot(false);
106-
animateTimer->setInterval(int(1000 / fps));
107-
animateTimer->start();
104+
this->animStep = int(this->animTVal * this->animNumSteps) % this->animNumSteps;
105+
animateTimer->setSingleShot(false);
106+
animateTimer->setInterval(int(1000 / fps));
107+
animateTimer->start();
108108
}
109109

110110
QPalette defaultPalette;
@@ -129,25 +129,25 @@ void Animate::updatedAnimFpsAndAnimSteps()
129129

130130
void Animate::updatedAnimDump(bool checked)
131131
{
132-
if (!checked) this->animDumping = false;
132+
if (!checked) this->animDumping = false;
133133

134134
updatePauseButtonIcon();
135135
}
136136

137137
// Only called from animate_timer
138138
void Animate::incrementTVal()
139139
{
140-
if (this->animNumSteps == 0) return;
140+
if (this->animNumSteps == 0) return;
141141

142-
if (mainWindow->windowActionHideCustomizer->isVisible()) {
142+
if (mainWindow->parameterDock->isVisible()) {
143143
if (mainWindow->activeEditor->parameterWidget->childHasFocus()) return;
144144
}
145145

146146
if (this->animNumSteps > 1) {
147-
this->animStep = (this->animStep + 1) % this->animNumSteps;
148-
this->animTVal = 1.0 * this->animStep / this->animNumSteps;
147+
this->animStep = (this->animStep + 1) % this->animNumSteps;
148+
this->animTVal = 1.0 * this->animStep / this->animNumSteps;
149149
} else if (this->animNumSteps > 0) {
150-
this->animStep = 0;
150+
this->animStep = 0;
151151
this->animTVal = 0.0;
152152
}
153153

@@ -159,17 +159,17 @@ void Animate::incrementTVal()
159159

160160
void Animate::updateTVal()
161161
{
162-
if (this->animNumSteps == 0) return;
162+
if (this->animNumSteps == 0) return;
163163

164164
if (this->animStep < 0) {
165-
this->animStep = this->animNumSteps - this->animStep - 2;
165+
this->animStep = this->animNumSteps - this->animStep - 2;
166166
}
167167

168168
if (this->animNumSteps > 1) {
169-
this->animStep = (this->animStep) % this->animNumSteps;
170-
this->animTVal = 1.0 * this->animStep / this->animNumSteps;
169+
this->animStep = (this->animStep) % this->animNumSteps;
170+
this->animTVal = 1.0 * this->animStep / this->animNumSteps;
171171
} else if (this->animNumSteps > 0) {
172-
this->animStep = 0;
172+
this->animStep = 0;
173173
this->animTVal = 0.0;
174174
}
175175

@@ -180,14 +180,14 @@ void Animate::updateTVal()
180180
}
181181

182182
void Animate::pauseAnimation(){
183-
animateTimer->stop();
183+
animateTimer->stop();
184184
updatePauseButtonIcon();
185185
}
186186

187187
void Animate::on_pauseButton_pressed()
188188
{
189-
if (animateTimer->isActive()) {
190-
animateTimer->stop();
189+
if (animateTimer->isActive()) {
190+
animateTimer->stop();
191191
updatePauseButtonIcon();
192192
} else {
193193
this->updatedAnimFpsAndAnimSteps();
@@ -196,7 +196,7 @@ void Animate::on_pauseButton_pressed()
196196

197197
void Animate::updatePauseButtonIcon()
198198
{
199-
if (animateTimer->isActive()) {
199+
if (animateTimer->isActive()) {
200200
pauseButton->setIcon(this->iconPause);
201201
pauseButton->setToolTip(_("press to pause animation") );
202202
} else {
@@ -223,29 +223,29 @@ void Animate::animateUpdate()
223223
if (mainWindow->animateDockContents->isVisible()) {
224224
double fps = this->e_fps->text().toDouble(&this->fpsOK);
225225
if (this->fpsOK && fps <= 0 && !animateTimer->isActive()) {
226-
animateTimer->stop();
227-
animateTimer->setSingleShot(true);
228-
animateTimer->setInterval(50);
229-
animateTimer->start();
226+
animateTimer->stop();
227+
animateTimer->setSingleShot(true);
228+
animateTimer->setInterval(50);
229+
animateTimer->start();
230230
}
231231
}
232232
}
233233

234234
bool Animate::dumpPictures(){
235-
return this->e_dump->isChecked() && this->animateTimer->isActive();
235+
return this->e_dump->isChecked() && this->animateTimer->isActive();
236236
}
237237

238238
int Animate::nextFrame(){
239-
if (animDumping && animDumpStartStep == animStep) {
240-
animDumping = false;
239+
if (animDumping && animDumpStartStep == animStep) {
240+
animDumping = false;
241241
e_dump->setChecked(false);
242242
} else {
243-
if (!animDumping) {
244-
animDumping = true;
245-
animDumpStartStep = animStep;
243+
if (!animDumping) {
244+
animDumping = true;
245+
animDumpStartStep = animStep;
246246
}
247247
}
248-
return animStep;
248+
return animStep;
249249
}
250250

251251
void Animate::resizeEvent(QResizeEvent *event)

src/gui/Dock.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
Dock::Dock(QWidget *parent) : QDockWidget(parent)
99
{
1010
connect(this, &QDockWidget::topLevelChanged, this, &Dock::onTopLevelStatusChanged);
11+
connect(this, &QDockWidget::visibilityChanged, this, &Dock::onVisibilityChanged);
12+
1113
dockTitleWidget = new QWidget();
1214
}
1315

@@ -21,16 +23,12 @@ void Dock::disableSettingsUpdate()
2123
updateSettings = false;
2224
}
2325

24-
void Dock::setVisible(bool visible)
26+
void Dock::onVisibilityChanged(bool isDockVisible)
2527
{
2628
if (updateSettings) {
2729
QSettingsCached settings;
28-
settings.setValue(configKey, !visible);
29-
}
30-
if (action != nullptr) {
31-
action->setChecked(!visible);
30+
settings.setValue(configKey, !isVisible());
3231
}
33-
QDockWidget::setVisible(visible);
3432
}
3533

3634
void Dock::setTitleBarVisibility(bool isVisible)
@@ -43,11 +41,6 @@ void Dock::setConfigKey(const QString& configKey)
4341
this->configKey = configKey;
4442
}
4543

46-
void Dock::setAction(QAction *action)
47-
{
48-
this->action = action;
49-
}
50-
5144
void Dock::updateTitle(){
5245
QString title(name);
5346
if (isTopLevel() && !namesuffix.isEmpty()) {

src/gui/Dock.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Dock : public QDockWidget
1313
virtual ~Dock();
1414

1515
void setConfigKey(const QString& configKey);
16-
void setAction(QAction *action);
1716
void disableSettingsUpdate();
1817

1918
void setName(const QString& name_);
@@ -23,16 +22,14 @@ class Dock : public QDockWidget
2322
void setTitleBarVisibility(bool isVisible);
2423
void updateTitle();
2524

26-
2725
public slots:
28-
void setVisible(bool visible) override;
26+
void onVisibilityChanged(bool visible);
2927
void onTopLevelStatusChanged(bool);
3028

3129
private:
3230
QString name;
3331
QString namesuffix;
3432
QString configKey;
35-
QAction *action{nullptr};
3633
bool updateSettings{true};
3734
QWidget *dockTitleWidget;
3835
};

0 commit comments

Comments
 (0)