diff --git a/app/dialog/CMakeLists.txt b/app/dialog/CMakeLists.txt index 48c9884d1..b1a19fe5a 100644 --- a/app/dialog/CMakeLists.txt +++ b/app/dialog/CMakeLists.txt @@ -23,6 +23,7 @@ add_subdirectory(diskcache) add_subdirectory(export) add_subdirectory(footagerelink) add_subdirectory(keyframeproperties) +add_subdirectory(nodeproperties) add_subdirectory(preferences) add_subdirectory(progress) add_subdirectory(rendercancel) diff --git a/app/dialog/nodeproperties/CMakeLists.txt b/app/dialog/nodeproperties/CMakeLists.txt new file mode 100644 index 000000000..f1c44b5af --- /dev/null +++ b/app/dialog/nodeproperties/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2021 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/nodeproperties/nodepropertiesdialog.cpp + dialog/nodeproperties/nodepropertiesdialog.h + PARENT_SCOPE +) diff --git a/app/dialog/nodeproperties/nodepropertiesdialog.cpp b/app/dialog/nodeproperties/nodepropertiesdialog.cpp new file mode 100644 index 000000000..123b6c69b --- /dev/null +++ b/app/dialog/nodeproperties/nodepropertiesdialog.cpp @@ -0,0 +1,74 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2021 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 "nodepropertiesdialog.h" + +#include +#include + +#include "core.h" +#include "widget/nodeview/nodeviewundo.h" + +namespace olive { + +NodePropertiesDialog::NodePropertiesDialog(Node *node, const rational &timebase, QWidget *parent) : + QDialog(parent), + node_(node) +{ + setWindowTitle(tr("Node Properties")); + + QVBoxLayout *layout = new QVBoxLayout(this); + + QHBoxLayout *label_layout = new QHBoxLayout(); + label_layout->setMargin(0); + layout->addLayout(label_layout); + + label_layout->addWidget(new QLabel(tr("Name:"))); + + label_edit_ = new QLineEdit(); + label_edit_->setText(node->GetLabel()); + label_layout->addWidget(label_edit_); + + NodeParamViewItem *item = new NodeParamViewItem(node); + item->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + item->SetTimebase(timebase); + item->setTitleBarWidget(new QWidget()); + layout->addWidget(item); + + layout->addStretch(); + + QDialogButtonBox *btns = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(btns, &QDialogButtonBox::accepted, this, &NodePropertiesDialog::accept); + connect(btns, &QDialogButtonBox::rejected, this, &NodePropertiesDialog::reject); + layout->addWidget(btns); +} + +void NodePropertiesDialog::accept() +{ + if (label_edit_->text() != node_->GetLabel()) { + NodeRenameCommand* rename_command = new NodeRenameCommand(); + rename_command->AddNode(node_, label_edit_->text()); + Core::instance()->undo_stack()->push(rename_command); + } + + QDialog::accept(); +} + +} diff --git a/app/dialog/nodeproperties/nodepropertiesdialog.h b/app/dialog/nodeproperties/nodepropertiesdialog.h new file mode 100644 index 000000000..5375a1313 --- /dev/null +++ b/app/dialog/nodeproperties/nodepropertiesdialog.h @@ -0,0 +1,52 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2021 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 NODEPROPERTIESDIALOG_H +#define NODEPROPERTIESDIALOG_H + +#include + +#include "widget/nodeparamview/nodeparamviewitem.h" + +namespace olive { + +class NodePropertiesDialog : public QDialog +{ + Q_OBJECT +public: + NodePropertiesDialog(Node *node, const rational &timebase, QWidget *parent = nullptr); + NodePropertiesDialog(const QVector &node, const rational &timebase, QWidget *parent = nullptr) : + NodePropertiesDialog(node.first(), timebase, parent) + { + } + +public slots: + virtual void accept() override; + +private: + Node *node_; + + QLineEdit *label_edit_; + +}; + +} + +#endif // NODEPROPERTIESDIALOG_H diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index d653384f5..d229cf112 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -30,6 +30,7 @@ #include "common/define.h" #include "core.h" +#include "dialog/nodeproperties/nodepropertiesdialog.h" #include "dialog/sequence/sequence.h" #include "projectexplorerundo.h" #include "task/precache/precachetask.h" @@ -439,11 +440,12 @@ void ProjectExplorer::ShowItemPropertiesDialog() // FIXME: Support for multiple items if (dynamic_cast(sel)) { - Core::instance()->LabelNodes({static_cast(sel)}); + NodePropertiesDialog npd(sel, static_cast(sel)->GetVideoParams().time_base(), this); + npd.exec(); } else if (dynamic_cast(sel)) { - Core::instance()->LabelNodes({static_cast(sel)}); + Core::instance()->LabelNodes(context_menu_items_); } else if (dynamic_cast(sel)) { diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 1d3fbea4a..5fa05ab70 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -28,6 +28,7 @@ #include "core.h" #include "common/range.h" #include "common/timecodefunctions.h" +#include "dialog/nodeproperties/nodepropertiesdialog.h" #include "dialog/sequence/sequence.h" #include "node/block/transition/transition.h" #include "tool/add.h" @@ -992,7 +993,8 @@ void TimelineWidget::ShowContextMenu() nodes.append(i); } - Core::instance()->LabelNodes(nodes); + NodePropertiesDialog npd(nodes, timebase(), this); + npd.exec(); }); }