added real portable mode

This commit is contained in:
itsmattkc
2018-10-29 18:15:50 +11:00
parent a54fee767d
commit 0817a1e486
10 changed files with 39 additions and 14 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ ToneEffect::ToneEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_TONE_EFFECT
connect(mix_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
void ToneEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int channel_count) {
void ToneEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int) {
double interval = (timecode_end - timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=4) {
double timecode = timecode_start+(interval*i);
+16
View File
@@ -0,0 +1,16 @@
#include "path.h"
#include <QStandardPaths>
#include <QFileInfo>
#include <QCoreApplication>
QString get_data_path() {
QString app_path = QCoreApplication::applicationFilePath();
QString app_dir = app_path.left(app_path.lastIndexOf('/'));
if (QFileInfo::exists(app_dir + "/portable")) {
return app_dir;
} else {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef PATH_H
#define PATH_H
#include <QString>
QString get_data_path();
#endif // PATH_H
+3 -3
View File
@@ -4,7 +4,7 @@
#include "panels/viewer.h"
#include "panels/project.h"
#include "io/config.h"
#include "io/crc32.h"
#include "io/path.h"
#include "debug.h"
#include <QPainter>
@@ -14,8 +14,8 @@
#include <QSemaphore>
#include <QCryptographicHash>
#include <QFile>
#include <QStandardPaths>
#include <QDir>
#include <QDateTime>
#define WAVEFORM_RESOLUTION 64
@@ -38,7 +38,7 @@ PreviewGenerator::PreviewGenerator(QTreeWidgetItem* i, Media* m, bool r) :
replace(r),
cancelled(false)
{
data_path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/previews";
data_path = get_data_path() + "/previews";
QDir data_dir(data_path);
if (!data_dir.exists()) {
data_dir.mkpath(".");
+3 -3
View File
@@ -2,6 +2,7 @@
#include "ui_mainwindow.h"
#include "io/config.h"
#include "io/path.h"
#include "project/sequence.h"
@@ -33,7 +34,6 @@
#include <QStyleFactory>
#include <QMessageBox>
#include <QFileDialog>
#include <QStandardPaths>
#include <QTimer>
#include <QCloseEvent>
#include <QMovie>
@@ -120,7 +120,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->menuEdit, SIGNAL(aboutToShow()), this, SLOT(editMenu_About_To_Be_Shown()));
connect(ui->menu_File, SIGNAL(aboutToShow()), this, SLOT(fileMenu_About_To_Be_Shown()));
QString data_dir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString data_dir = get_data_path();
if (!data_dir.isEmpty()) {
QDir dir(data_dir);
dir.mkpath(".");
@@ -198,7 +198,7 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow() {
set_sequence(NULL);
QString data_dir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString data_dir = get_data_path();
if (!data_dir.isEmpty() && !autorecovery_filename.isEmpty()) {
if (QFile::exists(autorecovery_filename)) {
QFile::rename(autorecovery_filename, autorecovery_filename + "." + QDateTime::currentDateTimeUtc().toString("yyyyMMddHHmmss"));
+4 -2
View File
@@ -87,7 +87,8 @@ SOURCES += \
effects/video/temperatureeffect.cpp \
io/crc32.cpp \
dialogs/loaddialog.cpp \
debug.cpp
debug.cpp \
io/path.cpp
HEADERS += \
mainwindow.h \
@@ -153,7 +154,8 @@ HEADERS += \
effects/video/temperatureeffect.h \
io/crc32.h \
dialogs/loaddialog.h \
debug.h
debug.h \
io/path.h
FORMS += \
mainwindow.ui \
+1 -1
View File
@@ -263,7 +263,7 @@ void EffectControls::on_add_audio_transition_button_clicked()
show_effect_menu(false, true);
}
void EffectControls::resizeEvent(QResizeEvent *event) {
void EffectControls::resizeEvent(QResizeEvent*) {
ui->verticalScrollBar->setMaximum(qMax(0, ui->effects_area->height() - ui->keyframeView->height() - ui->headers->height()));
}
+1 -1
View File
@@ -319,6 +319,6 @@ void stop_recording() {
}
}
const QString& get_recorded_audio_filename() {
QString get_recorded_audio_filename() {
return output_recording.fileName();
}
+1 -1
View File
@@ -48,7 +48,7 @@ int get_buffer_offset_from_frame(Sequence *s, long frame);
bool start_recording();
void stop_recording();
const QString& get_recorded_audio_filename();
QString get_recorded_audio_filename();
extern bool recording;
#endif // AUDIO_H
+1 -2
View File
@@ -114,8 +114,7 @@ void get_clip_frame(Clip* c, long playhead) {
MediaStream* ms = static_cast<Media*>(c->media)->get_stream_from_file_index(c->track < 0, c->media_stream);
int64_t target_pts = playhead_to_timestamp(c, playhead);
int64_t second_pts = qRound64(av_q2d(av_inv_q(c->stream->time_base)));
int64_t quarter_pts = second_pts >> 2;
int64_t second_pts = qRound64(av_q2d(av_inv_q(c->stream->time_base)));
if (ms->video_interlacing != VIDEO_PROGRESSIVE) {
target_pts *= 2;
second_pts *= 2;