Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
toolspage.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#include "toolspage.h"
19
20#include <QtMath>
21
22#include "preferencemanager.h"
23
24#include "ui_toolspage.h"
25
26ToolsPage::ToolsPage() : ui(new Ui::ToolsPage)
27{
28 ui->setupUi(this);
29
30 connect(ui->useQuickSizingBox, &QCheckBox::stateChanged, this, &ToolsPage::quickSizingChange);
31 connect(ui->rotationIncrementSlider, &QSlider::valueChanged, this, &ToolsPage::rotationIncrementChange);
32 connect(ui->invertZoomDirectionBox, &QCheckBox::stateChanged, this, &ToolsPage::invertZoomDirectionChange);
33}
34
35ToolsPage::~ToolsPage()
36{
37 delete ui;
38}
39
40void ToolsPage::updateValues()
41{
42 ui->useQuickSizingBox->setChecked(mManager->isOn(SETTING::QUICK_SIZING));
43 ui->invertZoomDirectionBox->setChecked(mManager->isOn(SETTING::INVERT_DRAG_ZOOM_DIRECTION));
44 setRotationIncrement(mManager->getInt(SETTING::ROTATION_INCREMENT));
45}
46
47void ToolsPage::quickSizingChange(int b)
48{
49 mManager->set(SETTING::QUICK_SIZING, b != Qt::Unchecked);
50}
51
52void ToolsPage::invertZoomDirectionChange(int b)
53{
54 mManager->set(SETTING::INVERT_DRAG_ZOOM_DIRECTION, b != Qt::Unchecked);
55}
56
57void ToolsPage::setRotationIncrement(int angle)
58{
59 int value = qSqrt((angle - 1) / 359.0) * 359;
60 ui->rotationIncrementSlider->setValue(value);
61}
62
63void ToolsPage::rotationIncrementChange(int value)
64{
65 // Use log scale
66 int angle = qPow(value / 359.0, 2) * 359 + 1;
67 // Basically round up to the nearest number that is a divisor of 360
68 while (360 % angle != 0) {
69 angle++;
70 }
71 ui->rotationIncrementDisplay->setText(tr("%1 degrees").arg(angle)); // don't use tr()'s plural settings, it breaks Transifex.
72 mManager->set(SETTING::ROTATION_INCREMENT, angle);
73}
ToolsPage
Definition: toolspage.h:28
QAbstractSlider::valueChanged
void valueChanged(int value)
QCheckBox::stateChanged
void stateChanged(int state)
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
Qt::Unchecked
Unchecked
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39