diff --git a/app/dialog/footageproperties/CMakeLists.txt b/app/dialog/footageproperties/CMakeLists.txt index 3c4ee65c3..84282a556 100644 --- a/app/dialog/footageproperties/CMakeLists.txt +++ b/app/dialog/footageproperties/CMakeLists.txt @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +add_subdirectory(streamproperties) + set(OLIVE_SOURCES ${OLIVE_SOURCES} dialog/footageproperties/footageproperties.h diff --git a/app/dialog/footageproperties/footageproperties.cpp b/app/dialog/footageproperties/footageproperties.cpp index d4ea2a2e1..94582b53c 100644 --- a/app/dialog/footageproperties/footageproperties.cpp +++ b/app/dialog/footageproperties/footageproperties.cpp @@ -30,12 +30,12 @@ #include #include #include -#include -namespace OCIO = OCIO_NAMESPACE::v1; +#include "streamproperties/audiostreamproperties.h" +#include "streamproperties/videostreamproperties.h" #include "undo/undostack.h" -FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, FootagePtr footage) : +FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *footage) : QDialog(parent), footage_(footage) { @@ -46,19 +46,41 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, FootagePtr foo int row = 0; - layout->addWidget(new QLabel(tr("Tracks:"), this), row, 0, 1, 2); + layout->addWidget(new QLabel(tr("Name:")), row, 0); + + footage_name_field_ = new QLineEdit(footage_->name()); + layout->addWidget(footage_name_field_, row, 1); row++; - track_list = new QListWidget(this); + layout->addWidget(new QLabel(tr("Tracks:")), row, 0, 1, 2); + row++; + + track_list = new QListWidget(); + layout->addWidget(track_list, row, 0, 1, 2); + + row++; + + stacked_widget_ = new QStackedWidget(); + layout->addWidget(stacked_widget_, row, 0, 1, 2); foreach (StreamPtr stream, footage_->streams()) { QListWidgetItem* item = new QListWidgetItem(stream->description(), track_list); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(stream->enabled() ? Qt::Checked : Qt::Unchecked); track_list->addItem(item); + + switch (stream->type()) { + case Stream::kVideo: + stacked_widget_->addWidget(new VideoStreamProperties(std::static_pointer_cast(stream))); + break; + case Stream::kAudio: + stacked_widget_->addWidget(new AudioStreamProperties(std::static_pointer_cast(stream))); + break; + default: + stacked_widget_->addWidget(new StreamProperties()); + } } - layout->addWidget(track_list, row, 0, 1, 2); row++; /*if (f->video_tracks.size() > 0) { @@ -125,10 +147,7 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, FootagePtr foo } */ - name_box = new QLineEdit(footage_->name(), this); - layout->addWidget(new QLabel(tr("Name:"), this), row, 0); - layout->addWidget(name_box, row, 1); - row++; + connect(track_list, SIGNAL(currentRowChanged(int)), stacked_widget_, SLOT(setCurrentIndex(int))); QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); buttons->setCenterButtons(true); @@ -205,5 +224,67 @@ void FootagePropertiesDialog::accept() { olive::undo_stack.push(ca);*/ + QUndoCommand* command = new QUndoCommand(); + + if (footage_->name() != footage_name_field_->text()) { + new FootageChangeCommand(footage_, + footage_name_field_->text(), + command); + } + + for (int i=0;istreams().size();i++) { + bool stream_enabled = (track_list->item(i)->checkState() == Qt::Checked); + + if (footage_->stream(i)->enabled() == stream_enabled) { + new StreamEnableChangeCommand(footage_->stream(i), + stream_enabled, + command); + } + } + + for (int i=0;icount();i++) { + static_cast(stacked_widget_->widget(i))->Accept(command); + } + + olive::undo_stack.pushIfHasChildren(command); + QDialog::accept(); } + +FootagePropertiesDialog::FootageChangeCommand::FootageChangeCommand(Footage *footage, const QString &name, QUndoCommand* command) : + QUndoCommand(command), + footage_(footage), + new_name_(name) +{ +} + +void FootagePropertiesDialog::FootageChangeCommand::redo() +{ + old_name_ = footage_->name(); + + footage_->set_name(new_name_); +} + +void FootagePropertiesDialog::FootageChangeCommand::undo() +{ + footage_->set_name(old_name_); +} + +FootagePropertiesDialog::StreamEnableChangeCommand::StreamEnableChangeCommand(StreamPtr stream, bool enabled, QUndoCommand *command) : + QUndoCommand(command), + stream_(stream), + new_enabled_(enabled) +{ +} + +void FootagePropertiesDialog::StreamEnableChangeCommand::redo() +{ + old_enabled_ = stream_->enabled(); + + stream_->set_enabled(new_enabled_); +} + +void FootagePropertiesDialog::StreamEnableChangeCommand::undo() +{ + stream_->set_enabled(old_enabled_); +} diff --git a/app/dialog/footageproperties/footageproperties.h b/app/dialog/footageproperties/footageproperties.h index 157dbf305..65af1baf8 100644 --- a/app/dialog/footageproperties/footageproperties.h +++ b/app/dialog/footageproperties/footageproperties.h @@ -21,12 +21,14 @@ #ifndef MEDIAPROPERTIESDIALOG_H #define MEDIAPROPERTIESDIALOG_H -#include +#include #include +#include +#include #include #include -#include -#include +#include +#include #include "project/item/footage/footage.h" @@ -50,8 +52,45 @@ public: * * Media object to set properties for. */ - FootagePropertiesDialog(QWidget *parent, FootagePtr footage); + FootagePropertiesDialog(QWidget *parent, Footage* footage); private: + class FootageChangeCommand : public QUndoCommand { + public: + FootageChangeCommand(Footage* footage, + const QString& name, + QUndoCommand *command = nullptr); + + virtual void redo() override; + virtual void undo() override; + + private: + Footage* footage_; + + QString new_name_; + QString old_name_; + }; + + class StreamEnableChangeCommand : public QUndoCommand { + public: + StreamEnableChangeCommand(StreamPtr stream, + bool enabled, + QUndoCommand* command = nullptr); + + virtual void redo() override; + virtual void undo() override; + + private: + StreamPtr stream_; + + bool old_enabled_; + bool new_enabled_; + }; + + /** + * @brief Stack of widgets that changes based on whether the stream is a video or audio stream + */ + QStackedWidget* stacked_widget_; + /** * @brief ComboBox for interlacing setting */ @@ -60,12 +99,12 @@ private: /** * @brief Media name text field */ - QLineEdit* name_box; + QLineEdit* footage_name_field_; /** * @brief Internal pointer to Media object (set in constructor) */ - FootagePtr footage_; + Footage* footage_; /** * @brief A list widget for listing the tracks in Media @@ -77,20 +116,12 @@ private: */ QDoubleSpinBox* conform_fr; - /** - * @brief Setting for associated/premultiplied alpha - */ - QCheckBox* premultiply_alpha_setting; - - /** - * @brief Setting for this media's color space - */ - QComboBox* input_color_space; private slots: /** * @brief Overridden accept function for saving the properties back to the Media class */ void accept(); + }; #endif // MEDIAPROPERTIESDIALOG_H diff --git a/app/dialog/footageproperties/streamproperties/CMakeLists.txt b/app/dialog/footageproperties/streamproperties/CMakeLists.txt new file mode 100644 index 000000000..b6952d2aa --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + dialog/footageproperties/streamproperties/streamproperties.h + dialog/footageproperties/streamproperties/streamproperties.cpp + dialog/footageproperties/streamproperties/audiostreamproperties.h + dialog/footageproperties/streamproperties/audiostreamproperties.cpp + dialog/footageproperties/streamproperties/videostreamproperties.h + dialog/footageproperties/streamproperties/videostreamproperties.cpp + PARENT_SCOPE +) diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp new file mode 100644 index 000000000..24e475515 --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp @@ -0,0 +1,30 @@ +/*** + + 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 . + +***/ + +#include "audiostreamproperties.h" + +AudioStreamProperties::AudioStreamProperties(AudioStreamPtr stream) : + stream_(stream) +{ +} + +void AudioStreamProperties::Accept(QUndoCommand*) +{ +} diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.h b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h new file mode 100644 index 000000000..0942797cc --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h @@ -0,0 +1,38 @@ +/*** + + 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 . + +***/ + +#ifndef AUDIOSTREAMPROPERTIES_H +#define AUDIOSTREAMPROPERTIES_H + +#include "project/item/footage/audiostream.h" +#include "streamproperties.h" + +class AudioStreamProperties : public StreamProperties +{ +public: + AudioStreamProperties(AudioStreamPtr stream); + + virtual void Accept(QUndoCommand* parent) override; + +private: + AudioStreamPtr stream_; +}; + +#endif // AUDIOSTREAMPROPERTIES_H diff --git a/app/dialog/footageproperties/streamproperties/streamproperties.cpp b/app/dialog/footageproperties/streamproperties/streamproperties.cpp new file mode 100644 index 000000000..29d938948 --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/streamproperties.cpp @@ -0,0 +1,26 @@ +/*** + + 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 . + +***/ + +#include "streamproperties.h" + +StreamProperties::StreamProperties(QWidget *parent) : + QWidget(parent) +{ +} diff --git a/app/dialog/footageproperties/streamproperties/streamproperties.h b/app/dialog/footageproperties/streamproperties/streamproperties.h new file mode 100644 index 000000000..72840f010 --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/streamproperties.h @@ -0,0 +1,35 @@ +/*** + + 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 . + +***/ + +#ifndef STREAMPROPERTIES_H +#define STREAMPROPERTIES_H + +#include +#include + +class StreamProperties : public QWidget +{ +public: + StreamProperties(QWidget* parent = nullptr); + + virtual void Accept(QUndoCommand*){} +}; + +#endif // STREAMPROPERTIES_H diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp new file mode 100644 index 000000000..26ed33054 --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp @@ -0,0 +1,92 @@ +/*** + + 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 . + +***/ + +#include "videostreamproperties.h" + +#include +#include +#include +namespace OCIO = OCIO_NAMESPACE::v1; + +#include "undo/undostack.h" + +VideoStreamProperties::VideoStreamProperties(VideoStreamPtr stream) : + stream_(stream) +{ + QGridLayout* video_layout = new QGridLayout(this); + video_layout->setMargin(0); + + video_layout->addWidget(new QLabel(tr("Color Space:")), 0, 0); + + video_color_space_ = new QComboBox(); + OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); + int number_of_colorspaces = config->getNumColorSpaces(); + + for (int i=0;igetColorSpaceNameByIndex(i); + + video_color_space_->addItem(colorspace); + } + + video_color_space_->setCurrentText(stream_->colorspace()); + + video_layout->addWidget(video_color_space_, 0, 1); + + video_premultiply_alpha_ = new QCheckBox(tr("Premultiplied Alpha")); + video_premultiply_alpha_->setChecked(stream_->premultiplied_alpha()); + video_layout->addWidget(video_premultiply_alpha_, 1, 0, 1, 2); +} + +void VideoStreamProperties::Accept(QUndoCommand *parent) +{ + if (video_premultiply_alpha_->isChecked() != stream_->premultiplied_alpha() + || video_color_space_->currentText() != stream_->colorspace()) { + new VideoStreamChangeCommand(stream_, + video_premultiply_alpha_->isChecked(), + video_color_space_->currentText(), + parent); + } +} + +VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand(VideoStreamPtr stream, + bool premultiplied, + QString colorspace, + QUndoCommand *parent) : + QUndoCommand(parent), + stream_(stream), + new_premultiplied_(premultiplied), + new_colorspace_(colorspace) +{ +} + +void VideoStreamProperties::VideoStreamChangeCommand::redo() +{ + old_premultiplied_ = stream_->premultiplied_alpha(); + old_colorspace_ = stream_->colorspace(); + + stream_->set_premultiplied_alpha(new_premultiplied_); + stream_->set_colorspace(new_colorspace_); +} + +void VideoStreamProperties::VideoStreamChangeCommand::undo() +{ + stream_->set_premultiplied_alpha(old_premultiplied_); + stream_->set_colorspace(old_colorspace_); +} diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.h b/app/dialog/footageproperties/streamproperties/videostreamproperties.h new file mode 100644 index 000000000..4536f907b --- /dev/null +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.h @@ -0,0 +1,75 @@ +/*** + + 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 . + +***/ + +#ifndef VIDEOSTREAMPROPERTIES_H +#define VIDEOSTREAMPROPERTIES_H + +#include +#include +#include + +#include "project/item/footage/videostream.h" +#include "streamproperties.h" + +class VideoStreamProperties : public StreamProperties +{ +public: + VideoStreamProperties(VideoStreamPtr stream); + + virtual void Accept(QUndoCommand* parent) override; + +private: + /** + * @brief Attached video stream + */ + VideoStreamPtr stream_; + + /** + * @brief Setting for associated/premultiplied alpha + */ + QCheckBox* video_premultiply_alpha_; + + /** + * @brief Setting for this media's color space + */ + QComboBox* video_color_space_; + + class VideoStreamChangeCommand : public QUndoCommand { + public: + VideoStreamChangeCommand(VideoStreamPtr stream, + bool premultiplied, + QString colorspace, + QUndoCommand* parent = nullptr); + + virtual void redo() override; + virtual void undo() override; + + private: + VideoStreamPtr stream_; + + bool new_premultiplied_; + QString new_colorspace_; + + bool old_premultiplied_; + QString old_colorspace_; + }; +}; + +#endif // VIDEOSTREAMPROPERTIES_H diff --git a/app/dialog/preferences/preferences.cpp b/app/dialog/preferences/preferences.cpp index 28848beb3..f87e35024 100644 --- a/app/dialog/preferences/preferences.cpp +++ b/app/dialog/preferences/preferences.cpp @@ -31,7 +31,6 @@ #include "tabs/preferencesappearancetab.h" #include "tabs/preferencesplaybacktab.h" #include "tabs/preferencesaudiotab.h" -#include "tabs/preferencescolormanagementtab.h" #include "tabs/preferenceskeyboardtab.h" PreferencesDialog::PreferencesDialog(QWidget *parent, QMenuBar* main_menu_bar) : @@ -52,7 +51,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, QMenuBar* main_menu_bar) : AddTab(new PreferencesGeneralTab(), tr("General")); AddTab(new PreferencesAppearanceTab(), tr("Appearance")); AddTab(new PreferencesBehaviorTab(), tr("Behavior")); - AddTab(new PreferencesColorManagementTab(), tr("Color Management")); AddTab(new PreferencesPlaybackTab(), tr("Playback")); AddTab(new PreferencesAudioTab(), tr("Audio")); AddTab(new PreferencesKeyboardTab(main_menu_bar), tr("Keyboard")); diff --git a/app/dialog/preferences/tabs/CMakeLists.txt b/app/dialog/preferences/tabs/CMakeLists.txt index 1d1f26e3b..10f978449 100644 --- a/app/dialog/preferences/tabs/CMakeLists.txt +++ b/app/dialog/preferences/tabs/CMakeLists.txt @@ -28,8 +28,6 @@ set(OLIVE_SOURCES dialog/preferences/tabs/preferencesaudiotab.cpp dialog/preferences/tabs/preferenceskeyboardtab.h dialog/preferences/tabs/preferenceskeyboardtab.cpp - dialog/preferences/tabs/preferencescolormanagementtab.h - dialog/preferences/tabs/preferencescolormanagementtab.cpp dialog/preferences/tabs/preferencestab.h dialog/preferences/tabs/preferencestab.cpp PARENT_SCOPE diff --git a/app/dialog/preferences/tabs/preferencescolormanagementtab.cpp b/app/dialog/preferences/tabs/preferencescolormanagementtab.cpp deleted file mode 100644 index 90162f2e9..000000000 --- a/app/dialog/preferences/tabs/preferencescolormanagementtab.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "preferencescolormanagementtab.h" - -#include -#include -#include -#include -#include -#include -#include - -PreferencesColorManagementTab::PreferencesColorManagementTab() -{ - QGridLayout* color_management_layout = new QGridLayout(this); - color_management_layout->setMargin(0); - - int row = 0; - - QGroupBox* opencolorio_groupbox = new QGroupBox(); - QGridLayout* opencolorio_groupbox_layout = new QGridLayout(opencolorio_groupbox); - - // COLOR MANAGEMENT -> OpenColorIO Config File - opencolorio_groupbox_layout->addWidget(new QLabel(tr("OpenColorIO Config File:")), 0, 0); - - ocio_config_file = new QLineEdit(); - // ocio_config_file->setText(olive::config.ocio_config_path); - connect(ocio_config_file, SIGNAL(textChanged(const QString &)), this, SLOT(update_ocio_config(const QString&))); - opencolorio_groupbox_layout->addWidget(ocio_config_file, 0, 1, 1, 4); - - QPushButton* ocio_config_browse_btn = new QPushButton(tr("Browse")); - connect(ocio_config_browse_btn, SIGNAL(clicked(bool)), this, SLOT(browse_ocio_config())); - opencolorio_groupbox_layout->addWidget(ocio_config_browse_btn, 0, 5); - - // COLOR MANAGEMENT -> Default Input Color Space - ocio_default_input = new QComboBox(); - opencolorio_groupbox_layout->addWidget(new QLabel(tr("Default Input Color Space:")), 1, 0); - opencolorio_groupbox_layout->addWidget(ocio_default_input, 1, 1, 1, 5); - - // COLOR MANAGEMENT -> Display - ocio_display = new QComboBox(); - connect(ocio_display, SIGNAL(currentIndexChanged(int)), this, SLOT(update_ocio_view_menu())); - opencolorio_groupbox_layout->addWidget(new QLabel(tr("Display:")), 2, 0); - opencolorio_groupbox_layout->addWidget(ocio_display, 2, 1); - - // COLOR MANAGEMENT -> View - ocio_view = new QComboBox(); - opencolorio_groupbox_layout->addWidget(new QLabel(tr("View:")), 2, 2); - opencolorio_groupbox_layout->addWidget(ocio_view, 2, 3); - - // COLOR MANAGEMENT -> Look - ocio_look = new QComboBox(); - opencolorio_groupbox_layout->addWidget(new QLabel(tr("Look:")), 2, 4); - opencolorio_groupbox_layout->addWidget(ocio_look, 2, 5); - - color_management_layout->addWidget(opencolorio_groupbox, row, 0); - - row++; - - // COLOR MANAGEMENT -> Bit Depth - QGroupBox* bit_depth_groupbox = new QGroupBox(tr("Bit Depth")); - QGridLayout* bit_depth_groupbox_layout = new QGridLayout(bit_depth_groupbox); - - // COLOR MANAGEMENT -> Bit Depth -> Playback - playback_bit_depth = new QComboBox(); - /*for (int i=0;iaddItem(olive::pixel_formats.at(i).name, i); - } - playback_bit_depth->setCurrentIndex(olive::config.playback_bit_depth);*/ - bit_depth_groupbox_layout->addWidget(new QLabel(tr("Playback (Offline):")), 0, 0); - bit_depth_groupbox_layout->addWidget(playback_bit_depth, 0, 1); - - // COLOR MANAGEMENT -> Bit Depth -> Export - export_bit_depth = new QComboBox(); - /*for (int i=0;iaddItem(olive::pixel_formats.at(i).name, i); - } - export_bit_depth->setCurrentIndex(olive::config.export_bit_depth);*/ - bit_depth_groupbox_layout->addWidget(new QLabel(tr("Export (Online):")), 0, 2); - bit_depth_groupbox_layout->addWidget(export_bit_depth, 0, 3); - - color_management_layout->addWidget(bit_depth_groupbox, row, 0); - - //row++; - - populate_ocio_menus(OCIO::GetCurrentConfig()); -} - -void PreferencesColorManagementTab::Accept() -{ - -} - -void PreferencesColorManagementTab::populate_ocio_menus(OCIO::ConstConfigRcPtr config) -{ - if (!config) { - - // Just clear everything - ocio_display->clear(); - ocio_default_input->clear(); - ocio_view->clear(); - ocio_look->clear(); - - } else { - - // Get input color spaces for setting the default input color space - ocio_default_input->clear(); - for (int i=0;igetNumColorSpaces();i++) { - QString colorspace = config->getColorSpaceNameByIndex(i); - - ocio_default_input->addItem(colorspace); - - /*if (colorspace == olive::config.ocio_default_input_colorspace) { - ocio_default_input->setCurrentIndex(i); - }*/ - } - - // Get current display name (if the config is empty, get the current default display) - /*QString current_display = olive::config.ocio_display; - if (current_display.isEmpty()) { - current_display = config->getDefaultDisplay(); - }*/ - - // Populate the display menu - ocio_display->clear(); - for (int i=0;igetNumDisplays();i++) { - ocio_display->addItem(config->getDisplay(i)); - - // Check if this index is the currently selected - /*if (config->getDisplay(i) == current_display) { - ocio_display->setCurrentIndex(i); - }*/ - } - - update_ocio_view_menu(config); - - // Populate the look menu - ocio_look->clear(); - ocio_look->addItem(tr("(None)"), QString()); - for (int i=0;igetNumLooks();i++) { - const char* look = config->getLookNameByIndex(i); - - ocio_look->addItem(look, look); - - /*if (look == olive::config.ocio_look) { - ocio_look->setCurrentIndex(i+1); - }*/ - } - - } -} - -OCIO::ConstConfigRcPtr PreferencesColorManagementTab::TestOCIOConfig(const QString &url) -{ - // Check whether OCIO can load it - OCIO::ConstConfigRcPtr config; - try { - config = OCIO::Config::CreateFromFile(url.toUtf8()); - } catch (OCIO::Exception& e) { - QMessageBox::critical(this, - tr("OpenColorIO Config Error"), - tr("Failed to set OpenColorIO configuration: %1").arg(e.what()), - QMessageBox::Ok); - } - return config; -} - -void PreferencesColorManagementTab::update_ocio_view_menu(OCIO::ConstConfigRcPtr config) -{ - - // Get views for the current display set in `ocio_display` - QString display = ocio_display->currentText(); - - // Get current view - /*QString current_view = olive::config.ocio_view; - if (current_view.isEmpty()) { - current_view = config->getDefaultView(display.toUtf8()); - }*/ - - // Populate the view menu - int ocio_view_count = config->getNumViews(display.toUtf8()); - ocio_view->clear(); - for (int i=0;igetView(display.toUtf8(), i); - - ocio_view->addItem(view); - - /*if (current_view == view) { - ocio_view->setCurrentIndex(i); - }*/ - } -} - -void PreferencesColorManagementTab::update_ocio_config(const QString &s) -{ - OCIO::ConstConfigRcPtr file_config; - - if (!s.isEmpty() && QFileInfo::exists(s)) { - file_config = TestOCIOConfig(s); - } - - populate_ocio_menus(file_config); -} - -void PreferencesColorManagementTab::browse_ocio_config() -{ - QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration")); - if (!fn.isEmpty()) { - ocio_config_file->setText(fn); - } -} - -void PreferencesColorManagementTab::update_ocio_view_menu() -{ - update_ocio_view_menu(OCIO::GetCurrentConfig()); -} diff --git a/app/dialog/preferences/tabs/preferencescolormanagementtab.h b/app/dialog/preferences/tabs/preferencescolormanagementtab.h deleted file mode 100644 index 99190082e..000000000 --- a/app/dialog/preferences/tabs/preferencescolormanagementtab.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef PREFERENCESCOLORMANAGEMENTTAB_H -#define PREFERENCESCOLORMANAGEMENTTAB_H - -#include -#include -#include -#include -namespace OCIO = OCIO_NAMESPACE::v1; - -#include "preferencestab.h" - -class PreferencesColorManagementTab : public PreferencesTab -{ - Q_OBJECT -public: - PreferencesColorManagementTab(); - - virtual void Accept() override; - -private slots: - // OCIO function - void browse_ocio_config(); - void update_ocio_view_menu(); - void update_ocio_view_menu(OCIO::ConstConfigRcPtr config); - void update_ocio_config(const QString&); - -private: - /** - * @brief Tests an OpenColorIO configuration file to determine whether it's valid and throws a messagebox if not - * - * @param url - * - * URL to the OpenColorIO configuration file. - * - * @return - * - * A OCIO::ConstConfigRcPtr config pointer if the configuration file is valid, nullptr if not. - */ - OCIO::ConstConfigRcPtr TestOCIOConfig(const QString& url); - - void populate_ocio_menus(OCIO::ConstConfigRcPtr config); - - QLineEdit* ocio_config_file; - QComboBox* ocio_default_input; - QComboBox* ocio_display; - QComboBox* ocio_view; - QComboBox* ocio_look; - QComboBox* playback_bit_depth; - QComboBox* export_bit_depth; -}; - -#endif // PREFERENCESCOLORMANAGEMENTTAB_H diff --git a/app/project/item/footage/imagestream.cpp b/app/project/item/footage/imagestream.cpp index d538ce068..48b250299 100644 --- a/app/project/item/footage/imagestream.cpp +++ b/app/project/item/footage/imagestream.cpp @@ -20,9 +20,14 @@ #include "imagestream.h" -ImageStream::ImageStream() +#include "render/colormanager.h" + +ImageStream::ImageStream() : + premultiplied_alpha_(false) { set_type(kImage); + + connect(ColorManager::instance(), SIGNAL(ConfigChanged()), this, SLOT(ColorConfigChangedSlot())); } QString ImageStream::description() @@ -51,3 +56,31 @@ void ImageStream::set_height(const int &height) { height_ = height; } + +bool ImageStream::premultiplied_alpha() +{ + return premultiplied_alpha_; +} + +void ImageStream::set_premultiplied_alpha(bool e) +{ + premultiplied_alpha_ = e; +} + +const QString &ImageStream::colorspace() +{ + return colorspace_; +} + +void ImageStream::set_colorspace(const QString &color) +{ + colorspace_ = color; + + emit ColorSpaceChanged(); +} + +void ImageStream::ColorConfigChangedSlot() +{ + // FIXME: Update colorspace correctly + colorspace_.clear(); +} diff --git a/app/project/item/footage/imagestream.h b/app/project/item/footage/imagestream.h index e5d292a25..e1ee1131a 100644 --- a/app/project/item/footage/imagestream.h +++ b/app/project/item/footage/imagestream.h @@ -26,7 +26,7 @@ /** * @brief A Stream derivative containing video-specific information */ -class ImageStream : public Stream +class ImageStream : public Stream, public QObject { public: ImageStream(); @@ -39,9 +39,23 @@ public: const int& height(); void set_height(const int& height); + bool premultiplied_alpha(); + void set_premultiplied_alpha(bool e); + + const QString& colorspace(); + void set_colorspace(const QString& color); + +signals: + void ColorSpaceChanged(); + private: int width_; int height_; + bool premultiplied_alpha_; + QString colorspace_; + +private slots: + void ColorConfigChangedSlot(); }; using ImageStreamPtr = std::shared_ptr; diff --git a/app/project/item/footage/videostream.h b/app/project/item/footage/videostream.h index 94c66c5c8..334182b01 100644 --- a/app/project/item/footage/videostream.h +++ b/app/project/item/footage/videostream.h @@ -40,6 +40,7 @@ public: private: rational frame_rate_; + }; using VideoStreamPtr = std::shared_ptr; diff --git a/app/widget/playbackcontrols/playbackcontrols.cpp b/app/widget/playbackcontrols/playbackcontrols.cpp index c8d20b99a..b5e8af2d4 100644 --- a/app/widget/playbackcontrols/playbackcontrols.cpp +++ b/app/widget/playbackcontrols/playbackcontrols.cpp @@ -113,7 +113,7 @@ PlaybackControls::PlaybackControls(QWidget *parent) : lower_right_layout->setMargin(0); lower_right_layout->addStretch(); - end_tc_lbl_ = new QLabel("00:00:00;00"); + end_tc_lbl_ = new QLabel(); lower_right_layout->addWidget(end_tc_lbl_); UpdateIcons(); @@ -132,7 +132,9 @@ void PlaybackControls::SetTimebase(const rational &r) void PlaybackControls::SetTime(const int64_t &r) { - Q_ASSERT(time_base_.denominator() != 0); + if (time_base_.isNull()) { + return; + } cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index a12f9f21c..a4aa4b9a5 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -21,8 +21,10 @@ #include "projectexplorer.h" #include +#include #include +#include "dialog/footageproperties/footageproperties.h" #include "projectexplorerdefines.h" ProjectExplorer::ProjectExplorer(QWidget *parent) : @@ -47,14 +49,17 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) : // Add tree view to stacked widget tree_view_ = new ProjectExplorerTreeView(stacked_widget_); + tree_view_->setContextMenuPolicy(Qt::CustomContextMenu); AddView(tree_view_); // Add list view to stacked widget list_view_ = new ProjectExplorerListView(stacked_widget_); + list_view_->setContextMenuPolicy(Qt::CustomContextMenu); AddView(list_view_); // Add icon view to stacked widget icon_view_ = new ProjectExplorerIconView(stacked_widget_); + icon_view_->setContextMenuPolicy(Qt::CustomContextMenu); AddView(icon_view_); // Set default view to tree view @@ -66,6 +71,10 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) : // Set rename timer timeout rename_timer_.setInterval(500); connect(&rename_timer_, SIGNAL(timeout()), this, SLOT(RenameTimerSlot())); + + connect(tree_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); + connect(list_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); + connect(icon_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); } const olive::ProjectViewType &ProjectExplorer::view_type() @@ -210,6 +219,29 @@ void ProjectExplorer::RenameTimerSlot() rename_timer_.stop(); } +void ProjectExplorer::ShowContextMenu() +{ + QMenu menu; + + // FIXME: Support for multiple items and items other than Footage + QList selected_items = SelectedItems(); + + QAction* properties_action = menu.addAction(tr("P&roperties")); + + if (selected_items.first()->type() == Item::kFootage) { + connect(properties_action, SIGNAL(triggered(bool)), this, SLOT(ShowFootagePropertiesDialog())); + } + + menu.exec(QCursor::pos()); +} + +void ProjectExplorer::ShowFootagePropertiesDialog() +{ + // FIXME: Support for multiple items and items other than Footage + FootagePropertiesDialog fpd(this, static_cast(SelectedItems().first())); + fpd.exec(); +} + Project *ProjectExplorer::project() { return model_.project(); diff --git a/app/widget/projectexplorer/projectexplorer.h b/app/widget/projectexplorer/projectexplorer.h index 383323e1d..df3f6da81 100644 --- a/app/widget/projectexplorer/projectexplorer.h +++ b/app/widget/projectexplorer/projectexplorer.h @@ -142,6 +142,10 @@ private slots: void DirUpSlot(); void RenameTimerSlot(); + + void ShowContextMenu(); + + void ShowFootagePropertiesDialog(); }; #endif // PROJECTEXPLORER_H