Animate show and replace widget.

this feature is totally useless and by consequent indispensable.
This commit is contained in:
Claveau Joshua
2020-04-23 19:52:56 +02:00
parent f4cbf21075
commit 9525278be7
8 changed files with 606 additions and 238 deletions

View File

@@ -39,6 +39,7 @@
#include "qetgraphicstableitem.h"
#include "bomexportdialog.h"
#include "nomenclaturemodel.h"
#include "QWidgetAnimation/qwidgetanimation.h"
#include <KAutoSaveFile>
@@ -66,9 +67,17 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
splitter_->setOrientation(Qt::Vertical);
splitter_->addWidget(&m_workspace);
splitter_->addWidget(&m_search_and_replace_widget);
m_search_and_replace_widget.setHidden(true);
m_search_and_replace_widget.setEditor(this);
setCentralWidget(splitter_);
m_search_and_replace_widget.setEditor(this);
QList<int> s;
s << m_workspace.maximumHeight() << m_search_and_replace_widget.minimumSizeHint().height();
splitter_->setSizes(s); //Force the size of the search and replace widget, force have a good animation the first time he is showed
auto anim = new QWidgetAnimation(&m_search_and_replace_widget, Qt::Vertical, QWidgetAnimation::lastSize, 250);
anim->setObjectName("search and replace animator");
m_search_and_replace_widget.setHidden(true);
anim->setLastShowSize(m_search_and_replace_widget.minimumSizeHint().height());
//Set object name to be retrieved by the stylesheets
m_workspace.setBackground(QBrush(Qt::NoBrush));
@@ -654,8 +663,13 @@ void QETDiagramEditor::setUpActions()
m_find = new QAction(tr("Chercher/remplacer"), this);
m_find->setShortcut(QKeySequence::Find);
connect(m_find, &QAction::triggered, [this]() {
this->m_search_and_replace_widget.setHidden(!m_search_and_replace_widget.isHidden());
connect(m_find, &QAction::triggered, [this]()
{
if (auto animator = m_search_and_replace_widget.findChild<QWidgetAnimation *>("search and replace animator")) {
animator->setHidden(!m_search_and_replace_widget.isHidden());
} else {
this->m_search_and_replace_widget.setHidden(!m_search_and_replace_widget.isHidden());
}
});
}