From 4d6cbef1dd29166679030d87c61d161882fb2ca3 Mon Sep 17 00:00:00 2001 From: Odizinne Date: Fri, 16 Aug 2024 21:00:31 +0200 Subject: [PATCH] ubuntu workflow attempt --- .github/workflows/qt-linux-build.yml | 41 +++++++++++++++++++++++ HeadsetControl-Qt.pro | 5 +-- src/HeadsetControlQt/headsetcontrolqt.cpp | 16 +++++++-- src/ShortcutManager/shortcutmanager.cpp | 12 ++++--- src/Utils/utils.cpp | 21 ++++++++++++ src/Utils/utils.h | 1 + 6 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/qt-linux-build.yml diff --git a/.github/workflows/qt-linux-build.yml b/.github/workflows/qt-linux-build.yml new file mode 100644 index 0000000..06a46c7 --- /dev/null +++ b/.github/workflows/qt-linux-build.yml @@ -0,0 +1,41 @@ +name: Build + +on: + push: + branches: + - linux + +jobs: + linux-build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: '6.4.2' + host: 'linux' + add-tools-to-path: true + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev + + - name: Build with qmake + run: | + mkdir build + cd build + qmake ../HeadsetControl-Qt.pro CONFIG+=release + make -j$(nproc) + pwd + ls + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: HeadsetControl-Qt_linux_64 + path: build/HeadsetControl-Qt \ No newline at end of file diff --git a/HeadsetControl-Qt.pro b/HeadsetControl-Qt.pro index 238cdd7..9dfd904 100644 --- a/HeadsetControl-Qt.pro +++ b/HeadsetControl-Qt.pro @@ -50,6 +50,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin DEPENDENCIES_DIR = $$PWD/src/dependencies DEST_DIR = $$OUT_PWD/release/dependencies -QMAKE_POST_LINK += powershell -Command "New-Item -ItemType Directory -Path '$$DEST_DIR' -Force; Copy-Item -Path '$$DEPENDENCIES_DIR\*' -Destination '$$DEST_DIR' -Recurse -Force" -#mkdir $$DEST_DIR +win32 { + QMAKE_POST_LINK += powershell -Command "New-Item -ItemType Directory -Path '$$DEST_DIR' -Force; Copy-Item -Path '$$DEPENDENCIES_DIR\*' -Destination '$$DEST_DIR' -Recurse -Force" +} diff --git a/src/HeadsetControlQt/headsetcontrolqt.cpp b/src/HeadsetControlQt/headsetcontrolqt.cpp index 1c47712..3fcc825 100644 --- a/src/HeadsetControlQt/headsetcontrolqt.cpp +++ b/src/HeadsetControlQt/headsetcontrolqt.cpp @@ -1,5 +1,5 @@ -#include "HeadsetControlQt.h" -#include "ui_HeadsetControlQt.h" +#include "headsetcontrolqt.h" +#include "ui_headsetcontrolqt.h" #include "utils.h" #include "shortcutmanager.h" #include @@ -299,7 +299,17 @@ QString HeadsetControlQt::getBatteryIcon(int batteryLevel, bool charging, bool m QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString desktop = env.value("XDG_CURRENT_DESKTOP"); if (desktop.contains("KDE", Qt::CaseInsensitive)) { - theme = "symbolic"; + QString kdeVersion = getKDEPlasmaVersion(); + if (kdeVersion.startsWith("5")) { + qDebug() << "KDE Plasma 5 detected"; + theme = "light"; + } else if (kdeVersion.startsWith("6")) { + qDebug() << "KDE Plasma 6 detected"; + theme = "symbolic"; + } else { + qDebug() << "Unknown KDE Plasma version"; + theme = "light"; + } } else { theme = "dark"; // Fallback for non-KDE environments } diff --git a/src/ShortcutManager/shortcutmanager.cpp b/src/ShortcutManager/shortcutmanager.cpp index f901bd2..5c50621 100644 --- a/src/ShortcutManager/shortcutmanager.cpp +++ b/src/ShortcutManager/shortcutmanager.cpp @@ -6,13 +6,16 @@ #include #include #include -#include -#include -#include -const QString desktopFile = QDir::homePath() + "/.config/autostart/headsetcontrol-qt.desktop"; +#ifdef _WIN32 + #include + #include + #include +#endif +const QString desktopFile = QDir::homePath() + "/.config/autostart/headsetcontrol-qt.desktop"; +#ifdef _WIN32 QString getStartupFolder() { QString path; @@ -104,6 +107,7 @@ void manageShortcut(bool state) } } } +#endif bool isDesktopfilePresent() { diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index 81aae56..1977bed 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -30,3 +30,24 @@ QIcon getIconForTheme() return QIcon(iconPath); } +QString getKDEPlasmaVersion() { + QProcess process; + process.start("plasmashell", QStringList() << "--version"); + process.waitForFinished(); + + QString output = process.readAllStandardOutput(); + QStringList lines = output.split('\n'); + QString versionLine; + + // Find the line containing the version info + for (const QString &line : lines) { + if (line.contains("plasmashell")) { + versionLine = line; + break; + } + } + + // Extract version number from the line + QString version = versionLine.split(' ').last().trimmed(); + return version; +} diff --git a/src/Utils/utils.h b/src/Utils/utils.h index d517977..298af4f 100644 --- a/src/Utils/utils.h +++ b/src/Utils/utils.h @@ -5,5 +5,6 @@ QString getTheme(); QIcon getIconForTheme(); +QString getKDEPlasmaVersion(); #endif // UTILS_H