File indexing completed on 2024-05-19 04:01:20

0001 /*
0002     SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #include <notificationpopup.h>
0008 #include <provider.h>
0009 #include <surveyinfo.h>
0010 
0011 #include <QApplication>
0012 #include <QPushButton>
0013 #include <QStandardPaths>
0014 #include <QUuid>
0015 #include <QVBoxLayout>
0016 
0017 using namespace KUserFeedback;
0018 
0019 int main(int argc, char **argv)
0020 {
0021     QStandardPaths::setTestModeEnabled(true);
0022 
0023     QCoreApplication::setApplicationName(QStringLiteral("notificationpopuptest"));
0024     QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
0025     QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
0026     QCoreApplication::setApplicationVersion(QStringLiteral("1984"));
0027 
0028     QApplication app(argc, argv);
0029 
0030     Provider provider;
0031 
0032     QWidget topLevel;
0033     auto layout = new QVBoxLayout(&topLevel);
0034     auto button = new QPushButton(QStringLiteral("Show Encouragement"));
0035     layout->addWidget(button);
0036     QObject::connect(button, &QPushButton::clicked, &provider, &Provider::showEncouragementMessage);
0037     button = new QPushButton(QStringLiteral("New Survey Available"));
0038     layout->addWidget(button);
0039     QObject::connect(button, &QPushButton::clicked, &provider, [&provider]() {
0040         SurveyInfo info;
0041         info.setUuid(QUuid(QStringLiteral("{9e529dfa-0213-413e-a1a8-8a9cea7d5a97}")));
0042         info.setUrl(QUrl(QStringLiteral("https://www.kde.org/")));
0043         Q_EMIT provider.surveyAvailable(info);
0044     });
0045 
0046     auto popup = new NotificationPopup(&topLevel);
0047     popup->setFeedbackProvider(&provider);
0048 
0049     topLevel.resize(1024, 786);
0050     topLevel.show();
0051     return app.exec();
0052 }