summaryrefslogtreecommitdiffstats
path: root/examples/corelib/platform/androidnotifier/main.cpp
blob: 33e77c7018de3b779058eb3884715860a3de350c (plain)
1
2
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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "notificationclient.h"

#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QFont>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget widget;
    QPushButton happyButton;
    happyButton.setIcon(QIcon(":/images/happy.png"));
    happyButton.setIconSize(QSize(happyButton.width(), 120));

    QPushButton sadButton;
    sadButton.setIcon(QIcon(":/images/sad.png"));
    sadButton.setIconSize(QSize(sadButton.width(), 120));

    QVBoxLayout mainLayout;
    QHBoxLayout labelLayout;
    QLabel label = QLabel("Click a smiley to notify your mood");
    QFont font = label.font();
    font.setPointSize(20);
    label.setFont(font);
    labelLayout.addWidget(&label);
    labelLayout.setAlignment(Qt::AlignHCenter);
    mainLayout.addLayout(&labelLayout);

    QHBoxLayout smileysLayout;
    smileysLayout.addWidget(&sadButton);
    smileysLayout.addWidget(&happyButton);
    smileysLayout.setAlignment(Qt::AlignCenter);
    mainLayout.addLayout(&smileysLayout);
    widget.setLayout(&mainLayout);

//! [Connect button signals]
    QObject::connect(&happyButton, &QPushButton::clicked, []() {
        NotificationClient().setNotification("The user is happy!");
    });

    QObject::connect(&sadButton, &QPushButton::clicked, []() {
        NotificationClient().setNotification("The user is sad!");
    });
//! [Connect button signals]

    widget.show();
    return a.exec();
}