From b4e742f5646f3761b1fc976aab2295c233b727f2 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Mon, 18 Mar 2024 20:14:03 +0100 Subject: [PATCH] Issue #159: Linux fix --- Pdf4QtLaunchPad/launchdialog.cpp | 21 +++++++++++++++++---- Pdf4QtLaunchPad/main.cpp | 16 ---------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Pdf4QtLaunchPad/launchdialog.cpp b/Pdf4QtLaunchPad/launchdialog.cpp index 7bab124..eb09f27 100644 --- a/Pdf4QtLaunchPad/launchdialog.cpp +++ b/Pdf4QtLaunchPad/launchdialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include LaunchDialog::LaunchDialog(QWidget* parent) : QDialog(parent, Qt::WindowStaysOnTopHint | Qt::Window | Qt::Dialog) @@ -79,26 +80,38 @@ LaunchDialog::~LaunchDialog() void LaunchDialog::startEditor() { - startProgram("./Pdf4QtEditor"); + startProgram("Pdf4QtEditor"); } void LaunchDialog::startViewer() { - startProgram("./Pdf4QtViewer"); + startProgram("Pdf4QtViewer"); } void LaunchDialog::startPageMaster() { - startProgram("./Pdf4QtPageMaster"); + startProgram("Pdf4QtPageMaster"); } void LaunchDialog::startDiff() { - startProgram("./Pdf4QtDiff"); + startProgram("Pdf4QtDiff"); } void LaunchDialog::startProgram(const QString& program) { +#ifndef Q_OS_WIN + QString appDir = qgetenv("APPDIR"); + QString internalToolPath = appDir.isEmpty() ? QString("./%1").arg(program) + : QString("%1/usr/bin/%2").arg(appDir, program); + + qint64 pid = 0; + if (!QProcess::startDetached(internalToolPath, {}, QString(), &pid)) + { + QMessageBox::critical(this, tr("Error"), tr("Failed to start process '%1'").arg(internalToolPath)); + } +#else QProcess::startDetached(program); +#endif close(); } diff --git a/Pdf4QtLaunchPad/main.cpp b/Pdf4QtLaunchPad/main.cpp index 524ec26..f6fe252 100644 --- a/Pdf4QtLaunchPad/main.cpp +++ b/Pdf4QtLaunchPad/main.cpp @@ -14,22 +14,6 @@ // // You should have received a copy of the GNU Lesser General Public License // along with PDF4QT. If not, see . -// Copyright (C) 2024 Jakub Melka -// -// This file is part of PDF4QT. -// -// PDF4QT is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// with the written consent of the copyright owner, any later version. -// -// PDF4QT is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with PDF4QT. If not, see . #include "launchdialog.h"