move to qt6

This commit is contained in:
Martin Brodbeck 2022-07-07 17:16:51 +02:00
parent 2b6628bdf8
commit 0427bd4077
3 changed files with 16 additions and 8 deletions

View file

@ -8,11 +8,12 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
# Find the QtWidgets library # Find the QtWidgets library
find_package(Qt5Widgets CONFIG REQUIRED) find_package(Qt6 COMPONENTS Widgets Network PrintSupport CONFIG REQUIRED)
find_package(Qt5PrintSupport CONFIG REQUIRED) #find_package(Qt5Widgets CONFIG REQUIRED)
#find_package(Qt5PrintSupport CONFIG REQUIRED)
# For SingleApplication: # For SingleApplication:
find_package(Qt5Network CONFIG REQUIRED) #find_package(Qt5Network CONFIG REQUIRED)
set(QAPPLICATION_CLASS QApplication) set(QAPPLICATION_CLASS QApplication)
add_compile_definitions(QAPPLICATION_CLASS=${QAPPLICATION_CLASS}) add_compile_definitions(QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
@ -40,7 +41,9 @@ set(GUI_SOURCES
add_executable(kima2 ${GUI_SOURCES} kima2.rc) add_executable(kima2 ${GUI_SOURCES} kima2.rc)
target_include_directories(kima2 PRIVATE ${PROJECT_BINARY_DIR}) target_include_directories(kima2 PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(kima2 PRIVATE ${PROJECT_SOURCE_DIR}/subprojects/singleapplication/singleapplication.git) target_include_directories(kima2 PRIVATE ${PROJECT_SOURCE_DIR}/subprojects/singleapplication/singleapplication.git)
target_link_libraries(kima2 core printer Qt5::Widgets Qt5::PrintSupport Qt5::Network stdc++fs) # target_link_libraries(kima2 core printer Qt5::Widgets Qt5::PrintSupport Qt5::Network stdc++fs)
target_link_libraries(kima2 core printer Qt::Core Qt::PrintSupport Qt::Network stdc++fs)
if(WIN32) if(WIN32)
set_target_properties(kima2 PROPERTIES LINK_FLAGS "-mwindows") set_target_properties(kima2 PROPERTIES LINK_FLAGS "-mwindows")
endif(WIN32) endif(WIN32)

View file

@ -7,12 +7,13 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QSharedMemory> #include <QSharedMemory>
#include <QTranslator>
#include <QStyleFactory> #include <QStyleFactory>
#include <QTranslator>
#include <singleapplication.h> #include <singleapplication.h>
#include <stdexcept>
int main(int argc, char* argv[]) int main(int argc, char *argv[])
{ {
SingleApplication kimaApp(argc, argv); SingleApplication kimaApp(argc, argv);
@ -23,7 +24,11 @@ int main(int argc, char* argv[])
QTranslator qTranslator; QTranslator qTranslator;
QLocale german(QLocale::German); QLocale german(QLocale::German);
#ifdef __linux__ #ifdef __linux__
qTranslator.load("qt_" + german.name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); bool retVal =
qTranslator.load("qt_" + german.name(), QLibraryInfo::path(QLibraryInfo::TranslationsPath));
if (!retVal) {
throw std::runtime_error("Could not load translation.");
}
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
QApplication::setStyle(QStyleFactory::create("Fusion")); QApplication::setStyle(QStyleFactory::create("Fusion"));

View file

@ -96,7 +96,7 @@ MainWindow::MainWindow()
connect(m_ui.aboutQtAction, &QAction::triggered, this, &MainWindow::onAboutQt); connect(m_ui.aboutQtAction, &QAction::triggered, this, &MainWindow::onAboutQt);
connect(m_ui.aboutAction, &QAction::triggered, this, &MainWindow::onAbout); connect(m_ui.aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
connect(m_ui.openManualAction, &QAction::triggered, this, []() { connect(m_ui.openManualAction, &QAction::triggered, this, []() {
auto locations = QStandardPaths::standardLocations(QStandardPaths::DataLocation); auto locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
for (auto location : locations) { for (auto location : locations) {
if (QFile::exists(location + QString("/Benutzerhandbuch.pdf"))) { if (QFile::exists(location + QString("/Benutzerhandbuch.pdf"))) {
QDesktopServices::openUrl( QDesktopServices::openUrl(