From 3d0f11c6ef196961349bb55b412920a852ccfe0f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 8 May 2020 23:08:50 +1000 Subject: [PATCH] nodeview: first attempt at filter dialog --- app/widget/nodeview/CMakeLists.txt | 2 + app/widget/nodeview/nodeview.cpp | 14 ++- app/widget/nodeview/nodeview.h | 5 + app/widget/nodeview/nodeviewfilter.cpp | 139 +++++++++++++++++++++++++ app/widget/nodeview/nodeviewfilter.h | 56 ++++++++++ 5 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 app/widget/nodeview/nodeviewfilter.cpp create mode 100644 app/widget/nodeview/nodeviewfilter.h diff --git a/app/widget/nodeview/CMakeLists.txt b/app/widget/nodeview/CMakeLists.txt index c36c19882..10163c953 100644 --- a/app/widget/nodeview/CMakeLists.txt +++ b/app/widget/nodeview/CMakeLists.txt @@ -21,6 +21,8 @@ set(OLIVE_SOURCES widget/nodeview/nodeviewcommon.h widget/nodeview/nodeviewedge.h widget/nodeview/nodeviewedge.cpp + widget/nodeview/nodeviewfilter.h + widget/nodeview/nodeviewfilter.cpp widget/nodeview/nodeviewitem.h widget/nodeview/nodeviewitem.cpp widget/nodeview/nodeviewitemwidgetproxy.h diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index bd4781440..a09338c58 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -26,6 +26,7 @@ #include "core.h" #include "nodeviewundo.h" #include "node/factory.h" +#include "nodeviewfilter.h" #include "widget/menu/menushared.h" #define super HandMovableView @@ -258,7 +259,7 @@ void NodeView::ItemsChanged() { QHash::const_iterator i; - for (i=scene_.edge_map().begin();i!=scene_.edge_map().end();i++) { + for (i=scene_.edge_map().begin(); i!=scene_.edge_map().end(); i++) { i.value()->Adjust(); } } @@ -432,6 +433,11 @@ void NodeView::ShowContextMenu(const QPoint &pos) } else { + QAction* filters_action = m.addAction(tr("Filters...")); + connect(filters_action, &QAction::triggered, this, &NodeView::ContextMenuShowFiltersDialog); + + m.addSeparator(); + Menu* direction_menu = new Menu(tr("Direction"), &m); m.addMenu(direction_menu); @@ -515,6 +521,12 @@ void NodeView::ContextMenuLabelNode() } } +void NodeView::ContextMenuShowFiltersDialog() +{ + NodeViewFilterDialog fd(this); + fd.exec(); +} + void NodeView::PlaceNode(NodeViewItem *n, const QPointF &pos) { QRectF destination_rect = n->rect(); diff --git a/app/widget/nodeview/nodeview.h b/app/widget/nodeview/nodeview.h index 2701f4a1d..19e87eb0c 100644 --- a/app/widget/nodeview/nodeview.h +++ b/app/widget/nodeview/nodeview.h @@ -146,6 +146,11 @@ private slots: */ void ContextMenuLabelNode(); + /** + * @brief Receiver that shows the filters dialog + */ + void ContextMenuShowFiltersDialog(); + }; OLIVE_NAMESPACE_EXIT diff --git a/app/widget/nodeview/nodeviewfilter.cpp b/app/widget/nodeview/nodeviewfilter.cpp new file mode 100644 index 000000000..fea2d42dc --- /dev/null +++ b/app/widget/nodeview/nodeviewfilter.cpp @@ -0,0 +1,139 @@ +/*** + + 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 "nodeviewfilter.h" + +#include +#include +#include +#include +#include +#include +#include + +#define FILTER_COLUMN_COUNT 7 + +OLIVE_NAMESPACE_ENTER + +NodeViewFilterDialog::NodeViewFilterDialog(QWidget *parent) : + QDialog(parent), + row_count_(0) +{ + setWindowTitle(tr("Configure Node Filters")); + + QVBoxLayout* layout = new QVBoxLayout(this); + + { + QGroupBox* filter_group = new QGroupBox(); + filter_group->setTitle(tr("Filters")); + + QVBoxLayout* filter_outer_layout = new QVBoxLayout(filter_group); + filter_layout_ = new QGridLayout(); + filter_layout_->setMargin(0); + filter_outer_layout->addLayout(filter_layout_); + filter_outer_layout->addStretch(); + + layout->addWidget(filter_group); + } + + plus_btn_ = new QPushButton(tr("+")); + plus_btn_->setFixedWidth(plus_btn_->sizeHint().height()); + connect(plus_btn_, &QPushButton::clicked, this, &NodeViewFilterDialog::AppendRow); + + AppendRow(); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + layout->addWidget(buttons); +} + +void NodeViewFilterDialog::AppendRow() +{ + QCheckBox* enabled_check = new QCheckBox(); + enabled_check->setChecked(true); + filter_layout_->addWidget(enabled_check, row_count_, 0); + + QComboBox* showhide_combo = new QComboBox(); + showhide_combo->addItem(tr("Show")); + showhide_combo->addItem(tr("Hide")); + filter_layout_->addWidget(showhide_combo, row_count_, 1); + + QComboBox* type_combo = new QComboBox(); + type_combo->addItem(tr("Any")); + type_combo->addItem(tr("Selected")); + filter_layout_->addWidget(type_combo, row_count_, 2); + + QComboBox* from_combo = new QComboBox(); + from_combo->addItem(tr("From Node")); + from_combo->addItem(tr("From Category")); + filter_layout_->addWidget(from_combo, row_count_, 3); + + QComboBox* from_entry_combo = new QComboBox(); + filter_layout_->addWidget(from_entry_combo, row_count_, 4); + + QComboBox* to_entry_combo = new QComboBox(); + filter_layout_->addWidget(to_entry_combo, row_count_, 5); + + QPushButton* minus_btn = new QPushButton(tr("-")); + minus_btn->setFixedWidth(minus_btn->sizeHint().height()); + connect(minus_btn, &QPushButton::clicked, this, &NodeViewFilterDialog::RemoveRowButtonClicked); + filter_layout_->addWidget(minus_btn, row_count_, 6); + + row_count_++; + + UpdateAddButtonPos(); +} + +void NodeViewFilterDialog::RemoveRowButtonClicked() +{ + for (int i=0;iitemAtPosition(i, FILTER_COLUMN_COUNT-1)->widget() == sender()) { + RemoveRow(i); + return; + } + } +} + +void NodeViewFilterDialog::RemoveRow(int row) +{ + for (int i=0;iitemAtPosition(row, i)->widget(); + } + + for (int j=row+1;jitemAtPosition(j, i)->widget(); + + filter_layout_->addWidget(w, j - 1, i); + } + } + + row_count_--; + + UpdateAddButtonPos(); +} + +void NodeViewFilterDialog::UpdateAddButtonPos() +{ + filter_layout_->addWidget(plus_btn_, row_count_, FILTER_COLUMN_COUNT - 1); +} + +OLIVE_NAMESPACE_EXIT diff --git a/app/widget/nodeview/nodeviewfilter.h b/app/widget/nodeview/nodeviewfilter.h new file mode 100644 index 000000000..38e28f4ad --- /dev/null +++ b/app/widget/nodeview/nodeviewfilter.h @@ -0,0 +1,56 @@ +/*** + + 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 NODEVIEWFILTERDIALOG_H +#define NODEVIEWFILTERDIALOG_H + +#include +#include + +#include "node/node.h" + +OLIVE_NAMESPACE_ENTER + +class NodeViewFilterDialog : public QDialog +{ +public: + NodeViewFilterDialog(QWidget* parent = nullptr); + +private: + void RemoveRow(int row); + + void UpdateAddButtonPos(); + + int row_count_; + + QGridLayout* filter_layout_; + + QPushButton* plus_btn_; + +private slots: + void AppendRow(); + + void RemoveRowButtonClicked(); + +}; + +OLIVE_NAMESPACE_EXIT + +#endif // NODEVIEWFILTERDIALOG_H