diff --git a/Tests/kstars_ui/kstars_ui_tests.cpp b/Tests/kstars_ui/kstars_ui_tests.cpp --- a/Tests/kstars_ui/kstars_ui_tests.cpp +++ b/Tests/kstars_ui/kstars_ui_tests.cpp @@ -63,6 +63,9 @@ writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation)); KCrash::initialize(); + // Explicitly provide the RC file from the main app resources, not the user-customized one + KStars::setResourceFile(":/kxmlgui5/kstars/kstarsui.rc"); + // This holds the final result of the test session int failure = 0; diff --git a/kstars/kstars.h b/kstars/kstars.h --- a/kstars/kstars.h +++ b/kstars/kstars.h @@ -817,10 +817,18 @@ /// Set to true when the application is being closed static bool Closing; + /** @brief Override KStars UI resource file. + * @note This is used by UI tests, which need to use the same resources with a different app name + */ + static bool setResourceFile(QString const rc); + private: /// Pointer to an instance of KStars static KStars *pinstance; + // Resource file to load - overridable by UI tests + static QString m_KStarsUIResource; + KActionMenu *colorActionMenu { nullptr }; KActionMenu *fovActionMenu { nullptr }; KActionMenu *hipsActionMenu { nullptr }; diff --git a/kstars/kstarsinit.cpp b/kstars/kstarsinit.cpp --- a/kstars/kstarsinit.cpp +++ b/kstars/kstarsinit.cpp @@ -131,6 +131,19 @@ } } +// Resource file override - used by UI tests +QString KStars::m_KStarsUIResource = "kstarsui.rc"; +bool KStars::setResourceFile(QString const rc) +{ + if (QFile(rc).exists()) + { + m_KStarsUIResource = rc; + return true; + } + else return false; +} + + void KStars::initActions() { // Check if we have this specific Breeze icon. If not, try to set the theme search path and if appropriate, the icon theme rcc file @@ -933,8 +946,9 @@ initStatusBar(); initActions(); - // Provide resource file explicitely for UI tests to display resources properly - setupGUI(StandardWindowOptions(Default), ":/kxmlgui5/kstars/kstarsui.rc"); + // Setup GUI from the settings file + // UI tests provide the default settings file from the resources explicitly file to render UI properly + setupGUI(StandardWindowOptions(Default), m_KStarsUIResource); //get focus of keyboard and mouse actions (for example zoom in with +) map()->QWidget::setFocus();