diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cce0e326..ea32dbdd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,8 +40,8 @@ build:shared_windows_release: script: - python -m pip install -U pip wheel - python -m pip install -U aqtinstall - - aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all - - aqt install-tool -O ../aqt windows desktop tools_ifw + - python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all + - python -m aqt install-tool -O ../aqt windows desktop tools_ifw - cd Tools - python setup.py - python build.py -type release -use-aqt -installer @@ -58,8 +58,8 @@ build:windows_release: script: - python -m pip install -U pip wheel - python -m pip install -U aqtinstall - - aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all - - aqt install-tool -O ../aqt windows desktop tools_ifw + - python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all + - python -m aqt install-tool -O ../aqt windows desktop tools_ifw - cd Tools - python setup.py - python build.py -type release -use-aqt -installer @@ -75,8 +75,8 @@ build:windows_release_steam: script: - python -m pip install -U pip wheel - python -m pip install -U aqtinstall - - aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all - - aqt install-tool -O ../aqt windows desktop tools_ifw + - python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all + - python -m aqt install-tool -O ../aqt windows desktop tools_ifw - cd Tools - python setup.py - python build.py -type release -steam -use-aqt -installer @@ -92,8 +92,8 @@ build:osx_release: script: - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - - aqt install-tool -O ../aqt mac desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all + - python3 -m aqt install-tool -O ../aqt mac desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -use-aqt -installer @@ -109,8 +109,8 @@ build:osx_release_steam: script: - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - - aqt install-tool -O ../aqt mac desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all + - python3 -m aqt install-tool -O ../aqt mac desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -steam -use-aqt -installer @@ -137,8 +137,8 @@ build:linux_release: - apt install mesa-common-dev libxkbcommon-* libfontconfig curl zip unzip tar git pkg-config apt-transport-https ca-certificates gnupg software-properties-common wget software-properties-common wget python3-pip build-essential libgl1-mesa-dev lld ninja-build cmake -y - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all - - aqt install-tool -O ../aqt linux desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all + - python3 -m aqt install-tool -O ../aqt linux desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -steam -use-aqt -installer @@ -154,8 +154,8 @@ release:windows_steam: script: - python -m pip install -U pip wheel - python -m pip install -U aqtinstall - - aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all - - aqt install-tool -O ../aqt windows desktop tools_ifw + - python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all + - python -m aqt install-tool -O ../aqt windows desktop tools_ifw - cd Tools - python setup.py - python build.py -type release -use-aqt -steam @@ -173,8 +173,8 @@ release:windows_standalone: script: - python -m pip install -U pip wheel - python -m pip install -U aqtinstall - - aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all - - aqt install-tool -O ../aqt windows desktop tools_ifw + - python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all + - python -m aqt install-tool -O ../aqt windows desktop tools_ifw - cd Tools - python setup.py - python build.py -type release -use-aqt -installer @@ -192,8 +192,8 @@ release:osx_steam: script: - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - - aqt install-tool -O ../aqt mac desktop tools_ifw + - python -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all + - python -m aqt install-tool -O ../aqt mac desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -steam -use-aqt -sign @@ -211,8 +211,8 @@ release:osx_standalone: script: - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - - aqt install-tool -O ../aqt mac desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all + - python3 -m aqt install-tool -O ../aqt mac desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -installer -use-aqt -sign @@ -241,8 +241,8 @@ release:linux_steam: - apt install mesa-common-dev libxkbcommon-* libfontconfig curl zip unzip tar git pkg-config apt-transport-https ca-certificates gnupg software-properties-common wget software-properties-common wget python3-pip build-essential libgl1-mesa-dev lld ninja-build cmake -y - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all - - aqt install-tool -O ../aqt linux desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all + - python3 -m aqt install-tool -O ../aqt linux desktop tools_ifw - curl -OL $CQTDEPLOYER_URL - chmod +x ./CQtDeployer_*.deb - apt install ./CQtDeployer_*.deb -y @@ -274,8 +274,8 @@ release:linux_standalone: - apt install mesa-common-dev libxkbcommon-* libfontconfig curl zip unzip tar git pkg-config apt-transport-https ca-certificates gnupg software-properties-common wget software-properties-common wget python3-pip build-essential libgl1-mesa-dev lld ninja-build cmake -y - pip3 install -U pip - pip3 install aqtinstall - - aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all - - aqt install-tool -O ../aqt linux desktop tools_ifw + - python3 -m aqt install-qt -O ../aqt linux desktop $QT_VERSION gcc_64 -m all + - python3 -m aqt install-tool -O ../aqt linux desktop tools_ifw - cd Tools - python3 setup.py - python3 build.py -type release -installer -use-aqt diff --git a/CMake/CreateIFWInstaller.cmake b/CMake/CreateIFWInstaller.cmake index 4e9533b6..511fe511 100644 --- a/CMake/CreateIFWInstaller.cmake +++ b/CMake/CreateIFWInstaller.cmake @@ -1,16 +1,12 @@ # Variable must be around "" to be equal! if("${CPACK_IFW_ROOT}" STREQUAL "") # Hardcoded Qt paths that are used by the QtMaintanance tool for now... - if(WIN32) - if(${GITLAB_CI}) - set(SCREENPLAY_IFW_ROOT "${CMAKE_SOURCE_DIR}/../aqt/Tools/QtInstallerFramework/${SCREENPLAY_IFW_VERSION}") - else() + if(${GITLAB_CI}) + set(SCREENPLAY_IFW_ROOT "${CMAKE_SOURCE_DIR}/../aqt/Tools/QtInstallerFramework/${SCREENPLAY_IFW_VERSION}") + else() + if(WIN32) set(SCREENPLAY_IFW_ROOT "C:/Qt/Tools/QtInstallerFramework/${SCREENPLAY_IFW_VERSION}") - endif() - elseif(UNIX) - if(${GITLAB_CI}) - set(SCREENPLAY_IFW_ROOT "${CMAKE_SOURCE_DIR}/../aqt/Tools/QtInstallerFramework/${SCREENPLAY_IFW_VERSION}") - else() + elseif(UNIX) set(SCREENPLAY_IFW_ROOT "$ENV{HOME}/Qt/Tools/QtInstallerFramework/${SCREENPLAY_IFW_VERSION}") endif() endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 84531267..e80daf28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,10 +54,11 @@ list(APPEND QML_DIRS "${SCREENPLAY_QML_MODULES_PATH}") set(QML_IMPORT_PATH "${QML_DIRS}" CACHE STRING "Qt Creator extra qml import paths") set(SCREENPLAY_IFW_ROOT "") -set(SCREENPLAY_IFW_VERSION "4.3") +set(SCREENPLAY_IFW_VERSION "4.4") set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg") set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}") +set(VCPKG_BIN_PATH "${VCPKG_INSTALLED_PATH}/bin") option(SCREENPLAY_STEAM "For FOSS distribution so we do not bundle proprietary code." ON) option(SCREENPLAY_RELEASE "Marks this version as an official release version. This version uses different import paths and other settings." OFF) diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 2010f2ea..566d3bed 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -364,6 +364,9 @@ if(WIN32) configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY) configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/zlib1.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY) + configure_file(${VCPKG_BIN_PATH}/libssl-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY) + configure_file(${VCPKG_BIN_PATH}/libcrypto-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY) + endif() if(APPLE) diff --git a/ScreenPlaySysInfo/qml/TestMain.qml b/ScreenPlaySysInfo/qml/TestMain.qml index 428fcbb8..436557d4 100644 --- a/ScreenPlaySysInfo/qml/TestMain.qml +++ b/ScreenPlaySysInfo/qml/TestMain.qml @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl import ScreenPlaySysInfo Window { @@ -10,11 +11,10 @@ Window { height: 768 visible: true title: qsTr("ScreenPlaySysInfo") - color: "#19181E" - property color accentColor: "#FF9800" + property color accentColor: Material.secondaryTextColor property string fontFamily: "Arial" - property int fontPointSize: 16 + property int fontPointSize: 14 SysInfo { id: sysInfo @@ -32,27 +32,44 @@ Window { return out } - RowLayout { - spacing: 40 - anchors.fill: parent - anchors.margins: 20 + Rectangle { + anchors.fill: wrapper + anchors.margins: -50 + color: Material.backgroundColor + radius: 4 + layer.enabled: true + layer.effect: ElevationEffect { + elevation: 4 + } + } + + RowLayout { + id:wrapper + spacing: 40 + anchors.centerIn: parent ColumnLayout { id: wrapperLeft - Text { - text: "IpAddress" - color: root.accentColor - font.family: root.fontFamily - font.pointSize: 60 - horizontalAlignment: Text.AlignHCenter - } + Layout.preferredWidth: 500 + ColumnLayout { + spacing: 10 + Item { + Layout.fillWidth: true + } + Text { + text: "Private Addresses" + color: root.accentColor + font { + pointSize: 24 + family: root.fontFamily + } + } Text { text: root.stringListToString( ipAddress.privateIpV4AddressList) color: root.accentColor - horizontalAlignment: Text.AlignHCenter font { pointSize: 16 family: "Fira Code" @@ -62,22 +79,35 @@ Window { text: root.stringListToString( ipAddress.privateIpV6AddressList) color: root.accentColor - horizontalAlignment: Text.AlignHCenter font { pointSize: 16 family: "Fira Code" } } + Item { + Layout.fillWidth: true + } + Rectangle { color: root.accentColor - Layout.preferredHeight: 5 + Layout.preferredHeight: 3 Layout.fillWidth: true } + Item { + Layout.fillWidth: true + } + Text { + text: "Public Addresses" + color: root.accentColor + font { + pointSize: 24 + family: root.fontFamily + } + } Text { text: ipAddress.publicIpV4Address color: root.accentColor - horizontalAlignment: Text.AlignHCenter font { pointSize: 16 family: root.fontFamily @@ -86,7 +116,6 @@ Window { Text { text: ipAddress.publicIpV6Address color: root.accentColor - horizontalAlignment: Text.AlignHCenter font { pointSize: 16 family: root.fontFamily @@ -96,18 +125,19 @@ Window { } Rectangle { color: root.accentColor - Layout.fillHeight: true - width: 10 + Layout.preferredHeight: 600 + width: 3 } ColumnLayout { id: wrapperRight - + spacing: 20 + Layout.preferredWidth: 500 Text { id: txtGPU text: "GPU" color: root.accentColor font.family: root.fontFamily - font.pointSize: 60 + font.pointSize: 36 horizontalAlignment: Text.AlignHCenter } @@ -137,20 +167,13 @@ Window { text: "UPTIME" color: root.accentColor font.family: root.fontFamily - font.pointSize: 60 + font.pointSize: 36 horizontalAlignment: Text.AlignHCenter } RowLayout { id: valuesLayout spacing: 20 - Text { - id: txtYears - text: "YEARS " + sysInfo.uptime.years - color: root.accentColor - font.family: root.fontFamily - font.pointSize: root.fontPointSize - } Text { text: "DAYS " + sysInfo.uptime.days color: root.accentColor @@ -183,13 +206,12 @@ Window { text: "CPU" color: root.accentColor font.family: root.fontFamily - font.pointSize: 60 + font.pointSize: 36 horizontalAlignment: Text.AlignHCenter } - Row { - id: row + RowLayout { spacing: 10 - Layout.fillWidth: true + Layout.preferredWidth: 300 Text { id: txtCPUValue text: Math.floor(sysInfo.cpu.usage) @@ -210,14 +232,10 @@ Window { text: "STORAGE" color: root.accentColor font.family: root.fontFamily - font.pointSize: 60 + font.pointSize: 36 horizontalAlignment: Text.AlignHCenter } - Item { - Layout.fillWidth: true - Layout.preferredHeight: 20 - } ListView { id: storageListView @@ -225,10 +243,12 @@ Window { Layout.preferredHeight: 100 model: sysInfo.storage delegate: Item { - width: storageListView.width + width: 500 height: 40 - Row { + RowLayout { spacing: 10 + width: 500 + Text { id: txtStorageName text: name @@ -240,7 +260,7 @@ Window { from: 0 to: bytesTotal value: bytesAvailable - width: storageListView.width - txtStorageName.width - row.spacing + Layout.fillWidth: true } } } diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/ListPropertyHelper.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/ListPropertyHelper.h index f46d1722..c6832d82 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/ListPropertyHelper.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/ListPropertyHelper.h @@ -5,12 +5,12 @@ #include "HelpersCommon.h" -template -class QQmlSmartListWrapper : public QQmlListProperty { +template +class QQmlSmartListWrapper : public QQmlListProperty { public: - typedef QVector CppListType; - typedef QQmlListProperty QmlListPropertyType; - typedef QQmlSmartListWrapper SmartListWrapperType; + typedef QVector CppListType; + typedef QQmlListProperty QmlListPropertyType; + typedef QQmlSmartListWrapper SmartListWrapperType; typedef typename CppListType::const_iterator const_iterator; @@ -41,12 +41,12 @@ public: static void callbackClear(QmlListPropertyType* prop) { static_cast(prop->data)->clear(); } - static void callbackAppend(QmlListPropertyType* prop, ObjType* obj) + static void callbackAppend(QmlListPropertyType* prop, T* obj) { static_cast(prop->data)->append(obj); } - static ObjType* callbackAt(QmlListPropertyType* prop, qsizetype idx) + static T* callbackAt(QmlListPropertyType* prop, qsizetype idx) { return static_cast(prop->data)->at(idx); } diff --git a/ScreenPlayWeather/qml/TestMain.qml b/ScreenPlayWeather/qml/TestMain.qml index 0aec7f20..d9d7a204 100644 --- a/ScreenPlayWeather/qml/TestMain.qml +++ b/ScreenPlayWeather/qml/TestMain.qml @@ -2,6 +2,8 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl +import Qt5Compat.GraphicalEffects import ScreenPlayWeather Window { @@ -16,8 +18,12 @@ Window { city: "Friedrichshafen" onReady: { rp.model = weather.days + // Qt bug https://bugreports.qt.io/browse/QTBUG-105137 + test() } } + function test() {} + function mapWeatherCode(code) { const weather_time = "" // or "-day", "-night" const weather_prefix = "wi" + weather_time + "-" @@ -62,10 +68,29 @@ Window { return weather_prefix + "storm-showers" } } + Rectangle { + anchors.fill: wrapper + color: Material.backgroundColor + Material.elevation: 5 + radius: 4 + } + + Rectangle { + anchors.fill: wrapper + color: Material.backgroundColor + radius: 4 + + layer.enabled: true + layer.effect: ElevationEffect { + elevation: 4 + } + } ColumnLayout { - anchors.fill: parent - anchors.margins: 20 + id: wrapper + anchors.centerIn: parent + width: implicitWidth + 100 + height: implicitHeight + 100 TextField { Layout.alignment: Qt.AlignCenter horizontalAlignment: Text.AlignHCenter @@ -80,76 +105,87 @@ Window { + "m - population: " + weather.population } + component TextItem: Column { + property alias value: value.text + property alias text: description.text + Layout.preferredWidth: 120 + Text { + id: value + width: 120 + font.pointSize: 16 + horizontalAlignment: Text.AlignHCenter + color: Material.primaryTextColor + } + Text { + id: description + horizontalAlignment: Text.AlignHCenter + color: Material.secondaryTextColor + width: 120 + } + } + RowLayout { Layout.alignment: Qt.AlignHCenter Repeater { id: rp + onModelChanged: print("MODEL CHANGED") onCountChanged: print(count) ColumnLayout { id: cl spacing: 20 - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: day + "\nday" + Layout.preferredWidth: 120 + TextItem { + text: "Day" + value: day } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: dateTime + "\ndateTime" + TextItem { + text: "Sunrise" + value: sunrise } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: sunrise + "\nsunrise" - } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: sunset + "\nsunset" + TextItem { + text: "Sunset" + value: sunset } Image { + height: 64 + width: height + sourceSize: Qt.size(height, height) + layer { + enabled: true + effect: ColorOverlay { + color: Material.primaryColor + } + } Layout.alignment: Qt.AlignCenter horizontalAlignment: Image.AlignHCenter source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode( weatherCode) + ".svg" } + TextItem { + text: "Weather Code" + value: weatherCode + } + TextItem { + text: "Temperature min" + value: temperature_2m_min + } + TextItem { + text: "Temperature max" + value: temperature_2m_max + } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: weatherCode + "\nweatherCode" - } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: temperature_2m_min + "\ntemperature_2m_min" - } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: temperature_2m_max + "\ntemperature_2m_max" - } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: precipitationHours + "\nprecipitationHours" - } - Text { - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - text: precipitationSum + "\nprecipitationSum" - } + // TextItem { + // text: "Precipitation Sum" + // value: precipitationSum + // } + + // TextItem { + // text: "Precipitation Hours" + // value: precipitationHours + // } } } } - Button { - text: "getDay" - onClicked: { - var day = weather.getDay(1) - print("weatherCode:", day.weatherCode, day.precipitationSum) - } - } } } diff --git a/ScreenPlayWeather/src/day.h b/ScreenPlayWeather/src/day.h index 11e8fe8f..a5fa37f7 100644 --- a/ScreenPlayWeather/src/day.h +++ b/ScreenPlayWeather/src/day.h @@ -10,8 +10,8 @@ class Day : public QObject { public: W_PROPERTY(int, day) W_PROPERTY(QDateTime, dateTime) - W_PROPERTY(QDateTime, sunrise) - W_PROPERTY(QDateTime, sunset) + W_PROPERTY(QString, sunrise) + W_PROPERTY(QString, sunset) W_PROPERTY_DEFAULT(int, weatherCode, 0) W_PROPERTY_DEFAULT(float, temperature_2m_min, 0.0f) W_PROPERTY_DEFAULT(float, temperature_2m_max, 0.0f) diff --git a/ScreenPlayWeather/src/screenplayweather.cpp b/ScreenPlayWeather/src/screenplayweather.cpp index e1c61300..54d61778 100644 --- a/ScreenPlayWeather/src/screenplayweather.cpp +++ b/ScreenPlayWeather/src/screenplayweather.cpp @@ -25,7 +25,7 @@ void ScreenPlayWeather::updateLatitudeLongtitude(const QString& city) request.setUrl(url); auto* reply = m_networkAccessManager.get(request); - QObject::connect(reply, &QNetworkReply::readyRead, this, [this, reply]() { + QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { const QByteArray data = reply->readAll(); if (data.size() <= 0) return; @@ -50,7 +50,7 @@ void ScreenPlayWeather::updateLatitudeLongtitude(const QString& city) if (result.contains("population")) setPopulation(result.value("population").toInt()); }); - QObject::connect(reply, &QNetworkReply::finished, this, []() { qInfo() << "finished!"; }); + QObject::connect(reply, &QNetworkReply::finished, this, []() { qInfo() << "updateLatitudeLongtitude finished!"; }); QObject::connect(reply, &QNetworkReply::errorOccurred, this, []() { qInfo() << "errorOccurred!"; }); } @@ -80,7 +80,7 @@ void ScreenPlayWeather::update() qInfo() << url; auto* reply = m_networkAccessManager.get(request); - QObject::connect(reply, &QNetworkReply::readyRead, this, [this, reply]() { + QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { const QByteArray data = reply->readAll(); if (data.size() <= 0) return; @@ -108,9 +108,9 @@ void ScreenPlayWeather::update() for (int i = 0; i < time.size(); ++i) { auto day = new Day(); day->set_day(i); - day->set_sunrise(QDateTime::fromString(sunrise.at(i).toString(), m_dataTimeFormat)); - day->set_sunset(QDateTime::fromString(sunset.at(i).toString(), m_dataTimeFormat)); day->set_dateTime(QDateTime::fromString(time.at(i).toString(), m_dataTimeFormat)); + day->set_sunrise(QDateTime::fromString(sunrise.at(i).toString(), m_dataTimeFormat).toString("mm:ss")); + day->set_sunset(QDateTime::fromString(sunset.at(i).toString(), m_dataTimeFormat).toString("mm:ss")); day->set_weatherCode(weathercode.at(i).toInt()); day->set_temperature_2m_min(ScreenPlayUtil::roundDecimalPlaces(temperature_2m_min.at(i).toDouble())); day->set_temperature_2m_max(ScreenPlayUtil::roundDecimalPlaces(temperature_2m_max.at(i).toDouble())); @@ -121,7 +121,7 @@ void ScreenPlayWeather::update() const auto hourly = msgOpt->value("hourly").toObject(); emit ready(); }); - QObject::connect(reply, &QNetworkReply::finished, this, []() { qInfo() << "finished!"; }); + QObject::connect(reply, &QNetworkReply::errorOccurred, this, []() { qInfo() << "errorOccurred!"; }); } diff --git a/Tools/download_ffmpeg.bat b/Tools/download_ffmpeg.bat deleted file mode 100644 index a662f3e8..00000000 --- a/Tools/download_ffmpeg.bat +++ /dev/null @@ -1,19 +0,0 @@ -cd .. - -rem Download 7-zip -curl.exe -L https://www.7-zip.org/a/7z1900.msi --ssl-no-revoke --output 7z.msi -rem Extract 7z -msiexec /a 7z.msi /qb TARGETDIR="%cd%\7z" - -rem Donwload ffmpeg -curl.exe -L https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z --ssl-no-revoke --output ffmpeg.7z -rem Extract ffmpeg -"%cd%\7z\Files\7-Zip\7z.exe" e -y ffmpeg.7z -o"%cd%\Common\ffmpeg" *.exe *.dll -r - -rem Remove not used ffplay -DEL Common\ffmpeg\ffplay.exe - -rem Deleting FFmpeg temp -DEL ffmpeg.7z -DEL 7z.msi -rmdir 7z /s /q \ No newline at end of file diff --git a/Tools/download_ffmpeg.py b/Tools/download_ffmpeg.py index aac502a9..39d2e736 100644 --- a/Tools/download_ffmpeg.py +++ b/Tools/download_ffmpeg.py @@ -1,42 +1,119 @@ -import zipfile +from fileinput import filename +import pathlib +from zipfile import ZipFile +from pathlib import Path +import py7zr +import platform from urllib.request import urlopen import os +from shutil import move, rmtree +from util import cd_repo_root_path + +FFMPEG_VERSION = "5.0.1" -def download_and_extract(file_base_path, name): - print("Download: ", name) +def download( + download_server_base_url, + extraction_path, + name) -> str: - download_server_base_url = 'https://evermeet.cx/ffmpeg/' - filedata = urlopen(download_server_base_url + name) + url = download_server_base_url + name + print(f"Downloading {name} from: {url}") + filedata = urlopen(url) datatowrite = filedata.read() - path_and_filename = os.path.join(file_base_path, name) + path_and_filename = os.path.join(extraction_path, name) print("Save tmp file: ", path_and_filename) with open(path_and_filename, 'wb') as f: f.write(datatowrite) - extraction_path = os.path.join(file_base_path, "../Common/ffmpeg") + return path_and_filename - print("Extract to:", extraction_path) - with zipfile.ZipFile(path_and_filename,"r") as zip_ref: + +def extract_zip(extraction_path, path_and_filename): + print(f"Extract {path_and_filename} to {extraction_path}") + + with ZipFile(path_and_filename, "r") as zip_ref: zip_ref.extractall(extraction_path) - print("Delete tmp file: ", path_and_filename) - os.remove(path_and_filename) + print(f"Delete tmp file: {path_and_filename}") + os.remove(path_and_filename) -def download_prebuild_ffmpeg(): - ffmpeg_7zip_name = 'ffmpeg-4.4.zip' - ffprobe_7zip_name = 'ffprobe-4.4.zip' - current_path = os.path.join(os.path.abspath(os.getcwd()),"") - extraction_path = os.path.abspath(os.path.join(current_path, "../Common/ffmpeg")) - if not os.path.exists(extraction_path): - os.makedirs(extraction_path) +def extract_zip_executables(extraction_path, path_and_filename): + files = [] + listOfFileNames = [] + with ZipFile(path_and_filename, 'r') as zipObj: + # Get a list of all archived file names from the zip + listOfFileNames = zipObj.namelist() + # Iterate over the file names + for fileName in listOfFileNames: + # Check filename endswith csv + if fileName.endswith('.exe'): + # Extract a single file from zip + zipObj.extract(fileName, extraction_path) + print(f"Extract {fileName} to {extraction_path}") + files.append(fileName) - download_and_extract(current_path, ffmpeg_7zip_name) - download_and_extract(current_path, ffprobe_7zip_name) + for file in files: + abs_file_path = os.path.join(extraction_path, file) + move(abs_file_path, extraction_path) + print(f"Move {abs_file_path} to {extraction_path}") + + print(f"Delete tmp zip file: {path_and_filename}") + os.remove(path_and_filename) + # We need the first folder name of a file: + # ffmpeg-5.0.1-essentials_build/bin/ffmpeg.exe + empty_ffmpeg_folder = os.path.join(extraction_path,os.path.dirname(os.path.dirname(files[0]))) + ffprobe = os.path.join(extraction_path,"ffprobe.exe") + print(f"Delete not needed {ffprobe}") + os.remove(ffprobe) + print(f"Delete empty folder: {empty_ffmpeg_folder}") + rmtree(empty_ffmpeg_folder) + + +def download_prebuild_ffmpeg_mac(extraction_path: str): + + print("Setup ffmpeg mac") + ffmpeg_zip_name = f'ffmpeg-{FFMPEG_VERSION}.zip' + ffprobe_zip_name = f'ffprobe-{FFMPEG_VERSION}.zip' + download_server_base_url = 'https://evermeet.cx/ffmpeg/' + + ffmpeg_path_and_filename = download( + download_server_base_url, extraction_path, ffmpeg_zip_name) + extract_zip(extraction_path, ffmpeg_path_and_filename) + + ffprobe_path_and_filename = download( + download_server_base_url, extraction_path, ffprobe_zip_name) + extract_zip(extraction_path, ffprobe_path_and_filename) + + +def download_prebuild_ffmpeg_windows(extraction_path: str): + + print("Setup ffmpeg Windows") + ffmpeg_shared_7zip_name = "ffmpeg-release-essentials.zip" + download_server_base_url = 'https://www.gyan.dev/ffmpeg/builds/' + + ffmpeg_path_and_filename = download( + download_server_base_url, extraction_path, ffmpeg_shared_7zip_name) + + extract_zip_executables(extraction_path, ffmpeg_path_and_filename) if __name__ == "__main__": - download_prebuild_ffmpeg() + # Make sure the script is always started from the same folder + root_path = cd_repo_root_path() + tools_path = os.path.join(root_path, "Tools") + extraction_path = os.path.join(root_path, "Common/ffmpeg") + + if os.path.exists(extraction_path): + rmtree(extraction_path) + + os.makedirs(extraction_path) + + + if platform.system() == "Windows": + download_prebuild_ffmpeg_windows(extraction_path) + elif platform.os.system() == "Darwin": + download_prebuild_ffmpeg_mac(extraction_path) diff --git a/Tools/install_requirements.py b/Tools/install_requirements.py new file mode 100644 index 00000000..c5478677 --- /dev/null +++ b/Tools/install_requirements.py @@ -0,0 +1,10 @@ +#!/usr/bin/python3 +import os +import sys +import subprocess + + +def install_requirements(): + print("Set up required python modules") + script_path = os.path.dirname(os.path.realpath(__file__)) + subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", script_path + "/requirements.txt"]) diff --git a/Tools/requirements.txt b/Tools/requirements.txt new file mode 100644 index 00000000..d02517e7 --- /dev/null +++ b/Tools/requirements.txt @@ -0,0 +1,3 @@ +pyunpack +py7zr +cmake-format \ No newline at end of file diff --git a/Tools/setup.py b/Tools/setup.py index 16e1bff2..5b5c56b6 100755 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -1,15 +1,17 @@ #!/usr/bin/python3 +from install_requirements import install_requirements + +install_requirements() + import argparse import shutil from platform import system from pathlib import Path from execute_util import execute -from download_ffmpeg import download_prebuild_ffmpeg - -vcpkg_version = "2ac61f8" # Master 23.04.2022 - +import download_ffmpeg +vcpkg_version = "98f8d00e89fb6a8019c2045cfa1edbe9d92d3405" # Master 09.07.2022 class commands_list(): def __init__(self): @@ -80,12 +82,8 @@ without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Q vcpkg_command = "vcpkg.exe" vcpkg_packages_list.append("infoware[d3d]") vcpkg_packages_list.append("sentry-native") - if shutil.which("pwsh"): - print("Using experimental pwsh, may not work properly.") - platform_command.add("pwsh.exe -NoProfile -ExecutionPolicy Bypass .\scripts\\bootstrap.ps1", vcpkg_path) - else: - platform_command.add("bootstrap-vcpkg.bat", vcpkg_path, False) - platform_command.add("download_ffmpeg.bat", project_source_path.joinpath("Tools"), False) + platform_command.add("bootstrap-vcpkg.bat", vcpkg_path, False) + download_ffmpeg.download_prebuild_ffmpeg_windows() vcpkg_triplet = ["x64-windows"] elif system() == "Darwin": vcpkg_command = "./vcpkg" @@ -95,7 +93,7 @@ without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Q platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False) platform_command.add("chmod +x vcpkg", vcpkg_path) vcpkg_triplet = ["x64-osx", "arm64-osx"] - platform_command.add(download_prebuild_ffmpeg) + download_ffmpeg.download_prebuild_ffmpeg_mac() elif system() == "Linux": vcpkg_command = "./vcpkg" #vcpkg_packages_list.append("infoware[opengl]") diff --git a/Tools/util.py b/Tools/util.py index 2961180f..41b7ba26 100644 --- a/Tools/util.py +++ b/Tools/util.py @@ -1,7 +1,8 @@ from pathlib import Path -import os +from pathlib import Path +from os import chdir import subprocess def run(cmd, cwd=Path.cwd()): @@ -9,3 +10,14 @@ def run(cmd, cwd=Path.cwd()): if result.returncode != 0: raise RuntimeError(f"Failed to execute {cmd}") + + +def cd_repo_root_path() -> str: + # Make sure the script is always started from the same + # ScreenPlay root folder + root_path = Path.cwd() + if root_path.name == "Tools": + root_path = root_path.parent + print(f"Change root directory to: {root_path}") + chdir(root_path) + return root_path