Skip to content

Commit

Permalink
More use of Controls2
Browse files Browse the repository at this point in the history
  • Loading branch information
gschwann committed Oct 12, 2016
1 parent edb6405 commit adddebc
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 36 deletions.
79 changes: 79 additions & 0 deletions src/DetailsTextArea.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
** This file is part of the Baugeschichte.at project.
**
** The MIT License (MIT)
**
** Copyright (c) 2016 Guenter Schwann
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in all
** copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**/

import QtQuick 2.4
import QtQuick.Controls 2.0
import "./"

Item {
id: root

Rectangle {
id: textBackground
anchors.fill: root
color: "white"
}

Flickable {
id: textArea
anchors.fill: parent

contentWidth: textItem.paintedWidth
contentHeight: textItem.paintedHeight
clip: true

flickableDirection: Flickable.VerticalFlick
ScrollBar.vertical: ScrollBar {}

Item {
width: textArea.width
height: textArea.height

Text {
id: textItem
anchors.fill: parent
anchors.margins: Theme.smallMargin

wrapMode: TextEdit.WordWrap
textFormat: TextEdit.RichText
font.pixelSize: Theme.smallFontSize

text: (detailText.length > 0) ? detailText : qsTr("Kein Text")

onLinkActivated: {
if (link.substr(0, 11) === "internal://") {
var newBuilding = link.substring(11, link.length);
console.debug("Open internal link: "+newBuilding);
appCore.selectAndCenterHouse(newBuilding);
} else {
console.debug("Open external link: "+link);
appCore.openExternalLink(link);
}
}
}
}
}
}
38 changes: 9 additions & 29 deletions src/DetailsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
****************************************************************************/

import QtQuick 2.4
import QtQuick.Controls 1.4
import QtQuick.Controls 1.4 as Controls1
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import "./"

Expand Down Expand Up @@ -113,7 +114,7 @@ BaseView {
border.color: "#8E8E8E"
}

SplitView {
Controls1.SplitView {
id: splitView
anchors {
top: parent.top
Expand Down Expand Up @@ -215,34 +216,13 @@ BaseView {
wrapMode: Text.Wrap
}

TextArea {
anchors { top: titleText.bottom;
bottom: parent.bottom; left: parent.left;
right: parent.right
}
textMargin:Theme.smallMargin
readOnly: true
verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
wrapMode: TextEdit.WordWrap
text: (detailText.length > 0) ? detailText : qsTr("Kein Text")
textFormat: TextEdit.RichText
font.pixelSize: Theme.smallFontSize

onLinkActivated: {
if (link.substr(0, 11) === "internal://") {
var newBuilding = link.substring(11, link.length);
console.debug("Open internal link: "+newBuilding);
appCore.selectAndCenterHouse(newBuilding);
} else {
console.debug("Open external link: "+link);
appCore.openExternalLink(link);
}
}
DetailsTextArea {
anchors.top: titleText.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 1
}

Keys.onLeftPressed: console.log("onLeft Details")
Keys.onRightPressed: console.log("onLeft Details")
}
}
}
Expand Down
29 changes: 22 additions & 7 deletions src/MapComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
**/

import QtQuick 2.4
import QtQuick.Controls 1.4 as Controls1
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtLocation 5.5
import QtPositioning 5.5
Expand Down Expand Up @@ -270,18 +270,33 @@ BaseView {
}
}

Controls1.Slider {
Slider {
id: zoomSlider
minimumValue: map.minimumZoomLevel
maximumValue: map.maximumZoomLevel
from: map.minimumZoomLevel
to: map.maximumZoomLevel
anchors.margins: 10
anchors.bottom: scaleItem.top
anchors.top: parent.top
anchors.right: parent.right
orientation: Qt.Vertical
value: map.zoomLevel
onValueChanged: {
map.zoomLevel = value
onPositionChanged: {
map.zoomLevel = position2value(position);
}
function position2value(pos) {
return from + (to - from) * pos
}

Connections{
target: map
onZoomLevelChanged: {
if (!zoomSlider.pressed) {
zoomSlider.value = map.zoomLevel;
}
}
}

Component.onCompleted: {
zoomSlider.value = map.zoomLevel;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ int main(int argc, char* argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);

// style for Controls2
qputenv("QT_QUICK_CONTROLS_STYLE", "Material");

QGuiApplication app(argc, argv);
app.setApplicationDisplayName(QStringLiteral("Baugeschichte.at"));

Expand Down
3 changes: 3 additions & 0 deletions src/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.4 as Controls1
import QtQuick.Controls.Material 2.0
import QtPositioning 5.5
import QtLocation 5.5
import Qt.labs.settings 1.0
Expand All @@ -40,6 +41,8 @@ Item {

visible: true

Material.accent: Material.LightBlue

readonly property bool loading: (uiStack.currentItem && uiStack.currentItem.loading) ||
markerLoader.loading ||
categoryLoader.isLoading || routeLoader.loading
Expand Down
1 change: 1 addition & 0 deletions src/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
<file>qmldir</file>
<file>ShutDownDialog.qml</file>
<file>LoadIndicator.qml</file>
<file>DetailsTextArea.qml</file>
</qresource>
</RCC>

0 comments on commit adddebc

Please sign in to comment.