qtquick|tests: Fix verifying frame min size
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
|
||||
class TestDocks;
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class TitleBar;
|
||||
@@ -278,10 +280,12 @@ protected:
|
||||
virtual DockWidgetBase *dockWidgetAt_impl(int index) const = 0;
|
||||
virtual DockWidgetBase *currentDockWidget_impl() const = 0;
|
||||
virtual int dockWidgetCount_impl() const = 0;
|
||||
virtual int nonContentsHeight() const = 0;
|
||||
|
||||
bool m_inDtor = false;
|
||||
private:
|
||||
Q_DISABLE_COPY(Frame)
|
||||
friend class TestDocks;
|
||||
friend class ::TestDocks;
|
||||
friend class TabWidget;
|
||||
void onCurrentTabChanged(int index);
|
||||
void scheduleDeleteLater();
|
||||
|
||||
@@ -55,11 +55,12 @@ protected:
|
||||
void renameTab(int index, const QString &) override;
|
||||
Q_INVOKABLE void setStackLayout(QQuickItem *);
|
||||
|
||||
int nonContentsHeight() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void tabTitlesChanged();
|
||||
private:
|
||||
void updateConstriants();
|
||||
int nonContentsHeight() const;
|
||||
QQuickItem *m_stackLayout = nullptr;
|
||||
QQuickItem *m_visualItem = nullptr;
|
||||
DockWidgetBase *m_currentDockWidget = nullptr;
|
||||
|
||||
@@ -44,13 +44,23 @@ Rectangle {
|
||||
top: titleBar.bottom
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
onHeightChanged: {
|
||||
// console.log("FloatingWindow.qml.dropArea height changed to " + height + " ; root.height= " + root.height)
|
||||
}
|
||||
}
|
||||
|
||||
onDropAreaCppChanged: {
|
||||
// Parent the cpp obj to the visual obj. So the user can style it
|
||||
if (dropAreaCpp) {
|
||||
//console.log("Setup start: height=" + height + "; dropArea.height=" + dropAreaCpp.height);
|
||||
dropAreaCpp.parent = dropArea;
|
||||
dropAreaCpp.anchors.fill = dropArea;
|
||||
//console.log("Setup done: height=" + height + "; dropArea.height=" + dropAreaCpp.height);
|
||||
}
|
||||
}
|
||||
|
||||
onHeightChanged: {
|
||||
//console.log("FloatingWindow.qml.root height changed to " + height)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ Rectangle {
|
||||
id: root
|
||||
property QtObject frameCpp
|
||||
readonly property QtObject titleBarCpp: frameCpp ? frameCpp.titleBar : null
|
||||
readonly property int nonContentsHeight: (titleBar.visible ? titleBar.height : 0) +
|
||||
(tabbar.visible ? tabbar.height : 0)
|
||||
readonly property int nonContentsHeight: titleBar.height + tabbar.height
|
||||
color: "cyan"
|
||||
anchors.fill: parent
|
||||
|
||||
|
||||
@@ -180,3 +180,12 @@ void FrameWidget::renameTab(int index, const QString &text)
|
||||
m_tabWidget->renameTab(index, text);
|
||||
}
|
||||
|
||||
|
||||
int KDDockWidgets::FrameWidget::nonContentsHeight() const
|
||||
{
|
||||
TitleBar *tb = titleBar();
|
||||
QWidget *tabBar = this->tabBar();
|
||||
|
||||
return (tb->isVisible() ? tb->height() : 0) +
|
||||
(tabBar->isVisible() ? tabBar->height() : 0);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ protected:
|
||||
int dockWidgetCount_impl() const override;
|
||||
QRect dragRect() const override;
|
||||
void renameTab(int index, const QString &) override;
|
||||
int nonContentsHeight() const override;
|
||||
private:
|
||||
friend class TestDocks;
|
||||
TabWidget *const m_tabWidget;
|
||||
|
||||
@@ -6125,15 +6125,15 @@ void TestDocks::tst_constraintsPropagateUp()
|
||||
|
||||
auto frame1 = dock1->frame();
|
||||
|
||||
QVERIFY(qAbs(widgetMinLength(frame1, Qt::Vertical) - minHeight) < 10); //10px for styling differences
|
||||
QVERIFY(qAbs(widgetMinLength(frame1, Qt::Horizontal) - minWidth) < 10); //10px for styling differences
|
||||
QVERIFY(qAbs(widgetMinLength(frame1, Qt::Vertical) - (minHeight + frame1->nonContentsHeight()) < 10)); //10px for styling differences
|
||||
|
||||
// Add dock2 side-by side, so the Frame now has a title bar.
|
||||
auto oldFw2 = dock2->window();
|
||||
dock1->addDockWidgetToContainingWindow(dock2, Location_OnLeft);
|
||||
TitleBar *tb = dock1->titleBar();
|
||||
QVERIFY(tb->isVisible());
|
||||
QVERIFY(qAbs(widgetMinLength(frame1, Qt::Vertical) - (minHeight + tb->height())) < 10);
|
||||
QVERIFY(qAbs(widgetMinLength(frame1, Qt::Vertical) - (minHeight + frame1->nonContentsHeight())) < 10);
|
||||
|
||||
delete dock1->window();
|
||||
delete oldFw2;
|
||||
|
||||
Reference in New Issue
Block a user