Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run hotspot without GUI for any command-line only option #549

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,20 @@ void Q_DECL_UNUSED initRCCIconTheme()

std::unique_ptr<QCoreApplication> createApplication(int& argc, char* argv[])
{
const std::initializer_list<std::string_view> nonGUIOptions = {"--version", "-v", "--exportTo",
"--help", "-h", "--help-all"};

// create command line app if one of the command-line only options are used
for (int i = 1; i < argc; ++i) {
if (!qstrcmp(argv[i], "--exportTo"))
if (std::find(nonGUIOptions.begin(), nonGUIOptions.end(), argv[i]) != nonGUIOptions.end()) {
return std::make_unique<QCoreApplication>(argc, argv);
}
}

// otherwise create full gui app
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
return std::make_unique<QApplication>(argc, argv);
}

Expand All @@ -73,17 +83,13 @@ int main(int argc, char** argv)
QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com"));
QCoreApplication::setApplicationName(QStringLiteral("hotspot"));
QCoreApplication::setApplicationVersion(QStringLiteral(HOTSPOT_VERSION_STRING));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif

auto app = createApplication(argc, argv);

// init
Util::appImageEnvironment();

#if APPIMAGE_BUILD

// cleanup the environment when we are running from within the AppImage
// to allow launching system applications using Qt without them loading
// the bundled Qt we ship in the AppImage
Expand Down