core: use QApplication and respect user theme choice (#6)

Fixes qqc2-desktop-style usage
This commit is contained in:
outfoxxed 2024-10-13 16:26:29 -07:00 committed by GitHub
parent 49f20fbcc5
commit 52a32d3afe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -8,7 +8,7 @@ project(hsi VERSION ${VER} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick QuickControls2) find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
@ -41,7 +41,7 @@ qt_add_resources(hyprsysteminfo "resource"
) )
target_link_libraries(hyprsysteminfo target_link_libraries(hyprsysteminfo
PRIVATE Qt6::Quick Qt6::Gui Qt6::QuickControls2 PkgConfig::deps PRIVATE Qt6::Widgets Qt6::Quick Qt6::Gui Qt6::QuickControls2 PkgConfig::deps
) )
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@ -1,6 +1,6 @@
#include "qmlSources/SystemIconProvider.hpp" #include "qmlSources/SystemIconProvider.hpp"
#include "qmlSources/SystemInternals.hpp" #include "qmlSources/SystemInternals.hpp"
#include <QGuiApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include <QQuickStyle> #include <QQuickStyle>
@ -11,6 +11,7 @@
#include <hyprutils/string/VarList.hpp> #include <hyprutils/string/VarList.hpp>
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <qtenvironmentvariables.h>
using namespace Hyprutils::String; using namespace Hyprutils::String;
static std::string readFile(const std::string& filename) { static std::string readFile(const std::string& filename) {
@ -205,11 +206,12 @@ static void getSystemInfo(CSystemInternals* hsi, QGuiApplication* app) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
QGuiApplication app(argc, argv); QApplication app(argc, argv);
app.setApplicationName("Hyprland System Info"); app.setApplicationName("Hyprland System Info");
QQuickStyle::setStyle("org.kde.desktop"); if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
QQuickStyle::setStyle("org.kde.desktop");
auto systemInternals = new CSystemInternals; auto systemInternals = new CSystemInternals;