work towards project explorer navigation bar

This commit is contained in:
itsmattkc
2019-07-02 16:46:09 -07:00
parent 85b5bbd5d6
commit 0f7192fc33
16 changed files with 274 additions and 32 deletions
+2
View File
@@ -84,6 +84,8 @@ public:
*/
virtual bool Probe(Footage* f) = 0;
/**
* @brief Open media/allocate memory
*
+6 -5
View File
@@ -167,11 +167,7 @@ bool FFmpegDecoder::Probe(Footage *f)
if (error_code == 0) {
// Retrieve metadata about the media
av_dump_format(fmt_ctx_, stream()->index(), filename, 0);
// Set duration
f->set_duration(rational(fmt_ctx_->duration, AV_TIME_BASE));
qDebug() << "Found duration:" << f->duration().ToDouble();
av_dump_format(fmt_ctx_, 0, filename, 0);
// Dump it into the Footage object
for (unsigned int i=0;i<fmt_ctx_->nb_streams;i++) {
@@ -190,6 +186,8 @@ bool FFmpegDecoder::Probe(Footage *f)
str = video_stream;
qDebug() << "Stream V" << i << "Len" << (rational(avstream_->duration) * rational(avstream_->time_base)).ToDouble();
} else if (avstream_->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
// Create an audio stream object
@@ -201,6 +199,8 @@ bool FFmpegDecoder::Probe(Footage *f)
str = audio_stream;
qDebug() << "Stream A" << i << "Len" << (rational(avstream_->duration) * rational(avstream_->time_base)).ToDouble();
} else {
// This is data we can't utilize at the moment, but we make a Stream object anyway to keep parity with the file
@@ -234,6 +234,7 @@ bool FFmpegDecoder::Probe(Footage *f)
str->set_index(avstream_->index);
str->set_timebase(avstream_->time_base);
str->set_duration(avstream_->duration);
f->add_stream(str);
}
+4 -10
View File
@@ -77,16 +77,6 @@ void Footage::set_timestamp(const QDateTime &t)
timestamp_ = t;
}
const rational &Footage::duration()
{
return duration_;
}
void Footage::set_duration(const rational &duration)
{
duration_ = duration;
}
void Footage::add_stream(Stream *s)
{
// Add a copy of this stream to the list
@@ -142,6 +132,7 @@ void Footage::UpdateIcon()
{
switch (status_) {
case kUnprobed:
case kUnindexed:
// FIXME Set a waiting icon
set_icon(QIcon());
break;
@@ -178,6 +169,9 @@ void Footage::UpdateTooltip()
case kUnprobed:
set_tooltip(QCoreApplication::translate("Footage", "Waiting for probe"));
break;
case kUnindexed:
set_tooltip(QCoreApplication::translate("Footage", "Waiting for index"));
break;
case kReady:
{
QString tip = QCoreApplication::translate("Footage", "Filename: %1").arg(filename());
+1 -8
View File
@@ -34,6 +34,7 @@ class Footage : public Item
public:
enum Status {
kUnprobed,
kUnindexed,
kReady,
kInvalid
};
@@ -138,10 +139,6 @@ public:
*/
void set_timestamp(const QDateTime& t);
const rational& duration();
void set_duration(const rational& duration);
/**
* @brief Add a stream metadata object to this footage
*
@@ -232,10 +229,6 @@ private:
*/
Status status_;
/**
* @brief Media duration
*/
rational duration_;
};
#endif // FOOTAGE_H
+10
View File
@@ -70,3 +70,13 @@ void Stream::set_index(const int &index)
{
index_ = index;
}
const int64_t &Stream::duration()
{
return duration_;
}
void Stream::set_duration(const int64_t &duration)
{
duration_ = duration;
}
+5
View File
@@ -68,11 +68,16 @@ public:
const int& index();
void set_index(const int& index);
const int64_t& duration();
void set_duration(const int64_t& duration);
private:
Footage* footage_;
rational timebase_;
int64_t duration_;
int index_;
Type type_;
@@ -18,6 +18,7 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/projectexplorer/projectexplorer.h
widget/projectexplorer/projectexplorer.cpp
widget/projectexplorer/projectexplorerdefines.h
widget/projectexplorer/projectexplorertreeview.h
widget/projectexplorer/projectexplorertreeview.cpp
widget/projectexplorer/projectexplorerlistview.h
+44 -8
View File
@@ -21,20 +21,46 @@
#include "projectexplorer.h"
#include <QDebug>
#include <QVBoxLayout>
#include "projectexplorerdefines.h"
ProjectExplorer::ProjectExplorer(QWidget *parent) :
QStackedWidget(parent),
QWidget(parent),
view_type_(olive::TreeView),
model_(this)
{
tree_view_ = new ProjectExplorerTreeView(this);
// Create layout
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(0);
layout->setMargin(0);
// Set up navigation bar
nav_bar_ = new ProjectExplorerNavigation(this);
connect(nav_bar_, SIGNAL(SizeChanged(int)), this, SLOT(SizeChangedSlot(int)));
layout->addWidget(nav_bar_);
// Set up stacked widget
stacked_widget_ = new QStackedWidget(this);
layout->addWidget(stacked_widget_);
// Add tree view to stacked widget
tree_view_ = new ProjectExplorerTreeView(stacked_widget_);
AddView(tree_view_);
list_view_ = new ProjectExplorerListView(this);
// Add list view to stacked widget
list_view_ = new ProjectExplorerListView(stacked_widget_);
AddView(list_view_);
icon_view_ = new ProjectExplorerIconView(this);
// Add icon view to stacked widget
icon_view_ = new ProjectExplorerIconView(stacked_widget_);
AddView(icon_view_);
// Set default view to tree view
set_view_type(olive::TreeView);
// Set default icon size
SizeChangedSlot(olive::kProjectIconSizeDefault);
}
const olive::ProjectViewType &ProjectExplorer::view_type()
@@ -49,13 +75,16 @@ void ProjectExplorer::set_view_type(olive::ProjectViewType type)
// Set widget based on view type
switch (view_type_) {
case olive::TreeView:
setCurrentWidget(tree_view_);
stacked_widget_->setCurrentWidget(tree_view_);
nav_bar_->setVisible(false);
break;
case olive::ListView:
setCurrentWidget(list_view_);
stacked_widget_->setCurrentWidget(list_view_);
nav_bar_->setVisible(true);
break;
case olive::IconView:
setCurrentWidget(icon_view_);
stacked_widget_->setCurrentWidget(icon_view_);
nav_bar_->setVisible(true);
break;
}
}
@@ -64,7 +93,7 @@ void ProjectExplorer::AddView(QAbstractItemView *view)
{
view->setModel(&model_);
connect(view, SIGNAL(DoubleClickedView(const QModelIndex&)), this, SLOT(DoubleClickViewSlot(const QModelIndex&)));
addWidget(view);
stacked_widget_->addWidget(view);
}
void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
@@ -85,6 +114,13 @@ void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
}
}
void ProjectExplorer::SizeChangedSlot(int s)
{
icon_view_->setGridSize(QSize(s, s));
list_view_->setIconSize(QSize(s, s));
}
Project *ProjectExplorer::project()
{
return model_.project();
+8 -1
View File
@@ -30,6 +30,7 @@
#include "widget/projectexplorer/projectexplorericonview.h"
#include "widget/projectexplorer/projectexplorerlistview.h"
#include "widget/projectexplorer/projectexplorertreeview.h"
#include "widget/projectexplorer/projectexplorernavigation.h"
/**
* @brief The ProjectExplorer class
@@ -41,7 +42,7 @@
*
* This widget contains three views, tree view, list view, and icon view. These can be switched at any time.
*/
class ProjectExplorer : public QStackedWidget
class ProjectExplorer : public QWidget
{
Q_OBJECT
public:
@@ -77,6 +78,10 @@ private:
*/
void AddView(QAbstractItemView* view);
QStackedWidget* stacked_widget_;
ProjectExplorerNavigation* nav_bar_;
ProjectExplorerIconView* icon_view_;
ProjectExplorerListView* list_view_;
ProjectExplorerTreeView* tree_view_;
@@ -87,6 +92,8 @@ private:
private slots:
void DoubleClickViewSlot(const QModelIndex& index);
void SizeChangedSlot(int s);
};
#endif // PROJECTEXPLORER_H
@@ -0,0 +1,13 @@
#ifndef PROJECTEXPLORERDEFINES_H
#define PROJECTEXPLORERDEFINES_H
namespace olive {
const int kProjectIconSizeMinimum = 16;
const int kProjectIconSizeMaximum = 256;
const int kProjectIconSizeDefault = 64;
}
#endif // PROJECTEXPLORERDEFINES_H
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#include "projectexplorericonviewitemdelegate.h"
#include <QPainter>
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#ifndef PROJECTEXPLORERICONVIEWITEMDELEGATE_H
#define PROJECTEXPLORERICONVIEWITEMDELEGATE_H
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#include "projectexplorerlistviewitemdelegate.h"
#include <QPainter>
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#ifndef PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
#define PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
@@ -1,15 +1,77 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#include "projectexplorernavigation.h"
#include <QEvent>
#include <QHBoxLayout>
#include "ui/icons/icons.h"
#include "widget/projectexplorer/projectexplorerdefines.h"
ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
QWidget(parent)
{
// Create widget layout
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
// Create "directory up" button
dir_up_btn_ = new QPushButton(this);
dir_up_btn_->setIcon(olive::icon::DirUp);
dir_up_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
layout->addWidget(dir_up_btn_);
connect(dir_up_btn_, SIGNAL(clicked(bool)), this, SIGNAL(DirectoryUpClicked()));
// Create directory tree label
dir_lbl_ = new QLabel(this);
dir_lbl_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
layout->addWidget(dir_lbl_);
// Create size slider
size_slider_ = new QSlider(this);
size_slider_->setOrientation(Qt::Horizontal);
size_slider_->setMinimum(olive::kProjectIconSizeMinimum);
size_slider_->setMaximum(olive::kProjectIconSizeMaximum);
size_slider_->setValue(olive::kProjectIconSizeDefault);
size_slider_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
layout->addWidget(size_slider_);
connect(size_slider_, SIGNAL(valueChanged(int)), this, SIGNAL(SizeChanged(int)));
Retranslate();
}
void ProjectExplorerNavigation::set_text(const QString &s)
{
dir_lbl_->setText(s);
}
void ProjectExplorerNavigation::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
Retranslate();
}
QWidget::changeEvent(e);
}
void ProjectExplorerNavigation::Retranslate()
{
dir_up_btn_->setToolTip(tr("Go to parent folder"));
}
@@ -1,16 +1,54 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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/>.
***/
#ifndef PROJECTEXPLORERLISTVIEWTOOLBAR_H
#define PROJECTEXPLORERLISTVIEWTOOLBAR_H
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QWidget>
class ProjectExplorerNavigation : public QWidget
{
Q_OBJECT
public:
ProjectExplorerNavigation(QWidget* parent);
void set_text(const QString& s);
signals:
void DirectoryUpClicked();
void SizeChanged(int size);
protected:
virtual void changeEvent(QEvent *) override;
private:
void Retranslate();
QPushButton* dir_up_btn_;
QLabel* dir_lbl_;
QSlider* size_slider_;
};
#endif // PROJECTEXPLORERLISTVIEWTOOLBAR_H