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;
|
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) :
|
ContainerWidget::ContainerWidget(QWidget *parent) :
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
#include <QSplitter>
|
||||||
|
|
||||||
#ifdef ADS_ANIMATIONS_ENABLED
|
#ifdef ADS_ANIMATIONS_ENABLED
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
@ -23,6 +24,21 @@
|
|||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
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) :
|
SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
_content(content),
|
_content(content),
|
||||||
@ -103,12 +119,12 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
resizeAnim->setDuration(ADS_ANIMATION_DURATION);
|
resizeAnim->setDuration(ADS_ANIMATION_DURATION);
|
||||||
|
|
||||||
auto animGroup = new QParallelAnimationGroup(this);
|
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();
|
auto data = _fw->takeContent();
|
||||||
_fw->deleteLater();
|
_fw->deleteLater();
|
||||||
_fw.clear();
|
_fw.clear();
|
||||||
sw->addContent(data, true);
|
cw->dropContent(data, sw, loc);
|
||||||
});
|
});
|
||||||
animGroup->addAnimation(moveAnim);
|
animGroup->addAnimation(moveAnim);
|
||||||
animGroup->addAnimation(resizeAnim);
|
animGroup->addAnimation(resizeAnim);
|
||||||
@ -203,6 +219,10 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
delete section;
|
delete section;
|
||||||
section = NULL;
|
section = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete old splitter, if it is empty now
|
||||||
|
deleteEmptySplitter(cw);
|
||||||
|
|
||||||
ev->accept();
|
ev->accept();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user