Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add support for Splitter #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/declarativesplitter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
declarativesplitter.cpp

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "declarativesplitter_p.h"

DeclarativeSplitter::DeclarativeSplitter(QWidget *parent)
: QSplitter(parent)
{
}
39 changes: 39 additions & 0 deletions src/declarativesplitter_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
declarativesplitter_p.h

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DECLARATIVESPLITTER_P_H
#define DECLARATIVESPLITTER_P_H

#include <QSplitter>

class DeclarativeSplitter : public QSplitter
{
public:
DeclarativeSplitter(QWidget *parent = Q_NULLPTR);
};

#endif // DECLARATIVESPLITTER_P_H
3 changes: 3 additions & 0 deletions src/declarativewidgets_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "declarativeseparator_p.h"
#include "declarativesizepolicy_p.h"
#include "declarativespaceritem_p.h"
#include "declarativesplitter_p.h"
#include "declarativestackedlayout_p.h"
#include "declarativestatusbar_p.h"
#include "declarativestringlistmodelextension_p.h"
Expand All @@ -68,6 +69,7 @@
#include "menubarwidgetcontainer_p.h"
#include "menuwidgetcontainer_p.h"
#include "scrollareawidgetcontainer_p.h"
#include "splitterwidgetcontainer_p.h"
#include "stackedwidgetwidgetcontainer_p.h"
#include "toolbarwidgetcontainer_p.h"

Expand Down Expand Up @@ -206,4 +208,5 @@ void ExtensionpluginPlugin::registerTypes(const char *uri)
qmlRegisterExtendedType<QWebEngineView, DeclarativeWidgetExtension>(uri, 1, 0, "WebEngineView");
#endif
qmlRegisterExtendedType<QWidget, DeclarativeWidgetExtension>(uri, 1, 0, "Widget");
qmlRegisterExtendedType<DeclarativeSplitter, DeclarativeContainerWidgetExtension<SplitterWidgetContainer>>(uri, 1, 0, "Splitter");
}
55 changes: 55 additions & 0 deletions src/splitterwidgetcontainer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
splitterwidgetcontainer.cpp

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "splitterwidgetcontainer_p.h"

#include "declarativesplitter_p.h"

#include <QQmlInfo>
#include <QSplitter>

SplitterWidgetContainer::SplitterWidgetContainer(QObject *parent)
: DefaultWidgetContainer(qobject_cast<QSplitter*>(parent))
{
Q_ASSERT(m_widget);
}

void SplitterWidgetContainer::setLayout(QLayout *layout)
{
Q_UNUSED(layout);
qmlInfo(m_widget) << "Can not set a Layout to a Splitter";
}

void SplitterWidgetContainer::addWidget(QWidget *widget)
{
extendedSplitter()->addWidget(widget);
}

QSplitter *SplitterWidgetContainer::extendedSplitter() const
{
return static_cast<QSplitter*>(m_widget);
}
52 changes: 52 additions & 0 deletions src/splitterwidgetcontainer_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
splitterwidgetcontainer_p.h

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SPLITTERWIDGETCONTAINER_P_H
#define SPLITTERWIDGETCONTAINER_P_H

#include <QtGlobal>

#include "defaultwidgetcontainer.h"

QT_BEGIN_NAMESPACE
class QSplitter;
class QObject;
QT_END_NAMESPACE

class SplitterWidgetContainer : public DefaultWidgetContainer
{
public:
explicit SplitterWidgetContainer(QObject *parent = Q_NULLPTR);

void setLayout(QLayout *layout) Q_DECL_OVERRIDE;
void addWidget(QWidget *widget) Q_DECL_OVERRIDE;

private:
QSplitter *extendedSplitter() const;
};

#endif // SPLITTERWIDGETCONTAINER_P_H
8 changes: 6 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ HEADERS = \
staticdialogmethodattached_p.h \
toolbarwidgetcontainer_p.h \
widgetcontainerinterface_p.h \
declarativesizepolicy_p.h
declarativesizepolicy_p.h \
splitterwidgetcontainer_p.h \
declarativesplitter_p.h

SOURCES = \
abstractdeclarativeobject.cpp \
Expand Down Expand Up @@ -137,4 +139,6 @@ SOURCES = \
stackedwidgetwidgetcontainer.cpp \
staticdialogmethodattached.cpp \
toolbarwidgetcontainer.cpp \
declarativesizepolicy.cpp
declarativesizepolicy.cpp \
splitterwidgetcontainer.cpp \
declarativesplitter.cpp
1 change: 1 addition & 0 deletions tests/auto/instantiatetypes/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
<file>qml/uncreatable/ItemSelectionModel.qml</file>
<file>qml/uncreatable/TextDocument.qml</file>
<file>qml/creatable/webenginewidgets/WebEngineView.qml</file>
<file>qml/creatable/widgets/Splitter.qml</file>
</qresource>
</RCC>
32 changes: 32 additions & 0 deletions tests/auto/instantiatetypes/qml/creatable/widgets/Splitter.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Splitter.qml

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtWidgets 1.0

Splitter {

}
9 changes: 6 additions & 3 deletions tests/auto/layouts/layouts.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ SOURCES += tst_layouts.cpp \
formlayoutwidget.cpp \
gridlayoutwidget.cpp \
stackedlayoutwidget.cpp \
stackedwidget.cpp
stackedwidget.cpp \
splitter.cpp

RESOURCES += \
qml.qrc
Expand All @@ -16,12 +17,14 @@ FORMS += \
vboxlayout.ui \
formlayout.ui \
gridlayout.ui \
stackedwidget.ui
stackedwidget.ui \
splitter.ui

HEADERS += \
hboxlayoutwidget.h \
vboxlayoutwidget.h \
formlayoutwidget.h \
gridlayoutwidget.h \
stackedlayoutwidget.h \
stackedwidget.h
stackedwidget.h \
splitter.h
1 change: 1 addition & 0 deletions tests/auto/layouts/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<file>qml/GridLayoutTest.qml</file>
<file>qml/StackedLayoutTest.qml</file>
<file>qml/StackedWidgetTest.qml</file>
<file>qml/SplitterTest.qml</file>
</qresource>
</RCC>
37 changes: 37 additions & 0 deletions tests/auto/layouts/qml/SplitterTest.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
SplitterTest.qml

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtWidgets 1.0

Splitter {
Label {
text: "Label 1"
}
Label {
text: "Label 2"
}
}
42 changes: 42 additions & 0 deletions tests/auto/layouts/splitter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
splitter.cpp

This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML.

Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "splitter.h"

#include "ui_splitter.h"

Splitter::Splitter(QWidget *parent)
: QSplitter(parent)
, ui(new Ui::Splitter)
{
ui->setupUi(this);
}

Splitter::~Splitter()
{
delete ui;
}
Loading