From 3421f6f64063d26925d6b311c84bbc26d511f7ff Mon Sep 17 00:00:00 2001 From: Adrian Verban Date: Fri, 28 Apr 2017 20:36:46 +0300 Subject: [PATCH 1/2] v3.0.2 - changed how tray controller works --- CppFiles/TrayController.cpp | 34 +++++++++++++++++----------------- CppFiles/TrayController.h | 4 +--- CreditsView.qml | 2 +- main.cpp | 2 +- main.qml | 3 +-- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/CppFiles/TrayController.cpp b/CppFiles/TrayController.cpp index a2e4d3f..30e0fa6 100644 --- a/CppFiles/TrayController.cpp +++ b/CppFiles/TrayController.cpp @@ -20,7 +20,12 @@ * along with Cumulus. If not, see . */ #include "TrayController.h" +#include "Util.h" + +#include TrayController::TrayController(QObject *parent) : QObject(parent) { + trayIcon = NULL; + setTrayVisibility(Util::trayVisibility()); } QString TrayController::icon() const { @@ -29,35 +34,26 @@ QString TrayController::icon() const { void TrayController::setIcon(const QString &icon) { if (m_icon != icon && icon.trimmed().size() > 0) { + m_icon = icon; setTrayIcon(icon); emit iconChanged(); } } -bool TrayController::startUp() const { - return m_startUp; -} - -void TrayController::setStartUp(const bool &startUp) { - if (m_startUp != startUp) { - if (startUp == true) { - initialiseTray(); - } - emit startUpChanged(); - } -} - bool TrayController::trayVisibility() const { return m_trayVisibility; } -void TrayController::setTrayVisibility(const bool &trayVisibility) { - if (m_trayVisibility != trayVisibility) { +void TrayController::setTrayVisibility(const bool &trayVisibility) { + if (m_trayVisibility != trayVisibility) { if (trayVisibility == true) { + if (trayIcon == NULL) + initialiseTray(); enableTray(); } else { - disableTray(); + if (trayIcon != NULL) + disableTray(); } m_trayVisibility = trayVisibility; emit trayVisibilityChanged(); @@ -77,7 +73,8 @@ void TrayController::setTrayIcon(const QString &weather) { } void TrayController::setTrayIcon(const QImage &image) { - trayIcon->setIcon(QIcon(QPixmap::fromImage(image))); + if (trayIcon != NULL) + trayIcon->setIcon(QIcon(QPixmap::fromImage(image))); thread->quit(); thread->wait(); } @@ -101,12 +98,15 @@ void TrayController::initialiseTray() { void TrayController::enableTray() { if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon->show(); + setTrayIcon(m_icon); } } void TrayController::disableTray() { if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon->hide(); + delete trayIcon; + trayIcon = NULL; } } diff --git a/CppFiles/TrayController.h b/CppFiles/TrayController.h index 11dfa0f..853e598 100644 --- a/CppFiles/TrayController.h +++ b/CppFiles/TrayController.h @@ -38,11 +38,10 @@ class TrayController : public QObject { Q_OBJECT Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) - Q_PROPERTY(bool startUp READ startUp WRITE setStartUp NOTIFY startUpChanged) Q_PROPERTY(bool trayVisibility READ trayVisibility WRITE setTrayVisibility NOTIFY trayVisibilityChanged) QString m_icon; - bool m_startUp, m_trayVisibility; + bool m_trayVisibility; QSystemTrayIcon *trayIcon; void initialiseTray(); @@ -66,7 +65,6 @@ private slots: void setTrayIcon(const QImage &image); signals: void iconChanged(); - void startUpChanged(); void trayVisibilityChanged(); void closeApp(); void showGui(); diff --git a/CreditsView.qml b/CreditsView.qml index 4fe76dd..b3d261f 100644 --- a/CreditsView.qml +++ b/CreditsView.qml @@ -27,7 +27,7 @@ import QtQuick.Layouts 1.1 Item { id: rootDialog visible: false - property string appVersion: "3.0.1" + property string appVersion: "3.0.2" property string textColor: util.textColor() property string backgroundColor: util.backgroundColor() property int contentWidth: rootDialog.width * 90 / 100 diff --git a/main.cpp b/main.cpp index 65434af..8920673 100644 --- a/main.cpp +++ b/main.cpp @@ -73,5 +73,5 @@ void registerQmlType() { qmlRegisterType("ownTypes.weather", 1, 8, "Weather"); qmlRegisterType("ownTypes.settingsController", 0, 5, "SettingsController"); qmlRegisterType("ownTypes.searchLocation", 0, 4, "LocationSearchController"); - qmlRegisterType("ownTypes.TrayController", 0, 1, "TrayController"); + qmlRegisterType("ownTypes.TrayController", 0, 2, "TrayController"); } diff --git a/main.qml b/main.qml index c1ec062..8ef0679 100644 --- a/main.qml +++ b/main.qml @@ -26,7 +26,7 @@ import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import ownTypes.settingsController 0.5 -import ownTypes.TrayController 0.1 +import ownTypes.TrayController 0.2 ApplicationWindow { id: mainWindow @@ -223,7 +223,6 @@ ApplicationWindow { TrayController { id: trayController - startUp: true trayVisibility: applicationSettingsController.trayVisibility icon: weatherView.tempValue onCloseApp: Qt.quit() From 3af3fca86c0e5dea10b4ffb8a992f45850f134d1 Mon Sep 17 00:00:00 2001 From: Adrian Verban Date: Wed, 3 May 2017 21:16:41 +0300 Subject: [PATCH 2/2] v3.0.2 - updated application to use Qt 5.8 - cleaned code - updated main view for android version - removed unused type --- ApplicationBar.qml | 4 +- ColorPalleteButton.qml | 4 +- CppFiles/DbConnection.cpp | 8 +- CppFiles/TrayController.cpp | 2 +- CppFiles/YWeatherController.cpp | 4 +- CreditsView.qml | 56 ++++++------ CustomBorder.qml | 46 ---------- ForecastDelegate.qml | 2 +- ForecastView.qml | 5 +- LinkedText.qml | 2 +- SearchLocation.qml | 18 ++-- SelectionButton.qml | 4 +- SettingsOptionItem.qml | 4 +- SettingsWindow.qml | 28 ++++-- WeatherWindow.qml | 4 +- main-android.qml | 157 ++++++++++++++++---------------- main.qml | 30 ++++-- qml.qrc | 1 - 18 files changed, 178 insertions(+), 201 deletions(-) delete mode 100644 CustomBorder.qml diff --git a/ApplicationBar.qml b/ApplicationBar.qml index 33dd992..eb78243 100644 --- a/ApplicationBar.qml +++ b/ApplicationBar.qml @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 Item { id: root diff --git a/ColorPalleteButton.qml b/ColorPalleteButton.qml index 9250cf1..d8c53f2 100644 --- a/ColorPalleteButton.qml +++ b/ColorPalleteButton.qml @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 Item { id: root diff --git a/CppFiles/DbConnection.cpp b/CppFiles/DbConnection.cpp index 5a83cc6..b4c8868 100644 --- a/CppFiles/DbConnection.cpp +++ b/CppFiles/DbConnection.cpp @@ -20,12 +20,16 @@ * along with Cumulus. If not, see . */ #include "DbConnection.h" +#include "Util.h" #include - #include + DbConnection::DbConnection(QObject *parent) : QObject(parent){ QString appName = QApplication::applicationName(); - QString databaseName = QApplication::applicationDirPath() + "/" + appName + "-local.db"; + QString databaseName = appName + "-local.db"; + if (Util::osType() != "android") { + databaseName = QApplication::applicationDirPath() + "/" + appName + "-local.db"; + } db = QSqlDatabase::database(); if (db.isValid() == false) { db = QSqlDatabase::addDatabase("QSQLITE"); diff --git a/CppFiles/TrayController.cpp b/CppFiles/TrayController.cpp index 30e0fa6..14f22c5 100644 --- a/CppFiles/TrayController.cpp +++ b/CppFiles/TrayController.cpp @@ -25,7 +25,7 @@ #include TrayController::TrayController(QObject *parent) : QObject(parent) { trayIcon = NULL; - setTrayVisibility(Util::trayVisibility()); + m_trayVisibility = false; } QString TrayController::icon() const { diff --git a/CppFiles/YWeatherController.cpp b/CppFiles/YWeatherController.cpp index ce69d58..8af66bd 100644 --- a/CppFiles/YWeatherController.cpp +++ b/CppFiles/YWeatherController.cpp @@ -30,12 +30,12 @@ YWeatherController::YWeatherController(QObject *parent) : AbstractWeatherControl void YWeatherController::searchByLocation(QString &location) { operationData = OperationData::GetLocationId; - dataController->getDataFromUrl("https://query.yahooapis.com/v1/public/yql?q=select woeid from geo.places(1) where text='" + location + "'&format=json&env=store://datatables.org/alltableswithkeys"); + dataController->getDataFromUrl("https://query.yahooapis.com/v1/public/yql?q=select woeid from geo.places(1) where text='" + location + "'&format=json"); } void YWeatherController::searchBycode(QString &code) { operationData = OperationData::GetWeather; - dataController->getDataFromUrl("https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid=" + code +"&format=json&env=store://datatables.org/alltableswithkeys"); + dataController->getDataFromUrl("https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid=" + code +"&format=json"); } void YWeatherController::readJsonData(QJsonObject jsonObject) { diff --git a/CreditsView.qml b/CreditsView.qml index b3d261f..a3c90d1 100644 --- a/CreditsView.qml +++ b/CreditsView.qml @@ -19,10 +19,9 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Dialogs 1.2 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 Item { id: rootDialog @@ -37,20 +36,22 @@ Item { color: backgroundColor width: rootDialog.width height: rootDialog.height - ScrollView { - id: rootScrollView + Flickable { + id: rootView anchors.fill: parent - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - ColumnLayout { + width: rootDialog.width + height: rootDialog.height + contentWidth: rootDialog.width + contentHeight: contentItem.height + Rectangle { + id: contentItem + color: "transparent" width: rootDialog.width - spacing: 0 + height: childrenRect.height LinkedText { id: versionText - Layout.fillHeight: false - Layout.preferredHeight: 60 - Layout.fillWidth: false - Layout.preferredWidth: rootDialog.contentWidth - Layout.alignment: Qt.AlignCenter + height: 60 + width: rootDialog.contentWidth horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true @@ -60,10 +61,11 @@ Item { url: "https://vadrian89.github.io/cumulus-qt/" } LinkedText { - Layout.fillHeight: true - Layout.fillWidth: false - Layout.preferredWidth: rootDialog.contentWidth - Layout.alignment: Qt.AlignCenter + id: fontCreditsText + anchors.top: versionText.bottom + anchors.left: parent.left + anchors.leftMargin: (rootDialog.width - fontCreditsText.width) / 2 + width: rootDialog.contentWidth font.pixelSize: 14 color: rootDialog.textColor wrapMode: Text.Wrap @@ -72,10 +74,10 @@ Item { } Text { id: creditsText - Layout.fillHeight: true - Layout.fillWidth: false - Layout.preferredWidth: rootDialog.contentWidth - Layout.alignment: Qt.AlignCenter + anchors.top: fontCreditsText.bottom + anchors.left: parent.left + anchors.leftMargin: (rootDialog.width - creditsText.width) / 2 + width: rootDialog.contentWidth font.pixelSize: 14 color: rootDialog.textColor wrapMode: Text.Wrap @@ -90,11 +92,11 @@ Item { } ListView { id: iconCreditsList - Layout.fillHeight: false - Layout.preferredHeight: 200 - Layout.fillWidth: false - Layout.preferredWidth: rootDialog.contentWidth - Layout.alignment: Qt.AlignCenter + anchors.top: creditsText.bottom + anchors.left: parent.left + anchors.leftMargin: (rootDialog.width - iconCreditsList.width) / 2 + height: 300 + width: rootDialog.contentWidth orientation: ListView.Vertical clip: true spacing: 0 diff --git a/CustomBorder.qml b/CustomBorder.qml deleted file mode 100644 index bca1ad8..0000000 --- a/CustomBorder.qml +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (C) 2016 - 2017 Adrian Verban -* Maintainers: Adrian Verban -* Derived from Typhoon by Archisman Panigrahi which is based on Stormcloud by Jono Cooper -* Thanks to all the contributors. -* Using the Ubuntu Condensed font. -* This file is part of Cumulus. -# -* Cumulus 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 3 of the License, or -* (at your option) any later version. -# -* Cumulus 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 Cumulus. If not, see . -*/ -import QtQuick 1.1 - -Rectangle { - property bool commonBorder : true - property int lBorderwidth : 1 - property int rBorderwidth : 1 - property int tBorderwidth : 1 - property int bBorderwidth : 1 - property int commonBorderWidth : 1 - property string borderColor : "white" - z : -1 - color: borderColor - - anchors { - left: parent.left - right: parent.right - top: parent.top - bottom: parent.bottom - - topMargin : commonBorder ? -commonBorderWidth : -tBorderwidth - bottomMargin : commonBorder ? -commonBorderWidth : -bBorderwidth - leftMargin : commonBorder ? -commonBorderWidth : -lBorderwidth - rightMargin : commonBorder ? -commonBorderWidth : -rBorderwidth - } -} diff --git a/ForecastDelegate.qml b/ForecastDelegate.qml index 7d1c34d..4e69554 100644 --- a/ForecastDelegate.qml +++ b/ForecastDelegate.qml @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 +import QtQuick 2.7 Item { property string forecastDay diff --git a/ForecastView.qml b/ForecastView.qml index ea27c6b..d8fedba 100644 --- a/ForecastView.qml +++ b/ForecastView.qml @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.0 +import QtQuick 2.7 Item { id: root @@ -53,5 +53,8 @@ Item { forecastTemperature: model.modelData.tempHigh + "° / " + model.modelData.tempLow + "°" forecastDesc: util.firstLetterUp(model.modelData.forecastDesc) } + onModelChanged: positionViewAtBeginning() + onWidthChanged: positionViewAtBeginning() + onHeightChanged: positionViewAtBeginning() } } diff --git a/LinkedText.qml b/LinkedText.qml index 02e1c7e..89ebc60 100644 --- a/LinkedText.qml +++ b/LinkedText.qml @@ -1,4 +1,4 @@ -import QtQuick 2.5 +import QtQuick 2.7 Text { id: root diff --git a/SearchLocation.qml b/SearchLocation.qml index 2291dc2..de1c1f2 100644 --- a/SearchLocation.qml +++ b/SearchLocation.qml @@ -19,11 +19,10 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Window 2.0 -import QtQuick.Controls 1.4 +import QtQuick 2.7 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.1 import QtQuick.Dialogs 1.2 -import QtQuick.Controls.Styles 1.4 import ownTypes.searchLocation 0.4 @@ -54,13 +53,10 @@ Item { anchors.topMargin: 10 anchors.left: parent.left anchors.leftMargin: (parent.width - width) / 2 - style: TextFieldStyle { - textColor: root.textColor - placeholderTextColor: root.textColor - background: Rectangle { - border.width: 0 - color: "transparent" - } + color: root.textColor + background: Rectangle { + border.width: 0 + color: "transparent" } onTextChanged: { diff --git a/SelectionButton.qml b/SelectionButton.qml index 1e3a074..a5bcfe8 100644 --- a/SelectionButton.qml +++ b/SelectionButton.qml @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick 2.7 +import QtQuick.Controls 2.1 Item { id: rootItem diff --git a/SettingsOptionItem.qml b/SettingsOptionItem.qml index 72fef21..c85db66 100644 --- a/SettingsOptionItem.qml +++ b/SettingsOptionItem.qml @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.0 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 Item { id: root diff --git a/SettingsWindow.qml b/SettingsWindow.qml index 6ae3a3f..9860d74 100644 --- a/SettingsWindow.qml +++ b/SettingsWindow.qml @@ -19,12 +19,11 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Window 2.0 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.3 import QtQuick.Dialogs 1.2 -import QtGraphicalEffects 1.0 Item { id: root @@ -38,6 +37,7 @@ Item { property string temperatureUnit: util.getTemperatureUnit() property string api: util.getWeatherApi() property int settingsItemHeight: 64 + property int textFontSize: 14 signal locationChanged() signal showCredits() @@ -52,7 +52,6 @@ Item { contentWidth: root.width width: root.width height: root.height - Rectangle { id: settingsBody width: settingsFlick.width @@ -137,7 +136,17 @@ Item { anchors.leftMargin: width / 2 visible: false model: [ "°F", "°C" ] - // model: [ "°F", "°C", "°K" ] + delegate: ItemDelegate { + width: tempUnitSelect.width + height: tempUnitSelect.height + contentItem: Text { + text: modelData + font.pixelSize: root.textFontSize + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + } + } + onVisibleChanged: { if(tempUnitSelect.visible == false) { speedUnitItem.anchors.top = tempUnitItem.bottom @@ -298,7 +307,7 @@ Item { SettingsOptionItem { id: apiSelectItem - optionText: "API" + optionText: "Provider" backgroundColor: "#ffffff" anchors.top: colorPalettesItem.bottom height: root.settingsItemHeight @@ -399,10 +408,11 @@ Item { } } } + ColorDialog { id: colorDialog title: "Please choose a color" - showAlphaChannel: true + showAlphaChannel: purpose == "background" ? true : false modality: Qt.ApplicationModal property string purpose onVisibleChanged: visible == false ? root.focus = true : root.focus = false diff --git a/WeatherWindow.qml b/WeatherWindow.qml index 27ad343..856b842 100644 --- a/WeatherWindow.qml +++ b/WeatherWindow.qml @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 import ownTypes.weather 1.8 diff --git a/main-android.qml b/main-android.qml index 8c01cc3..be504e2 100644 --- a/main-android.qml +++ b/main-android.qml @@ -19,10 +19,10 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.0 +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 import ownTypes.settingsController 0.5 @@ -77,93 +77,92 @@ ApplicationWindow { id: appView width: parent.width height: parent.height - applicationBar.height - initialItem: bodyView anchors.top: applicationBar.bottom - Flickable { - id: bodyView - contentHeight: height - contentWidth: width - interactive: false - contentX: 0 + initialItem: bodyView + } - WeatherWindow { - id: weatherView - width: bodyView.width - height: bodyView.height - textColor: applicationSettingsController.textColor - textFontFamily: ubuntuCondensed.name - iconsFont: weatherIcons.name - speedUnit: settingsView.speedUnit - onNoLocationDetected: { - visible = false - settingsView.visible = true - settingsView.searchLocationAlias.visible = true - applicationBar.menuButtonAlias.visible = false - applicationBar.refreshButtonAlias.visible = false - } - onFinishedWeatherUpdate: { - visible = true - applicationBar.menuButtonAlias.visible = true - applicationBar.refreshButtonAlias.visible = true - } - onUpdateWeather: { - if (applicationBar.animationAlias.running == false) { - applicationBar.animationAlias.start() - applicationBar.animationAlias.loops = RotationAnimation.Infinite - } - } - onDataDownloadFinished: { - applicationBar.animationAlias.stop() - timer.interval = 3600000 - } + Flickable { + id: bodyView + contentWidth: width + contentHeight: height + interactive: false + contentX: 0 + WeatherWindow { + id: weatherView + width: bodyView.width + height: bodyView.height + textColor: applicationSettingsController.textColor + textFontFamily: ubuntuCondensed.name + iconsFont: weatherIcons.name + speedUnit: settingsView.speedUnit + visible: false + onNoLocationDetected: { + appView.push(settingsView) + creditsView.forceActiveFocus() + settingsView.searchLocationAlias.visible = true + applicationBar.menuButtonAlias.visible = false + applicationBar.refreshButtonAlias.visible = false } - } - - SettingsWindow { - id: settingsView - onLocationChanged: { - weatherView.updateWeather() - visible = false + onFinishedWeatherUpdate: { + visible = true + applicationBar.menuButtonAlias.visible = true + applicationBar.refreshButtonAlias.visible = true } - onTextColorChanged: applicationSettingsController.textColor = textColor - onBackgroundColorChanged: applicationSettingsController.applicationBackground = backgroundColor - onTemperatureUnitChanged: { - if (visible == true) { - weatherView.changeTempUnit(settingsView.temperatureUnit) + onUpdateWeather: { + if (applicationBar.animationAlias.running == false) { + applicationBar.animationAlias.start() + applicationBar.animationAlias.loops = RotationAnimation.Infinite } } - onSpeedUnitChanged: { - if (visible == true) { - weatherView.changeSpeedUnit(settingsView.speedUnit) - } + onDataDownloadFinished: { + applicationBar.animationAlias.stop() + timer.interval = 3600000 } - onApiChanged: { - if (visible == true) { - weatherView.weatherApi = api - } + } + Component.onCompleted: weatherView.updateWeather() + } + + SettingsWindow { + id: settingsView + onLocationChanged: { + weatherView.updateWeather() + appView.pop() + bodyView.forceActiveFocus() + } + onTextColorChanged: applicationSettingsController.textColor = textColor + onBackgroundColorChanged: applicationSettingsController.applicationBackground = backgroundColor + onTemperatureUnitChanged: { + if (visible == true) { + weatherView.changeTempUnit(settingsView.temperatureUnit) } - Keys.onPressed: { - if (event.key == Qt.Key_Escape || event.key == Qt.Key_Back) { - appView.pop() - bodyView.forceActiveFocus() - } + } + onSpeedUnitChanged: { + if (visible == true) { + weatherView.changeSpeedUnit(settingsView.speedUnit) } - onShowCredits: { - appView.push(creditsView) - creditsView.forceActiveFocus() + } + onApiChanged: { + if (visible == true) { + weatherView.weatherApi = api } } + onShowCredits: { + appView.push(creditsView) + creditsView.forceActiveFocus() + } + Keys.onBackPressed: { + appView.pop() + bodyView.forceActiveFocus() + } + } - CreditsView { - id: creditsView - textColor: applicationSettingsController.textColor - backgroundColor: applicationSettingsController.applicationBackground - Keys.onPressed: { - if (event.key == Qt.Key_Escape || event.key == Qt.Key_Back) { - appView.pop() - settingsView.forceActiveFocus() - } - } + CreditsView { + id: creditsView + textColor: applicationSettingsController.textColor + backgroundColor: applicationSettingsController.applicationBackground + Keys.onBackPressed: { + appView.pop() + settingsView.forceActiveFocus() } } } diff --git a/main.qml b/main.qml index 8ef0679..4f94a50 100644 --- a/main.qml +++ b/main.qml @@ -19,11 +19,9 @@ * You should have received a copy of the GNU General Public License * along with Cumulus. If not, see . */ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.1 +import QtQuick 2.7 +import QtQuick.Controls 2.1 import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.2 import ownTypes.settingsController 0.5 import ownTypes.TrayController 0.2 @@ -73,6 +71,10 @@ ApplicationWindow { } } + background: Rectangle { + color: "transparent" + } + Rectangle { id: appBody anchors.fill: parent @@ -168,13 +170,13 @@ ApplicationWindow { } Component.onCompleted: weatherView.updateWeather() - Dialog { + ApplicationWindow { id: settingsViewDialog width: 300 height: 500 visible: false - modality: Qt.ApplicationModal - contentItem: SettingsWindow { + flags: Qt.Dialog + SettingsWindow { id: settingsView anchors.fill: parent visible: true @@ -203,15 +205,19 @@ ApplicationWindow { onShowCredits: creditsViewDialog.visible = true Keys.onEscapePressed: settingsViewDialog.visible = false } + onVisibilityChanged: { + if (visible == true) + settingsView.forceActiveFocus() + } } - Dialog { + ApplicationWindow { id: creditsViewDialog width: settingsView.width height: settingsView.height visible: false - modality: Qt.ApplicationModal - contentItem: CreditsView { + flags: Qt.Dialog + CreditsView { id: creditsView anchors.fill: parent visible: true @@ -219,6 +225,10 @@ ApplicationWindow { backgroundColor: applicationSettingsController.applicationBackground Keys.onEscapePressed: creditsViewDialog.visible = false } + onVisibilityChanged: { + if (visible == true) + creditsView.forceActiveFocus() + } } TrayController { diff --git a/qml.qrc b/qml.qrc index a735ff3..f9dcd13 100644 --- a/qml.qrc +++ b/qml.qrc @@ -51,7 +51,6 @@ icons/icon.png SettingsWindow.qml SelectionButton.qml - CustomBorder.qml MenuButton.qml main.qml ApplicationBar.qml