Prepairing for the pull request

This commit is contained in:
elsandosgrande
2019-03-02 04:47:54 +01:00
12 changed files with 193 additions and 82 deletions
+1
View File
@@ -5,6 +5,7 @@ __Olive version:__
__Source:__ *(AppImage, Website etc.)*
__Operating system:__ *(Ubuntu 18.04 64-bit)*
__CPU:__ *Intel i5-4300U*
__RAM:__ *8GB*
__GPU:__ *NVIDIA Geforce GT 1030 2GB (Driver ver xxx.xx.xx)*
### Detailed Description
+4 -2
View File
@@ -1,8 +1,10 @@
# Olive Video Editor
# Olive Video Editor [![Build Status](https://travis-ci.org/olive-editor/olive.svg?branch=master)](https://travis-ci.org/olive-editor/olive)
Olive is a free non-linear video editor for Windows, macOS, and Linux.
Discover more and download binaries at: https://www.olivevideoeditor.org/
![screen](https://www.olivevideoeditor.org/img/screenshot.jpg)
**Discover more:** [Website](https://www.olivevideoeditor.org/) | [Twitter](https://twitter.com/oliveteam) | [Discord](https://discord.gg/rvJMEYQ)
Please consider supporting Olive:
+1 -1
View File
@@ -2,7 +2,7 @@ Source: olive-editor
Section: video
Priority: optional
Maintainer: Olive Team <itsmattkc@gmail.com>
Build-Depends: debhelper (>=9), build-essential, qt5-default, qtmultimedia5-dev, libqt5opengl5-dev, libqt5multimedia5-plugins, libavformat-dev, libavcodec-dev, libavutil-dev, libswscale-dev, libswresample-dev, libavfilter-dev, libpostproc-dev, git, frei0r-plugins-dev, qttools5-dev-tools
Build-Depends: debhelper (>=9), build-essential, qt5-default, qtmultimedia5-dev, libqt5opengl5-dev, libqt5svg5-dev, libqt5multimedia5-plugins, libavformat-dev, libavcodec-dev, libavutil-dev, libswscale-dev, libswresample-dev, libavfilter-dev, libpostproc-dev, git, frei0r-plugins-dev, qttools5-dev-tools
Standards-Version: 3.9.6
Homepage: https://olivevideoeditor.org/
+85 -4
View File
@@ -76,17 +76,71 @@ void MainWindow::setup_layout(bool reset) {
QFile panel_config(get_config_dir().filePath("layout"));
if (panel_config.exists() && panel_config.open(QFile::ReadOnly)) {
// default to resetting unless we find the tag in the XML file
// default to resetting unless we find layout data in the XML file
reset = true;
// read XML layout file
QXmlStreamReader stream(&panel_config);
// loop through XML for all data
while (!stream.atEnd()) {
stream.readNextStartElement();
if (stream.name() == "panels") {
restoreState(QByteArray::fromBase64(stream.readElementText().toUtf8()), 0);
stream.readNext();
if (stream.name() == "panels" && stream.isStartElement()) {
// element contains MainWindow layout data to restore
stream.readNext();
restoreState(QByteArray::fromBase64(stream.text().toUtf8()), 0);
reset = false;
} else if (stream.name() == "panel" && stream.isStartElement()) {
// element contains layout data specific to a panel, we'll find the panel and load it
// get panel name from XML attribute
QString panel_name;
const QXmlStreamAttributes& attributes = stream.attributes();
for (int i=0;i<attributes.size();i++) {
const QXmlStreamAttribute& attr = attributes.at(i);
if (attr.name() == "name") {
panel_name = attr.value().toString();
break;
}
}
if (panel_name.isEmpty()) {
qWarning() << "Layout file specified data for a panel but didn't specify a name. Layout wasn't loaded.";
} else {
// loop through panels for a panel with the same name
bool found_panel = false;
for (int i=0;i<olive::panels.size();i++) {
Panel* panel = olive::panels.at(i);
if (panel->objectName() == panel_name) {
// found the panel, so we can load its state
stream.readNext();
panel->LoadLayoutState(QByteArray::fromBase64(stream.text().toUtf8()));
// we found it, no more need to loop through panels
found_panel = true;
break;
}
}
if (!found_panel) {
qWarning() << "Panel specified in layout data doesn't exist. Layout wasn't loaded.";
}
}
}
}
panel_config.close();
@@ -904,10 +958,37 @@ void MainWindow::closeEvent(QCloseEvent *e) {
QFile panel_config(get_config_dir().filePath("layout"));
if (panel_config.open(QFile::WriteOnly)) {
QXmlStreamWriter stream(&panel_config);
stream.setAutoFormatting(true);
stream.writeStartDocument();
stream.writeStartElement("layout");
stream.writeTextElement("panels", saveState(0).toBase64());
// if the panels have any specific layout data to save, save it now
for (int i=0;i<olive::panels.size();i++) {
QByteArray layout_data = olive::panels.at(i)->SaveLayoutState();
if (!layout_data.isEmpty()) {
// layout data is matched with the panel's objectName(), which we can't do if the panel has no name
const QString& panel_name = olive::panels.at(i)->objectName();
if (panel_name.isEmpty()) {
qWarning() << "Panel" << i << "had layout state data but no objectName(). Layout was not saved.";
} else {
stream.writeStartElement("panel");
stream.writeAttribute("name", panel_name);
stream.writeCharacters(layout_data.toBase64());
stream.writeEndElement();
}
}
}
stream.writeEndElement(); // layout
stream.writeEndDocument();
panel_config.close();
} else {
+11 -2
View File
@@ -24,7 +24,6 @@
#include <QVBoxLayout>
#include <QResizeEvent>
#include <QScrollBar>
#include <QSplitter>
#include <QScrollArea>
#include <QPushButton>
#include <QSpacerItem>
@@ -321,7 +320,7 @@ void EffectControls::setup_ui() {
hlayout->setSpacing(0);
hlayout->setMargin(0);
QSplitter* splitter = new QSplitter();
splitter = new QSplitter();
splitter->setOrientation(Qt::Horizontal);
splitter->setChildrenCollapsible(false);
@@ -507,6 +506,16 @@ void EffectControls::Retranslate() {
UpdateTitle();
}
void EffectControls::LoadLayoutState(const QByteArray &data)
{
splitter->restoreState(data);
}
QByteArray EffectControls::SaveLayoutState()
{
return splitter->saveState();
}
void EffectControls::update_scrollbar() {
verticalScrollBar->setMaximum(qMax(0, effects_area->height() - keyframeView->height() - headers->height()));
verticalScrollBar->setPageStep(verticalScrollBar->height());
+5
View File
@@ -29,6 +29,7 @@
#include <QLabel>
#include <QScrollBar>
#include <QHBoxLayout>
#include <QSplitter>
#include "project/projectelements.h"
#include "ui/timelineheader.h"
@@ -78,6 +79,9 @@ public:
void add_effect_paste_action(QMenu* menu);
virtual void Retranslate() override;
virtual void LoadLayoutState(const QByteArray& data) override;
virtual QByteArray SaveLayoutState() override;
public slots:
void cut();
void copy(bool del = false);
@@ -112,6 +116,7 @@ private:
QString panel_name;
int mode;
QSplitter* splitter;
QPushButton* btnAddVideoEffect;
QLabel* lblVideoEffects;
QPushButton* btnAddVideoTransition;
+1 -1
View File
@@ -1185,7 +1185,7 @@ void Project::save_project(bool autorecovery) {
sequence_id = 1;
QFile file(autorecovery ? autorecovery_filename : olive::ActiveProjectFilename);
if (!file.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) {
if (!file.open(QIODevice::WriteOnly)) {
qCritical() << "Could not open file";
return;
}
+4 -3
View File
@@ -756,12 +756,13 @@ void Timeline::set_zoom_value(double v) {
zoom_just_changed = true;
// set scrollbar to center the playhead
if (olive::ActiveSequence != nullptr
&& !horizontalScrollBar->is_resizing()) {
if (olive::ActiveSequence != nullptr) {
// update scrollbar maximum value for new zoom
set_sb_max();
center_scroll_to_playhead(horizontalScrollBar, zoom, olive::ActiveSequence->playhead);
if (!horizontalScrollBar->is_resizing()) {
center_scroll_to_playhead(horizontalScrollBar, zoom, olive::ActiveSequence->playhead);
}
}
// repaint the timeline for the new zoom/location
+2 -1
View File
@@ -31,7 +31,8 @@ parts:
source: .
build-packages:
- qt5-default
- qtmultimedia5-dev
- qtmultimedia5-dev
- libqt5svg5-dev
- libavformat-dev
- libavfilter-dev
- frei0r-plugins-dev
+7
View File
@@ -37,6 +37,13 @@ Panel::~Panel()
olive::panels.removeAll(this);
}
void Panel::LoadLayoutState(const QByteArray &) {}
QByteArray Panel::SaveLayoutState()
{
return QByteArray();
}
void Panel::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
+4
View File
@@ -28,7 +28,11 @@ class Panel : public QDockWidget {
public:
Panel(QWidget* parent = nullptr);
virtual ~Panel() override;
virtual void Retranslate() = 0;
virtual void LoadLayoutState(const QByteArray& data);
virtual QByteArray SaveLayoutState();
protected:
virtual void changeEvent(QEvent* e) override;
};
+68 -68
View File
@@ -29,98 +29,98 @@
#define RESIZE_HANDLE_SIZE 10
ResizableScrollBar::ResizableScrollBar(QWidget *parent) :
QScrollBar(parent),
resize_init(false),
resize_proc(false)
QScrollBar(parent),
resize_init(false),
resize_proc(false)
{
setSingleStep(20);
setMaximum(0);
setMouseTracking(true);
setSingleStep(20);
setMaximum(0);
setMouseTracking(true);
}
bool ResizableScrollBar::is_resizing() {
return resize_proc;
return resize_proc;
}
void ResizableScrollBar::resizeEvent(QResizeEvent *event) {
setPageStep(event->size().width());
setPageStep(event->size().width());
}
void ResizableScrollBar::mousePressEvent(QMouseEvent *e) {
if (resize_init) {
QStyleOptionSlider opt;
initStyleOption(&opt);
if (resize_init) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
resize_proc = true;
resize_start = e->pos().x();
resize_proc = true;
resize_start = e->pos().x();
resize_start_max = maximum();
resize_start_width = sr.width();
} else {
QScrollBar::mousePressEvent(e);
}
resize_start_max = maximum();
resize_start_width = sr.width();
} else {
QScrollBar::mousePressEvent(e);
}
}
void ResizableScrollBar::mouseMoveEvent(QMouseEvent *e) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect gr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarGroove, this);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect gr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarGroove, this);
if (resize_proc) {
int diff = (e->pos().x() - resize_start);
if (resize_top) diff = -diff;
double scale = double(sr.width())/double(sr.width()+diff);
if (!qIsInf(scale) && !qIsNull(scale)) {
emit resize_move(scale);
resize_start = e->pos().x();
if (resize_proc) {
int diff = (e->pos().x() - resize_start);
if (resize_top) diff = -diff;
double scale = double(sr.width())/double(sr.width()+diff);
if (!qIsInf(scale) && !qIsNull(scale)) {
emit resize_move(scale);
resize_start = e->pos().x();
if (resize_top) {
int slider_min = gr.x();
int slider_max = gr.right() - (sr.width()+diff);
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
if (resize_top) {
int slider_min = gr.x();
int slider_max = gr.right() - (sr.width()+diff);
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
setValue(val);
} else {
setValue(qRound(value() * scale));
}
}
} else {
bool new_resize_init = false;
setValue(val);
} else {
setValue(qRound(value() * scale));
}
}
} else {
bool new_resize_init = false;
if ((orientation() == Qt::Horizontal && e->pos().x() > sr.left()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.left()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.top()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.top()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = true;
} else if ((orientation() == Qt::Horizontal && e->pos().x() > sr.right()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.right()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.bottom()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.bottom()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = false;
}
if ((orientation() == Qt::Horizontal && e->pos().x() > sr.left()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.left()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.top()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.top()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = true;
} else if ((orientation() == Qt::Horizontal && e->pos().x() > sr.right()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.right()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.bottom()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.bottom()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = false;
}
if (resize_init != new_resize_init) {
if (new_resize_init) {
setCursor(Qt::SizeHorCursor);
} else {
unsetCursor();
}
resize_init = new_resize_init;
}
if (resize_init != new_resize_init) {
if (new_resize_init) {
setCursor(Qt::SizeHorCursor);
} else {
unsetCursor();
}
resize_init = new_resize_init;
}
QScrollBar::mouseMoveEvent(e);
}
QScrollBar::mouseMoveEvent(e);
}
}
void ResizableScrollBar::mouseReleaseEvent(QMouseEvent *e) {
if (resize_proc) {
resize_proc = false;
} else {
QScrollBar::mouseReleaseEvent(e);
}
if (resize_proc) {
resize_proc = false;
} else {
QScrollBar::mouseReleaseEvent(e);
}
}