From aae4a326f4738be368088f0d0f7a91d75b02a9ad Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Sat, 7 Nov 2015 00:39:06 +0100 Subject: organize qml files in subdirectories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the organization of the qml files a bit more fine-grained, it prevents mixing of .cpp and QML files, and also of what's compiled, and what's included in the app as qrc data. In particular: - subsurface specific QML items go into the qml/ subdirectory - theme and unit definitions to into qml/theme subdirectory (they already were located in a theme directory) - generic components, such as our Label goes into qml/components This facilitates sharing of functionality and identifying common stuff better. Ideally, we can pull qml/theme and qml/components from a standardized set at some point, so we don't have to maintain that code. Signed-off-by: Sebastian Kügler Signed-off-by: Dirk Hohndel --- qt-mobile/DiveDetails.qml | 97 ------------- qt-mobile/DiveList.qml | 170 ---------------------- qt-mobile/DownloadFromDiveComputer.qml | 97 ------------- qt-mobile/Label.qml | 11 -- qt-mobile/Log.qml | 37 ----- qt-mobile/Preferences.qml | 87 ------------ qt-mobile/TextButton.qml | 37 ----- qt-mobile/ThemeTest.qml | 72 ---------- qt-mobile/TopBar.qml | 67 --------- qt-mobile/main.qml | 219 ----------------------------- qt-mobile/mobile-resources.qrc | 20 --- qt-mobile/qml/DiveDetails.qml | 97 +++++++++++++ qt-mobile/qml/DiveList.qml | 170 ++++++++++++++++++++++ qt-mobile/qml/DownloadFromDiveComputer.qml | 97 +++++++++++++ qt-mobile/qml/Log.qml | 37 +++++ qt-mobile/qml/Preferences.qml | 87 ++++++++++++ qt-mobile/qml/TextButton.qml | 37 +++++ qt-mobile/qml/ThemeTest.qml | 72 ++++++++++ qt-mobile/qml/TopBar.qml | 67 +++++++++ qt-mobile/qml/components/Label.qml | 11 ++ qt-mobile/qml/main.qml | 219 +++++++++++++++++++++++++++++ qt-mobile/qml/mobile-resources.qrc | 20 +++ qt-mobile/qml/theme/Theme.qml | 57 ++++++++ qt-mobile/qml/theme/Units.qml | 102 ++++++++++++++ qt-mobile/qml/theme/qmldir | 2 + qt-mobile/theme/Theme.qml | 57 -------- qt-mobile/theme/Units.qml | 102 -------------- qt-mobile/theme/qmldir | 2 - 28 files changed, 1075 insertions(+), 1075 deletions(-) delete mode 100644 qt-mobile/DiveDetails.qml delete mode 100644 qt-mobile/DiveList.qml delete mode 100644 qt-mobile/DownloadFromDiveComputer.qml delete mode 100644 qt-mobile/Label.qml delete mode 100644 qt-mobile/Log.qml delete mode 100644 qt-mobile/Preferences.qml delete mode 100644 qt-mobile/TextButton.qml delete mode 100644 qt-mobile/ThemeTest.qml delete mode 100644 qt-mobile/TopBar.qml delete mode 100644 qt-mobile/main.qml delete mode 100644 qt-mobile/mobile-resources.qrc create mode 100644 qt-mobile/qml/DiveDetails.qml create mode 100644 qt-mobile/qml/DiveList.qml create mode 100644 qt-mobile/qml/DownloadFromDiveComputer.qml create mode 100644 qt-mobile/qml/Log.qml create mode 100644 qt-mobile/qml/Preferences.qml create mode 100644 qt-mobile/qml/TextButton.qml create mode 100644 qt-mobile/qml/ThemeTest.qml create mode 100644 qt-mobile/qml/TopBar.qml create mode 100644 qt-mobile/qml/components/Label.qml create mode 100644 qt-mobile/qml/main.qml create mode 100644 qt-mobile/qml/mobile-resources.qrc create mode 100644 qt-mobile/qml/theme/Theme.qml create mode 100644 qt-mobile/qml/theme/Units.qml create mode 100644 qt-mobile/qml/theme/qmldir delete mode 100644 qt-mobile/theme/Theme.qml delete mode 100644 qt-mobile/theme/Units.qml delete mode 100644 qt-mobile/theme/qmldir (limited to 'qt-mobile') diff --git a/qt-mobile/DiveDetails.qml b/qt-mobile/DiveDetails.qml deleted file mode 100644 index afb62104a..000000000 --- a/qt-mobile/DiveDetails.qml +++ /dev/null @@ -1,97 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.2 -import org.subsurfacedivelog.mobile 1.0 - -Item { - id: diveDetailsWindow - width: parent.width - objectName: "DiveDetails" - - property string location - property string dive_id - property string airtemp - property string watertemp - property string suit - property string buddy - property string divemaster; - property string notes; - property string date - property string number - - onDive_idChanged: { - qmlProfile.diveId = dive_id - qmlProfile.update() - } - - Flickable { - id: flick - width: parent.width - anchors { top: parent.top; bottom: parent.bottom } - contentHeight: parent.height - clip: true - ColumnLayout { - width: parent.width - spacing: 8 - - TopBar { - - } - - Button { - text: "Hide Dive Profile" - onClicked: { - qmlProfile.visible = !qmlProfile.visible - if (qmlProfile.visible) { - text = "Hide Dive Profile" - } else { - text = "Show Dive Profile" - } - } - } - - GridLayout { - id: editorDetails - width: parent.width - columns: 2 - Text { - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - text: "Dive " + number + " (" + date + ")"; font.bold: true - } - QMLProfile { - Layout.columnSpan: 2 - Layout.fillWidth: true - id: qmlProfile - height: 500 - } - Text { text: "Location:"; font.bold: true } - TextField { id: txtLocation; text: location; Layout.fillWidth: true } - Text { text: "Air Temp:"; font.bold: true } - TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } - Text { text: "Water Temp:"; font.bold: true } - TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } - Text { text: "Suit:"; font.bold: true } - TextField { id: txtSuit; text: suit; Layout.fillWidth: true } - Text { text: "Buddy:"; font.bold: true } - TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } - Text { text: "Dive Master:"; font.bold: true } - TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} - Text { text: "Notes:"; font.bold: true } - TextEdit{ - id: txtNotes - text: notes - focus: true - Layout.fillWidth: true - Layout.fillHeight: true - selectByMouse: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } - } - } - } -} diff --git a/qt-mobile/DiveList.qml b/qt-mobile/DiveList.qml deleted file mode 100644 index c95b4dcaa..000000000 --- a/qt-mobile/DiveList.qml +++ /dev/null @@ -1,170 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import org.subsurfacedivelog.mobile 1.0 -import QtQuick.Layouts 1.0 - -Rectangle { - id: page - objectName: "DiveList" - - Component { - id: diveDelegate - Item { - id: dive - - property real detailsOpacity : 0 - - width: diveListView.width - units.smallSpacing - height: childrenRect.height - - //Mouse region: When clicked, the mode changes to details view - MouseArea { - anchors.fill: parent - onClicked: { - detailsWindow.width = parent.width - detailsWindow.location = location - detailsWindow.dive_id = id - detailsWindow.buddy = buddy - detailsWindow.suit = suit - detailsWindow.airtemp = airtemp - detailsWindow.watertemp = watertemp - detailsWindow.divemaster = divemaster - detailsWindow.notes = notes - detailsWindow.number = diveNumber - detailsWindow.date = date - stackView.push(detailsWindow) - } - } - - //Layout of the page: (mini profile, dive no, date at the top - //And other details at the bottom. - Item { - x: units.smallSpacing - width: parent.width - units.smallSpacing * 2 - height: childrenRect.height + units.smallSpacing * 2 - //spacing: units.smallSpacing / 2 - anchors.margins: units.smallSpacing - - Text { - id: locationText - text: location - color: theme.textColor - scale: 1.1 // Let's see how this works, otherwise, we'll need the default point size somewhere - transformOrigin: Item.TopLeft - anchors { - left: parent.left - top: parent.top - } - } - Text { - text: date - opacity: 0.6 - color: theme.textColor - anchors { - right: parent.right - top: parent.top - bottomMargin: units.smallSpacing / 2 - } - } - Row { - id: descriptionText - anchors { - left: parent.left - right: parent.right - bottom: numberText.bottom - } - Text { - text: 'Depth: ' - opacity: 0.6 - color: theme.textColor - } - Text { - text: depth - width: Math.max(units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview - color: theme.textColor - } - Text { - text: 'Duration: ' - opacity: 0.6 - color: theme.textColor - } - Text { - text: duration - color: theme.textColor - } - } - Text { - id: numberText - text: "#" + diveNumber - color: theme.textColor - scale: 1.2 - transformOrigin: Item.BottomRight - opacity: 0.4 - anchors { - right: parent.right - topMargin: units.smallSpacing - top: locationText.bottom - } - } - //Text { text: location; width: parent.width } - Rectangle { - color: theme.textColor - opacity: .2 - height: Math.max(1, units.gridUnit / 24) // we really want a thin line - anchors { - left: parent.left - right: parent.right - top: numberText.bottom - } - } - } - } - } - - Component { - id: tripHeading - Item { - width: page.width - units.smallSpacing * 2 - height: childrenRect.height + units.smallSpacing * 2 - - Text { - id: sectionText - text: section - anchors { - top: parent.top - left: parent.left - leftMargin: units.smallSpacing - right: parent.right - } - color: theme.textColor - font.pointSize: 16 - } - Rectangle { - height: Math.max(2, units.gridUnit / 12) // we want a thicker line - anchors { - top: sectionText.bottom - left: parent.left - leftMargin: units.smallSpacing - right: parent.right - } - color: theme.accentColor - } - } - } - - ListView { - id: diveListView - anchors.fill: parent - model: diveModel - delegate: diveDelegate - boundsBehavior: Flickable.StopAtBounds - //highlight: Rectangle { color: theme.highlightColor; width: units.smallSpacing } - focus: true - clip: true - section.property: "trip" - section.criteria: ViewSection.FullString - section.delegate: tripHeading - } -} diff --git a/qt-mobile/DownloadFromDiveComputer.qml b/qt-mobile/DownloadFromDiveComputer.qml deleted file mode 100644 index d23754407..000000000 --- a/qt-mobile/DownloadFromDiveComputer.qml +++ /dev/null @@ -1,97 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import org.subsurfacedivelog.mobile 1.0 - -Item { - id: diveComputerDownloadWindow - anchors.top: parent.top - width: parent.width - height: parent.height - - GridLayout { - columns: 2 - anchors.top: parent.top - width: parent.width - height: parent.height - ColumnLayout { - height: parent.height - width: parent.width - ColumnLayout { - width: parent.width - Layout.fillHeight: true - ColumnLayout { - Layout.fillHeight: true - Layout.fillWidth: true - ColumnLayout { - height: parent.height - Layout.fillWidth: true - Text { text: "Vendor" } - ComboBox { Layout.fillWidth: true } - Text { text: "Dive Computer" } - ComboBox { Layout.fillWidth: true } - Text { text: "Device or mount point" } - RowLayout { - Layout.fillWidth: true - TextField { Layout.fillWidth: true } - Button { text: "..." } - } - GridLayout { - columns: 2 - CheckBox { text: "Force download of all dives" } - CheckBox { text: "Always prefer downloaded dives" } - CheckBox { text: "Download into new trip" } - CheckBox { text: "Save libdivecomputer logfile" } - CheckBox { text: "Save libdivecomputer dumpfile" } - CheckBox { text: "Choose Bluetooth download mode" } - } - - RowLayout { - Layout.fillWidth: true - ProgressBar { Layout.fillWidth: true } - Button { text: "Download" } - } - } - } - ColumnLayout { - height: parent.height - Layout.fillWidth: true - RowLayout { - Text { - text: "Downloaded dives" - } - Button { - text: "Select All" - } - Button { - text: "Unselect All" - } - } - TableView { - Layout.fillWidth: true - Layout.fillHeight: true - } - } - } - RowLayout { - width: parent.width - Button { - text: "OK" - - onClicked: { - stackView.pop(); - } - } - Button { - text: "Cancel" - - onClicked: { - stackView.pop(); - } - } - } - } - } -} diff --git a/qt-mobile/Label.qml b/qt-mobile/Label.qml deleted file mode 100644 index 617e05245..000000000 --- a/qt-mobile/Label.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.5 -//import QtQuick.Controls 1.2 as QuickControls -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 - -Text { - - font.pointSize: 18 - color: theme.textColor -} diff --git a/qt-mobile/Log.qml b/qt-mobile/Log.qml deleted file mode 100644 index 8e660f2c7..000000000 --- a/qt-mobile/Log.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.2 -import org.subsurfacedivelog.mobile 1.0 - -Item { - id: logWindow - width: parent.width - height: parent.height - objectName: "Log" - - ColumnLayout { - width: parent.width - height: parent.height - spacing: 8 - - TopBar { - id: topBar - anchors.top: parent.top - } - - Rectangle { - anchors.top: topBar.bottom - Layout.fillHeight: true - Layout.fillWidth: true - Text { - anchors.fill: parent - wrapMode: Text.WrapAnywhere - text: manager.logText - } - } - } -} diff --git a/qt-mobile/Preferences.qml b/qt-mobile/Preferences.qml deleted file mode 100644 index 8f4a15328..000000000 --- a/qt-mobile/Preferences.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import org.subsurfacedivelog.mobile 1.0 - -Item { - id: loginWindow - - signal accept - - property string username: login.text; - property string password: password.text; - property bool issave: savePassword.checked; - - GridLayout { - columns: 2 - anchors.centerIn: parent - width: parent.width - - Label { - text: "Enter your Subsurface cloud credentials" - Layout.columnSpan: 2 - } - - Label { - text: "Email Address:" - } - - TextField { - id: login - text: manager.cloudUserName - Layout.fillWidth: true - } - - Label { - text: "Password" - } - - TextField { - id: password - text: manager.cloudPassword - echoMode: TextInput.Password - Layout.fillWidth: true - } - - Label { - text: "Save Password locally" - } - - CheckBox { - checked: manager.saveCloudPassword - id: savePassword - } - - Item { - height: saveButton.height - width: saveButton.width - Button { - id: saveButton - text: "Save" - anchors.centerIn: parent - onClicked: { - manager.cloudUserName = login.text - manager.cloudPassword = password.text - manager.saveCloudPassword = savePassword.checked - manager.savePreferences() - stackView.pop() - } - } - } - - Item { - height: cancelButton.height - width: cancelButton.width - Button { - id: cancelButton - text: "Cancel" - - onClicked: { - stackView.pop(); - } - } - } - } -} diff --git a/qt-mobile/TextButton.qml b/qt-mobile/TextButton.qml deleted file mode 100644 index 3e5a36735..000000000 --- a/qt-mobile/TextButton.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.3 - -Rectangle { - id: container - - property alias text: label.text - - signal clicked - - width: label.width + 20; height: label.height + 6 - smooth: true - radius: 10 - - gradient: Gradient { - GradientStop { id: gradientStop; position: 0.0; color: palette.light } - GradientStop { position: 1.0; color: palette.button } - } - - SystemPalette { id: palette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { container.clicked() } - } - - Text { - id: label - anchors.centerIn: parent - } - - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: gradientStop; color: palette.dark } - } -} diff --git a/qt-mobile/ThemeTest.qml b/qt-mobile/ThemeTest.qml deleted file mode 100644 index 7452acc1b..000000000 --- a/qt-mobile/ThemeTest.qml +++ /dev/null @@ -1,72 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 - -GridLayout { - id: themetest - columns: 2 - - Label { - Layout.columnSpan: 2 - Layout.fillHeight: true - text: "Theme Information" - } - - FontMetrics { - id: fm - } - - Label { - text: "units.gridUnit:" - } - Label { - text: units.gridUnit - } - - Label { - text: "units.devicePixelRatio:" - } - Label { - text: units.devicePixelRatio - } - - Label { - text: "FontMetrics pointSize:" - } - Label { - text: fm.font.pointSize - } - - Label { - text: "FontMetrics pixelSize:" - } - Label { - text: fm.height - - } - - Label { - text: "hand-computed devicePixelRatio:" - } - Label { - text: fm.height / fm.font.pointSize - } - - Text { - text: "Text item pixelSize:" - } - Text { - text: font.pixelSize - } - - Text { - text: "Text item pointSize:" - } - Text { - text: font.pointSize - } - - Label { - Layout.columnSpan: 2 - Layout.fillHeight: true - } -} diff --git a/qt-mobile/TopBar.qml b/qt-mobile/TopBar.qml deleted file mode 100644 index 552159d53..000000000 --- a/qt-mobile/TopBar.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.2 -import org.subsurfacedivelog.mobile 1.0 - -Rectangle { - id: topBar - color: theme.accentColor - Layout.fillWidth: true - Layout.margins: 0 - Layout.minimumHeight: prefsButton.height + units.smallSpacing * 2 - RowLayout { - anchors.bottom: topBar.bottom - anchors.bottomMargin: units.smallSpacing - anchors.left: topBar.left - anchors.leftMargin: units.smallSpacing - anchors.right: topBar.right - anchors.rightMargin: units.smallSpacing - Button { - id: backButton - Layout.maximumHeight: prefsButton.height - Layout.minimumHeight: prefsButton.height - Layout.preferredWidth: units.gridUnit * 2 - text: "\u2190" - style: ButtonStyle { - background: Rectangle { - color: theme.accentColor - implicitWidth: units.gridUnit * 2 - } - label: Text { - id: txt - color: theme.accentTextColor - font.pointSize: 18 - font.bold: true - text: control.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - onClicked: { - if (stackView.currentItem.objectName == "DiveDetails") - { - manager.commitChanges( - dive_id, - suit, - buddy, - divemaster, - notes - ) - } - stackView.pop(); - } - } - Text { - text: qsTr("Subsurface mobile") - font.pointSize: 18 - color: theme.accentTextColor - anchors.left: backButton.right - anchors.leftMargin: units.smallSpacing - //horizontalAlignment: Text.AlignHCenter - } - } -} diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml deleted file mode 100644 index f75476537..000000000 --- a/qt-mobile/main.qml +++ /dev/null @@ -1,219 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.2 -import org.subsurfacedivelog.mobile 1.0 -import "qrc:/qml/theme" as Theme - - -ApplicationWindow { - title: qsTr("Subsurface mobile") - property bool fullscreen: true - property alias messageText: message.text - visible: true - - Theme.Units { - id: units - } - - Theme.Theme { - id: theme - /* Added for subsurface */ - property color accentColor: "#2d5b9a" - property color accentTextColor: "#ececec" - } - - Menu { - id: prefsMenu - title: "Menu" - - MenuItem { - text: "Preferences" - onTriggered: { - stackView.push(prefsWindow) - } - } - - MenuItem { - text: "Load Dives" - onTriggered: { - manager.loadDives(); - } - } - - MenuItem { - text: "Download Dives" - onTriggered: { - stackView.push(downloadDivesWindow) - } - } - - MenuItem { - text: "Add Dive" - onTriggered: { - manager.addDive(); - stackView.push(detailsWindow) - } - } - - MenuItem { - text: "Save Changes" - onTriggered: { - manager.saveChanges(); - } - } - - MenuItem { - text: "View Log" - onTriggered: { - stackView.push(logWindow) - } - } - - MenuItem { - text: "Theme Information" - onTriggered: { - stackView.push(themetest) - } - } - } - - StackView { - id: stackView - anchors.fill: parent - focus: true - Keys.onReleased: if (event.key == Qt.Key_Back && stackView.depth > 1) { - stackView.pop() - event.accepted = true; - } - initialItem: Item { - width: parent.width - height: parent.height - - ColumnLayout { - id: awLayout - anchors.fill: parent - spacing: units.gridUnit / 2 - Rectangle { - id: topPart - color: theme.accentColor - Layout.minimumHeight: units.gridUnit * 2 + units.smallSpacing * 2 - Layout.fillWidth: true - Layout.margins: 0 - RowLayout { - anchors.bottom: topPart.bottom - anchors.bottomMargin: units.smallSpacing - anchors.left: topPart.left - anchors.leftMargin: units.smallSpacing - anchors.right: topPart.right - anchors.rightMargin: units.smallSpacing - Image { - source: "qrc:/qml/subsurface-mobile-icon.png" - Layout.maximumWidth: units.gridUnit * 2 - Layout.preferredWidth: units.gridUnit * 2 - Layout.preferredHeight: units.gridUnit * 2 - } - Text { - text: qsTr("Subsurface mobile") - font.pointSize: 18 - Layout.fillWidth: false - color: theme.accentTextColor - } - Item { - Layout.fillWidth: true - } - Button { - id: prefsButton - text: "\u22ee" - anchors.right: parent.right - Layout.preferredWidth: units.gridUnit * 2 - Layout.preferredHeight: units.gridUnit * 2 - style: ButtonStyle { - background: Rectangle { - implicitWidth: units.gridUnit * 2 - color: theme.accentColor - } - label: Text { - id: txt - color: theme.accentTextColor - font.pointSize: 18 - font.bold: true - text: control.text - horizontalAlignment: Text.AlignHCenter - } - } - onClicked: { - prefsMenu.popup() - } - } - - } - - } - - Rectangle { - id: detailsPage - Layout.fillHeight: true - Layout.fillWidth: true - - DiveList { - anchors.fill: detailsPage - id: diveDetails - color: theme.backgroundColor - } - } - - Rectangle { - id: messageArea - height: childrenRect.height - Layout.fillWidth: true - - Text { - id: message - color: theme.textColor - text: "" - styleColor: theme.textColor - font.pointSize: 10 - } - } - - } - } - } - - QMLManager { - id: manager - } - - Preferences { - id: prefsWindow - visible: false - } - - DiveDetails { - id: detailsWindow - visible: false - } - - DownloadFromDiveComputer { - id: downloadDivesWindow - visible: false - } - - Log { - id: logWindow - visible: false - } - - ThemeTest { - id: themetest - visible: false - } - - Component.onCompleted: { - print("units.gridUnit is: " + units.gridUnit); - } -} diff --git a/qt-mobile/mobile-resources.qrc b/qt-mobile/mobile-resources.qrc deleted file mode 100644 index e331288f8..000000000 --- a/qt-mobile/mobile-resources.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - - main.qml - TextButton.qml - Preferences.qml - DiveList.qml - DiveDetails.qml - DownloadFromDiveComputer.qml - Log.qml - TopBar.qml - ThemeTest.qml - Label.qml - ../icons/subsurface-mobile-icon.png - - - theme/Theme.qml - theme/qmldir - theme/Units.qml - - diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml new file mode 100644 index 000000000..afb62104a --- /dev/null +++ b/qt-mobile/qml/DiveDetails.qml @@ -0,0 +1,97 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: diveDetailsWindow + width: parent.width + objectName: "DiveDetails" + + property string location + property string dive_id + property string airtemp + property string watertemp + property string suit + property string buddy + property string divemaster; + property string notes; + property string date + property string number + + onDive_idChanged: { + qmlProfile.diveId = dive_id + qmlProfile.update() + } + + Flickable { + id: flick + width: parent.width + anchors { top: parent.top; bottom: parent.bottom } + contentHeight: parent.height + clip: true + ColumnLayout { + width: parent.width + spacing: 8 + + TopBar { + + } + + Button { + text: "Hide Dive Profile" + onClicked: { + qmlProfile.visible = !qmlProfile.visible + if (qmlProfile.visible) { + text = "Hide Dive Profile" + } else { + text = "Show Dive Profile" + } + } + } + + GridLayout { + id: editorDetails + width: parent.width + columns: 2 + Text { + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignHCenter + text: "Dive " + number + " (" + date + ")"; font.bold: true + } + QMLProfile { + Layout.columnSpan: 2 + Layout.fillWidth: true + id: qmlProfile + height: 500 + } + Text { text: "Location:"; font.bold: true } + TextField { id: txtLocation; text: location; Layout.fillWidth: true } + Text { text: "Air Temp:"; font.bold: true } + TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } + Text { text: "Water Temp:"; font.bold: true } + TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } + Text { text: "Suit:"; font.bold: true } + TextField { id: txtSuit; text: suit; Layout.fillWidth: true } + Text { text: "Buddy:"; font.bold: true } + TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } + Text { text: "Dive Master:"; font.bold: true } + TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} + Text { text: "Notes:"; font.bold: true } + TextEdit{ + id: txtNotes + text: notes + focus: true + Layout.fillWidth: true + Layout.fillHeight: true + selectByMouse: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } + } + } + } +} diff --git a/qt-mobile/qml/DiveList.qml b/qt-mobile/qml/DiveList.qml new file mode 100644 index 000000000..c95b4dcaa --- /dev/null +++ b/qt-mobile/qml/DiveList.qml @@ -0,0 +1,170 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import org.subsurfacedivelog.mobile 1.0 +import QtQuick.Layouts 1.0 + +Rectangle { + id: page + objectName: "DiveList" + + Component { + id: diveDelegate + Item { + id: dive + + property real detailsOpacity : 0 + + width: diveListView.width - units.smallSpacing + height: childrenRect.height + + //Mouse region: When clicked, the mode changes to details view + MouseArea { + anchors.fill: parent + onClicked: { + detailsWindow.width = parent.width + detailsWindow.location = location + detailsWindow.dive_id = id + detailsWindow.buddy = buddy + detailsWindow.suit = suit + detailsWindow.airtemp = airtemp + detailsWindow.watertemp = watertemp + detailsWindow.divemaster = divemaster + detailsWindow.notes = notes + detailsWindow.number = diveNumber + detailsWindow.date = date + stackView.push(detailsWindow) + } + } + + //Layout of the page: (mini profile, dive no, date at the top + //And other details at the bottom. + Item { + x: units.smallSpacing + width: parent.width - units.smallSpacing * 2 + height: childrenRect.height + units.smallSpacing * 2 + //spacing: units.smallSpacing / 2 + anchors.margins: units.smallSpacing + + Text { + id: locationText + text: location + color: theme.textColor + scale: 1.1 // Let's see how this works, otherwise, we'll need the default point size somewhere + transformOrigin: Item.TopLeft + anchors { + left: parent.left + top: parent.top + } + } + Text { + text: date + opacity: 0.6 + color: theme.textColor + anchors { + right: parent.right + top: parent.top + bottomMargin: units.smallSpacing / 2 + } + } + Row { + id: descriptionText + anchors { + left: parent.left + right: parent.right + bottom: numberText.bottom + } + Text { + text: 'Depth: ' + opacity: 0.6 + color: theme.textColor + } + Text { + text: depth + width: Math.max(units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview + color: theme.textColor + } + Text { + text: 'Duration: ' + opacity: 0.6 + color: theme.textColor + } + Text { + text: duration + color: theme.textColor + } + } + Text { + id: numberText + text: "#" + diveNumber + color: theme.textColor + scale: 1.2 + transformOrigin: Item.BottomRight + opacity: 0.4 + anchors { + right: parent.right + topMargin: units.smallSpacing + top: locationText.bottom + } + } + //Text { text: location; width: parent.width } + Rectangle { + color: theme.textColor + opacity: .2 + height: Math.max(1, units.gridUnit / 24) // we really want a thin line + anchors { + left: parent.left + right: parent.right + top: numberText.bottom + } + } + } + } + } + + Component { + id: tripHeading + Item { + width: page.width - units.smallSpacing * 2 + height: childrenRect.height + units.smallSpacing * 2 + + Text { + id: sectionText + text: section + anchors { + top: parent.top + left: parent.left + leftMargin: units.smallSpacing + right: parent.right + } + color: theme.textColor + font.pointSize: 16 + } + Rectangle { + height: Math.max(2, units.gridUnit / 12) // we want a thicker line + anchors { + top: sectionText.bottom + left: parent.left + leftMargin: units.smallSpacing + right: parent.right + } + color: theme.accentColor + } + } + } + + ListView { + id: diveListView + anchors.fill: parent + model: diveModel + delegate: diveDelegate + boundsBehavior: Flickable.StopAtBounds + //highlight: Rectangle { color: theme.highlightColor; width: units.smallSpacing } + focus: true + clip: true + section.property: "trip" + section.criteria: ViewSection.FullString + section.delegate: tripHeading + } +} diff --git a/qt-mobile/qml/DownloadFromDiveComputer.qml b/qt-mobile/qml/DownloadFromDiveComputer.qml new file mode 100644 index 000000000..d23754407 --- /dev/null +++ b/qt-mobile/qml/DownloadFromDiveComputer.qml @@ -0,0 +1,97 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: diveComputerDownloadWindow + anchors.top: parent.top + width: parent.width + height: parent.height + + GridLayout { + columns: 2 + anchors.top: parent.top + width: parent.width + height: parent.height + ColumnLayout { + height: parent.height + width: parent.width + ColumnLayout { + width: parent.width + Layout.fillHeight: true + ColumnLayout { + Layout.fillHeight: true + Layout.fillWidth: true + ColumnLayout { + height: parent.height + Layout.fillWidth: true + Text { text: "Vendor" } + ComboBox { Layout.fillWidth: true } + Text { text: "Dive Computer" } + ComboBox { Layout.fillWidth: true } + Text { text: "Device or mount point" } + RowLayout { + Layout.fillWidth: true + TextField { Layout.fillWidth: true } + Button { text: "..." } + } + GridLayout { + columns: 2 + CheckBox { text: "Force download of all dives" } + CheckBox { text: "Always prefer downloaded dives" } + CheckBox { text: "Download into new trip" } + CheckBox { text: "Save libdivecomputer logfile" } + CheckBox { text: "Save libdivecomputer dumpfile" } + CheckBox { text: "Choose Bluetooth download mode" } + } + + RowLayout { + Layout.fillWidth: true + ProgressBar { Layout.fillWidth: true } + Button { text: "Download" } + } + } + } + ColumnLayout { + height: parent.height + Layout.fillWidth: true + RowLayout { + Text { + text: "Downloaded dives" + } + Button { + text: "Select All" + } + Button { + text: "Unselect All" + } + } + TableView { + Layout.fillWidth: true + Layout.fillHeight: true + } + } + } + RowLayout { + width: parent.width + Button { + text: "OK" + + onClicked: { + stackView.pop(); + } + } + Button { + text: "Cancel" + + onClicked: { + stackView.pop(); + } + } + } + } + } +} diff --git a/qt-mobile/qml/Log.qml b/qt-mobile/qml/Log.qml new file mode 100644 index 000000000..8e660f2c7 --- /dev/null +++ b/qt-mobile/qml/Log.qml @@ -0,0 +1,37 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: logWindow + width: parent.width + height: parent.height + objectName: "Log" + + ColumnLayout { + width: parent.width + height: parent.height + spacing: 8 + + TopBar { + id: topBar + anchors.top: parent.top + } + + Rectangle { + anchors.top: topBar.bottom + Layout.fillHeight: true + Layout.fillWidth: true + Text { + anchors.fill: parent + wrapMode: Text.WrapAnywhere + text: manager.logText + } + } + } +} diff --git a/qt-mobile/qml/Preferences.qml b/qt-mobile/qml/Preferences.qml new file mode 100644 index 000000000..8f4a15328 --- /dev/null +++ b/qt-mobile/qml/Preferences.qml @@ -0,0 +1,87 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: loginWindow + + signal accept + + property string username: login.text; + property string password: password.text; + property bool issave: savePassword.checked; + + GridLayout { + columns: 2 + anchors.centerIn: parent + width: parent.width + + Label { + text: "Enter your Subsurface cloud credentials" + Layout.columnSpan: 2 + } + + Label { + text: "Email Address:" + } + + TextField { + id: login + text: manager.cloudUserName + Layout.fillWidth: true + } + + Label { + text: "Password" + } + + TextField { + id: password + text: manager.cloudPassword + echoMode: TextInput.Password + Layout.fillWidth: true + } + + Label { + text: "Save Password locally" + } + + CheckBox { + checked: manager.saveCloudPassword + id: savePassword + } + + Item { + height: saveButton.height + width: saveButton.width + Button { + id: saveButton + text: "Save" + anchors.centerIn: parent + onClicked: { + manager.cloudUserName = login.text + manager.cloudPassword = password.text + manager.saveCloudPassword = savePassword.checked + manager.savePreferences() + stackView.pop() + } + } + } + + Item { + height: cancelButton.height + width: cancelButton.width + Button { + id: cancelButton + text: "Cancel" + + onClicked: { + stackView.pop(); + } + } + } + } +} diff --git a/qt-mobile/qml/TextButton.qml b/qt-mobile/qml/TextButton.qml new file mode 100644 index 000000000..3e5a36735 --- /dev/null +++ b/qt-mobile/qml/TextButton.qml @@ -0,0 +1,37 @@ +import QtQuick 2.3 + +Rectangle { + id: container + + property alias text: label.text + + signal clicked + + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } + } + + SystemPalette { id: palette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } + } + + Text { + id: label + anchors.centerIn: parent + } + + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } + } +} diff --git a/qt-mobile/qml/ThemeTest.qml b/qt-mobile/qml/ThemeTest.qml new file mode 100644 index 000000000..7452acc1b --- /dev/null +++ b/qt-mobile/qml/ThemeTest.qml @@ -0,0 +1,72 @@ +import QtQuick 2.5 +import QtQuick.Layouts 1.1 + +GridLayout { + id: themetest + columns: 2 + + Label { + Layout.columnSpan: 2 + Layout.fillHeight: true + text: "Theme Information" + } + + FontMetrics { + id: fm + } + + Label { + text: "units.gridUnit:" + } + Label { + text: units.gridUnit + } + + Label { + text: "units.devicePixelRatio:" + } + Label { + text: units.devicePixelRatio + } + + Label { + text: "FontMetrics pointSize:" + } + Label { + text: fm.font.pointSize + } + + Label { + text: "FontMetrics pixelSize:" + } + Label { + text: fm.height + + } + + Label { + text: "hand-computed devicePixelRatio:" + } + Label { + text: fm.height / fm.font.pointSize + } + + Text { + text: "Text item pixelSize:" + } + Text { + text: font.pixelSize + } + + Text { + text: "Text item pointSize:" + } + Text { + text: font.pointSize + } + + Label { + Layout.columnSpan: 2 + Layout.fillHeight: true + } +} diff --git a/qt-mobile/qml/TopBar.qml b/qt-mobile/qml/TopBar.qml new file mode 100644 index 000000000..552159d53 --- /dev/null +++ b/qt-mobile/qml/TopBar.qml @@ -0,0 +1,67 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import org.subsurfacedivelog.mobile 1.0 + +Rectangle { + id: topBar + color: theme.accentColor + Layout.fillWidth: true + Layout.margins: 0 + Layout.minimumHeight: prefsButton.height + units.smallSpacing * 2 + RowLayout { + anchors.bottom: topBar.bottom + anchors.bottomMargin: units.smallSpacing + anchors.left: topBar.left + anchors.leftMargin: units.smallSpacing + anchors.right: topBar.right + anchors.rightMargin: units.smallSpacing + Button { + id: backButton + Layout.maximumHeight: prefsButton.height + Layout.minimumHeight: prefsButton.height + Layout.preferredWidth: units.gridUnit * 2 + text: "\u2190" + style: ButtonStyle { + background: Rectangle { + color: theme.accentColor + implicitWidth: units.gridUnit * 2 + } + label: Text { + id: txt + color: theme.accentTextColor + font.pointSize: 18 + font.bold: true + text: control.text + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + onClicked: { + if (stackView.currentItem.objectName == "DiveDetails") + { + manager.commitChanges( + dive_id, + suit, + buddy, + divemaster, + notes + ) + } + stackView.pop(); + } + } + Text { + text: qsTr("Subsurface mobile") + font.pointSize: 18 + color: theme.accentTextColor + anchors.left: backButton.right + anchors.leftMargin: units.smallSpacing + //horizontalAlignment: Text.AlignHCenter + } + } +} diff --git a/qt-mobile/qml/components/Label.qml b/qt-mobile/qml/components/Label.qml new file mode 100644 index 000000000..617e05245 --- /dev/null +++ b/qt-mobile/qml/components/Label.qml @@ -0,0 +1,11 @@ +import QtQuick 2.5 +//import QtQuick.Controls 1.2 as QuickControls +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 + +Text { + + font.pointSize: 18 + color: theme.textColor +} diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml new file mode 100644 index 000000000..f75476537 --- /dev/null +++ b/qt-mobile/qml/main.qml @@ -0,0 +1,219 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import org.subsurfacedivelog.mobile 1.0 +import "qrc:/qml/theme" as Theme + + +ApplicationWindow { + title: qsTr("Subsurface mobile") + property bool fullscreen: true + property alias messageText: message.text + visible: true + + Theme.Units { + id: units + } + + Theme.Theme { + id: theme + /* Added for subsurface */ + property color accentColor: "#2d5b9a" + property color accentTextColor: "#ececec" + } + + Menu { + id: prefsMenu + title: "Menu" + + MenuItem { + text: "Preferences" + onTriggered: { + stackView.push(prefsWindow) + } + } + + MenuItem { + text: "Load Dives" + onTriggered: { + manager.loadDives(); + } + } + + MenuItem { + text: "Download Dives" + onTriggered: { + stackView.push(downloadDivesWindow) + } + } + + MenuItem { + text: "Add Dive" + onTriggered: { + manager.addDive(); + stackView.push(detailsWindow) + } + } + + MenuItem { + text: "Save Changes" + onTriggered: { + manager.saveChanges(); + } + } + + MenuItem { + text: "View Log" + onTriggered: { + stackView.push(logWindow) + } + } + + MenuItem { + text: "Theme Information" + onTriggered: { + stackView.push(themetest) + } + } + } + + StackView { + id: stackView + anchors.fill: parent + focus: true + Keys.onReleased: if (event.key == Qt.Key_Back && stackView.depth > 1) { + stackView.pop() + event.accepted = true; + } + initialItem: Item { + width: parent.width + height: parent.height + + ColumnLayout { + id: awLayout + anchors.fill: parent + spacing: units.gridUnit / 2 + Rectangle { + id: topPart + color: theme.accentColor + Layout.minimumHeight: units.gridUnit * 2 + units.smallSpacing * 2 + Layout.fillWidth: true + Layout.margins: 0 + RowLayout { + anchors.bottom: topPart.bottom + anchors.bottomMargin: units.smallSpacing + anchors.left: topPart.left + anchors.leftMargin: units.smallSpacing + anchors.right: topPart.right + anchors.rightMargin: units.smallSpacing + Image { + source: "qrc:/qml/subsurface-mobile-icon.png" + Layout.maximumWidth: units.gridUnit * 2 + Layout.preferredWidth: units.gridUnit * 2 + Layout.preferredHeight: units.gridUnit * 2 + } + Text { + text: qsTr("Subsurface mobile") + font.pointSize: 18 + Layout.fillWidth: false + color: theme.accentTextColor + } + Item { + Layout.fillWidth: true + } + Button { + id: prefsButton + text: "\u22ee" + anchors.right: parent.right + Layout.preferredWidth: units.gridUnit * 2 + Layout.preferredHeight: units.gridUnit * 2 + style: ButtonStyle { + background: Rectangle { + implicitWidth: units.gridUnit * 2 + color: theme.accentColor + } + label: Text { + id: txt + color: theme.accentTextColor + font.pointSize: 18 + font.bold: true + text: control.text + horizontalAlignment: Text.AlignHCenter + } + } + onClicked: { + prefsMenu.popup() + } + } + + } + + } + + Rectangle { + id: detailsPage + Layout.fillHeight: true + Layout.fillWidth: true + + DiveList { + anchors.fill: detailsPage + id: diveDetails + color: theme.backgroundColor + } + } + + Rectangle { + id: messageArea + height: childrenRect.height + Layout.fillWidth: true + + Text { + id: message + color: theme.textColor + text: "" + styleColor: theme.textColor + font.pointSize: 10 + } + } + + } + } + } + + QMLManager { + id: manager + } + + Preferences { + id: prefsWindow + visible: false + } + + DiveDetails { + id: detailsWindow + visible: false + } + + DownloadFromDiveComputer { + id: downloadDivesWindow + visible: false + } + + Log { + id: logWindow + visible: false + } + + ThemeTest { + id: themetest + visible: false + } + + Component.onCompleted: { + print("units.gridUnit is: " + units.gridUnit); + } +} diff --git a/qt-mobile/qml/mobile-resources.qrc b/qt-mobile/qml/mobile-resources.qrc new file mode 100644 index 000000000..42a89bd21 --- /dev/null +++ b/qt-mobile/qml/mobile-resources.qrc @@ -0,0 +1,20 @@ + + + main.qml + TextButton.qml + Preferences.qml + DiveList.qml + DiveDetails.qml + DownloadFromDiveComputer.qml + Log.qml + TopBar.qml + ThemeTest.qml + components/Label.qml + ../../icons/subsurface-mobile-icon.png + + + theme/Theme.qml + theme/qmldir + theme/Units.qml + + diff --git a/qt-mobile/qml/theme/Theme.qml b/qt-mobile/qml/theme/Theme.qml new file mode 100644 index 000000000..2c51ae00f --- /dev/null +++ b/qt-mobile/qml/theme/Theme.qml @@ -0,0 +1,57 @@ +/* + * Copyright 2015 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.0 + +//pragma Singleton + +/*! + \qmltype Theme + \inqmlmodule Material 0.1 + + \brief Provides access to standard colors that follow the Material Design specification. + + See \l {http://www.google.com/design/spec/style/color.html#color-ui-color-application} for + details about choosing a color scheme for your application. + */ +QtObject { + id: theme + + property color textColor: Qt.rgba(0,0,0, 0.54) + + property color highlightColor: "#2196F3" + property color backgroundColor: "#f3f3f3" + property color linkColor: "#2196F3" + property color visitedLinkColor: "#2196F3" + + property color buttonTextColor: Qt.rgba(0,0,0, 0.54) + property color buttonBackgroundColor: "#f3f3f3" + property color buttonHoverColor: "#2196F3" + property color buttonFocusColor: "#2196F3" + + property color viewTextColor: Qt.rgba(0,0,0, 0.54) + property color viewBackgroundColor: "#f3f3f3" + property color viewHoverColor: "#2196F3" + property color viewFocusColor: "#2196F3" + + property color complementaryTextColor: "#f3f3f3" + property color complementaryBackgroundColor: Qt.rgba(0,0,0, 0.54) + property color complementaryHoverColor: "#2196F3" + property color complementaryFocusColor: "#2196F3" +} diff --git a/qt-mobile/qml/theme/Units.qml b/qt-mobile/qml/theme/Units.qml new file mode 100644 index 000000000..1d0899fbc --- /dev/null +++ b/qt-mobile/qml/theme/Units.qml @@ -0,0 +1,102 @@ +/* + * Copyright 2015 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.5 +import QtQuick.Window 2.2 + +//pragma Singleton + + +QtObject { + id: units + + /** + * The fundamental unit of space that should be used for sizes, expressed in pixels. + * Given the screen has an accurate DPI settings, it corresponds to a width of + * the capital letter M + */ + property int gridUnit: fontMetrics.height + + /** + * units.iconSizes provides access to platform-dependent icon sizing + * + * The icon sizes provided are normalized for different DPI, so icons + * will scale depending on the DPI. + * + * Icon sizes from KIconLoader, adjusted to devicePixelRatio: + * * small + * * smallMedium + * * medium + * * large + * * huge + * * enormous + * + * Not devicePixelRation-adjusted:: + * * desktop + */ + property QtObject iconSizes: QtObject { + property int small: 16 * devicePixelRatio + property int smallMedium: 22 * devicePixelRatio + property int medium: 32 * devicePixelRatio + property int large: 48 * devicePixelRatio + property int huge: 64 * devicePixelRatio + property int enormous: 128 * devicePixelRatio + } + + /** + * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, + * for example as spacing in Columns. Internally, this size depends on the size of + * the default font as rendered on the screen, so it takes user-configured font size and DPI + * into account. + */ + property int smallSpacing: gridUnit/4 + + /** + * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, + * for example between an icon and the corresponding text. Internally, this size depends on + * the size of the default font as rendered on the screen, so it takes user-configured font + * size and DPI into account. + */ + property int largeSpacing: gridUnit + + /** + * The ratio between physical and device-independent pixels. This value does not depend on the \ + * size of the configured font. If you want to take font sizes into account when scaling elements, + * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. + * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. + */ + property real devicePixelRatio: Screen.devicePixelRatio + + /** + * units.longDuration should be used for longer, screen-covering animations, for opening and + * closing of dialogs and other "not too small" animations + */ + property int longDuration: 250 + + /** + * units.shortDuration should be used for short animations, such as accentuating a UI event, + * hover events, etc.. + */ + property int shortDuration: 150 + + property QtObject fontMetrics: FontMetrics { + //id: textSpacer + //text: "M" + } +} diff --git a/qt-mobile/qml/theme/qmldir b/qt-mobile/qml/theme/qmldir new file mode 100644 index 000000000..c654dbad6 --- /dev/null +++ b/qt-mobile/qml/theme/qmldir @@ -0,0 +1,2 @@ +#singleton Units Units.qml +#//singleton Theme Theme.qml diff --git a/qt-mobile/theme/Theme.qml b/qt-mobile/theme/Theme.qml deleted file mode 100644 index 2c51ae00f..000000000 --- a/qt-mobile/theme/Theme.qml +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.0 - -//pragma Singleton - -/*! - \qmltype Theme - \inqmlmodule Material 0.1 - - \brief Provides access to standard colors that follow the Material Design specification. - - See \l {http://www.google.com/design/spec/style/color.html#color-ui-color-application} for - details about choosing a color scheme for your application. - */ -QtObject { - id: theme - - property color textColor: Qt.rgba(0,0,0, 0.54) - - property color highlightColor: "#2196F3" - property color backgroundColor: "#f3f3f3" - property color linkColor: "#2196F3" - property color visitedLinkColor: "#2196F3" - - property color buttonTextColor: Qt.rgba(0,0,0, 0.54) - property color buttonBackgroundColor: "#f3f3f3" - property color buttonHoverColor: "#2196F3" - property color buttonFocusColor: "#2196F3" - - property color viewTextColor: Qt.rgba(0,0,0, 0.54) - property color viewBackgroundColor: "#f3f3f3" - property color viewHoverColor: "#2196F3" - property color viewFocusColor: "#2196F3" - - property color complementaryTextColor: "#f3f3f3" - property color complementaryBackgroundColor: Qt.rgba(0,0,0, 0.54) - property color complementaryHoverColor: "#2196F3" - property color complementaryFocusColor: "#2196F3" -} diff --git a/qt-mobile/theme/Units.qml b/qt-mobile/theme/Units.qml deleted file mode 100644 index 1d0899fbc..000000000 --- a/qt-mobile/theme/Units.qml +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2015 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.5 -import QtQuick.Window 2.2 - -//pragma Singleton - - -QtObject { - id: units - - /** - * The fundamental unit of space that should be used for sizes, expressed in pixels. - * Given the screen has an accurate DPI settings, it corresponds to a width of - * the capital letter M - */ - property int gridUnit: fontMetrics.height - - /** - * units.iconSizes provides access to platform-dependent icon sizing - * - * The icon sizes provided are normalized for different DPI, so icons - * will scale depending on the DPI. - * - * Icon sizes from KIconLoader, adjusted to devicePixelRatio: - * * small - * * smallMedium - * * medium - * * large - * * huge - * * enormous - * - * Not devicePixelRation-adjusted:: - * * desktop - */ - property QtObject iconSizes: QtObject { - property int small: 16 * devicePixelRatio - property int smallMedium: 22 * devicePixelRatio - property int medium: 32 * devicePixelRatio - property int large: 48 * devicePixelRatio - property int huge: 64 * devicePixelRatio - property int enormous: 128 * devicePixelRatio - } - - /** - * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, - * for example as spacing in Columns. Internally, this size depends on the size of - * the default font as rendered on the screen, so it takes user-configured font size and DPI - * into account. - */ - property int smallSpacing: gridUnit/4 - - /** - * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, - * for example between an icon and the corresponding text. Internally, this size depends on - * the size of the default font as rendered on the screen, so it takes user-configured font - * size and DPI into account. - */ - property int largeSpacing: gridUnit - - /** - * The ratio between physical and device-independent pixels. This value does not depend on the \ - * size of the configured font. If you want to take font sizes into account when scaling elements, - * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. - * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. - */ - property real devicePixelRatio: Screen.devicePixelRatio - - /** - * units.longDuration should be used for longer, screen-covering animations, for opening and - * closing of dialogs and other "not too small" animations - */ - property int longDuration: 250 - - /** - * units.shortDuration should be used for short animations, such as accentuating a UI event, - * hover events, etc.. - */ - property int shortDuration: 150 - - property QtObject fontMetrics: FontMetrics { - //id: textSpacer - //text: "M" - } -} diff --git a/qt-mobile/theme/qmldir b/qt-mobile/theme/qmldir deleted file mode 100644 index c654dbad6..000000000 --- a/qt-mobile/theme/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -#singleton Units Units.qml -#//singleton Theme Theme.qml -- cgit v1.2.3-70-g09d2