Commit 45e057e8 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

move QObject data about handbook handling to KPAboutData container

parent 4045b455
......@@ -22,13 +22,7 @@
// KDE includes
#include <kaction.h>
#include <khelpmenu.h>
#include <kicon.h>
#include <klocale.h>
#include <kmenu.h>
#include <kpushbutton.h>
#include <ktoolinvocation.h>
// Local includes
......@@ -46,6 +40,7 @@ KPToolDialog::KPToolDialog(QWidget* const parent)
KPToolDialog::~KPToolDialog()
{
delete d;
}
void KPToolDialog::setAboutData(KPAboutData* const about, KPushButton* const help)
......@@ -62,6 +57,7 @@ KPWizardDialog::KPWizardDialog(QWidget* const parent)
KPWizardDialog::~KPWizardDialog()
{
delete d;
}
void KPWizardDialog::setAboutData(KPAboutData* const about, KPushButton* const help)
......@@ -79,6 +75,7 @@ KPPageDialog::KPPageDialog(QWidget* const parent)
KPPageDialog::~KPPageDialog()
{
delete d;
}
void KPPageDialog::setAboutData(KPAboutData* const about, KPushButton* const help)
......
......@@ -20,7 +20,7 @@
*
* ============================================================ */
#include "kptooldialog_p.moc"
#include "kptooldialog_p.h"
// KDE includes
......@@ -56,23 +56,10 @@ void KPDialogPrivate::setAboutData(KPAboutData* const data, KPushButton* help)
if (!help) help = m_dialog->button(KDialog::Help);
if (!help) return;
m_about = data;
KHelpMenu* helpMenu = new KHelpMenu(m_dialog, m_about, false);
helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
KAction* handbook = new KAction(KIcon("help-contents"), i18n("Handbook"), m_dialog);
connect(handbook, SIGNAL(triggered(bool)),
this, SLOT(slotHelp()));
helpMenu->menu()->insertAction(helpMenu->menu()->actions().first(), handbook);
help->setMenu(helpMenu->menu());
}
m_about = data;
void KPDialogPrivate::slotHelp()
{
KToolInvocation::invokeHelp(m_about ? m_about->handbookEntry : QString(), "kipi-plugins");
m_about->setHelpButton(help);
}
} // namespace KIPIPlugins
......@@ -23,10 +23,6 @@
#ifndef KPTOOLDIALOG_PRIVATE_H
#define KPTOOLDIALOG_PRIVATE_H
// Qt includes
#include <QObject>
// Local includes
#include "kptooldialog.h"
......@@ -36,10 +32,8 @@ class KPushButton;
namespace KIPIPlugins
{
class KPDialogPrivate : public QObject
class KPDialogPrivate
{
Q_OBJECT
public:
KPDialogPrivate(KDialog* const dlg);
......@@ -47,10 +41,6 @@ public:
void setAboutData(KPAboutData* const data, KPushButton* help=0);
private Q_SLOTS:
void slotHelp();
private:
KPAboutData* m_about;
......
......@@ -21,7 +21,7 @@
*
* ============================================================ */
#include "kpaboutdata.h"
#include "kpaboutdata.moc"
// KDE includes
......@@ -29,6 +29,13 @@
#include <kstandarddirs.h>
#include <kglobalsettings.h>
#include <kdebug.h>
#include <kaction.h>
#include <khelpmenu.h>
#include <kicon.h>
#include <klocale.h>
#include <kmenu.h>
#include <kpushbutton.h>
#include <ktoolinvocation.h>
// Local includes
......@@ -42,7 +49,8 @@ KPAboutData::KPAboutData(const KLocalizedString& pluginName,
enum LicenseKey licenseType,
const KLocalizedString& pluginDescription,
const KLocalizedString& copyrightStatement)
: KAboutData(QByteArray("kipiplugins"), // Name without minus separator for KDE bug report.
: QObject(),
KAboutData(QByteArray("kipiplugins"), // Name without minus separator for KDE bug report.
QByteArray(),
pluginName,
kipipluginsVersion().toAscii(),
......@@ -77,9 +85,30 @@ KPAboutData::KPAboutData(const KLocalizedString& pluginName,
}
KPAboutData::KPAboutData(const KPAboutData& other)
: KAboutData(other)
: QObject((QObject*)(&other)),
KAboutData(other)
{
handbookEntry = other.handbookEntry;
}
void KPAboutData::setHelpButton(KPushButton* const help)
{
if (!help) return;
KHelpMenu* helpMenu = new KHelpMenu(help, this, false);
helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
KAction* handbook = new KAction(KIcon("help-contents"), i18n("Handbook"), helpMenu);
connect(handbook, SIGNAL(triggered(bool)),
this, SLOT(slotHelp()));
helpMenu->menu()->insertAction(helpMenu->menu()->actions().first(), handbook);
help->setMenu(helpMenu->menu());
}
void KPAboutData::slotHelp()
{
KToolInvocation::invokeHelp(handbookEntry, "kipi-plugins");
}
} // namespace KIPIPlugins
......@@ -26,17 +26,24 @@
// KDE includes
#include <QObject>
// KDE includes
#include <kaboutdata.h>
// Local includes
#include "kipiplugins_export.h"
class KPushButton;
namespace KIPIPlugins
{
class KIPIPLUGINS_EXPORT KPAboutData : public KAboutData
class KIPIPLUGINS_EXPORT KPAboutData : public QObject, public KAboutData
{
Q_OBJECT
public:
......@@ -48,6 +55,12 @@ public:
KPAboutData(const KPAboutData& other);
void setHelpButton(KPushButton* const help);
private Q_SLOTS:
void slotHelp();
public:
QString handbookEntry;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment