From e96db9d38377e326777828395ac911f3223ec039 Mon Sep 17 00:00:00 2001 From: Spiros Date: Tue, 11 Jun 2024 19:03:29 +0300 Subject: [PATCH] Build using Qt6 --- CMakeLists.txt | 21 +++++++++++---------- mainwindow.cpp | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6c5aff..ee4535a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) project(KDiskInfo VERSION 0.1 LANGUAGES CXX) @@ -9,7 +9,6 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) set(PROJECT_SOURCES @@ -17,6 +16,13 @@ set(PROJECT_SOURCES mainwindow.cpp mainwindow.h mainwindow.ui + custombutton.h + custombutton.cpp + statusdot.h + statusdot.cpp + jsonparser.h + jsonparser.cpp + resources.qrc ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) @@ -38,11 +44,6 @@ else() else() add_executable(KDiskInfo ${PROJECT_SOURCES} - custombutton.h custombutton.cpp - statusdot.h statusdot.cpp - jsonparser.h jsonparser.cpp - resources.qrc - ) endif() endif() @@ -52,9 +53,7 @@ target_link_libraries(KDiskInfo PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. -if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.KDiskInfo) -endif() + set_target_properties(KDiskInfo PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} @@ -73,3 +72,5 @@ install(TARGETS KDiskInfo if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(KDiskInfo) endif() +include(FeatureSummary) +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/mainwindow.cpp b/mainwindow.cpp index 13f221c..8f3241c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -106,7 +106,7 @@ void MainWindow::scanDevices() devices = jsonObj["devices"].toArray(); QStringList commandList; - for (const QJsonValue &value : qAsConst(devices)) { + for (const QJsonValue &value : std::as_const(devices)) { QJsonObject device = value.toObject(); QString deviceName = device["name"].toString(); commandList.append(QString("smartctl --all --json %1").arg(deviceName));