success.cpp 2.91 KB
Newer Older
David Rosca's avatar
David Rosca committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*****************************************************************************
 * This file is part of the KDE project                                      *
 *                                                                           *
 * Copyright (C) 2010 Alejandro Fiestas Olivares <afiestas@kde.org>          *
 * Copyright (C) 2010-2011 UFO Coders <info@ufocoders.com>                   *
 * Copyright (C) 2014 David Rosca <nowrep@gmail.com>                         *
 *                                                                           *
 * This library is free software; you can redistribute it and/or             *
 * modify it under the terms of the GNU Library General Public               *
 * License as published by the Free Software Foundation; either              *
 * version 2 of the License, or (at your option) any later version.          *
 *                                                                           *
 * This library is distributed in the hope that it will be useful,           *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 * Library General Public License for more details.                          *
 *                                                                           *
 * You should have received a copy of the GNU Library General Public License *
 * along with this library; see the file COPYING.LIB.  If not, write to      *
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,      *
 * Boston, MA 02110-1301, USA.                                               *
 *****************************************************************************/

#include "success.h"
David Rosca's avatar
David Rosca committed
25
#include "../bluewizard.h"
David Rosca's avatar
David Rosca committed
26
27
#include "debug_p.h"

David Rosca's avatar
David Rosca committed
28
#include <BluezQt/Device>
David Rosca's avatar
David Rosca committed
29

30
31
#include <KNotification>

David Rosca's avatar
David Rosca committed
32
33
34
35
36
37
38
SuccessPage::SuccessPage(BlueWizard *parent)
    : QWizardPage(parent)
    , m_wizard(parent)
{

}

David Rosca's avatar
David Rosca committed
39
40
41
42
43
int SuccessPage::nextId() const
{
    return -1;
}

David Rosca's avatar
David Rosca committed
44
45
void SuccessPage::initializePage()
{
46
    qCDebug(WIZARD) << "Sending Success notification";
David Rosca's avatar
David Rosca committed
47

David Rosca's avatar
David Rosca committed
48
49
    BluezQt::DevicePtr device = m_wizard->device();

50
51
52
53
    KNotification *notification = new KNotification(QStringLiteral("SetupFinished"),
                                                    KNotification::CloseOnTimeout, this);
    notification->setComponentName(QStringLiteral("bluedevil"));
    notification->setTitle(i18n("Setup Finished"));
David Rosca's avatar
David Rosca committed
54
    if (device->name().isEmpty()) {
55
        notification->setText(i18n("The device has been set up and can now be used."));
David Rosca's avatar
David Rosca committed
56
    } else {
57
58
        notification->setText(i18nc("Placeholder is device name",
                                    "The device '%1' has been set up and can now be used.", device->name()));
David Rosca's avatar
David Rosca committed
59
    }
60
61
62
63
64
    // Mark as response to explicit user action ("pairing the device")
    notification->setHint(QStringLiteral("x-kde-user-action-feedback"), true);
    notification->sendEvent();

    setFinalPage(true);
David Rosca's avatar
David Rosca committed
65
}