diff --git a/src/bluedevil.notifyrc b/src/bluedevil.notifyrc --- a/src/bluedevil.notifyrc +++ b/src/bluedevil.notifyrc @@ -539,3 +539,9 @@ Comment[zh_TW]=連線到裝置失敗 Icon=preferences-system-bluetooth Action=Popup + +[Event/SetupFinished] +Name=Device Setup Finished +Comment=Setting up a Bluetooth device finished successfully +Icon=dialog-positive +Action=Popup diff --git a/src/wizard/CMakeLists.txt b/src/wizard/CMakeLists.txt --- a/src/wizard/CMakeLists.txt +++ b/src/wizard/CMakeLists.txt @@ -27,6 +27,7 @@ KF5::I18n KF5::CoreAddons KF5::DBusAddons + KF5::Notifications KF5::WidgetsAddons KF5::IconThemes KF5::BluezQt) diff --git a/src/wizard/bluewizard.cpp b/src/wizard/bluewizard.cpp --- a/src/wizard/bluewizard.cpp +++ b/src/wizard/bluewizard.cpp @@ -73,6 +73,14 @@ BluezQt::InitManagerJob *initJob = m_manager->init(); initJob->start(); connect(initJob, &BluezQt::InitManagerJob::result, this, &BlueWizard::initJobResult); + + // When Finished page is opened, close wizard automatically + connect(this, &QWizard::currentIdChanged, this, [this](int id) { + if (id == Success) { + done(QDialog::Accepted); + } + // Sending notification in SuccessPage is asynchronous, so this needs to be queued. + }, Qt::QueuedConnection); } BluezQt::DevicePtr BlueWizard::device() const diff --git a/src/wizard/pages/success.cpp b/src/wizard/pages/success.cpp --- a/src/wizard/pages/success.cpp +++ b/src/wizard/pages/success.cpp @@ -25,17 +25,15 @@ #include "../bluewizard.h" #include "debug_p.h" -#include - #include +#include + SuccessPage::SuccessPage(BlueWizard *parent) : QWizardPage(parent) , m_wizard(parent) { - setupUi(this); - successIcon->setPixmap(QIcon::fromTheme(QStringLiteral("emblem-success")).pixmap(48)); } int SuccessPage::nextId() const @@ -45,21 +43,23 @@ void SuccessPage::initializePage() { - qCDebug(WIZARD) << "Initialize Success Page"; - - QList list; - list << QWizard::Stretch; - list << QWizard::FinishButton; - - m_wizard->setButtonLayout(list); - - setFinalPage(true); + qCDebug(WIZARD) << "Sending Success notification"; BluezQt::DevicePtr device = m_wizard->device(); + KNotification *notification = new KNotification(QStringLiteral("SetupFinished"), + KNotification::CloseOnTimeout, this); + notification->setComponentName(QStringLiteral("bluedevil")); + notification->setTitle(i18n("Setup Finished")); if (device->name().isEmpty()) { - successLbl->setText(i18nc("This string is shown when the wizard succeeds", "The setup of the device has succeeded")); + notification->setText(i18n("The device has been set up and can now be used.")); } else { - successLbl->setText(i18n("The setup of %1 has succeeded", device->name())); + notification->setText(i18nc("Placeholder is device name", + "The device '%1' has been set up and can now be used.", device->name())); } + // Mark as response to explicit user action ("pairing the device") + notification->setHint(QStringLiteral("x-kde-user-action"), true); + notification->sendEvent(); + + setFinalPage(true); }