| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 
 | /* ============================================================
 *
 * This file is a part of KDE project
 *
 *
 * Date        : 2006-14-09
 * Description : Kipi-Plugins shared library.
 *
 * Copyright (C) 2006-2010 by Angelo Naselli <anaselli at linux dot it>
 * Copyright (C) 2010-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * 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, 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.
 *
 * ============================================================ */
#include "kpaboutdata.h"
// Qt includes
#include <QUrl>
#include <QUrlQuery>
#include <QDesktopServices>
#include <QIcon>
#include <QAction>
#include <QMenu>
#include <QPushButton>
#include <QStandardPaths>
#include <QMessageBox>
#include <QApplication>
// Local includes
#include "kipiplugins_debug.h"
#include "kpversion.h"
namespace KIPIPlugins
{
KPAboutData::KPAboutData(const KLocalizedString& tool,
                         const KLocalizedString& description,
                         const KLocalizedString& copyright)
    : QObject()
{
    m_tool        = tool.toString();
    m_description = description.toString();
    m_copyright   = copyright.toString();
}
KPAboutData::KPAboutData(const KPAboutData& other)
    : QObject((QObject*)(&other))
{
    m_tool          = other.m_tool;
    m_description   = other.m_description;
    m_copyright     = other.m_copyright;
    m_handbookEntry = other.m_handbookEntry;
}
KPAboutData::~KPAboutData()
{
}
void KPAboutData::setHandbookEntry(const QString& entry)
{
    m_handbookEntry = entry;
}
void KPAboutData::setHelpButton(QPushButton* const help)
{
    QMenu* const menu = new QMenu(help);
    
    QAction* const book = menu->addAction(QIcon::fromTheme(QString::fromLatin1("help-contents")), i18n("Handbook"));
    connect(book, &QAction::triggered,
            this, &KPAboutData::slotHelp);
    QAction* const about = menu->addAction(QIcon::fromTheme(QString::fromLatin1("help-about")), i18n("About..."));
    connect(about, &QAction::triggered,
            this, &KPAboutData::slotAbout);    
   
    help->setMenu(menu);
}
void KPAboutData::addAuthor(const QString& name, const QString& role, const QString& email)
{
    QString mailUrl = email;
    mailUrl.remove(QLatin1String(" "));
    QString data = QString::fromUtf8("%1 <%2>\n%3").arg(name).arg(mailUrl).arg(role);
    m_authors.append(data);
}
void KPAboutData::slotHelp()
{
    QUrl url = QUrl(QString::fromUtf8("help:/%1/index.html").arg(QString::fromLatin1("kipi-plugins")));
    if (!m_handbookEntry.isEmpty())
    {
        QUrlQuery query(url);
        query.addQueryItem(QStringLiteral("anchor"), m_handbookEntry);
        url.setQuery(query);
    }
    QDesktopServices::openUrl(url);
}
void KPAboutData::slotAbout()
{
    QString text;
    
    text.append(m_description);
    text.append(QLatin1String("\n\n"));
    text.append(i18n("Version: %1", kipipluginsVersion()));
    text.append(QLatin1String("\n\n"));
    text.append(m_copyright);
    text.append(QLatin1String("\n\n"));
    
    foreach(QString data, m_authors)
    {
        text.append(data);
        text.append(QLatin1String("\n\n"));
    }
    
    text.remove(text.size()-2, 2);
    QMessageBox::about(qApp->activeWindow(), i18n("About %1", m_tool), text);
}
} // namespace KIPIPlugins
 |