mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Deletes empty QSplitter objects
This commit is contained in:
parent
b52436aac7
commit
8029069335
@ -19,19 +19,6 @@ static QSplitter* newSplitter(Qt::Orientation orientation = Qt::Horizontal)
|
||||
return s;
|
||||
}
|
||||
|
||||
//static void deleteEmptySplitter(ContainerWidget* container)
|
||||
//{
|
||||
// auto splitters = container->findChildren<QSplitter*>();
|
||||
// for (auto i = 0; i < splitters.count(); ++i)
|
||||
// {
|
||||
// if (splitters[i]->count() == 0 && container->_splitter != splitters[i])
|
||||
// {
|
||||
// qDebug() << "Delete empty QSplitter";
|
||||
// splitters[i]->deleteLater();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
ContainerWidget::ContainerWidget(QWidget *parent) :
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QDrag>
|
||||
#include <QCursor>
|
||||
#include <QStyle>
|
||||
#include <QSplitter>
|
||||
|
||||
#ifdef ADS_ANIMATIONS_ENABLED
|
||||
#include <QPropertyAnimation>
|
||||
@ -23,6 +24,21 @@
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
static void deleteEmptySplitter(ContainerWidget* container)
|
||||
{
|
||||
auto splitters = container->findChildren<QSplitter*>();
|
||||
for (auto i = 0; i < splitters.count(); ++i)
|
||||
{
|
||||
if (splitters[i]->count() == 0 && container->_splitter != splitters[i])
|
||||
{
|
||||
if (splitters[i] == container->_splitter)
|
||||
continue;
|
||||
qDebug() << "Delete empty QSplitter";
|
||||
splitters[i]->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent) :
|
||||
QFrame(parent),
|
||||
_content(content),
|
||||
@ -103,12 +119,12 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
resizeAnim->setDuration(ADS_ANIMATION_DURATION);
|
||||
|
||||
auto animGroup = new QParallelAnimationGroup(this);
|
||||
QObject::connect(animGroup, &QPropertyAnimation::finished, [this, sw]()
|
||||
QObject::connect(animGroup, &QPropertyAnimation::finished, [this, data, sw, loc]()
|
||||
{
|
||||
auto data = _fw->takeContent();
|
||||
_fw->deleteLater();
|
||||
_fw.clear();
|
||||
sw->addContent(data, true);
|
||||
cw->dropContent(data, sw, loc);
|
||||
});
|
||||
animGroup->addAnimation(moveAnim);
|
||||
animGroup->addAnimation(resizeAnim);
|
||||
@ -203,6 +219,10 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||
delete section;
|
||||
section = NULL;
|
||||
}
|
||||
|
||||
// Delete old splitter, if it is empty now
|
||||
deleteEmptySplitter(cw);
|
||||
|
||||
ev->accept();
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user