Commit 5101d790 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Wizard] Show notification instead of finished page when pairing succeeds

Saves the user from having to close the dialog when pairing succeeded.

Differential Revision: https://phabricator.kde.org/D26120
parent 9291b9d0
......@@ -539,3 +539,9 @@ Comment[zh_CN]=连接设备失败
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
......@@ -27,6 +27,7 @@ target_link_libraries(bluedevil-wizard
KF5::I18n
KF5::CoreAddons
KF5::DBusAddons
KF5::Notifications
KF5::WidgetsAddons
KF5::IconThemes
KF5::BluezQt)
......
......@@ -73,6 +73,14 @@ BlueWizard::BlueWizard()
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
......
......@@ -25,17 +25,15 @@
#include "../bluewizard.h"
#include "debug_p.h"
#include <QIcon>
#include <BluezQt/Device>
#include <KNotification>
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 @@ int SuccessPage::nextId() const
void SuccessPage::initializePage()
{
qCDebug(WIZARD) << "Initialize Success Page";
QList<QWizard::WizardButton> 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-feedback"), true);
notification->sendEvent();
setFinalPage(true);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment