astyle formatting

This commit is contained in:
Daniel Marjamäki 2020-08-05 13:58:06 +02:00
parent d5b64d9c3a
commit d83757f1a1
2 changed files with 84 additions and 85 deletions

View File

@ -1,62 +1,62 @@
#include "assistant.h" #include "assistant.h"
#include <QByteArray> #include <QByteArray>
#include <QDir> #include <QDir>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
Assistant::Assistant() Assistant::Assistant()
: mProc(nullptr) : mProc(nullptr)
{ {
} }
Assistant::~Assistant() Assistant::~Assistant()
{ {
if (mProc && mProc->state() == QProcess::Running) { if (mProc && mProc->state() == QProcess::Running) {
mProc->terminate(); mProc->terminate();
mProc->waitForFinished(3000); mProc->waitForFinished(3000);
} }
delete mProc; delete mProc;
} }
void Assistant::showDocumentation(const QString &page) void Assistant::showDocumentation(const QString &page)
{ {
if (!startAssistant()) if (!startAssistant())
return; return;
QByteArray ba("SetSource "); QByteArray ba("SetSource ");
ba.append("qthelp://cppcheck.sourceforge.net/doc/"); ba.append("qthelp://cppcheck.sourceforge.net/doc/");
mProc->write(ba + page.toLocal8Bit() + '\n'); mProc->write(ba + page.toLocal8Bit() + '\n');
} }
bool Assistant::startAssistant() bool Assistant::startAssistant()
{ {
if (!mProc) if (!mProc)
mProc = new QProcess(); mProc = new QProcess();
if (mProc->state() != QProcess::Running) { if (mProc->state() != QProcess::Running) {
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
#if !defined(Q_OS_MAC) #if !defined(Q_OS_MAC)
app += QLatin1String("assistant"); app += QLatin1String("assistant");
#else #else
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant"); app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
#endif #endif
QStringList args; QStringList args;
args << QLatin1String("-collectionFile") args << QLatin1String("-collectionFile")
<< QLatin1String("online-help.qhc") << QLatin1String("online-help.qhc")
<< QLatin1String("-enableRemoteControl"); << QLatin1String("-enableRemoteControl");
mProc->start(app, args); mProc->start(app, args);
if (!mProc->waitForStarted()) { if (!mProc->waitForStarted()) {
QMessageBox::critical(nullptr, QMessageBox::critical(nullptr,
tr("Cppcheck"), tr("Cppcheck"),
tr("Unable to launch Qt Assistant (%1)").arg(app)); tr("Unable to launch Qt Assistant (%1)").arg(app));
return false; return false;
} }
} }
return true; return true;
} }

View File

@ -1,23 +1,22 @@
#ifndef ASSISTANT_H #ifndef ASSISTANT_H
#define ASSISTANT_H #define ASSISTANT_H
#include <QCoreApplication> #include <QCoreApplication>
#include <QString> #include <QString>
class QProcess; class QProcess;
class Assistant class Assistant {
{ Q_DECLARE_TR_FUNCTIONS(Assistant)
Q_DECLARE_TR_FUNCTIONS(Assistant)
public:
public: Assistant();
Assistant(); ~Assistant();
~Assistant(); void showDocumentation(const QString &file);
void showDocumentation(const QString &file);
private:
private: bool startAssistant();
bool startAssistant(); QProcess *mProc;
QProcess *mProc; };
};
#endif // ASSISTANT_H
#endif // ASSISTANT_H