more project management updates

This commit is contained in:
itsmattkc
2019-07-01 17:53:52 -07:00
parent 0966b62f29
commit 3e6bc54f48
17 changed files with 277 additions and 21 deletions
+101 -15
View File
@@ -20,11 +20,13 @@
#include "footage.h"
#include <QCoreApplication>
#include "ui/icons/icons.h"
Footage::Footage() :
status_(kUnprobed)
Footage::Footage()
{
Clear();
}
Footage::~Footage()
@@ -41,19 +43,9 @@ void Footage::set_status(const Footage::Status &status)
{
status_ = status;
switch (status_) {
case kUnprobed:
// FIXME Set a waiting icon
set_icon(QIcon());
break;
case kReady:
// FIXME Set a ready icon
set_icon(QIcon());
break;
case kInvalid:
set_icon(olive::icon::Error);
break;
}
UpdateIcon();
UpdateTooltip();
}
void Footage::Clear()
@@ -123,3 +115,97 @@ void Footage::ClearStreams()
// Empty array
streams_.clear();
}
bool Footage::HasStreamsOfType(const Stream::Type type)
{
// Return true if any streams are video streams
for (int i=0;i<streams_.size();i++) {
if (streams_.at(i)->type() == type) {
return true;
}
}
return false;
}
void Footage::UpdateIcon()
{
switch (status_) {
case kUnprobed:
// FIXME Set a waiting icon
set_icon(QIcon());
break;
case kReady:
if (HasStreamsOfType(Stream::kVideo)) {
// Prioritize the video icon
set_icon(olive::icon::Video);
// FIXME: When image sources can be reliably picked up, use image icon instead
// Perhaps all image sources can be left to OpenImageIO meaning only video sources need to be here
} else if (HasStreamsOfType(Stream::kAudio)) {
// Otherwise assume it's audio only
set_icon(olive::icon::Audio);
} else {
// FIXME Icon/indicator for a media file with no video or audio streams?
// The footage should probably be deemed kInvalid in this state
}
break;
case kInvalid:
set_icon(olive::icon::Error);
break;
}
}
void Footage::UpdateTooltip()
{
switch (status_) {
case kUnprobed:
set_tooltip(QCoreApplication::translate("Footage", "Waiting for probe"));
break;
case kReady:
{
QString tip = QCoreApplication::translate("Footage", "Filename: %1");
if (!streams_.isEmpty()) {
tip.append("\n");
for (int i=0;i<streams_.size();i++) {
Stream* s = streams_.at(i);
if (s->type() == Stream::kVideo) {
VideoStream* vs = static_cast<VideoStream*>(s);
tip.append(
QCoreApplication::translate("Footage",
"\nVideo %1: %2x%3").arg(QString::number(i),
QString::number(vs->width()),
QString::number(vs->height()))
);
} else if (streams_.at(i)->type() == Stream::kAudio) {
AudioStream* as = static_cast<AudioStream*>(s);
tip.append(
QCoreApplication::translate("Footage",
"\nAudio %1: %2 channels %3 Hz").arg(QString::number(i),
QString::number(as->channels()),
QString::number(as->sample_rate()))
);
}
}
}
set_tooltip(tip);
}
break;
case kInvalid:
set_tooltip(QCoreApplication::translate("Footage", "An error occurred probing this footage"));
break;
}
}
+30 -1
View File
@@ -81,7 +81,11 @@ public:
/**
* @brief Set ready state
*
* This should only be set by olive::ProbeMedia. Sets the ready state (see ready()).
* This should only be set by olive::ProbeMedia. Sets the Footage's current status to a member of enum
* Footage::Status.
*
* This function also runs UpdateIcon() and UpdateTooltip(). If you need to override the tooltip (e.g. for an error
* message), you must run set_tooltip() *after* running set_status();
*/
void set_status(const Status& status);
@@ -178,6 +182,31 @@ private:
*/
void ClearStreams();
/**
* @brief Check if this footage has streams of a certain type
*
* @param type
*
* The stream type to check for
*/
bool HasStreamsOfType(const Stream::Type type);
/**
* @brief Update the icon based on the Footage status
*
* For kUnprobed and kError an appropriate icon will be shown. For kReady, this function will determine what the
* dominant type of media in this Footage is (video/audio/image) and set the icon accordingly based on that.
*/
void UpdateIcon();
/**
* @brief Update the tooltip based on the Footage status
*
* For kUnprobed and kError, this sets an appropriate generic message. For kReady, this function will set
* basic information about the Footage in the tooltip (based on the results of a previous probe).
*/
void UpdateTooltip();
/**
* @brief Internal filename string
*/
+10
View File
@@ -73,6 +73,16 @@ void Item::set_name(const QString &n)
name_ = n;
}
const QString &Item::tooltip() const
{
return tooltip_;
}
void Item::set_tooltip(const QString &t)
{
tooltip_ = t;
}
const QIcon &Item::icon()
{
return icon_;
+5
View File
@@ -74,6 +74,9 @@ public:
const QString& name() const;
void set_name(const QString& n);
const QString& tooltip() const;
void set_tooltip(const QString& t);
const QIcon& icon();
void set_icon(const QIcon& icon);
@@ -89,6 +92,8 @@ private:
QIcon icon_;
QString tooltip_;
};
#endif // ITEM_H
+2
View File
@@ -148,6 +148,8 @@ QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
return internal_item->icon();
}
break;
case Qt::ToolTipRole:
return internal_item->tooltip();
}
return QVariant();