resizing based on contents implicit sizes

still to be made a tad more reliable
This commit is contained in:
Marco Martin 2013-02-27 14:03:36 +01:00
parent 8ea0de9892
commit 7e96fe9000
4 changed files with 27 additions and 1 deletions

View File

@ -42,7 +42,7 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
qWarning() << "Invalid home screen package";
}
setResizeMode(QQuickView::SizeRootObjectToView);
setResizeMode(QQuickView::SizeViewToRootObject);
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "config.qml")), this);
@ -76,4 +76,12 @@ void ConfigView::hideEvent(QHideEvent *ev)
deleteLater();
}
void ConfigView::resizeEvent(QResizeEvent *re)
{
rootObject()->setWidth(re->size().width());
rootObject()->setHeight(re->size().height());
QQuickWindow::resizeEvent(re);
}
#include "moc_configview.cpp"

View File

@ -40,6 +40,7 @@ public:
protected:
void hideEvent(QHideEvent *ev);
void resizeEvent(QResizeEvent *re);
private:
AppletInterface *m_appletInterface;

View File

@ -32,10 +32,13 @@ QtObject {
id: iconsPage
width: childrenRect.width
height: childrenRect.height
implicitWidth: mainColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property alias cfg_Test: testConfigField.text
Column {
id: pageColumn
anchors.fill: parent
spacing: 4
Row {

View File

@ -88,13 +88,20 @@ Rectangle {
Column {
id: mainColumn
anchors.fill: parent
property int implicitWidth: Math.max(contentRow.implicitWidth, buttonsRow.implicitWidth) + 8
property int implicitHeight: contentRow.implicitHeight + buttonsRow.implicitHeight + 8
Row {
id: contentRow
anchors {
left: parent.left
right: parent.right
}
spacing: 4
height: parent.height - buttonsRow.height
property int implicitWidth: categoriesScroll.implicitWidth + pageScroll.implicitWidth
property int implicitHeight: Math.max(categoriesScroll.implicitHeight, pageScroll.implicitHeight)
PlasmaExtras.ScrollArea {
id: categoriesScroll
anchors {
@ -103,6 +110,8 @@ Rectangle {
}
visible: configDialog.configPages.length > 0 && globalConfigPages.length > 0
width: visible ? 100 : 0
implicitWidth: width
implicitHeight: theme.defaultFont.mSize.height * 12
Flickable {
id: categoriesView
contentWidth: width
@ -149,12 +158,15 @@ Rectangle {
}
}
PlasmaExtras.ScrollArea {
id: pageScroll
anchors {
top: parent.top
bottom: parent.bottom
margins: 4
}
width: parent.width - categoriesScroll.width - 8
implicitWidth: main.currentPage ? main.currentPage.implicitWidth : 0
implicitHeight: main.currentPage ? main.currentPage.implicitHeight : 0
Flickable {
contentWidth: width
contentHeight: main.height
@ -167,6 +179,8 @@ Rectangle {
property Component sourceComponent
onSourceComponentChanged: {
replace(sourceComponent)
root.width = mainColumn.implicitWidth
root.height = mainColumn.implicitHeight
}
}
}