Falkon Develop
Cross-platform Qt-based web browser
qmlnotifications.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
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#include "qmlnotifications.h"
19#include "mainapplication.h"
21#include "qztools.h"
23
25 : QObject(parent)
26{
27}
28
29void QmlNotifications::create(const QVariantMap &map)
30{
31 const QString iconUrl = map.value(QSL("icon")).toString();
32 QmlFileUtils fileUtils(m_pluginPath);
33 const QString iconPath = fileUtils.resolve(iconUrl);
34 const QPixmap icon = QPixmap(iconPath);
35 const QString heading = map.value(QSL("heading")).toString();
36 const QString message = map.value(QSL("message")).toString();
37 mApp->desktopNotifications()->showNotification(icon, heading, message);
38}
39
40void QmlNotifications::setPluginPath(const QString &path)
41{
42 m_pluginPath = path;
43}
The QmlFileUtils class, exposed to QML as FileUtils.
Definition: qmlfileutils.h:26
Q_INVOKABLE QString resolve(const QString &filePath)
Get the path of the file within the plugin directory. If the filePath provided is resolved to be outs...
Q_INVOKABLE void create(const QVariantMap &map)
Create and display a notification.
QmlNotifications(QObject *parent=nullptr)
void setPluginPath(const QString &path)
#define mApp
#define QSL(x)
Definition: qzcommon.h:40