Fixes and optimizations

pull/838/head
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 <QCommandLineOption>
#if !defined Q_OS_ANDROID && !defined Q_OS_IOS && !defined UBPORTS
#include <QtWebView>
#endif
#include "libnymea-app-core.h"
@ -66,11 +69,15 @@ int main(int argc, char *argv[])
#ifdef Q_OS_OSX
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
// 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.
QLoggingCategory::setFilterRules("*.debug=false\n"
"Application.debug=true\n"
"qt.qml.connections.warning=false\n"
);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@ -95,10 +102,7 @@ int main(int argc, char *argv[])
parser.addOption(splashOption);
parser.process(application);
// Initialize app log controller as early as possible, but after setting app name etc
AppLogController::instance();
qCDebug(dcApplication()) << "*** nymea:app starting ***" << QDateTime::currentDateTime().toString();
qCInfo(dcApplication()) << "*** nymea:app starting ***" << QDateTime::currentDateTime().toString();
QTranslator qtTranslator;
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()) << "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;
bool translationResult = appTranslator.load("nymea-app-" + QLocale().name(), ":/translations/");
if (translationResult) {

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import "qrc:/ui/components"
ChartView {
id: root
backgroundColor: "transparent"
animationOptions: Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
animationOptions: animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
title: qsTr("Consumers balance")
titleColor: Style.foregroundColor
legend.visible: false
@ -23,6 +23,7 @@ ChartView {
property EnergyManager energyManager: null
property ThingsProxy consumers: null
property var colors: null
property bool animationsEnabled: true
readonly property Thing rootMeter: engine.thingManager.fetchingData ? null : engine.thingManager.things.getThing(energyManager.rootMeterId)
onRootMeterChanged: updateConsumers()
@ -109,7 +110,7 @@ ChartView {
d.thingsColorMap = colorMap
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 {
id: consumptionPieChart
backgroundColor: "transparent"
animationOptions: Qt.application.active ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
animationOptions: animationsEnabled ? NymeaUtils.chartsAnimationOptions : ChartView.NoAnimation
title: qsTr("My energy mix")
titleColor: Style.foregroundColor
legend.visible: false
@ -19,6 +19,7 @@ ChartView {
margins.bottom: 0
margins.top: 0
property bool animationsEnabled: true
property EnergyManager energyManager: null
ThingsProxy {

View File

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