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

Merge branch 'qt6-libarchive' into qt6-kde

This commit is contained in:
Graphicscore 2021-10-23 16:31:20 +02:00
commit c271e80516
13 changed files with 116 additions and 99 deletions

View File

@ -32,7 +32,7 @@ py setup.py
Append this:
``` bash
CMAKE_TOOLCHAIN_FILE:STRING=%{CurrentProject:Path}/../ScreenPlay-vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake
CMAKE_TOOLCHAIN_FILE:STRING=%{CurrentProject:Path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake
# Only _one_ of these lines that match your OS:
VCPKG_TARGET_TRIPLET:STRING=x64-windows
VCPKG_TARGET_TRIPLET:STRING=x64-linux
@ -68,7 +68,7 @@ VCPKG_TARGET_TRIPLET:STRING=x64-osx
1. Install dependencies for your distro:
``` bash
# Debian/Ubuntu
sudo apt install build-essential libgl1-mesa-dev lld ninja-build cmake
sudo apt install build-essential libgl1-mesa-dev lld ninja-build cmake git curl pkg-config ffmpeg qml-module-qt-websockets qtwebengine5-*
# Fedora/RHEL/CentOS (yum)
sudo yum groupinstall "C Development Tools and Libraries"

View File

@ -185,7 +185,9 @@ qt_add_big_resources(FONTS fonts.qrc)
add_library(ScreenPlayLib ${SOURCES} ${HEADER} ${RESOURCES} ${FONTS})
target_include_directories(ScreenPlayLib PUBLIC ./ src/)
target_include_directories(ScreenPlayLib PUBLIC ./ src/ ${LibArchive_INCLUDE_DIRS})
find_package(LibArchive REQUIRED)
target_link_libraries(
ScreenPlayLib
@ -203,7 +205,8 @@ target_link_libraries(
Qt6::WebSockets
Qt6::Svg
Qt6::WebEngineQuick
Qt6::WebEngineCore)
Qt6::WebEngineCore
${LibArchive_LIBRARIES})
if(${TESTS_ENABLED})
add_executable(tst_ScreenPlay tests/tst_main.cpp)

View File

@ -53,8 +53,15 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex
void CreateImportVideo::setupFFMPEG()
{
#ifdef Q_OS_LINUX
// Use system ffmpeg
m_ffprobeExecutable = "ffprobe";
m_ffmpegExecutable = "ffmpeg";
#else
m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableBinEnding();
m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableBinEnding();
#endif
if (!QFileInfo::exists(m_ffprobeExecutable)) {
qFatal("FFPROBE executable not found!");
@ -126,10 +133,9 @@ bool CreateImportVideo::createWallpaperInfo()
}
if (obj->empty()) {
qWarning() << "Error! File could not be parsed.";
qCritical() << "Error! File could not be parsed.";
emit processOutput("Error! File could not be parsed.");
emit createWallpaperStateChanged(ImportVideoState::ImportVideoState::AnalyseVideoError);
return false;
}

View File

@ -87,6 +87,18 @@ void ScreenPlayManager::init(
QObject::connect(m_websocketServer.get(), &QWebSocketServer::newConnection, this, [this]() {
qInfo() << "New Websocket Connection";
auto* socket = m_websocketServer->nextPendingConnection();
QObject::connect(socket, &QWebSocket::textMessageReceived, this, [this](const QString &message) {
qInfo() << "Message:" << message;
});
QObject::connect(socket, &QWebSocket::disconnected, this, [this,socket]() {
m_connections.removeOne(socket);
qInfo() << "Disconnected connection count: " << m_connections.count();
});
m_connections.push_back(socket);
socket->sendTextMessage("asdasd");
socket->flush();
});
}
@ -137,6 +149,22 @@ bool ScreenPlayManager::createWallpaper(
const QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile();
const QString appID = ScreenPlayUtil::generateRandomString();
if(m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE){
if(m_connections.empty())
return false;
QJsonObject msg;
msg.insert("command", "replace");
msg.insert("absolutePath", path);
msg.insert("type", static_cast<int>(type));
msg.insert("fillMode", static_cast<int>(fillMode));
msg.insert("volume", volume);
msg.insert("file", file);
m_connections.first()->sendTextMessage(QJsonDocument(msg).toJson());
m_connections.first()->flush();
}
// Only support remove wallpaper that spans over 1 monitor
if (monitorIndex.length() == 1) {
int i = 0;
@ -172,14 +200,16 @@ bool ScreenPlayManager::createWallpaper(
fillMode,
type,
properties,
m_settings->checkWallpaperVisible());
m_settings);
QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestSave, this, &ScreenPlayManager::requestSaveProfiles);
QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestClose, this, &ScreenPlayManager::removeWallpaper);
QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::error, this, &ScreenPlayManager::displayErrorPopup);
if (!wallpaper->start()) {
return false;
}
if(m_settings->desktopEnvironment() != Settings::DesktopEnvironment::KDE){
if (!wallpaper->start()) {
return false;
}
}
m_screenPlayWallpapers.append(wallpaper);
m_monitorListModel->setWallpaperMonitor(wallpaper, monitorIndex);
increaseActiveWallpaperCounter();

View File

@ -182,6 +182,7 @@ private:
std::shared_ptr<Settings> m_settings;
std::unique_ptr<QLocalServer> m_server;
std::unique_ptr<QWebSocketServer> m_websocketServer;
QVector<QWebSocket*> m_connections;
QVector<std::shared_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;
QVector<std::shared_ptr<ScreenPlayWidget>> m_screenPlayWidgets;

View File

@ -24,7 +24,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
const FillMode::FillMode fillMode,
const InstalledType::InstalledType type,
const QJsonObject& properties,
const bool checkWallpaperVisible,
const std::shared_ptr<Settings>& settings,
QObject* parent)
: QObject(parent)
, m_globalVariables { globalVariables }
@ -37,6 +37,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
, m_file { file }
, m_volume { volume }
, m_playbackRate { playbackRate }
, m_settings { settings }
{
QJsonObject projectSettingsListModelProperties;
@ -81,7 +82,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
QString::number(static_cast<double>(volume)),
QVariant::fromValue(fillMode).toString(),
QVariant::fromValue(type).toString(),
QString::number(checkWallpaperVisible),
QString::number(m_settings->checkWallpaperVisible()),
// Fixes issue 84 media key overlay
" --disable-features=HardwareMediaKeyHandling"
};

View File

@ -45,6 +45,7 @@
#include "projectsettingslistmodel.h"
#include "sdkconnection.h"
#include "util.h"
#include "settings.h"
namespace ScreenPlay {
@ -76,12 +77,15 @@ public:
const QString& absolutePath,
const QString& previewImage,
const QString& file,
const float volume, const float playbackRate,
const float volume,
const float playbackRate,
const FillMode::FillMode fillMode,
const InstalledType::InstalledType type, const QJsonObject& properties,
const bool checkWallpaperVisible,
const InstalledType::InstalledType type,
const QJsonObject& properties,
const std::shared_ptr<Settings>& settings,
QObject* parent = nullptr);
bool start();
void replace(
@ -228,6 +232,7 @@ public slots:
private:
const std::shared_ptr<GlobalVariables> m_globalVariables;
std::unique_ptr<SDKConnection> m_connection;
const std::shared_ptr<Settings> m_settings;
ProjectSettingsListModel m_projectSettingsListModel;
QVector<int> m_screenNumber;

View File

@ -6,6 +6,8 @@ Will not work because KDE uses the kpluginindex.json (that is actually a bz2 fil
#### Installation
```
sudo apt install qml-module-qt-websockets qtwebengine5-*
plasmapkg2 --install ScreenPlay
```
@ -21,3 +23,6 @@ Because Wallpaper and Widgets are already a different application we can extend
1. Open Desktop Settings
- Select Wallpaper type ScreenPlay
```
plasmapkg2 --upgrade ScreenPlay ; kquitapp5 plasmashell; kstart5 plasmashell
```

View File

@ -1,13 +1,14 @@
import QtQuick
import QtQuick.Controls as QQC
import QtQuick.Window
import Qt5Compat.GraphicalEffects
import QtQuick 2.11
import QtQuick.Controls 2.4 as QQC
import QtQuick.Window 2.0
import QtGraphicalEffects 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
import org.kde.kcm 1.1 as KCM
import org.kde.kirigami 2.4 as Kirigami
import org.kde.newstuff 1.1 as NewStuff
Column {
id: root

View File

@ -1,11 +1,13 @@
import QtQuick
import Qt5Compat.GraphicalEffects
import QtQuick.Window
import QtQuick 2.11
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtQuick.Window 2.15
import Qt.WebSockets 1.15
import QtWebEngine
import QtWebEngine 1.8
Rectangle {
id: root
color: "orange"
property string fullContentPath
property real volume: 1
@ -15,28 +17,25 @@ Rectangle {
function getSetVideoCommand() {
// TODO 30:
// Currently wont work. Commit anyways til QtCreator and Qt work with js template literals
var src = "";
src += "var videoPlayer = document.getElementById('videoPlayer');";
src += "var videoSource = document.getElementById('videoSource');";
src += "videoSource.src = '" + root.fullContentPath + "';";
src += "videoPlayer.load();";
src += "videoPlayer.volume = " + root.volume + ";";
src += "videoPlayer.setAttribute('style', 'object-fit :" + root.fillMode + ";');";
src += "videoPlayer.play();";
print(src);
return src;
var src = ""
src += "var videoPlayer = document.getElementById('videoPlayer');"
src += "var videoSource = document.getElementById('videoSource');"
src += "videoSource.src = '" + root.fullContentPath + "';"
src += "videoPlayer.load();"
src += "videoPlayer.volume = " + root.volume + ";"
src += "videoPlayer.setAttribute('style', 'object-fit :" + root.fillMode + ";');"
src += "videoPlayer.play();"
return src
}
color: "#333333"
Component.onCompleted: {
WebEngine.settings.localContentCanAccessFileUrls = true;
WebEngine.settings.localContentCanAccessRemoteUrls = true;
WebEngine.settings.allowRunningInsecureContent = true;
WebEngine.settings.accelerated2dCanvasEnabled = true;
WebEngine.settings.javascriptCanOpenWindows = false;
WebEngine.settings.showScrollBars = false;
WebEngine.settings.playbackRequiresUserGesture = false;
WebEngine.settings.focusOnNavigationEnabled = true;
WebEngine.settings.localContentCanAccessFileUrls = true
WebEngine.settings.localContentCanAccessRemoteUrls = true
WebEngine.settings.allowRunningInsecureContent = true
WebEngine.settings.accelerated2dCanvasEnabled = true
WebEngine.settings.javascriptCanOpenWindows = false
WebEngine.settings.showScrollBars = false
WebEngine.settings.playbackRequiresUserGesture = false
WebEngine.settings.focusOnNavigationEnabled = true
}
WebSocket {
@ -45,21 +44,25 @@ Rectangle {
url: "ws://127.0.0.1:16395"
active: true
onStatusChanged: {
if (socket.status === WebSocket.Error)
messageBox.text = "Error: " + socket.errorString;
else if (socket.status === WebSocket.Open)
socket.sendTextMessage("Hello World");
else if (socket.status === WebSocket.Closed)
messageBox.text += "Socket closed";
if (socket.status === WebSocket.Open)
socket.sendTextMessage("Hello World from QML wallpaper")
}
onTextMessageReceived: {
var obj = JSON.parse(message);
socket.sendTextMessage(message)
print(message)
var obj = JSON.parse(message)
if (obj.command === "replace") {
root.type = obj.type;
root.fillMode = obj.fillMode;
root.volume = obj.volume;
root.fullContentPath = obj.absolutePath + "/" + obj.file;
webView.setVideo();
socket.sendTextMessage("replace")
root.type = obj.type
//root.fillMode = obj.fillMode
root.volume = obj.volume
root.fullContentPath = obj.absolutePath + "/" + obj.file
const msg = "JSON: " +root.type + root.fillMode + root.volume + root.fullContentPath;
socket.sendTextMessage(root.getSetVideoCommand())
webView.setVideo()
}
}
}
@ -70,31 +73,8 @@ Rectangle {
function setVideo() {
webView.runJavaScript(root.getSetVideoCommand());
}
url:"index.html"
anchors.fill: parent
opacity: loadProgress === 100 ? 1 : 0
onLoadProgressChanged: {
if (loadProgress === 100)
setVideo();
}
}
Rectangle {
id: infoWrapper
width: 300
height: 200
opacity: 0
anchors.centerIn: parent
Text {
id: messageBox
text: qsTr("text")
anchors.centerIn: parent
}
}
}

View File

@ -46,24 +46,9 @@ LinuxWindow::LinuxWindow(
setHeight(m_window.height());
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.rootContext()->setContextProperty("window", this);
//m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
qmlRegisterSingletonInstance<LinuxWindow>("ScreenPlayWallpaper", 1, 0, "Wallpaper", this);
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setSource(QUrl("qrc:/mainWindow.qml"));
// WARNING: Setting Window flags must be called *here*!
Qt::WindowFlags flags = m_window.flags();
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop);
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.rootContext()->setContextProperty("window", this);
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setSource(QUrl("qrc:/Wallpaper.qml"));
m_window.setSource(QUrl("qrc:/ScreenPlayWallpaper/qml/Wallpaper.qml"));
}
void LinuxWindow::setupWallpaperForOneScreen(int activeScreen)

View File

@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 20)
find_package(
Qt6
COMPONENTS Quick QML Widgets Gui
COMPONENTS Quick Widgets Gui
REQUIRED)
set(SOURCES
@ -99,6 +99,5 @@ else()
if(${SCREENPLAY_STEAM})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/steam_appid.txt COPYONLY)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${WORKSHOP_PLUGIN_DIR}/qmldir COPYONLY)
configure_file(${STEAM_BIN} ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endif()

View File

@ -31,7 +31,7 @@ if __name__ == "__main__":
vcpkg_path = os.path.join(project_source_parent_path, "ScreenPlay-vcpkg")
print("vcpkg_path: ", vcpkg_path)
vcpkg_version = "9172179c513aa84308e48b8dd0e3df90acec7204" # Master 25.06.2021
vcpkg_version = "c1bd850c629977b98b71bd7a6ab6b7949a5f07e6" # Master 25.06.2021
print("Build vcpkg ", vcpkg_version)
execute("git fetch", vcpkg_path)
execute("git checkout {}".format(vcpkg_version), vcpkg_path)
@ -42,6 +42,7 @@ if __name__ == "__main__":
"sentry-native",
"doctest",
"benchmark",
"libarchive",
]
vcpkg_triplet = ""