Skip to content

Commit

Permalink
Integrate user manual into client and launcher UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkrause committed Jun 18, 2016
1 parent 2870eb4 commit dbb0a63
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 1 deletion.
1 change: 1 addition & 0 deletions config-gammaray.h.cmake
Expand Up @@ -13,6 +13,7 @@
#define GAMMARAY_BIN_INSTALL_DIR "${BIN_INSTALL_DIR}"
#define GAMMARAY_PROBE_INSTALL_DIR "${PROBE_INSTALL_DIR}"
#define GAMMARAY_TRANSLATION_INSTALL_DIR "${TRANSLATION_INSTALL_DIR}"
#define GAMMARAY_QCH_INSTALL_DIR "${QCH_INSTALL_DIR}"

#define GAMMARAY_PLUGIN_VERSION "${GAMMARAY_PLUGIN_VERSION}"
#define GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}${GAMMARAY_PROBE_ABI_POSTFIX}"
Expand Down
7 changes: 7 additions & 0 deletions launcher/ui/launcherwindow.cpp
Expand Up @@ -31,6 +31,7 @@
#include "launchoptions.h"

#include <ui/aboutdata.h>
#include <ui/helpcontroller.h>

#include <QPushButton>
#include <QSettings>
Expand All @@ -50,6 +51,7 @@ LauncherWindow::LauncherWindow(QWidget *parent)
ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(click()));
connect(ui->connectPage, SIGNAL(activate()),
ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(click()));
connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));

setWindowTitle(tr("GammaRay Launcher"));

Expand Down Expand Up @@ -105,3 +107,8 @@ void LauncherWindow::accept()
QDialog::accept();
}

void LauncherWindow::help()
{
HelpController::openPage("doc/gammaray-launcher-gui.html");
}

1 change: 1 addition & 0 deletions launcher/ui/launcherwindow.h
Expand Up @@ -52,6 +52,7 @@ class LauncherWindow : public QDialog

private slots:
void tabChanged();
void help();

private:
Ui::LauncherWindow *ui;
Expand Down
2 changes: 1 addition & 1 deletion launcher/ui/launcherwindow.ui
Expand Up @@ -119,7 +119,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions ui/CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ set(gammaray_ui_srcs
uiintegration.cpp
uistatemanager.cpp
remoteviewwidget.cpp
helpcontroller.cpp

paintanalyzerwidget.cpp
paintbufferviewer.cpp
Expand Down
128 changes: 128 additions & 0 deletions ui/helpcontroller.cpp
@@ -0,0 +1,128 @@
/*
helpcontroller.cpp
This file is part of GammaRay, the Qt application inspection and
manipulation tool.
Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Volker Krause <volker.krause@kdab.com>
Licensees holding valid commercial KDAB GammaRay licenses may use this file in
accordance with GammaRay Commercial License Agreement provided with the Software.
Contact info@kdab.com if any conditions of this licensing are not clear to you.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <config-gammaray.h>

#include "helpcontroller.h"

#include <common/paths.h>

#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QProcess>
#include <QString>
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#include <QStandardPaths>
#endif

using namespace GammaRay;

namespace GammaRay {

struct HelpControllerPrivate
{
HelpControllerPrivate() : proc(Q_NULLPTR) {}

void startProcess();
void sendCommand(const QByteArray &cmd);

QString assistantPath;
QString qhcPath;
QProcess *proc;
};

}

void HelpControllerPrivate::startProcess()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (proc)
return;

proc = new QProcess(QCoreApplication::instance());
QObject::connect(proc, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this](){
proc->deleteLater();
proc = Q_NULLPTR;
});
proc->setProgram(assistantPath);
proc->setArguments(QStringList() <<
QLatin1String("-collectionFile") <<
qhcPath <<
QLatin1String("-enableRemoteControl")
);
proc->start();
proc->waitForStarted();
sendCommand("expandToc 2;");
#endif
}

void HelpControllerPrivate::sendCommand(const QByteArray &cmd)
{
if (!proc)
return;
proc->write(cmd);
}

Q_GLOBAL_STATIC(HelpControllerPrivate, s_helpController)

bool HelpController::isAvailable()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
auto d = s_helpController();
if (!d->assistantPath.isEmpty() && !d->qhcPath.isEmpty())
return true;

d->assistantPath = QStandardPaths::findExecutable(QStringLiteral("assistant"));
if (d->assistantPath.isEmpty())
return false;

const auto qhcPath = Paths::rootPath() + QLatin1String("/" GAMMARAY_QCH_INSTALL_DIR "/gammaray.qhc");
if (QFileInfo::exists(qhcPath)) {
d->qhcPath = qhcPath;
return true;
}
#endif
return false;
}

void HelpController::openContents()
{
Q_ASSERT(isAvailable());
auto d = s_helpController();
d->startProcess();
d->sendCommand("setSource qthelp://com.kdab.GammaRay." GAMMARAY_PLUGIN_VERSION "/doc/index.html;syncContents\n");
}

void HelpController::openPage(const QString &page)
{
Q_ASSERT(isAvailable());
auto d = s_helpController();
d->startProcess();
d->sendCommand(QByteArray("setSource qthelp://com.kdab.GammaRay." GAMMARAY_PLUGIN_VERSION "/") + page.toUtf8() + ";syncContents\n");
}
57 changes: 57 additions & 0 deletions ui/helpcontroller.h
@@ -0,0 +1,57 @@
/*
helpcontroller.h
This file is part of GammaRay, the Qt application inspection and
manipulation tool.
Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Volker Krause <volker.krause@kdab.com>
Licensees holding valid commercial KDAB GammaRay licenses may use this file in
accordance with GammaRay Commercial License Agreement provided with the Software.
Contact info@kdab.com if any conditions of this licensing are not clear to you.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GAMMARAY_HELPCONTROLLER_H
#define GAMMARAY_HELPCONTROLLER_H

#include "gammaray_ui_export.h"

#include <qglobal.h>

QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE

namespace GammaRay {

/*! Controls the Assistant-based help browser. */
namespace HelpController
{
/*! Returns @c true if Assistant and our help collection are found. */
GAMMARAY_UI_EXPORT bool isAvailable();

/*! Open start page of the help collection. */
GAMMARAY_UI_EXPORT void openContents();

/*! Opens the specified page of the help collection. */
GAMMARAY_UI_EXPORT void openPage(const QString &page);
}

}

#endif // GAMMARAY_HELPCONTROLLER_H
10 changes: 10 additions & 0 deletions ui/mainwindow.cpp
Expand Up @@ -34,6 +34,7 @@
#include "clienttoolmodel.h"
#include "aboutdata.h"
#include "uiintegration.h"
#include "helpcontroller.h"

#include "common/objectbroker.h"
#include "common/modelroles.h"
Expand Down Expand Up @@ -146,6 +147,10 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(quitHost()));
ui->actionQuit->setIcon(QIcon::fromTheme(QStringLiteral("application-exit")));

ui->actionHelp->setShortcut(QKeySequence::HelpContents);
ui->actionHelp->setEnabled(HelpController::isAvailable());

connect(ui->actionHelp, SIGNAL(triggered(bool)), this, SLOT(help()));
connect(ui->actionPlugins, SIGNAL(triggered(bool)),
this, SLOT(aboutPlugins()));
connect(ui->actionMessageStatistics, SIGNAL(triggered(bool)), this, SLOT(showMessageStatistics()));
Expand Down Expand Up @@ -238,6 +243,11 @@ MainWindow::~MainWindow()
{
}

void MainWindow::help()
{
HelpController::openContents();
}

void MainWindow::about()
{
AboutDialog dialog(this);
Expand Down
1 change: 1 addition & 0 deletions ui/mainwindow.h
Expand Up @@ -66,6 +66,7 @@ class MainWindow : public QMainWindow
void targetQuitRequested();

private slots:
void help();
void about();
void aboutPlugins();
void aboutKDAB();
Expand Down
13 changes: 13 additions & 0 deletions ui/mainwindow.ui
Expand Up @@ -129,6 +129,8 @@ background-position:bottom right;
<addaction name="actionPlugins"/>
<addaction name="actionMessageStatistics"/>
</widget>
<addaction name="actionHelp"/>
<addaction name="separator"/>
<addaction name="menu_Diagnostics"/>
<addaction name="separator"/>
<addaction name="actionAboutGammaRay"/>
Expand Down Expand Up @@ -233,6 +235,17 @@ background-position:bottom right;
<string>Show GammaRay communication statistics.</string>
</property>
</action>
<action name="actionHelp">
<property name="icon">
<iconset theme="help-contents"/>
</property>
<property name="text">
<string>&amp;Help...</string>
</property>
<property name="toolTip">
<string>Show help browser.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down

0 comments on commit dbb0a63

Please sign in to comment.