Issue #159: Linux fix

This commit is contained in:
Jakub Melka 2024-03-18 20:14:03 +01:00
parent 35242f845e
commit b4e742f564
2 changed files with 17 additions and 20 deletions

View File

@ -22,6 +22,7 @@
#include <QLabel>
#include <QPushButton>
#include <QProcess>
#include <QMessageBox>
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();
}

View File

@ -14,22 +14,6 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
// 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 <https://www.gnu.org/licenses/>.
#include "launchdialog.h"