Skip to content

Commit

Permalink
ubuntu workflow attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Aug 16, 2024
1 parent 5d4bb27 commit d9ed6c8
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 9 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/qt-linux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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
chmod +x ./HeadsetControl-Qt
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: HeadsetControl-Qt_linux_64
path: build/HeadsetControl-Qt
5 changes: 3 additions & 2 deletions HeadsetControl-Qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

16 changes: 13 additions & 3 deletions src/HeadsetControlQt/headsetcontrolqt.cpp
Original file line number Diff line number Diff line change
@@ -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 <QIcon>
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 8 additions & 4 deletions src/ShortcutManager/shortcutmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
#include <QStandardPaths>
#include <QSysInfo>
#include <QtWidgets/QWidget>
#include <shlobj.h>
#include <shobjidl.h>
#include <windows.h>

const QString desktopFile = QDir::homePath() + "/.config/autostart/headsetcontrol-qt.desktop";
#ifdef _WIN32
#include <shlobj.h>
#include <shobjidl.h>
#include <windows.h>
#endif

const QString desktopFile = QDir::homePath() + "/.config/autostart/headsetcontrol-qt.desktop";

#ifdef _WIN32
QString getStartupFolder()
{
QString path;
Expand Down Expand Up @@ -104,6 +107,7 @@ void manageShortcut(bool state)
}
}
}
#endif

bool isDesktopfilePresent()
{
Expand Down
21 changes: 21 additions & 0 deletions src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/Utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

QString getTheme();
QIcon getIconForTheme();
QString getKDEPlasmaVersion();

#endif // UTILS_H
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
#ifdef _WIN32
a.setStyle("fusion");
#endif
QLocale locale;
QString languageCode = locale.name().section('_', 0, 0);
QTranslator translator;
Expand Down

0 comments on commit d9ed6c8

Please sign in to comment.