1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Merge commit '4334688ba101eda810a3bb963d40aa91a1f4c41d' into 130-add-macos-support

This commit is contained in:
Elias Steurer 2021-05-09 11:26:41 +02:00
commit 6960a419ba
27 changed files with 113 additions and 158 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "Common/qt-google-analytics"]
path = Common/qt-google-analytics
url = https://github.com/HSAnet/qt-google-analytics.git

@ -1 +0,0 @@
Subproject commit c1eda35682b4b4c21a313eb8b4670527bf4a6f09

View File

@ -27,7 +27,6 @@ endif()
set(src
main.cpp
app.cpp
../Common/qt-google-analytics/ganalytics.cpp
src/globalvariables.cpp
src/createimportvideo.cpp
src/installedlistmodel.cpp
@ -46,7 +45,6 @@ set(src
set(headers
app.h
../Common/qt-google-analytics/ganalytics.h
src/globalvariables.h
src/createimportvideo.h
src/installedlistmodel.h

View File

@ -54,7 +54,7 @@ App::App()
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("https://screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.13.1");
QGuiApplication::setApplicationVersion("0.13.2");
QGuiApplication::setQuitOnLastWindowClosed(false);
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
@ -128,7 +128,6 @@ App::App()
// ScreenPlayManager first to check if another ScreenPlay Instace is running
m_screenPlayManager = std::make_unique<ScreenPlayManager>();
m_isAnotherScreenPlayInstanceRunning = m_screenPlayManager->isAnotherScreenPlayInstanceRunning();
Util::appendToMetricsFile("screenplay_app_constructor", m_continuousIntegrationMetricsTimer.msecsSinceReference());
}
/*!
@ -140,8 +139,6 @@ App::App()
void App::init()
{
Util::appendToMetricsFile("screenplay_app_init", m_continuousIntegrationMetricsTimer.msecsSinceReference());
using std::make_shared, std::make_unique;
// Util should be created as first so we redirect qDebugs etc. into the log
@ -154,13 +151,8 @@ void App::init()
m_settings = make_shared<Settings>(m_globalVariables);
m_mainWindowEngine = make_unique<QQmlApplicationEngine>();
// Only create tracker if user did not disallow!
// Only create anonymousTelemetry if user did not disallow!
if (m_settings->anonymousTelemetry()) {
m_telemetry = make_shared<GAnalytics>("UA-152830367-3");
m_telemetry->setNetworkAccessManager(&m_networkAccessManager);
m_telemetry->setSendInterval(1000);
m_telemetry->startSession();
m_telemetry->sendEvent("version", QApplication::applicationVersion());
#ifdef Q_OS_WIN
sentry_options_t* options = sentry_options_new();
@ -199,12 +191,10 @@ void App::init()
}
qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "ScreenPlay", this);
Util::appendToMetricsFile("Screenplay_app_qqmlapplicationengine_load_begin", m_continuousIntegrationMetricsTimer.msecsSinceReference());
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
Util::appendToMetricsFile("Screenplay_app_qqmlapplicationengine_load_end", m_continuousIntegrationMetricsTimer.msecsSinceReference());
// Must be called last to display a error message on startup by the qml engine
m_screenPlayManager->init(m_globalVariables, m_monitorListModel, m_telemetry, m_settings);
m_screenPlayManager->init(m_globalVariables, m_monitorListModel, m_settings);
QObject::connect(m_monitorListModel.get(), &MonitorListModel::monitorConfigurationChanged, m_screenPlayManager.get(), &ScreenPlayManager::removeAllWallpapers);
}
@ -214,19 +204,12 @@ QString App::version() const
}
/*!
\brief Tries to send the telemetry quit event before we call quit ourself.
\brief Calls QApplication quit() and can be used to do additional
tasks before exiting.
*/
void App::exit()
{
if (!m_telemetry) {
QApplication::instance()->quit();
return;
} else {
// Workaround because we cannot force to send exit event
m_telemetry->setSendInterval(5);
m_telemetry->endSession();
QTimer::singleShot(150, this, []() { QApplication::instance()->quit(); });
}
QApplication::instance()->quit();
}
/*!

View File

@ -49,7 +49,6 @@
#include <QtWebEngine>
#include <QtSvg>
#include "ganalytics.h"
#include "src/create.h"
#include "src/globalvariables.h"
#include "src/installedlistfilter.h"
@ -123,12 +122,6 @@ public slots:
void exit();
bool loadSteamPlugin();
bool unloadSteamPlugin();
void setTrackerSendEvent(const QString& category, const QString& page)
{
if (m_telemetry) {
m_telemetry->sendEvent(category, page);
}
}
void setGlobalVariables(GlobalVariables* globalVariables)
{
@ -238,7 +231,6 @@ private:
std::unique_ptr<ScreenPlayManager> m_screenPlayManager;
std::unique_ptr<Util> m_util;
std::shared_ptr<GAnalytics> m_telemetry;
std::shared_ptr<GlobalVariables> m_globalVariables;
std::shared_ptr<Settings> m_settings;

View File

@ -51,18 +51,6 @@ int main(int argc, char* argv[])
QApplication qtGuiApp(argc, argv);
// Benchmarks
if (QGuiApplication::arguments().contains("--benchmark")) {
QFile metricsFile { QGuiApplication::applicationDirPath() + "/metrics.txt" };
if (metricsFile.exists())
qInfo() << "Removing old Continuous Integration Metrics Timer: " << metricsFile.remove();
QTimer::singleShot(10000, []() {
qInfo() << "Exit ScreenPlay benchmark mode!";
QGuiApplication::quit();
});
}
// Unit tests
doctest::Context context;
context.setOption("abort-after", 5); // stop test execution after 5 failed assertions

View File

@ -43,9 +43,6 @@ ApplicationWindow {
if (!ScreenPlay.settings.silentStart) {
window.show()
ScreenPlay.setTrackerSendEvent("navigation", "Installed")
} else {
ScreenPlay.setTrackerSendEvent("navigation", "Silent")
}
}

View File

@ -16,7 +16,7 @@ Item {
id: txtHeadline
text: headline
height: 20
font.pointSize: 10
font.pointSize: 14
font.family: ScreenPlay.settings.font
color: QQCM.Material.primaryTextColor
@ -31,6 +31,7 @@ Item {
spacing: 30
anchors {
top: txtHeadline.bottom
right: parent.right
bottom: parent.bottom
left: parent.left

View File

@ -32,29 +32,29 @@ Item {
CommunityNavItem {
text: qsTr("News")
openLink: webModel.get(0).url
openLink: "https://screen-play.app/blog/"
icon.source: "qrc:/assets/icons/icon_document.svg"
}
CommunityNavItem {
text: qsTr("Wiki")
openLink: webModel.get(1).url
openLink: "https://kelteseth.gitlab.io/ScreenPlayDocs/"
icon.source: "qrc:/assets/icons/icon_help_center.svg"
}
CommunityNavItem {
text: qsTr("Forum")
openLink: webModel.get(2).url
openLink: "https://forum.screen-play.app/"
icon.source: "qrc:/assets/icons/icon_forum.svg"
}
CommunityNavItem {
text: qsTr("Issue List")
openLink: webModel.get(3).url
openLink: "https://gitlab.com/kelteseth/ScreenPlay/-/issues"
icon.source: "qrc:/assets/icons/icon_report_problem.svg"
}
CommunityNavItem {
text: qsTr("Contribute")
openLink: webModel.get(4).url
openLink: "https://gitlab.com/kelteseth/ScreenPlay#general-contributing"
icon.source: "qrc:/assets/icons/icon_supervisor_account.svg"
}
CommunityNavItem {
@ -134,7 +134,7 @@ Item {
Timer {
id: timer
interval: 200
onTriggered: webView.url = webModel.get(index).url
onTriggered: webView.url = webModel.get(index +1).url
}
WebEngineView {

View File

@ -41,47 +41,51 @@ Item {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.family: ScreenPlay.settings.font
}
Text {
id: txtComboboxHeadline
text: qsTr("Set your preffered video codec:")
color: Material.secondaryTextColor
width: parent.width
font.pointSize: 14
font.family: ScreenPlay.settings.font
}
ComboBox {
id: comboBoxCodec
Layout.preferredWidth: 400
textRole: "text"
valueRole: "value"
currentIndex: 1
font.family: ScreenPlay.settings.font
model: ListModel {
id: model
ListElement {
text: "VP8 (Better for older hardware)"
value: Create.VP9
ColumnLayout {
spacing: 20
Text {
id: txtComboboxHeadline
text: qsTr("Set your preffered video codec:")
color: Material.primaryTextColor
width: parent.width
font.pointSize: 14
font.family: ScreenPlay.settings.font
}
ComboBox {
id: comboBoxCodec
Layout.preferredWidth: 400
textRole: "text"
valueRole: "value"
currentIndex: 1
font.family: ScreenPlay.settings.font
model: ListModel {
id: model
ListElement {
text: "VP8 (Better for older hardware)"
value: Create.VP9
}
ListElement {
text: "VP9 (Better for newer hardware 2018+)"
value: Create.VP8
}
// Import works but the QWebEngine cannot display AV1 :(
// ListElement {
// text: "AV1 (NVidia 3000, AMD 6000 or newer). ULTRA SLOW ENCODING!"
// value: Create.AV1
// }
}
ListElement {
text: "VP9 (Better for newer hardware 2018+)"
value: Create.VP8
}
// Import works but the QWebEngine cannot display AV1 :(
// ListElement {
// text: "AV1 (NVidia 3000, AMD 6000 or newer). ULTRA SLOW ENCODING!"
// value: Create.AV1
// }
}
}
Common.Slider {
id: sliderQuality
iconSource: "qrc:/assets/icons/icon_settings.svg"
headline: qsTr(
"Quality slider. Greater value means better quality.")
headline: qsTr("Quality slider. Lower value means better quality.")
slider {
from: 4
value: 50
to: 63
from: 63
value: 22
to: 0
stepSize: 1
}
Layout.preferredWidth: 400

View File

@ -95,7 +95,6 @@ Item {
margins: 10
}
onClicked: {
ScreenPlay.setTrackerSendEvent("createWallpaperError",txtFFMPEGDebug.text);
ScreenPlay.util.setNavigationActive(true)
ScreenPlay.util.setNavigation("Create")
}

View File

@ -89,7 +89,6 @@ Item {
busyIndicator.running = false
root.checkCanSave()
ScreenPlay.setTrackerSendEvent("createWallpaperSuccessful", "")
break
}
}

View File

@ -88,7 +88,6 @@ Item {
busyIndicator.running = false
root.checkCanSave()
ScreenPlay.setTrackerSendEvent("createWallpaperSuccessful", "")
break
}
}

View File

@ -61,8 +61,6 @@ Rectangle {
function onPageChanged(name) {
ScreenPlay.setTrackerSendEvent("navigation", name)
if (!navActive)
return

View File

@ -27,8 +27,6 @@ Item {
target: ScreenPlay.screenPlayManager
function onActiveWallpaperCounterChanged() {
rippleEffect.trigger()
ScreenPlay.setTrackerSendEvent("navigation",
"wallpaperConfiguration")
}
}

View File

@ -6,7 +6,6 @@ import QtGraphicalEffects 1.0
import QtQuick.Controls.Material.impl 2.12
import ScreenPlay.Workshop 1.0
import ScreenPlay.Workshop.SteamEnums 1.0
import SteamQMLImageProvider 1.0
import ScreenPlay 1.0

View File

@ -38,15 +38,14 @@ Item {
Component.onCompleted: {
if (steamWorkshop.online) {
steamWorkshop.workshopListModel.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend)
} else {
popupOffline.open()
}
}
Connections {
target: steamWorkshop.workshopListModel
target: steamWorkshop
function onWorkshopSearched() {
bannerTxt.text = steamWorkshop.workshopListModel.getBannerText()
background.backgroundImage = steamWorkshop.workshopListModel.getBannerUrl()
@ -130,7 +129,7 @@ Item {
Item {
id: header
height: 440
height: 350
anchors {
top: parent.top
topMargin: nav.height
@ -258,7 +257,7 @@ Item {
}
header: Item {
height: 70
height: 80
width: gridView.width - gridView.anchors.leftMargin
property alias searchField: tiSearch
@ -266,7 +265,7 @@ Item {
color: Material.backgroundColor
radius: 3
width: parent.width - 10
height: parent.height
height: 70
anchors.centerIn: parent
Item {
@ -279,7 +278,6 @@ Item {
leftMargin: 10
}
TextField {
id: tiSearch
anchors {
@ -289,14 +287,14 @@ Item {
left: parent.left
leftMargin: 10
}
leftPadding:25
selectByMouse:true
leftPadding: 25
selectByMouse: true
placeholderText: qsTr("Search for Wallpaper and Widgets...")
onTextChanged: timerSearch.restart()
Timer {
id: timerSearch
interval: 500
onTriggered: steamWorkshop.workshopListModel.searchWorkshopByText(
onTriggered: steamWorkshop.searchWorkshopByText(
tiSearch.text)
}
}
@ -305,22 +303,25 @@ Item {
source: "qrc:/assets/icons/icon_search.svg"
width: 14
height: width
sourceSize: Qt.size(width,width)
sourceSize: Qt.size(width, width)
anchors {
left: parent.left
leftMargin: 15
verticalCenter: parent.verticalCenter
bottom: parent.bottom
bottomMargin: 22
}
}
ToolButton {
id:tb
id: tb
enabled: tiSearch.text !== ""
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
bottom: parent.bottom
bottomMargin: 10
}
text: "X"
icon.source: "qrc:/assets/icons/font-awsome/close.svg"
onClicked: tiSearch.text = ""
}
}
@ -378,7 +379,7 @@ Item {
Layout.preferredHeight: searchWrapper.height
font.family: ScreenPlay.settings.font
onActivated: {
steamWorkshop.workshopListModel.searchWorkshop(
steamWorkshop.searchWorkshop(
cbQuerySort.currentValue)
}
model: [{
@ -453,7 +454,7 @@ Item {
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(
steamWorkshop.workshopListModel.currentPage - 1)
steamWorkshop.workshopListModel.searchWorkshop(
steamWorkshop.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}
@ -474,7 +475,7 @@ Item {
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(
steamWorkshop.workshopListModel.currentPage + 1)
steamWorkshop.workshopListModel.searchWorkshop(
steamWorkshop.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}

View File

@ -128,7 +128,6 @@ Popup {
id: btnAbort
text: qsTr("Abort")
onClicked: {
steamWorkshop.uploadListModel.clear()
wrapper.requestClosePopup()
}
@ -147,7 +146,6 @@ Popup {
anchors {
right: parent.right
bottom: parent.bottom
margins: 10
}
@ -202,8 +200,7 @@ Popup {
id: btnFinish
text: qsTr("Finish")
onClicked: {
steamWorkshop.uploadListModel.clear()
wrapper.requestClosePopup()
root.close()
}
highlighted: true
enabled: false

View File

@ -35,10 +35,13 @@ Page {
onSteamStatusChanged: {
let errorText
switch (steamStatus) {
// Everyting that is not OK is a fail. See steam_qt_enums_generated.h
case SteamEnums.K_EResultNone:
root.contentItem.state = "uploadComplete"
return
// Everyting that is not OK is a fail. See steam_qt_enums_generated.h
case SteamEnums.K_EResultOK:
root.contentItem.state = "uploadComplete"
return
case SteamEnums.K_EResultFail:
errorText = qsTr("Fail")
break
@ -461,7 +464,7 @@ Page {
Layout.fillWidth: true
Text {
text: qsTr("Upload Progress: ") + " " + Math.ceil(
root.progress * 100) + "%"
root.progress) + "%"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
@ -475,6 +478,7 @@ Page {
id: progressBar
Layout.fillWidth: true
value: root.progress
to: 100
}
}
}

View File

@ -609,6 +609,15 @@ bool CreateImportVideo::createWallpaperVideo()
if (m_codec == "av1")
args.append("libaom-av1");
args.append("-b:v");
args.append("3000k");
args.append("-threads");
args.append(QString::number(QThread::idealThreadCount()));
qInfo() << "threads" << QThread::idealThreadCount() << "m_quality" << m_quality;
args.append("-speed");
args.append("4");
args.append("-tile-columns");
args.append("0");
args.append("-frame-parallel");
args.append("0");
args.append("-crf");
args.append(QString::number(m_quality));
@ -643,7 +652,19 @@ bool CreateImportVideo::createWallpaperVideo()
if (m_codec == "av1")
args.append("libaom-av1");
args.append("-b:v");
args.append("3000k");
args.append("-threads");
args.append(QString::number(QThread::idealThreadCount()));
args.append("-speed");
args.append("0");
args.append("-tile-columns");
args.append("0");
args.append("-frame-parallel");
args.append("0");
args.append("-auto-alt-ref");
args.append("1");
args.append("-lag-in-frames");
args.append("25");
args.append("-crf");
args.append(QString::number(m_quality));
args.append("-pass");

View File

@ -59,7 +59,7 @@ public:
/*!
\brief We need to check if there was an error in the Wallpaper/Widgets.
For this we ping it every 1s.
For this we ping it every 3s.
*/
static const int contentPingAliveIntervalMS = 3000;

View File

@ -161,8 +161,12 @@ void InstalledListModel::loadInstalledContent()
int counter = 0;
for (const auto& item : list) {
const QString absoluteFilePath = m_globalVariables->localStoragePath().toLocalFile() + "/" + item.baseName() + "/project.json";
if (auto obj = ScreenPlayUtil::openJsonFileToObject(m_globalVariables->localStoragePath().toLocalFile() + "/" + item.baseName() + "/project.json")) {
if (!QFile::exists(absoluteFilePath))
continue;
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absoluteFilePath)) {
if (obj->isEmpty())
continue;

View File

@ -75,12 +75,10 @@ bool ScreenPlayManager::checkIsAnotherScreenPlayInstanceRunning()
void ScreenPlayManager::init(
const std::shared_ptr<GlobalVariables>& globalVariables,
const std::shared_ptr<MonitorListModel>& mlm,
const std::shared_ptr<GAnalytics>& telemetry,
const std::shared_ptr<Settings>& settings)
{
m_globalVariables = globalVariables;
m_monitorListModel = mlm;
m_telemetry = telemetry;
m_settings = settings;
if (m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE) {
@ -120,10 +118,6 @@ bool ScreenPlayManager::createWallpaper(
}
});
if (m_telemetry) {
m_telemetry->sendEvent("wallpaper", "start");
}
QJsonArray monitors;
for (const int index : monitorIndex) {
monitors.append(index);

View File

@ -41,7 +41,6 @@
#include <QtWebSockets/QWebSocket>
#include "ScreenPlayUtil/projectfile.h"
#include "ganalytics.h"
#include "globalvariables.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
@ -69,7 +68,6 @@ public:
void init(
const std::shared_ptr<GlobalVariables>& globalVariables,
const std::shared_ptr<MonitorListModel>& mlm,
const std::shared_ptr<GAnalytics>& telemetry,
const std::shared_ptr<Settings>& settings);
int activeWallpaperCounter() const { return m_activeWallpaperCounter; }
@ -181,7 +179,6 @@ private:
private:
std::shared_ptr<GlobalVariables> m_globalVariables;
std::shared_ptr<MonitorListModel> m_monitorListModel;
std::shared_ptr<GAnalytics> m_telemetry;
std::shared_ptr<Settings> m_settings;
std::unique_ptr<QLocalServer> m_server;
std::unique_ptr<QWebSocketServer> m_websocketServer;

View File

@ -70,27 +70,6 @@ bool Util::writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObj
return true;
}
void Util::appendToMetricsFile(const QString& key, const QVariant& value)
{
if (!QGuiApplication::arguments().contains("--benchmark"))
return;
const QString appDir = QGuiApplication::applicationDirPath();
QFile metricsFile { appDir + "/metrics.txt" };
if (!metricsFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
qWarning() << "Cannot open metrix file:" << appDir << metricsFile.fileName();
return;
}
QString text = key + "\t" + value.toString() + "\n";
QTextStream out(&metricsFile);
out << text;
metricsFile.flush();
metricsFile.close();
}
/*!
\brief Opens a native folder window on the given path. Windows and Mac only for now!
*/
@ -116,6 +95,11 @@ void Util::openFolderInExplorer(const QString& url) const
explorer.startDetached();
}
QString Util::toLocal(const QString& url)
{
return ScreenPlayUtil::toLocal(url);
}
/*!
\brief Loads all content of the legal folder in the qrc into a property string of this class.
allLicenseLoaded is emited when loading is finished.

View File

@ -54,6 +54,7 @@
#include <qqml.h>
#include "globalvariables.h"
#include "ScreenPlayUtil/util.h"
#include <fstream>
#include <iostream>
@ -101,11 +102,11 @@ signals:
public slots:
void copyToClipboard(const QString& text) const;
void openFolderInExplorer(const QString& url) const;
QString toLocal(const QString& url);
void requestAllLicenses();
void requestDataProtection();
static void appendToMetricsFile(const QString& key, const QVariant& value);
static void logToGui(QtMsgType type, const QMessageLogContext& context, const QString& msg);
static bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate = true);
static bool writeSettings(const QJsonObject& obj, const QString& absolutePath);

View File

@ -65,6 +65,7 @@ std::optional<QString> openJsonFileToString(const QString& path)
QFile file;
file.setFileName(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning() << "Unable to open file: " << path << file.errorString();
return std::nullopt;
}
QString fileContent = file.readAll();