text: added crude basic rich text dialog
To be expanded upon...
This commit is contained in:
@@ -24,6 +24,7 @@ add_subdirectory(preferences)
|
|||||||
add_subdirectory(progress)
|
add_subdirectory(progress)
|
||||||
add_subdirectory(projectproperties)
|
add_subdirectory(projectproperties)
|
||||||
add_subdirectory(rendercancel)
|
add_subdirectory(rendercancel)
|
||||||
|
add_subdirectory(richtext)
|
||||||
add_subdirectory(sequence)
|
add_subdirectory(sequence)
|
||||||
add_subdirectory(speedduration)
|
add_subdirectory(speedduration)
|
||||||
add_subdirectory(task)
|
add_subdirectory(task)
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set(OLIVE_SOURCES
|
||||||
|
${OLIVE_SOURCES}
|
||||||
|
dialog/richtext/richtext.h
|
||||||
|
dialog/richtext/richtext.cpp
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/***
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include "richtext.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "ui/icons/icons.h"
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
RichTextDialog::RichTextDialog(const QString &start, QWidget* parent) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
|
// Create toolbar
|
||||||
|
QHBoxLayout* toolbar_layout = new QHBoxLayout();
|
||||||
|
|
||||||
|
bold_btn_ = new QPushButton(QStringLiteral("B"));
|
||||||
|
bold_btn_->setCheckable(true);
|
||||||
|
toolbar_layout->addWidget(bold_btn_);
|
||||||
|
italic_btn_ = new QPushButton(QStringLiteral("I"));
|
||||||
|
italic_btn_->setCheckable(true);
|
||||||
|
toolbar_layout->addWidget(italic_btn_);
|
||||||
|
underline_btn_ = new QPushButton(QStringLiteral("U"));
|
||||||
|
underline_btn_->setCheckable(true);
|
||||||
|
toolbar_layout->addWidget(underline_btn_);
|
||||||
|
font_combo_ = new QFontComboBox();
|
||||||
|
toolbar_layout->addWidget(font_combo_);
|
||||||
|
size_slider_ = new FloatSlider();
|
||||||
|
size_slider_->SetMinimum(0.1);
|
||||||
|
toolbar_layout->addWidget(size_slider_);
|
||||||
|
|
||||||
|
toolbar_layout->addStretch();
|
||||||
|
|
||||||
|
layout->addLayout(toolbar_layout);
|
||||||
|
|
||||||
|
// Create text edit widget
|
||||||
|
text_edit_ = new QTextEdit();
|
||||||
|
connect(text_edit_, &QTextEdit::cursorPositionChanged, this, &RichTextDialog::UpdateButtons);
|
||||||
|
text_edit_->document()->setHtml(start);
|
||||||
|
layout->addWidget(text_edit_);
|
||||||
|
|
||||||
|
// Create buttons
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
connect(buttons, &QDialogButtonBox::accepted, this, &RichTextDialog::accept);
|
||||||
|
connect(buttons, &QDialogButtonBox::rejected, this, &RichTextDialog::reject);
|
||||||
|
|
||||||
|
// Connect font buttons
|
||||||
|
connect(bold_btn_, &QPushButton::clicked, this, [this](bool e){
|
||||||
|
text_edit_->setFontWeight(e ? QFont::Bold : QFont::Normal);
|
||||||
|
});
|
||||||
|
connect(italic_btn_, &QPushButton::clicked, text_edit_, &QTextEdit::setFontItalic);
|
||||||
|
connect(underline_btn_, &QPushButton::clicked, text_edit_, &QTextEdit::setFontUnderline);
|
||||||
|
connect(size_slider_, &FloatSlider::ValueChanged, text_edit_, &QTextEdit::setFontPointSize);
|
||||||
|
|
||||||
|
connect(font_combo_, &QFontComboBox::currentTextChanged, this, [this](const QString& s){
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setFontFamily(s);
|
||||||
|
|
||||||
|
QTextCursor cursor = text_edit_->textCursor();
|
||||||
|
if (!cursor.hasSelection())
|
||||||
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
cursor.mergeCharFormat(fmt);
|
||||||
|
text_edit_->mergeCurrentCharFormat(fmt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RichTextDialog::UpdateButtons()
|
||||||
|
{
|
||||||
|
bold_btn_->setChecked(text_edit_->fontWeight() > QFont::Normal);
|
||||||
|
italic_btn_->setChecked(text_edit_->fontItalic());
|
||||||
|
underline_btn_->setChecked(text_edit_->fontUnderline());
|
||||||
|
|
||||||
|
font_combo_->blockSignals(true);
|
||||||
|
QString font_family = text_edit_->fontFamily();
|
||||||
|
if (font_family.isEmpty()) {
|
||||||
|
font_family = QFont().family();
|
||||||
|
}
|
||||||
|
font_combo_->setCurrentFont(font_family);
|
||||||
|
font_combo_->blockSignals(false);
|
||||||
|
|
||||||
|
size_slider_->SetValue(text_edit_->fontPointSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/***
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***/
|
||||||
|
|
||||||
|
#ifndef RICHTEXTDIALOG_H
|
||||||
|
#define RICHTEXTDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QFontComboBox>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
#include "common/define.h"
|
||||||
|
#include "widget/slider/floatslider.h"
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
class RichTextDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RichTextDialog(const QString& start, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
QString text() const
|
||||||
|
{
|
||||||
|
return text_edit_->document()->toHtml("utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTextEdit* text_edit_;
|
||||||
|
|
||||||
|
QPushButton* bold_btn_;
|
||||||
|
QPushButton* italic_btn_;
|
||||||
|
QPushButton* underline_btn_;
|
||||||
|
QFontComboBox* font_combo_;
|
||||||
|
FloatSlider* size_slider_;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void UpdateButtons();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|
||||||
|
#endif // RICHTEXTDIALOG_H
|
||||||
@@ -26,6 +26,8 @@ set(OLIVE_SOURCES
|
|||||||
widget/nodeparamview/nodeparamviewitem.cpp
|
widget/nodeparamview/nodeparamviewitem.cpp
|
||||||
widget/nodeparamview/nodeparamviewkeyframecontrol.h
|
widget/nodeparamview/nodeparamviewkeyframecontrol.h
|
||||||
widget/nodeparamview/nodeparamviewkeyframecontrol.cpp
|
widget/nodeparamview/nodeparamviewkeyframecontrol.cpp
|
||||||
|
widget/nodeparamview/nodeparamviewrichtext.h
|
||||||
|
widget/nodeparamview/nodeparamviewrichtext.cpp
|
||||||
widget/nodeparamview/nodeparamviewundo.h
|
widget/nodeparamview/nodeparamviewundo.h
|
||||||
widget/nodeparamview/nodeparamviewundo.cpp
|
widget/nodeparamview/nodeparamviewundo.cpp
|
||||||
widget/nodeparamview/nodeparamviewwidgetbridge.h
|
widget/nodeparamview/nodeparamviewwidgetbridge.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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include "nodeparamviewrichtext.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "dialog/richtext/richtext.h"
|
||||||
|
#include "ui/icons/icons.h"
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
NodeParamViewRichText::NodeParamViewRichText(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
|
layout->setMargin(0);
|
||||||
|
|
||||||
|
line_edit_ = new QLineEdit();
|
||||||
|
connect(line_edit_, &QLineEdit::textEdited, this, &NodeParamViewRichText::textEdited);
|
||||||
|
layout->addWidget(line_edit_);
|
||||||
|
|
||||||
|
QPushButton* edit_btn = new QPushButton();
|
||||||
|
edit_btn->setIcon(icon::ToolEdit);
|
||||||
|
layout->addWidget(edit_btn);
|
||||||
|
connect(edit_btn, &QPushButton::clicked, this, &NodeParamViewRichText::ShowRichTextDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeParamViewRichText::ShowRichTextDialog()
|
||||||
|
{
|
||||||
|
RichTextDialog d(line_edit_->text(), this);
|
||||||
|
if (d.exec() == QDialog::Accepted) {
|
||||||
|
line_edit_->setText(d.text());
|
||||||
|
emit textEdited(d.text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/***
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***/
|
||||||
|
|
||||||
|
#ifndef NODEPARAMVIEWRICHTEXT_H
|
||||||
|
#define NODEPARAMVIEWRICHTEXT_H
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "common/define.h"
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
class NodeParamViewRichText : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
NodeParamViewRichText(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
QString text() const
|
||||||
|
{
|
||||||
|
return line_edit_->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setText(const QString &s)
|
||||||
|
{
|
||||||
|
line_edit_->setText(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void textEdited(const QString &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit* line_edit_;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ShowRichTextDialog();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|
||||||
|
#endif // NODEPARAMVIEWRICHTEXT_H
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFontComboBox>
|
#include <QFontComboBox>
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QVector4D>
|
#include <QVector4D>
|
||||||
@@ -30,6 +29,7 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "node/node.h"
|
#include "node/node.h"
|
||||||
#include "nodeparamviewarraywidget.h"
|
#include "nodeparamviewarraywidget.h"
|
||||||
|
#include "nodeparamviewrichtext.h"
|
||||||
#include "nodeparamviewundo.h"
|
#include "nodeparamviewundo.h"
|
||||||
#include "project/item/sequence/sequence.h"
|
#include "project/item/sequence/sequence.h"
|
||||||
#include "undo/undostack.h"
|
#include "undo/undostack.h"
|
||||||
@@ -146,9 +146,9 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
|||||||
}
|
}
|
||||||
case NodeParam::kText:
|
case NodeParam::kText:
|
||||||
{
|
{
|
||||||
QLineEdit* line_edit = new QLineEdit();
|
NodeParamViewRichText* line_edit = new NodeParamViewRichText();
|
||||||
widgets_.append(line_edit);
|
widgets_.append(line_edit);
|
||||||
connect(line_edit, &QLineEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
connect(line_edit, &NodeParamViewRichText::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NodeParam::kBoolean:
|
case NodeParam::kBoolean:
|
||||||
@@ -336,8 +336,8 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
|||||||
}
|
}
|
||||||
case NodeParam::kText:
|
case NodeParam::kText:
|
||||||
{
|
{
|
||||||
// Sender is a QLineEdit
|
// Sender is a NodeParamViewRichText
|
||||||
SetInputValue(static_cast<QLineEdit*>(sender())->text(), 0);
|
SetInputValue(static_cast<NodeParamViewRichText*>(sender())->text(), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NodeParam::kBoolean:
|
case NodeParam::kBoolean:
|
||||||
@@ -456,10 +456,8 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
|||||||
}
|
}
|
||||||
case NodeParam::kText:
|
case NodeParam::kText:
|
||||||
{
|
{
|
||||||
QLineEdit* e = static_cast<QLineEdit*>(widgets_.first());
|
NodeParamViewRichText* e = static_cast<NodeParamViewRichText*>(widgets_.first());
|
||||||
int pos = e->cursorPosition();
|
|
||||||
e->setText(input_->get_value_at_time(node_time).toString());
|
e->setText(input_->get_value_at_time(node_time).toString());
|
||||||
e->setCursorPosition(pos);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NodeParam::kBoolean:
|
case NodeParam::kBoolean:
|
||||||
|
|||||||
Reference in New Issue
Block a user