MauiKit Controls

mauiapp.cpp
1/*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2019 camilo <chiguitar@unal.edu.co>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "mauiapp.h"
20#include "fmh.h"
21#include "style.h"
22
23#include <QDir>
24#include <QStandardPaths>
25#include <QQuickWindow>
26#include <QWindow>
27
28#include <KLocalizedString>
29#include <KCoreAddons>
30
31#if defined BUNDLE_LUV_ICONS
32#include <QIcon>
33#endif
34
35#include <QQuickStyle>
36
37#include "../mauikit_version.h"
38#include "moduleinfo.h"
39
40Q_GLOBAL_STATIC(MauiApp, appInstance)
41
42KAboutComponent MauiApp::aboutMauiKit()
43{
44 return KAboutComponent("MauiKit", i18n("Multi-adaptable user interfaces."), MauiApp::getMauikitVersion(), "https://mauikit.org", KAboutLicense::GPL_V3);
45}
46
47MauiApp::MauiApp(QObject *parent)
48 : QObject(parent)
49{
50 qDebug() << "CREATING INSTANCE OF MAUI APP";
51
53 if (aboutData.translators().isEmpty())
54 {
55 aboutData.setTranslator(i18ndc(nullptr, "NAME OF TRANSLATORS", "Your names"), //
56 i18ndc(nullptr, "EMAIL OF TRANSLATORS", "Your emails"));
57
58 }
59
60 const auto MauiData = MauiKitCore::aboutData();
61 aboutData.addComponent(MauiData.name(),
62 MauiKitCore::buildVersion(),
63 MauiData.version(),
64 MauiData.webAddress(),
65 MauiData.license().key());
66
67 aboutData.addComponent("Qt", "", QT_VERSION_STR, "https://qt.io");
68
69 aboutData.addComponent(QStringLiteral("KDE Frameworks"), "", KCoreAddons::versionString(), "https://kde.org");
70
71
72#if defined BUNDLE_LUV_ICONS
73 const auto luvData = MauiKitCore::aboutLuv();
74 aboutData.addComponent(luvData.name(),
75 "",
76 luvData.version(),
77 luvData.webAddress(),
78 luvData.license().key());
79#endif
80
82 setDefaultMauiStyle();
83}
84
86{
87 return MAUIKIT_VERSION_STRING;
88}
89
91{
92 return m_iconName;
93}
94
95void MauiApp::setIconName(const QString &value)
96{
97 if (m_iconName == value)
98 return;
99
100 m_iconName = value;
101 Q_EMIT this->iconNameChanged();
102}
103
105{
106 return m_donationPage;
107}
108
110{
111 if (m_donationPage == value)
112 return;
113
114 m_donationPage = value;
115 Q_EMIT this->donationPageChanged();
116}
117
122
123void MauiApp::setDefaultMauiStyle()
124{
125#if defined BUNDLE_LUV_ICONS
126 Q_INIT_RESOURCE(icons);
127 QIcon::setThemeSearchPaths({":/icons/luv-icon-theme"});
128 QIcon::setThemeName("Luv");
129#endif
130
131#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
132 QQuickStyle::setStyle("maui-style");
133#else
134 QQuickStyle::setStyle(QStringLiteral("QtQuick.Controls.Maui"));
135#endif
136}
137
138MauiApp *MauiApp::qmlAttachedProperties(QObject *object)
139{
140 Q_UNUSED(object)
141 return MauiApp::instance();
142}
143
145{
146 return appInstance();
147}
148
150{
151 qDebug() << "Setting the MauiApp root component" << item;
152 if(m_rootComponent == item)
153 return;
154
155 m_rootComponent = item;
156 Q_EMIT rootComponentChanged();
157}
158
159QObject * MauiApp::rootComponent()
160{
161 return m_rootComponent;
162}
163
165{
166 if(!m_rootComponent)
167 return;
168
169 QMetaObject::invokeMethod(m_rootComponent, "about");
170}
static void setApplicationData(const KAboutData &aboutData)
static KAboutData applicationData()
The MauiApp class The MauiApp is a global singleton instance, can be accessed from QML as an attached...
Definition mauiapp.h:52
void setIconName(const QString &value)
Set the file URL to the application icon.
Definition mauiapp.cpp:95
QString getDonationPage() const
Donation web page link.
Definition mauiapp.cpp:104
static MauiApp * instance()
Retrieves the single instance of MauiApp.
Definition mauiapp.cpp:144
QString getIconName() const
The file URL to the application icon.
Definition mauiapp.cpp:90
KAboutData getAbout() const
Gather information about this module.
Definition mauiapp.cpp:118
Q_INVOKABLE void setRootComponent(QObject *item)
Define the root element of the Maui Application.
Definition mauiapp.cpp:149
void setDonationPage(const QString &value)
Set the donation web page link.
Definition mauiapp.cpp:109
static QString getMauikitVersion()
The formatted MauiKit version string.
Definition mauiapp.cpp:85
Q_INVOKABLE void aboutDialog()
Requests to display the about dialog.
Definition mauiapp.cpp:164
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT QString versionString()
void setThemeName(const QString &name)
void setThemeSearchPaths(const QStringList &paths)
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
Q_EMITQ_EMIT
void setStyle(const QString &style)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.