Alkimia API

alkapplication.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Ralf Habacker ralf.habacker @freenet.de
3
4 This file is part of libalkimia.
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7*/
8
9#include "alkapplication.h"
10
11#include <KAboutData>
12
13#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
14#include <KLocalizedString>
15#include <QApplication>
16#else
17#include <KApplication>
18#include <KCmdLineArgs>
19#endif
20
21class Private
22{
23public:
24 int _argc{0};
25 char **_argv{nullptr};
26 QStringList _args;
27 KAboutData *_aboutData{nullptr};
28#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
29 QApplication *_app{nullptr};
30#else
31 KApplication *_app{nullptr};
32#endif
33 ~Private()
34 {
35 delete _aboutData;
36 }
37};
38
39Q_GLOBAL_STATIC(Private, d)
40
41#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
42AlkAboutData::AlkAboutData(const QString &componentName, const QString &displayName, const QString &version,
43 const QString &shortDescription, AlkAboutData::License license, const QString &copyrightStatement)
44{
46 d->_aboutData = new KAboutData(componentName, displayName, version, shortDescription, static_cast<KAboutLicense::LicenseKey>(license), copyrightStatement);
47 d->_app = new QApplication(d->_argc, d->_argv);
48}
49
50AlkAboutData &AlkAboutData::setOrganizationDomain(const QByteArray &domain)
51{
52 d->_aboutData->setOrganizationDomain(domain);
53 return *this;
54}
55
56void AlkAboutData::setApplicationData(AlkAboutData &aboutData)
57{
58 Q_UNUSED(aboutData);
59
60 KAboutData::setApplicationData(*d->_aboutData);
61}
62
63QString AlkAboutData::displayName()
64{
65 return d()->_aboutData->displayName();
66}
67#else
68AlkAboutData::AlkAboutData(const QString &componentName, const QString &displayName, const QString &version,
69 const QString &shortDescription, AlkAboutData::License license, const QString &copyrightStatement)
70{
71 d()->_aboutData = new KAboutData(componentName.toLatin1(), componentName.toLatin1(), ki18n(displayName.toStdString().c_str()),
72 version.toStdString().c_str(), ki18n(shortDescription.toStdString().c_str()),
73 static_cast<KAboutData::LicenseKey>(license), ki18n(copyrightStatement.toStdString().c_str()));
74 KCmdLineArgs::init(d()->_aboutData);
75 d()->_app = new KApplication(true);
76}
77
78AlkAboutData &AlkAboutData::setOrganizationDomain(const QByteArray &domain)
79{
80 return *this;
81}
82
83void AlkAboutData::setApplicationData(AlkAboutData &aboutData)
84{
85}
86
87QString AlkAboutData::displayName()
88{
89 return d()->_aboutData->programName();
90}
91#endif
92
93QString AlkAboutData::shortDescription() const
94{
95 return d()->_aboutData->shortDescription();
96}
97
98AlkApplication::AlkApplication(int argc, char** argv)
99{
100 d()->_argc = argc;
101 d()->_argv = argv;
102 for (int i = 0; i < argc; i++)
103 d()->_args.append(argv[i]);
104}
105
106QStringList AlkApplication::arguments()
107{
108 return d()->_args;
109}
110
111int AlkApplication::exec()
112{
113 return d()->_app->exec();
114}
static void setApplicationData(const KAboutData &aboutData)
static void setApplicationDomain(const QByteArray &domain)
KLocalizedString KI18N_EXPORT ki18n(const char *text)
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
KCOREADDONS_EXPORT unsigned int version()
QByteArray toLatin1() const const
std::string toStdString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.