Skip to content

Commit

Permalink
Add save of default setting for fade filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Mar 12, 2015
1 parent 43cc2d0 commit e43d8fe
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/qml/filters/audio_fadein/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.audioInDuration * profile.fps)
filter.set('gain', 0)
filter.set('end', 1)
filter.set('in', filter.producerIn)
Expand All @@ -50,6 +50,12 @@ Rectangle {
maximumValue: 5000
value: filter.getDouble('out') - filter.getDouble('in') + 1
onValueChanged: filter.set('out', filter.getDouble('in') + value - 1)
onSetDefaultClicked: {
duration = Math.ceil(settings.audioInDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.audioInDuration = duration / profile.fps
}
}
}
Item {
Expand Down
8 changes: 7 additions & 1 deletion src/qml/filters/audio_fadeout/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.audioOutDuration * profile.fps)
filter.set('gain', 1)
filter.set('end', 0)
filter.set('out', filter.producerOut)
Expand All @@ -52,6 +52,12 @@ Rectangle {
onValueChanged: {
filter.set('in', filter.getDouble('out') - duration + 1)
}
onSetDefaultClicked: {
duration = Math.ceil(settings.audioOutDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.audioOutDuration = duration / profile.fps
}
}
}
Item {
Expand Down
8 changes: 7 additions & 1 deletion src/qml/filters/fadein_brightness/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.videoInDuration * profile.fps)
filter.set('level', '0=0; %1=1'.arg(duration - 1))
filter.set('alpha', 1)
filter.set('in', filter.producerIn)
Expand Down Expand Up @@ -58,6 +58,12 @@ Rectangle {
else
filter.set('level', '0=0; %1=1'.arg(duration - 1))
}
onSetDefaultClicked: {
duration = Math.ceil(settings.videoInDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.videoInDuration = duration / profile.fps
}
}
}
CheckBox {
Expand Down
8 changes: 7 additions & 1 deletion src/qml/filters/fadein_movit/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.videoInDuration * profile.fps)
filter.set('opacity', '0~=0; %1=1'.arg(duration - 1))
filter.set('alpha', 1)
filter.set('in', filter.producerIn)
Expand All @@ -51,6 +51,12 @@ Rectangle {
maximumValue: 5000
value: filter.getDouble('out') - filter.getDouble('in') + 1
onValueChanged: filter.set('out', filter.getDouble('in') + value - 1)
onSetDefaultClicked: {
duration = Math.ceil(settings.videoInDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.videoInDuration = duration / profile.fps
}
}
}
CheckBox {
Expand Down
8 changes: 7 additions & 1 deletion src/qml/filters/fadeout_brightness/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.videoOutDuration * profile.fps)
var out = filter.producerOut
var inFrame = out - duration + 1
filter.set('level', '0=1; %1=0'.arg(duration - 1))
Expand Down Expand Up @@ -60,6 +60,12 @@ Rectangle {
else
filter.set('level', '0=1; %1=0'.arg(duration - 1))
}
onSetDefaultClicked: {
duration = Math.ceil(settings.videoOutDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.videoOutDuration = duration / profile.fps
}
}
}
CheckBox {
Expand Down
8 changes: 7 additions & 1 deletion src/qml/filters/fadeout_movit/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rectangle {

Component.onCompleted: {
if (filter.isNew) {
duration = filter.framesFromTime('1:0')
duration = Math.ceil(settings.videoOutDuration * profile.fps)
var out = filter.producerOut
var inFrame = out - duration + 1
filter.set('opacity', '0~=1; %1=0'.arg(duration - 1))
Expand All @@ -53,6 +53,12 @@ Rectangle {
maximumValue: 5000
value: filter.getDouble('out') - filter.getDouble('in') + 1
onValueChanged: filter.set('in', filter.getDouble('out') - duration + 1)
onSetDefaultClicked: {
duration = Math.ceil(settings.videoOutDuration * profile.fps)
}
onSaveDefaultClicked: {
settings.videoOutDuration = duration / profile.fps
}
}
}
CheckBox {
Expand Down
27 changes: 27 additions & 0 deletions src/qml/modules/Shotcut/Controls/SaveDefaultButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2015 Meltytech, LLC
* Author: Brian Matherly <code@brianmatherly.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick.Controls 1.0

Button {
iconName: 'document-save'
iconSource: 'qrc:///icons/oxygen/32x32/actions/document-save.png'
tooltip: qsTr('Set as default')
implicitWidth: 20
implicitHeight: 20
}
9 changes: 9 additions & 0 deletions src/qml/modules/Shotcut/Controls/TimeSpinner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import QtQuick.Layouts 1.1
import QtQuick.Controls 1.1

RowLayout {
id: root
property int minimumValue: 0
property int maximumValue: 99
property int value: 0
signal setDefaultClicked()
signal saveDefaultClicked()

spacing: 0

Expand Down Expand Up @@ -78,6 +81,12 @@ RowLayout {
onTriggered: incrementAction.trigger()
}
}
UndoButton {
onClicked: root.setDefaultClicked()
}
SaveDefaultButton {
onClicked: root.saveDefaultClicked()
}
Action {
id: decrementAction
onTriggered: value = value = Math.max(value - 1, minimumValue)
Expand Down
1 change: 1 addition & 0 deletions src/qml/modules/Shotcut/Controls/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ Preset 1.0 Preset.qml
ToolTip 1.0 ToolTip.qml
UndoButton 1.0 UndoButton.qml
TimeSpinner 1.0 TimeSpinner.qml
SaveDefaultButton 1.0 SaveDefaultButton.qml
SliderSpinner 1.0 SliderSpinner.qml
RectangleControl 1.0 RectangleControl.qml
5 changes: 5 additions & 0 deletions src/qmltypes/qmlprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ double QmlProfile::aspectRatio() const
{
return MLT.profile().dar();
}

double QmlProfile::fps() const
{
return MLT.profile().fps();
}
2 changes: 2 additions & 0 deletions src/qmltypes/qmlprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class QmlProfile : public QObject
Q_PROPERTY(int width READ width CONSTANT)
Q_PROPERTY(int height READ height CONSTANT)
Q_PROPERTY(double aspectRatio READ aspectRatio CONSTANT)
Q_PROPERTY(double fps READ fps CONSTANT)

public:
static QmlProfile& singleton();

int width() const;
int height() const;
double aspectRatio() const;
double fps() const;

private:
explicit QmlProfile();
Expand Down
45 changes: 45 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,51 @@ void ShotcutSettings::setFilterFavorite(const QString& filterName, const QString
settings.setValue("filter/favorite/" + filterName, value);
}

double ShotcutSettings::audioInDuration() const
{
return settings.value("filter/audioInDuration", 1.0).toDouble();
}

void ShotcutSettings::setAudioInDuration(double d)
{
settings.setValue("filter/audioInDuration", d);
emit audioInDurationChanged();
}

double ShotcutSettings::audioOutDuration() const
{
return settings.value("filter/audioOutDuration", 1.0).toDouble();
}

void ShotcutSettings::setAudioOutDuration(double d)
{
settings.setValue("filter/audioOutDuration", d);
emit audioOutDurationChanged();
}


double ShotcutSettings::videoInDuration() const
{
return settings.value("filter/videoInDuration", 1.0).toDouble();
}

void ShotcutSettings::setVideoInDuration(double d)
{
settings.setValue("filter/videoInDuration", d);
emit videoInDurationChanged();
}

double ShotcutSettings::videoOutDuration() const
{
return settings.value("filter/videoOutDuration", 1.0).toDouble();
}

void ShotcutSettings::setVideoOutDuration(double d)
{
settings.setValue("filter/videoOutDuration", d);
emit videoOutDurationChanged();
}

void ShotcutSettings::sync()
{
settings.sync();
Expand Down
21 changes: 21 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class ShotcutSettings : public QObject
Q_PROPERTY(QString openPath READ openPath WRITE setOpenPath NOTIFY openPathChanged)
Q_PROPERTY(QString savePath READ savePath WRITE setSavePath NOTIFY savePathChanged)
Q_PROPERTY(bool playerGPU READ playerGPU NOTIFY playerGpuChanged)
Q_PROPERTY(double audioInDuration READ audioInDuration WRITE setAudioInDuration NOTIFY audioInDurationChanged)
Q_PROPERTY(double audioOutDuration READ audioOutDuration WRITE setAudioOutDuration NOTIFY audioOutDurationChanged)
Q_PROPERTY(double videoInDuration READ videoInDuration WRITE setVideoInDuration NOTIFY videoInDurationChanged)
Q_PROPERTY(double videoOutDuration READ videoOutDuration WRITE setVideoOutDuration NOTIFY videoOutDurationChanged)


public:
static ShotcutSettings& singleton();
Expand Down Expand Up @@ -102,13 +107,29 @@ class ShotcutSettings : public QObject
QString filterFavorite(const QString& filterName);
void setFilterFavorite(const QString& filterName, const QString& value);

double audioInDuration() const;
void setAudioInDuration(double);

double audioOutDuration() const;
void setAudioOutDuration(double);

double videoInDuration() const;
void setVideoInDuration(double);

double videoOutDuration() const;
void setVideoOutDuration(double);

void sync();

signals:
void openPathChanged();
void savePathChanged();
void timelineShowWaveformsChanged();
void playerGpuChanged();
void audioInDurationChanged();
void audioOutDurationChanged();
void videoInDurationChanged();
void videoOutDurationChanged();

private:
QSettings settings;
Expand Down

0 comments on commit e43d8fe

Please sign in to comment.