Skip to content

Commit

Permalink
Merge pull request #1143 from davidlamhauge/fps_field_in_settings
Browse files Browse the repository at this point in the history
Fps and field size in settings
  • Loading branch information
chchwy committed Dec 20, 2018
2 parents 82dc3e3 + aaa9a74 commit 87922a3
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
5 changes: 5 additions & 0 deletions core_lib/src/managers/playbackmanager.cpp
Expand Up @@ -20,6 +20,7 @@ GNU General Public License for more details.
#include <QTimer>
#include <QElapsedTimer>
#include <QDebug>
#include <QSettings>
#include "object.h"
#include "editor.h"
#include "layersound.h"
Expand All @@ -40,6 +41,8 @@ bool PlaybackManager::init()
{
mTimer = new QTimer(this);
mTimer->setTimerType(Qt::PreciseTimer);
QSettings settings (PENCIL2D, PENCIL2D);
mFps = settings.value(SETTING_FPS).toInt();

mElapsedTimer = new QElapsedTimer;
connect(mTimer, &QTimer::timeout, this, &PlaybackManager::timerTick);
Expand Down Expand Up @@ -144,6 +147,8 @@ void PlaybackManager::setFps(int fps)
if (mFps != fps)
{
mFps = fps;
QSettings settings (PENCIL2D, PENCIL2D);
settings.setValue(SETTING_FPS, fps);
emit fpsChanged(mFps);

// Update key-frame lengths of sound layers,
Expand Down
13 changes: 13 additions & 0 deletions core_lib/src/managers/preferencemanager.cpp
Expand Up @@ -73,6 +73,10 @@ void PreferenceManager::loadPrefs()
set(SETTING::LAYOUT_LOCK, settings.value(SETTING_LAYOUT_LOCK, false).toBool());
set(SETTING::FRAME_POOL_SIZE, settings.value(SETTING_FRAME_POOL_SIZE, 200).toInt());

set(SETTING::FPS, settings.value(SETTING_FPS, 12).toInt());
set(SETTING::FIELD_W, settings.value(SETTING_FIELD_W, 800).toInt());
set(SETTING::FIELD_H, settings.value(SETTING_FIELD_H, 600).toInt());

// Files
set(SETTING::AUTO_SAVE, settings.value(SETTING_AUTO_SAVE, true ).toBool());
set(SETTING::AUTO_SAVE_NUMBER, settings.value(SETTING_AUTO_SAVE_NUMBER, 25).toInt());
Expand Down Expand Up @@ -227,6 +231,15 @@ void PreferenceManager::set(SETTING option, int value)
case SETTING::ONION_WHILE_PLAYBACK:
settings.setValue(SETTING_ONION_WHILE_PLAYBACK, value);
break;
case SETTING::FPS:
settings.setValue(SETTING_FPS, value);
break;
case SETTING::FIELD_W:
settings.setValue(SETTING_FIELD_W, value);
break;
case SETTING::FIELD_H:
settings.setValue(SETTING_FIELD_H, value);
break;
default:
Q_ASSERT(false);
break;
Expand Down
3 changes: 3 additions & 0 deletions core_lib/src/managers/preferencemanager.h
Expand Up @@ -44,6 +44,9 @@ enum class SETTING
AUTO_SAVE,
AUTO_SAVE_NUMBER,
SHORT_SCRUB,
FPS,
FIELD_W,
FIELD_H,
FRAME_SIZE,
TIMELINE_SIZE,
LABEL_FONT_SIZE,
Expand Down
16 changes: 14 additions & 2 deletions core_lib/src/structure/layercamera.cpp
Expand Up @@ -24,7 +24,8 @@ GNU General Public License for more details.
#include <QHBoxLayout>
#include <QtDebug>
#include "camera.h"

#include <qsettings.h>
#include "pencildef.h"

CameraPropertiesDialog::CameraPropertiesDialog(QString name, int width, int height) :
QDialog(),
Expand Down Expand Up @@ -77,7 +78,15 @@ void CameraPropertiesDialog::setHeight(int height)
LayerCamera::LayerCamera( Object* object ) : Layer( object, Layer::CAMERA )
{
setName(tr("Camera Layer"));
viewRect = QRect(QPoint(-400, -300), QSize(800, 600));
QSettings settings (PENCIL2D, PENCIL2D);
mFieldW = settings.value("FieldW").toInt();
mFieldH = settings.value("FieldH").toInt();
if (mFieldW < 2 || mFieldH < 2)
{
mFieldW = 800;
mFieldH = 600;
}
viewRect = QRect(QPoint(-mFieldW/2, -mFieldH/2), QSize(mFieldW, mFieldH));
dialog = nullptr;
}

Expand Down Expand Up @@ -243,6 +252,9 @@ void LayerCamera::editProperties()
if (result == QDialog::Accepted)
{
setName( dialog->getName() );
QSettings settings (PENCIL2D, PENCIL2D);
settings.setValue(SETTING_FIELD_W, dialog->getWidth());
settings.setValue(SETTING_FIELD_H, dialog->getHeight());
viewRect = QRect(-dialog->getWidth()/2, -dialog->getHeight()/2, dialog->getWidth(), dialog->getHeight());

emit resolutionChanged();
Expand Down
2 changes: 2 additions & 0 deletions core_lib/src/structure/layercamera.h
Expand Up @@ -77,6 +77,8 @@ class LayerCamera : public Layer
private:
void linearInterpolateTransform(Camera*);

int mFieldW = 800;
int mFieldH = 600;
QRect viewRect;
CameraPropertiesDialog* dialog = nullptr;
};
Expand Down
5 changes: 4 additions & 1 deletion core_lib/src/structure/objectdata.cpp
Expand Up @@ -19,6 +19,9 @@ GNU General Public License for more details.

ObjectData::ObjectData()
{

QSettings settings(PENCIL2D,PENCIL2D);
mFps = settings.value(SETTING_FPS).toInt();
if (mFps < 1)
mFps = 12;
}

4 changes: 3 additions & 1 deletion core_lib/src/structure/objectdata.h
Expand Up @@ -20,6 +20,8 @@ GNU General Public License for more details.

#include <QColor>
#include <QTransform>
#include "pencildef.h"
#include <qsettings.h>


class ObjectData
Expand Down Expand Up @@ -65,7 +67,7 @@ class ObjectData
QTransform mCurrentView;

// playback manager
int mFps = 12;
int mFps = 12;
bool mIsLoop = false;
bool mIsRangedPlayback = false;
int mMarkInFrame = 1;
Expand Down
3 changes: 3 additions & 0 deletions core_lib/src/util/pencildef.h
Expand Up @@ -174,6 +174,9 @@ enum StabilizationLevel
#define SETTING_CURVE_SMOOTHING "CurveSmoothing"
#define SETTING_DISPLAY_EFFECT "RenderEffect"
#define SETTING_SHORT_SCRUB "ShortScrub"
#define SETTING_FPS "Fps"
#define SETTING_FIELD_W "FieldW"
#define SETTING_FIELD_H "FieldH"
#define SETTING_FRAME_SIZE "FrameSize"
#define SETTING_TIMELINE_SIZE "TimelineSize"
#define SETTING_LABEL_FONT_SIZE "LabelFontSize"
Expand Down

0 comments on commit 87922a3

Please sign in to comment.