diff --git a/samba/filepropertiesplugin/sambausershareplugin.h b/samba/filepropertiesplugin/sambausershareplugin.h --- a/samba/filepropertiesplugin/sambausershareplugin.h +++ b/samba/filepropertiesplugin/sambausershareplugin.h @@ -59,6 +59,10 @@ QLabel *m_sambaStatusMessage; QProgressBar *m_installProgress; QPushButton *m_installSambaButton; +#ifdef SAMBA_INSTALL + QWidget *m_justInstalledSambaWidgets; + QPushButton *m_restartButton; +#endif // SAMBA_INSTALL void setupModel(); void setupViews(); @@ -69,6 +73,7 @@ #ifdef SAMBA_INSTALL void installSamba(); void packageFinished(PackageKit::Transaction::Exit status, uint runtime); + void reboot(); #endif // SAMBA_INSTALL diff --git a/samba/filepropertiesplugin/sambausershareplugin.cpp b/samba/filepropertiesplugin/sambausershareplugin.cpp --- a/samba/filepropertiesplugin/sambausershareplugin.cpp +++ b/samba/filepropertiesplugin/sambausershareplugin.cpp @@ -20,9 +20,12 @@ */ +#include +#include #include #include #include +#include #include #include #include @@ -95,6 +98,20 @@ vLayout->addWidget(m_sambaStatusMessage); #ifdef SAMBA_INSTALL + m_justInstalledSambaWidgets = new QWidget(vbox); + vLayoutMaster->addWidget(m_justInstalledSambaWidgets); + QVBoxLayout *vJustInstalledLayout = new QVBoxLayout(m_justInstalledSambaWidgets); + vJustInstalledLayout->setAlignment(Qt::AlignJustify); + vJustInstalledLayout->addWidget(new QLabel(i18n("Restart the computer to complete the installation."), m_justInstalledSambaWidgets)); + m_restartButton = new QPushButton(i18n("Restart"), m_justInstalledSambaWidgets); + m_restartButton->setIcon(QIcon::fromTheme(QStringLiteral("system-reboot"))); + connect(m_restartButton, &QPushButton::clicked, + this, &SambaUserSharePlugin::reboot); + vJustInstalledLayout->addWidget(m_restartButton); + vJustInstalledLayout->addStretch(); + m_restartButton->setDefault(false); + m_justInstalledSambaWidgets->hide(); + m_installSambaButton = new QPushButton(i18n("Install Samba"), m_installSambaWidgets); m_installSambaButton->setDefault(false); vLayout->addWidget(m_installSambaButton); @@ -188,13 +205,20 @@ if (status == PackageKit::Transaction::ExitSuccess) { m_installSambaWidgets->hide(); m_failedSambaWidgets->hide(); - m_shareWidgets->show(); + m_shareWidgets->hide(); + m_justInstalledSambaWidgets->show(); } else { m_shareWidgets->hide(); m_installSambaWidgets->hide(); m_failedSambaWidgets->show(); } } + +void SambaUserSharePlugin::reboot() +{ + QDBusInterface interface(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"), QDBusConnection::sessionBus()); + interface.asyncCall(QStringLiteral("logout"), 0, 1, 2); // Options: do not ask again | reboot | force +} #endif // SAMBA_INSTALL void SambaUserSharePlugin::setupModel()