wip
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
|
||||
ItemContainer *Item::root() const
|
||||
{
|
||||
return m_parent ? m_parent->root()
|
||||
@@ -74,7 +75,7 @@ void Item::setFrame(QWidget *w)
|
||||
connect(m_widget, &QObject::destroyed, this, &Item::onWidgetDestroyed);
|
||||
connect(m_widget, SIGNAL(layoutInvalidated()), this, SLOT(onWidgetLayoutRequested())); // TODO: old-style
|
||||
m_widget->setParent(m_hostWidget);
|
||||
//setMinSize(m_widget->min)
|
||||
setMinSize(widgetMinSize(m_widget));
|
||||
}
|
||||
|
||||
updateObjectName();
|
||||
@@ -149,7 +150,7 @@ void Item::setParentContainer(ItemContainer *parent)
|
||||
|
||||
if (parent) {
|
||||
connect(this, &Item::minSizeChanged, parent, &ItemContainer::onChildMinSizeChanged);
|
||||
connect(this, &Item::visibleChanged, m_parent, &ItemContainer::onChildVisibleChanged);
|
||||
connect(this, &Item::visibleChanged, m_parent, &ItemContainer::onChildVisibleChanged);
|
||||
}
|
||||
|
||||
QObject::setParent(parent);
|
||||
@@ -233,6 +234,12 @@ void Item::insertItem(Item *item, Location loc, SizingOption sizingOption)
|
||||
}
|
||||
}
|
||||
|
||||
/** static */
|
||||
QSize Item::hardcodedMinimumSize()
|
||||
{
|
||||
return QSize(KDDOCKWIDGETS_MIN_WIDTH, KDDOCKWIDGETS_MIN_HEIGHT);
|
||||
}
|
||||
|
||||
int Item::x() const
|
||||
{
|
||||
return m_geometry.x();
|
||||
@@ -626,12 +633,23 @@ void ItemContainer::removeItem(Item *item, bool hardRemove)
|
||||
m_childPercentages.clear();
|
||||
Item *side1Item = visibleNeighbourFor(item, Side1);
|
||||
Item *side2Item = visibleNeighbourFor(item, Side2);
|
||||
const bool wasVisible = item->isVisible();
|
||||
|
||||
if (hardRemove) {
|
||||
m_children.removeOne(item);
|
||||
delete item;
|
||||
} else {
|
||||
item->setIsVisible(false);
|
||||
item->setFrame(nullptr);
|
||||
if (wasVisible) {
|
||||
item->setIsVisible(false);
|
||||
item->setFrame(nullptr);
|
||||
} else {
|
||||
// Nothing to do, item was already a placeholder.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wasVisible) {
|
||||
Q_EMIT root()->numVisibleItemsChanged();
|
||||
}
|
||||
|
||||
const bool containerShouldBeRemoved = !isRoot() && ((hardRemove && isEmpty()) ||
|
||||
@@ -1011,6 +1029,8 @@ void ItemContainer::insertItem(Item *item, int index, bool growItem)
|
||||
|
||||
if (growItem)
|
||||
restorePlaceholder(item);
|
||||
|
||||
Q_EMIT root()->numVisibleItemsChanged();
|
||||
}
|
||||
|
||||
bool ItemContainer::hasChildren() const
|
||||
|
||||
@@ -32,6 +32,9 @@ class TestMultiSplitter;
|
||||
|
||||
namespace Layouting {
|
||||
|
||||
#define KDDOCKWIDGETS_MIN_WIDTH 80
|
||||
#define KDDOCKWIDGETS_MIN_HEIGHT 90
|
||||
|
||||
enum Location {
|
||||
Location_None,
|
||||
Location_OnLeft, ///> Left docking location
|
||||
@@ -182,6 +185,11 @@ public:
|
||||
|
||||
virtual void insertItem(Item *item, Location, SizingOption = SizingOption::Calculate);
|
||||
|
||||
/**
|
||||
* @brief No widget can have a minimum size smaller than this, regardless of their minimum size.
|
||||
*/
|
||||
static QSize hardcodedMinimumSize();
|
||||
|
||||
int x() const;
|
||||
int y() const;
|
||||
int width() const;
|
||||
@@ -350,6 +358,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void itemsChanged();
|
||||
void numVisibleItemsChanged();
|
||||
public:
|
||||
QVector<qreal> m_childPercentages;
|
||||
Item::List m_children;
|
||||
@@ -357,4 +366,18 @@ public:
|
||||
bool m_isRoot = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the widget's min size
|
||||
*/
|
||||
inline QSize widgetMinSize(const QWidget *w)
|
||||
{
|
||||
const int minW = w->minimumWidth() > 0 ? w->minimumWidth()
|
||||
: w->minimumSizeHint().width();
|
||||
|
||||
const int minH = w->minimumHeight() > 0 ? w->minimumHeight()
|
||||
: w->minimumSizeHint().height();
|
||||
|
||||
return QSize(minW, minH).expandedTo(Item::hardcodedMinimumSize());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include <QScopedValueRollback>
|
||||
|
||||
#define INDICATOR_MINIMUM_LENGTH 100
|
||||
#define KDDOCKWIDGETS_MIN_WIDTH 80
|
||||
#define KDDOCKWIDGETS_MIN_HEIGHT 90
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
using namespace Layouting;
|
||||
@@ -79,12 +77,6 @@ MultiSplitterLayout::~MultiSplitterLayout()
|
||||
DockRegistry::self()->unregisterLayout(this);
|
||||
}
|
||||
|
||||
/**static*/
|
||||
QSize MultiSplitterLayout::hardcodedMinimumSize()
|
||||
{
|
||||
return QSize(KDDOCKWIDGETS_MIN_WIDTH, KDDOCKWIDGETS_MIN_HEIGHT);
|
||||
}
|
||||
|
||||
MultiSplitter *MultiSplitterLayout::multiSplitter() const
|
||||
{
|
||||
return m_multiSplitter;
|
||||
@@ -151,7 +143,7 @@ void MultiSplitterLayout::addWidget(QWidgetOrQuick *w, Location location, Frame
|
||||
<< "; relativeTo=" << relativeToWidget
|
||||
<< "; size=" << size()
|
||||
<< "; w.size=" << w->size()
|
||||
<< "; w.min=" << widgetMinLength(w, Layouting::orientationForLocation(Layouting::Location(location)))
|
||||
<< "; w.min=" << Layouting::widgetMinSize(w)
|
||||
<< "; frame=" << frame
|
||||
<< "; option=" << option;
|
||||
|
||||
|
||||
@@ -49,15 +49,6 @@ namespace Debug {
|
||||
class DebugWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the widget if orientation is Vertical, the height otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
inline int widgetLength(const T *w, Qt::Orientation orientation)
|
||||
{
|
||||
return (orientation == Qt::Vertical) ? w->width() : w->height();
|
||||
}
|
||||
|
||||
/**
|
||||
* A MultiSplitter is like a QSplitter but supports mixing vertical and horizontal splitters in
|
||||
* any combination.
|
||||
@@ -84,11 +75,6 @@ public:
|
||||
explicit MultiSplitterLayout(MultiSplitter *parent);
|
||||
~MultiSplitterLayout() override;
|
||||
|
||||
/**
|
||||
* @brief No widget can have a minimum size smaller than this, regardless of their minimum size.s
|
||||
*/
|
||||
static QSize hardcodedMinimumSize();
|
||||
|
||||
/**
|
||||
* @brief returns the widget that this layout manages
|
||||
*/
|
||||
@@ -427,31 +413,6 @@ private:
|
||||
Layouting::ItemContainer *const m_rootItem;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the widget's min-width if orientation is Vertical, the min-height otherwise.
|
||||
*/
|
||||
inline int widgetMinLength(const QWidgetOrQuick *w, Qt::Orientation orientation)
|
||||
{
|
||||
int min = 0;
|
||||
if (orientation == Qt::Vertical) {
|
||||
if (w->minimumWidth() > 0)
|
||||
min = w->minimumWidth();
|
||||
else
|
||||
min = w->minimumSizeHint().width();
|
||||
|
||||
min = qMax(MultiSplitterLayout::hardcodedMinimumSize().width(), min);
|
||||
} else {
|
||||
if (w->minimumHeight() > 0)
|
||||
min = w->minimumHeight();
|
||||
else
|
||||
min = w->minimumSizeHint().height();
|
||||
|
||||
min = qMax(MultiSplitterLayout::hardcodedMinimumSize().height(), min);
|
||||
}
|
||||
|
||||
return qMax(min, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(KDDockWidgets::MultiSplitterLayout::Length)
|
||||
|
||||
Reference in New Issue
Block a user