Fixes and optimizations

This commit is contained in:
Michael Zanetti 2022-06-27 23:32:37 +02:00
parent 55193ead45
commit 0ed4fa7c0d
6 changed files with 32 additions and 18 deletions

View File

@ -37,6 +37,9 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCommandLineOption> #include <QCommandLineOption>
#if !defined Q_OS_ANDROID && !defined Q_OS_IOS && !defined UBPORTS
#include <QtWebView>
#endif
#include "libnymea-app-core.h" #include "libnymea-app-core.h"
@ -66,11 +69,15 @@ int main(int argc, char *argv[])
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
qputenv("QT_WEBVIEW_PLUGIN", "native"); qputenv("QT_WEBVIEW_PLUGIN", "native");
#elif !defined Q_OS_ANDROID && !defined Q_OS_IOS && !defined UBPORTS
// FIXME: Platformhelper should be split into parts that shall run before initialisation and parts that require a UI context already running
QtWebView::initialize();
#endif #endif
// qt.qml.connections warnings are disabled since the replace only exists // qt.qml.connections warnings are disabled since the replace only exists
// in Qt 5.12. Remove that once 5.12 is the minimum supported version. // in Qt 5.12. Remove that once 5.12 is the minimum supported version.
QLoggingCategory::setFilterRules("*.debug=false\n" QLoggingCategory::setFilterRules("*.debug=false\n"
"Application.debug=true\n"
"qt.qml.connections.warning=false\n" "qt.qml.connections.warning=false\n"
); );
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@ -95,10 +102,7 @@ int main(int argc, char *argv[])
parser.addOption(splashOption); parser.addOption(splashOption);
parser.process(application); parser.process(application);
// Initialize app log controller as early as possible, but after setting app name etc qCInfo(dcApplication()) << "*** nymea:app starting ***" << QDateTime::currentDateTime().toString();
AppLogController::instance();
qCDebug(dcApplication()) << "*** nymea:app starting ***" << QDateTime::currentDateTime().toString();
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
@ -107,6 +111,9 @@ int main(int argc, char *argv[])
qCInfo(dcApplication()) << application.applicationName() << APP_VERSION << "running on" << QSysInfo::machineHostName() << QSysInfo::prettyProductName() << QSysInfo::productType() << QSysInfo::productVersion() << PlatformHelper::instance()->deviceManufacturer() << PlatformHelper::instance()->deviceModel(); qCInfo(dcApplication()) << application.applicationName() << APP_VERSION << "running on" << QSysInfo::machineHostName() << QSysInfo::prettyProductName() << QSysInfo::productType() << QSysInfo::productVersion() << PlatformHelper::instance()->deviceManufacturer() << PlatformHelper::instance()->deviceModel();
qCInfo(dcApplication()) << "Locale info:" << QLocale() << QLocale().name() << QLocale().language() << QLocale().system(); qCInfo(dcApplication()) << "Locale info:" << QLocale() << QLocale().name() << QLocale().language() << QLocale().system();
// Initialize app log controller as early as possible, but after setting app name and printing initial startup info
AppLogController::instance();
QTranslator appTranslator; QTranslator appTranslator;
bool translationResult = appTranslator.load("nymea-app-" + QLocale().name(), ":/translations/"); bool translationResult = appTranslator.load("nymea-app-" + QLocale().name(), ":/translations/");
if (translationResult) { if (translationResult) {

View File

@ -125,6 +125,7 @@ Page {
} }
QtObject { QtObject {
id: d id: d
property bool blurEnabled: PlatformHelper.deviceManufacturer !== "raspbian"
property var editRulePage: null property var editRulePage: null
property var configOverlay: null property var configOverlay: null
} }
@ -243,8 +244,6 @@ Page {
opacity: d.configOverlay === null ? 1 : 0 opacity: d.configOverlay === null ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } }
Repeater { Repeater {
model: d.configOverlay != null ? null : filteredContentModel model: d.configOverlay != null ? null : filteredContentModel
@ -254,6 +253,8 @@ Page {
height: swipeView.height height: swipeView.height
clip: true clip: true
source: "mainviews/" + model.source + ".qml" source: "mainviews/" + model.source + ".qml"
// visible: SwipeView.isCurrentItem
active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
Binding { Binding {
target: mainViewLoader.item target: mainViewLoader.item
@ -307,7 +308,7 @@ Page {
id: headerBlurSource id: headerBlurSource
width: contentContainer.width width: contentContainer.width
height: d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize height: d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize
sourceItem: contentContainer sourceItem: d.blurEnabled ? contentContainer : null
sourceRect: Qt.rect(0, 0, contentContainer.width, d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize) sourceRect: Qt.rect(0, 0, contentContainer.width, d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize)
visible: false visible: false
} }
@ -321,7 +322,8 @@ Page {
height: d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize height: d.configOverlay ? contentContainer.headerSize : contentContainer.headerBlurSize
radius: 40 radius: 40
transparentBorder: true transparentBorder: true
source: headerBlurSource source: d.blurEnabled ? headerBlurSource : null
visible: d.blurEnabled
} }
Rectangle { Rectangle {
@ -344,10 +346,10 @@ Page {
id: footerBlurSource id: footerBlurSource
width: contentContainer.width width: contentContainer.width
height: contentContainer.footerSize height: contentContainer.footerSize
sourceItem: contentContainer sourceItem: d.blurEnabled ? contentContainer : null
sourceRect: Qt.rect(0, contentContainer.height - height, contentContainer.width, contentContainer.footerSize) sourceRect: Qt.rect(0, contentContainer.height - height, contentContainer.width, contentContainer.footerSize)
visible: false visible: false
enabled: footer.shown enabled: d.blurEnabled && footer.shown
} }
FastBlur { FastBlur {
@ -359,8 +361,8 @@ Page {
height: contentContainer.footerSize height: contentContainer.footerSize
radius: 40 radius: 40
transparentBorder: false transparentBorder: false
source: footerBlurSource source: d.blurEnabled ? footerBlurSource : null
visible: footer.shown visible: d.blurEnabled && footer.shown
} }
Rectangle { Rectangle {

View File

@ -101,10 +101,9 @@ MainViewBase {
// GridLayout directly in a flickable causes problems at initialisation // GridLayout directly in a flickable causes problems at initialisation
Item { Item {
width: parent.width width: flickable.width
height: energyGrid.implicitHeight height: energyGrid.implicitHeight
GridLayout { GridLayout {
id: energyGrid id: energyGrid
width: parent.width width: parent.width
@ -119,12 +118,14 @@ MainViewBase {
Layout.preferredHeight: width Layout.preferredHeight: width
energyManager: energyManager energyManager: energyManager
visible: producers.count > 0 visible: producers.count > 0
animationsEnabled: Qt.application.active && root.isCurrentItem
} }
CurrentProductionBalancePieChart { CurrentProductionBalancePieChart {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: width Layout.preferredHeight: width
energyManager: energyManager energyManager: energyManager
visible: producers.count > 0 visible: producers.count > 0
animationsEnabled: Qt.application.active && root.isCurrentItem
} }
PowerConsumptionBalanceHistory { PowerConsumptionBalanceHistory {
@ -146,6 +147,7 @@ MainViewBase {
visible: consumers.count > 0 visible: consumers.count > 0
colors: root.thingColors colors: root.thingColors
consumers: consumers consumers: consumers
animationsEnabled: Qt.application.active && root.isCurrentItem
} }
// ConsumersBarChart { // ConsumersBarChart {

View File

@ -10,7 +10,7 @@ import "qrc:/ui/components"
ChartView { ChartView {
id: root id: root
backgroundColor: "transparent" backgroundColor: "transparent"
animationOptions: Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation animationOptions: animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
title: qsTr("Consumers balance") title: qsTr("Consumers balance")
titleColor: Style.foregroundColor titleColor: Style.foregroundColor
legend.visible: false legend.visible: false
@ -23,6 +23,7 @@ ChartView {
property EnergyManager energyManager: null property EnergyManager energyManager: null
property ThingsProxy consumers: null property ThingsProxy consumers: null
property var colors: null property var colors: null
property bool animationsEnabled: true
readonly property Thing rootMeter: engine.thingManager.fetchingData ? null : engine.thingManager.things.getThing(energyManager.rootMeterId) readonly property Thing rootMeter: engine.thingManager.fetchingData ? null : engine.thingManager.things.getThing(energyManager.rootMeterId)
onRootMeterChanged: updateConsumers() onRootMeterChanged: updateConsumers()
@ -109,7 +110,7 @@ ChartView {
d.thingsColorMap = colorMap d.thingsColorMap = colorMap
root.animationOptions = Qt.binding(function() { root.animationOptions = Qt.binding(function() {
return Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation return root.animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
}) })
} }

View File

@ -9,7 +9,7 @@ import Nymea 1.0
ChartView { ChartView {
id: consumptionPieChart id: consumptionPieChart
backgroundColor: "transparent" backgroundColor: "transparent"
animationOptions: Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation animationOptions: animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
title: qsTr("My energy mix") title: qsTr("My energy mix")
titleColor: Style.foregroundColor titleColor: Style.foregroundColor
legend.visible: false legend.visible: false
@ -19,6 +19,7 @@ ChartView {
margins.bottom: 0 margins.bottom: 0
margins.top: 0 margins.top: 0
property bool animationsEnabled: true
property EnergyManager energyManager: null property EnergyManager energyManager: null
ThingsProxy { ThingsProxy {

View File

@ -9,7 +9,7 @@ import Nymea 1.0
ChartView { ChartView {
id: productionPieChart id: productionPieChart
backgroundColor: "transparent" backgroundColor: "transparent"
animationOptions: Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation animationOptions: animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
title: qsTr("My energy production") title: qsTr("My energy production")
titleColor: Style.foregroundColor titleColor: Style.foregroundColor
legend.visible: false legend.visible: false
@ -19,6 +19,7 @@ ChartView {
margins.bottom: 0 margins.bottom: 0
margins.top: 0 margins.top: 0
property bool animationsEnabled: true
property EnergyManager energyManager: null property EnergyManager energyManager: null
ThingsProxy { ThingsProxy {