mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-10-06 09:17:07 +02:00
Add basic kde setup
This commit is contained in:
parent
a270fac447
commit
12053d9531
@ -1,7 +1,7 @@
|
||||
stages:
|
||||
- check
|
||||
- build
|
||||
- release
|
||||
- check
|
||||
- test
|
||||
|
||||
variables:
|
||||
|
@ -213,6 +213,7 @@ void App::init()
|
||||
QGuiApplication::instance()->addLibraryPath(QGuiApplication::instance()->applicationDirPath());
|
||||
|
||||
if (m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE) {
|
||||
|
||||
setupKDE();
|
||||
}
|
||||
|
||||
@ -237,72 +238,110 @@ void App::exit()
|
||||
QApplication::instance()->quit();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
*/
|
||||
bool App::setupKDE()
|
||||
bool App::isKDEInstalled()
|
||||
{
|
||||
QProcessEnvironment env;
|
||||
qInfo() << qgetenv("KDE_FULL_SESSION");
|
||||
qInfo() << qgetenv("DESKTOP_SESSION");
|
||||
qInfo() << qgetenv("XDG_CURRENT_DESKTOP");
|
||||
|
||||
QProcess plasmaShellVersionProcess;
|
||||
plasmaShellVersionProcess.start("plasmashell", { "--version" });
|
||||
plasmaShellVersionProcess.waitForFinished();
|
||||
QString versionOut = plasmaShellVersionProcess.readAll();
|
||||
if (!versionOut.contains("plasmashell ")) {
|
||||
qWarning() << "Unable to read plasma shell version";
|
||||
qWarning() << "Unable to read plasma shell version. ScreenPlay only works on KDE";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString kdeWallpaperPath = QDir(QDir::homePath() + "/.local/share/plasma/wallpapers/ScreenPlay/").canonicalPath();
|
||||
const QFileInfo installedWallpaperMetadata(kdeWallpaperPath + "/metadata.desktop");
|
||||
const QString appKdeWallapperPath = QGuiApplication::instance()->applicationDirPath() + "/kde";
|
||||
const QFileInfo currentWallpaperMetadata(appKdeWallapperPath + "/ScreenPlay/metadata.desktop");
|
||||
void App::installKDEWallpaper()
|
||||
{
|
||||
|
||||
if (!installedWallpaperMetadata.exists()) {
|
||||
process.setWorkingDirectory(appKdeWallapperPath);
|
||||
process.start("plasmapkg2", { "--install", "ScreenPlay" });
|
||||
process.waitForFinished();
|
||||
process.terminate();
|
||||
qInfo() << "Install ScreenPlay KDE Wallpaper";
|
||||
} else {
|
||||
QSettings installedWallpaperSettings(installedWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat);
|
||||
installedWallpaperSettings.beginGroup("Desktop Entry");
|
||||
const QString installedWallpaperVersion = installedWallpaperSettings.value("Version").toString();
|
||||
installedWallpaperSettings.endGroup();
|
||||
const QVersionNumber installedVersionNumber = QVersionNumber::fromString(installedWallpaperVersion);
|
||||
qInfo() << "Install ScreenPlay KDE Wallpaper";
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(m_appKdeWallapperPath);
|
||||
process.start("plasmapkg2", { "--install", "ScreenPlay" });
|
||||
process.waitForFinished();
|
||||
process.terminate();
|
||||
}
|
||||
|
||||
QSettings currentWallpaperSettings(currentWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat);
|
||||
currentWallpaperSettings.beginGroup("Desktop Entry");
|
||||
const QString currentWallpaperVersion = currentWallpaperSettings.value("Version").toString();
|
||||
currentWallpaperSettings.endGroup();
|
||||
const QVersionNumber currentVersionNumber = QVersionNumber::fromString(installedWallpaperVersion);
|
||||
void App::upgradeKDEWallpaper()
|
||||
{
|
||||
|
||||
if (installedVersionNumber.isNull() || currentVersionNumber.isNull()) {
|
||||
qCritical() << "Unable to parse version number from:" << currentWallpaperVersion << installedWallpaperVersion;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (installedVersionNumber <= currentVersionNumber)
|
||||
return true;
|
||||
|
||||
qInfo() << "Upgrade ScreenPlay KDE Wallpaper";
|
||||
process.setWorkingDirectory(appKdeWallapperPath);
|
||||
process.start("plasmapkg2", { "--upgrade", "ScreenPlay" });
|
||||
process.waitForFinished();
|
||||
process.terminate();
|
||||
qInfo() << process.readAllStandardError() << process.readAllStandardOutput();
|
||||
}
|
||||
qInfo() << "Upgrade ScreenPlay KDE Wallpaper";
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(m_appKdeWallapperPath);
|
||||
process.start("plasmapkg2", { "--upgrade", "ScreenPlay" });
|
||||
process.waitForFinished();
|
||||
process.terminate();
|
||||
qInfo() << process.readAllStandardError() << process.readAllStandardOutput();
|
||||
}
|
||||
|
||||
void App::restartKDE()
|
||||
{
|
||||
qInfo() << "Restart KDE ";
|
||||
QProcess process;
|
||||
process.start("kquitapp5", { "plasmashell" });
|
||||
process.waitForFinished();
|
||||
process.terminate();
|
||||
qInfo() << process.readAllStandardError() << process.readAllStandardOutput();
|
||||
process.startDetached("kstart5", { "plasmashell" });
|
||||
qInfo() << process.readAllStandardError() << process.readAllStandardOutput();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<bool> App::isNewestKDEWallpaperInstalled()
|
||||
{
|
||||
|
||||
QFileInfo installedWallpaperMetadata(m_kdeWallpaperPath + "/metadata.desktop");
|
||||
QSettings installedWallpaperSettings(installedWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat);
|
||||
installedWallpaperSettings.beginGroup("Desktop Entry");
|
||||
const QString installedWallpaperVersion = installedWallpaperSettings.value("Version").toString();
|
||||
installedWallpaperSettings.endGroup();
|
||||
const QVersionNumber installedVersionNumber = QVersionNumber::fromString(installedWallpaperVersion);
|
||||
|
||||
QFileInfo currentWallpaperMetadata(m_appKdeWallapperPath + "/ScreenPlay/metadata.desktop");
|
||||
QSettings currentWallpaperSettings(currentWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat);
|
||||
currentWallpaperSettings.beginGroup("Desktop Entry");
|
||||
const QString currentWallpaperVersion = currentWallpaperSettings.value("Version").toString();
|
||||
currentWallpaperSettings.endGroup();
|
||||
const QVersionNumber currentVersionNumber = QVersionNumber::fromString(currentWallpaperVersion);
|
||||
|
||||
qInfo() << "installedVersionNumber" << installedVersionNumber << "currentVersionNumber " << currentVersionNumber;
|
||||
if (installedVersionNumber.isNull() || currentVersionNumber.isNull()) {
|
||||
qInfo() << "Unable to parse version number from:" << currentWallpaperVersion << installedWallpaperVersion;
|
||||
qInfo() << "Reinstall ScreenPlay Wallpaper";
|
||||
return std::nullopt;
|
||||
} else {
|
||||
return {installedVersionNumber >= currentVersionNumber};
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
*/
|
||||
bool App::setupKDE()
|
||||
{
|
||||
|
||||
m_kdeWallpaperPath = QDir(QDir::homePath() + "/.local/share/plasma/wallpapers/ScreenPlay/").canonicalPath();
|
||||
m_appKdeWallapperPath = QGuiApplication::instance()->applicationDirPath() + "/kde";
|
||||
|
||||
if (!isKDEInstalled())
|
||||
return false;
|
||||
|
||||
QFileInfo installedWallpaperMetadata(m_kdeWallpaperPath + "/metadata.desktop");
|
||||
if (!installedWallpaperMetadata.exists()) {
|
||||
installKDEWallpaper();
|
||||
restartKDE();
|
||||
return true;
|
||||
}
|
||||
if (auto isNewer = isNewestKDEWallpaperInstalled()) {
|
||||
if (!isNewer.value()) {
|
||||
upgradeKDEWallpaper();
|
||||
return true;
|
||||
}
|
||||
|
||||
qInfo() << "All up to date!" << isNewer.value();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -217,6 +217,11 @@ public slots:
|
||||
|
||||
private:
|
||||
bool setupKDE();
|
||||
bool isKDEInstalled();
|
||||
void installKDEWallpaper();
|
||||
void upgradeKDEWallpaper();
|
||||
void restartKDE();
|
||||
std::optional<bool> isNewestKDEWallpaperInstalled();
|
||||
|
||||
private:
|
||||
QNetworkAccessManager m_networkAccessManager;
|
||||
@ -229,12 +234,14 @@ private:
|
||||
std::unique_ptr<Util> m_util;
|
||||
|
||||
std::shared_ptr<GlobalVariables> m_globalVariables;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
std::shared_ptr<InstalledListModel> m_installedListModel;
|
||||
std::shared_ptr<MonitorListModel> m_monitorListModel;
|
||||
std::shared_ptr<ProfileListModel> m_profileListModel;
|
||||
std::shared_ptr<InstalledListFilter> m_installedListFilter;
|
||||
QProcess process;
|
||||
|
||||
QString m_kdeWallpaperPath;
|
||||
QString m_appKdeWallapperPath;
|
||||
};
|
||||
}
|
||||
|
@ -93,10 +93,12 @@ void ScreenPlayManager::init(
|
||||
});
|
||||
QObject::connect(socket, &QWebSocket::disconnected, this, [this, socket]() {
|
||||
m_connections.removeOne(socket);
|
||||
setIsKDEConnected(false);
|
||||
qInfo() << "Disconnected connection count: " << m_connections.count();
|
||||
});
|
||||
|
||||
m_connections.push_back(socket);
|
||||
setIsKDEConnected(true);
|
||||
// socket->flush();
|
||||
});
|
||||
}
|
||||
@ -470,6 +472,7 @@ void ScreenPlayManager::newConnection()
|
||||
m_unconnectedClients.push_back(std::move(connection));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Removes a wallpaper from the given appID. Returns true on success.
|
||||
*/
|
||||
@ -726,4 +729,18 @@ TEST_CASE("Loads profiles.json")
|
||||
GlobalVariables globalVariables;
|
||||
ScreenPlayManager manager;
|
||||
}
|
||||
|
||||
bool ScreenPlayManager::isKDEConnected() const
|
||||
{
|
||||
return m_isKDEConnected;
|
||||
}
|
||||
|
||||
void ScreenPlayManager::setIsKDEConnected(bool isKDEConnected)
|
||||
{
|
||||
if (m_isKDEConnected == isKDEConnected)
|
||||
return;
|
||||
m_isKDEConnected = isKDEConnected;
|
||||
emit isKDEConnectedChanged(isKDEConnected);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ class ScreenPlayManager : public QObject {
|
||||
|
||||
Q_PROPERTY(int activeWallpaperCounter READ activeWallpaperCounter WRITE setActiveWallpaperCounter NOTIFY activeWallpaperCounterChanged)
|
||||
Q_PROPERTY(int activeWidgetsCounter READ activeWidgetsCounter WRITE setActiveWidgetsCounter NOTIFY activeWidgetsCounterChanged)
|
||||
Q_PROPERTY(bool isKDEConnected READ isKDEConnected WRITE setIsKDEConnected NOTIFY isKDEConnectedChanged)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayManager(QObject* parent = nullptr);
|
||||
@ -74,6 +75,9 @@ public:
|
||||
int activeWidgetsCounter() const { return m_activeWidgetsCounter; }
|
||||
bool isAnotherScreenPlayInstanceRunning() { return m_isAnotherScreenPlayInstanceRunning; }
|
||||
|
||||
bool isKDEConnected() const;
|
||||
void setIsKDEConnected(bool isKDEConnected);
|
||||
|
||||
signals:
|
||||
void activeWallpaperCounterChanged(int activeWallpaperCounter);
|
||||
void activeWidgetsCounterChanged(int activeWidgetsCounter);
|
||||
@ -85,6 +89,8 @@ signals:
|
||||
void profilesSaved();
|
||||
void displayErrorPopup(const QString& msg);
|
||||
|
||||
void isKDEConnectedChanged(bool isKDEConnected);
|
||||
|
||||
private slots:
|
||||
bool saveProfiles();
|
||||
|
||||
@ -196,6 +202,7 @@ private:
|
||||
QTimer m_saveLimiter;
|
||||
|
||||
const quint16 m_webSocketPort = 16395;
|
||||
bool m_isKDEConnected = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
<kcfgfile name=""/>
|
||||
|
||||
<group name="General">
|
||||
<entry name="StopWallpaperIfHidden" type="Bool">
|
||||
<label>Stop Wallpaper if not visible</label>
|
||||
<default>false</default>
|
||||
<entry name="MonitorIndex" type="int">
|
||||
<label>Monitor Index aaa</label>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
||||
|
@ -12,7 +12,8 @@ import org.kde.newstuff 1.1 as NewStuff
|
||||
Column {
|
||||
id: root
|
||||
|
||||
property alias cfg_StopWallpaperIfHidden: stopWallpaperIfHidden.checked
|
||||
property alias cfg_MonitorIndex: monitorIndex.text
|
||||
|
||||
|
||||
anchors.fill: parent
|
||||
spacing: units.largeSpacing
|
||||
@ -21,12 +22,12 @@ Column {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: units.largeSpacing
|
||||
|
||||
QQC.CheckBox {
|
||||
id: stopWallpaperIfHidden
|
||||
|
||||
text: i18nd("plasma_applet_org.kde.image", "Stop animation when a window is maximized")
|
||||
QQC.TextField {
|
||||
id: monitorIndex
|
||||
text: "0"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import QtWebEngine 1.8
|
||||
import QtMultimedia 5.12
|
||||
import Qt.labs.settings 1.1
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
Rectangle {
|
||||
id:root
|
||||
@ -22,7 +23,7 @@ Rectangle {
|
||||
|
||||
wallpaper.type = settings.value("SP_type")
|
||||
wallpaper.fillMode = settings.value("SP_fillMode")
|
||||
wallpaper.volume = settings.value("SP_volume")
|
||||
//wallpaper.volume = settings.value("SP_volume")
|
||||
wallpaper.play()
|
||||
}
|
||||
|
||||
@ -101,12 +102,21 @@ Rectangle {
|
||||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text:wallpaper.type + wallpaper.projectSourceFileAbsolute
|
||||
text: "wallpaper.type: " + wallpaper.type
|
||||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text:"Actitve: " +socket.active +" status: "+ socket.status + " reconnectTimer.retryCounter : "+ reconnectTimer.retryCounter
|
||||
text: "projectSourceFileAbsolute " + wallpaper.projectSourceFileAbsolute
|
||||
}arrier
|
||||
Text {
|
||||
color: "white"
|
||||
text:"reconnectTimer.retryCounter : "+ reconnectTimer.retryCounter
|
||||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: "MonitorIndex: " + wallpaper.configuration.MonitorIndex
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user