diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..f74cc0883 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ +# Contributing to Olive + +### Standards + +When contributing to Olive, it's recommended to use the following rules: + +* [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) +* 120 column limit \ No newline at end of file diff --git a/app/core.cpp b/app/core.cpp index 2fc0486dc..efd6dac09 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -155,11 +155,6 @@ void Core::ImportFiles(const QStringList &urls) f->set_timestamp(file_info.lastModified()); //olive::ProbeMedia(f); - // FIXME: Test code only - for (int i=0;i<8;i++) { - olive::task_manager.AddTask(new Task()); - } - // End test code active_project->root()->add_child(f); diff --git a/app/panel/CMakeLists.txt b/app/panel/CMakeLists.txt index 4d4cd5d48..49d1f651c 100644 --- a/app/panel/CMakeLists.txt +++ b/app/panel/CMakeLists.txt @@ -15,6 +15,7 @@ # along with this program. If not, see . add_subdirectory(project) +add_subdirectory(taskmanager) add_subdirectory(timeline) add_subdirectory(tool) add_subdirectory(viewer) diff --git a/app/panel/taskmanager/CMakeLists.txt b/app/panel/taskmanager/CMakeLists.txt new file mode 100644 index 000000000..63f6baa3c --- /dev/null +++ b/app/panel/taskmanager/CMakeLists.txt @@ -0,0 +1,22 @@ +# 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} + panel/taskmanager/taskmanager.h + panel/taskmanager/taskmanager.cpp + PARENT_SCOPE +) diff --git a/app/panel/taskmanager/taskmanager.cpp b/app/panel/taskmanager/taskmanager.cpp new file mode 100644 index 000000000..3a6f806f1 --- /dev/null +++ b/app/panel/taskmanager/taskmanager.cpp @@ -0,0 +1,52 @@ +/*** + + 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 "taskmanager.h" + +#include "task/taskmanager.h" + +TaskManagerPanel::TaskManagerPanel(QWidget* parent) : + PanelWidget(parent) +{ + // Create task view + view_ = new TaskView(this); + + // Set it as the main widget + setWidget(view_); + + // Connect task view to the task manager + connect(&olive::task_manager, SIGNAL(TaskAdded(Task*)), view_, SLOT(AddTask(Task*))); + + // Set strings + Retranslate(); +} + +void TaskManagerPanel::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + Retranslate(); + } + QDockWidget::changeEvent(e); +} + +void TaskManagerPanel::Retranslate() +{ + SetTitle(tr("Task Manager")); +} diff --git a/app/panel/taskmanager/taskmanager.h b/app/panel/taskmanager/taskmanager.h new file mode 100644 index 000000000..e96971fc7 --- /dev/null +++ b/app/panel/taskmanager/taskmanager.h @@ -0,0 +1,42 @@ +/*** + + 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 TASKMANAGER_PANEL_H +#define TASKMANAGER_PANEL_H + +#include "widget/taskview/taskview.h" +#include "widget/panel/panel.h" + +class TaskManagerPanel : public PanelWidget +{ + Q_OBJECT +public: + TaskManagerPanel(QWidget* parent); + +protected: + virtual void changeEvent(QEvent* e) override; + +private: + void Retranslate(); + + TaskView* view_; +}; + +#endif // TASKMANAGER_H diff --git a/app/task/task.h b/app/task/task.h index 3d0e1b728..c5a3c0a06 100644 --- a/app/task/task.h +++ b/app/task/task.h @@ -58,6 +58,8 @@ protected: signals: void StatusChanged(Task::Status s); + void ProgressChanged(int p); + private: void set_status(const Status& status); diff --git a/app/task/taskmanager.cpp b/app/task/taskmanager.cpp index ac2c5098d..eac4c6886 100644 --- a/app/task/taskmanager.cpp +++ b/app/task/taskmanager.cpp @@ -38,6 +38,9 @@ void TaskManager::AddTask(Task* t) // Add the Task to the queue tasks_.append(t); + // Emit signal that a Task was added + emit TaskAdded(t); + // Scan through queue and start any Tasks that can (including this one) StartNextWaiting(); } diff --git a/app/task/taskmanager.h b/app/task/taskmanager.h index 20f0f204f..6bcbab8d5 100644 --- a/app/task/taskmanager.h +++ b/app/task/taskmanager.h @@ -56,6 +56,16 @@ public: */ void AddTask(Task *t); +signals: + /** + * @brief Signal emitted when a Task is added by AddTask() + * + * @param t + * + * Task that was added + */ + void TaskAdded(Task* t); + private: /** * @brief Scan through the task queue and start any Tasks that are able to start diff --git a/app/widget/CMakeLists.txt b/app/widget/CMakeLists.txt index 9ee4973f5..1b230fe0d 100644 --- a/app/widget/CMakeLists.txt +++ b/app/widget/CMakeLists.txt @@ -20,6 +20,7 @@ add_subdirectory(panel) add_subdirectory(playbackcontrols) add_subdirectory(projectexplorer) add_subdirectory(projecttoolbar) +add_subdirectory(taskview) add_subdirectory(toolbar) add_subdirectory(viewer) diff --git a/app/widget/taskview/CMakeLists.txt b/app/widget/taskview/CMakeLists.txt new file mode 100644 index 000000000..99ecf3a8f --- /dev/null +++ b/app/widget/taskview/CMakeLists.txt @@ -0,0 +1,24 @@ +# 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} + widget/taskview/taskview.h + widget/taskview/taskview.cpp + widget/taskview/taskviewitem.h + widget/taskview/taskviewitem.cpp + PARENT_SCOPE +) diff --git a/app/widget/taskview/taskview.cpp b/app/widget/taskview/taskview.cpp new file mode 100644 index 000000000..6332febc8 --- /dev/null +++ b/app/widget/taskview/taskview.cpp @@ -0,0 +1,52 @@ +/*** + + 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 "taskview.h" + +#include + +TaskView::TaskView(QWidget* parent) : + QScrollArea(parent) +{ + // Allow scroll area to resize widget to fit + setWidgetResizable(true); + + // Create central widget + central_widget_ = new QWidget(this); + setWidget(central_widget_); + + // Create layout for central widget + layout_ = new QVBoxLayout(central_widget_); + layout_->setSpacing(0); + layout_->setMargin(0); + + // Add a "stretch" so that TaskViewItems don't try to expand all the way to the bottom + layout_->addStretch(); +} + +void TaskView::AddTask(Task *t) +{ + // Create TaskViewItem (UI representation of a Task) and connect it + TaskViewItem* item = new TaskViewItem(central_widget_); + + item->SetTask(t); + + layout_->insertWidget(0, item); +} diff --git a/app/widget/taskview/taskview.h b/app/widget/taskview/taskview.h new file mode 100644 index 000000000..59b77b083 --- /dev/null +++ b/app/widget/taskview/taskview.h @@ -0,0 +1,43 @@ +/*** + + 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 TASKVIEW_H +#define TASKVIEW_H + +#include +#include + +#include "widget/taskview/taskviewitem.h" + +class TaskView : public QScrollArea +{ + Q_OBJECT +public: + TaskView(QWidget* parent); + +public slots: + void AddTask(Task* t); + +private: + QWidget* central_widget_; + QVBoxLayout* layout_; +}; + +#endif // TASKVIEW_H diff --git a/app/widget/taskview/taskviewitem.cpp b/app/widget/taskview/taskviewitem.cpp new file mode 100644 index 000000000..3e4c41b45 --- /dev/null +++ b/app/widget/taskview/taskviewitem.cpp @@ -0,0 +1,90 @@ +/*** + + 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 "taskviewitem.h" + +#include + +TaskViewItem::TaskViewItem(QWidget *parent) : + QFrame(parent), + task_(nullptr) +{ + // Draw border around this item + setFrameShape(QFrame::StyledPanel); + + // Create layout + QVBoxLayout* layout = new QVBoxLayout(this); + + // Create header label + task_name_lbl_ = new QLabel(this); + layout->addWidget(task_name_lbl_); + + // Create progress bar + progress_bar_ = new QProgressBar(this); + progress_bar_->setRange(0, 100); + layout->addWidget(progress_bar_); + + // Create status label + task_status_lbl_ = new QLabel(this); + layout->addWidget(task_status_lbl_); +} + +void TaskViewItem::SetTask(Task *t) +{ + // Check if we already have a task and disconnect from it if so + if (task_ != nullptr) { + disconnect(task_, SIGNAL(StatusChanged(Task::Status)), this, SLOT(TaskStatusChange(Task::Status))); + disconnect(task_, SIGNAL(ProgressChanged(int)), progress_bar_, SLOT(setValue(int))); + } + + // Set task + task_ = t; + + // Set name label to the name (bolded) + task_name_lbl_->setText(QString("%1").arg(task_->text())); + + // Connect to the task + connect(t, SIGNAL(StatusChanged(Task::Status)), this, SLOT(TaskStatusChange(Task::Status))); + connect(t, SIGNAL(ProgressChanged(int)), progress_bar_, SLOT(setValue(int))); +} + +void TaskViewItem::TaskStatusChange(Task::Status status) +{ + switch (status) { + case Task::kWaiting: + task_status_lbl_->setText(tr("Waiting...")); + progress_bar_->setValue(0); + break; + case Task::kWorking: + task_status_lbl_->setText(tr("Working...")); + progress_bar_->setValue(0); + break; + case Task::kFinished: + task_status_lbl_->setText(tr("Done")); + progress_bar_->setValue(100); + break; + case Task::kError: + task_status_lbl_->setText( + tr("Error: %1").arg(static_cast(sender())->error()) + ); + progress_bar_->setValue(0); + break; + } +} diff --git a/app/widget/taskview/taskviewitem.h b/app/widget/taskview/taskviewitem.h new file mode 100644 index 000000000..29fac95cf --- /dev/null +++ b/app/widget/taskview/taskviewitem.h @@ -0,0 +1,50 @@ +/*** + + 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 TASKVIEWITEM_H +#define TASKVIEWITEM_H + +#include +#include +#include + +#include "task/task.h" + +class TaskViewItem : public QFrame +{ + Q_OBJECT +public: + TaskViewItem(QWidget* parent); + + void SetTask(Task* t); + +private: + QLabel* task_name_lbl_; + QProgressBar* progress_bar_; + QLabel* task_status_lbl_; + + Task* task_; + +private slots: + void TaskStatusChange(Task::Status status); + +}; + +#endif // TASKVIEWITEM_H diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 308169f7e..c3a463617 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -24,9 +24,10 @@ // Panel objects #include "panel/project/project.h" -#include "panel/viewer/viewer.h" +#include "panel/taskmanager/taskmanager.h" #include "panel/timeline/timeline.h" #include "panel/tool/tool.h" +#include "panel/viewer/viewer.h" // Main menu bar #include "mainmenu.h" @@ -67,6 +68,9 @@ void olive::MainWindow::ProjectOpen(Project* p) ToolPanel* tool_panel = new ToolPanel(this); addDockWidget(Qt::BottomDockWidgetArea, tool_panel); + TaskManagerPanel* task_panel = new TaskManagerPanel(this); + addDockWidget(Qt::BottomDockWidgetArea, task_panel); + TimelinePanel* timeline_panel = new TimelinePanel(this); addDockWidget(Qt::BottomDockWidgetArea, timeline_panel); }