Changeset View
Changeset View
Standalone View
Standalone View
samba/filepropertiesplugin/sambausershareplugin.cpp
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | 20 | | |||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include <QDBusInterface> | ||||
24 | #include <QDBusPendingReply> | ||||
23 | #include <QDialogButtonBox> | 25 | #include <QDialogButtonBox> | ||
24 | #include <QFileInfo> | 26 | #include <QFileInfo> | ||
25 | #include <QFrame> | 27 | #include <QFrame> | ||
28 | #include <QIcon> | ||||
26 | #include <QPushButton> | 29 | #include <QPushButton> | ||
27 | #include <QStandardPaths> | 30 | #include <QStandardPaths> | ||
28 | #include <QStringList> | 31 | #include <QStringList> | ||
29 | #include <QDebug> | 32 | #include <QDebug> | ||
30 | 33 | | |||
31 | #include <KMessageBox> | 34 | #include <KMessageBox> | ||
32 | #include <KPluginFactory> | 35 | #include <KPluginFactory> | ||
33 | #include <KPluginLoader> | 36 | #include <KPluginLoader> | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 64 | { | |||
90 | vLayout->setAlignment(Qt::AlignJustify); | 93 | vLayout->setAlignment(Qt::AlignJustify); | ||
91 | vLayout->setMargin(0); | 94 | vLayout->setMargin(0); | ||
92 | 95 | | |||
93 | m_sambaStatusMessage = new QLabel(i18n("Samba must be installed before folders can be shared.")); | 96 | m_sambaStatusMessage = new QLabel(i18n("Samba must be installed before folders can be shared.")); | ||
94 | m_sambaStatusMessage->setAlignment(Qt::AlignCenter); | 97 | m_sambaStatusMessage->setAlignment(Qt::AlignCenter); | ||
95 | vLayout->addWidget(m_sambaStatusMessage); | 98 | vLayout->addWidget(m_sambaStatusMessage); | ||
96 | 99 | | |||
97 | #ifdef SAMBA_INSTALL | 100 | #ifdef SAMBA_INSTALL | ||
101 | m_justInstalledSambaWidgets = new QWidget(vbox); | ||||
102 | vLayoutMaster->addWidget(m_justInstalledSambaWidgets); | ||||
103 | QVBoxLayout *vJustInstalledLayout = new QVBoxLayout(m_justInstalledSambaWidgets); | ||||
104 | vJustInstalledLayout->setAlignment(Qt::AlignJustify); | ||||
105 | vJustInstalledLayout->addWidget(new QLabel(i18n("Restart the computer to complete the installation."), m_justInstalledSambaWidgets)); | ||||
106 | m_restartButton = new QPushButton(i18n("Restart"), m_justInstalledSambaWidgets); | ||||
107 | m_restartButton->setIcon(QIcon::fromTheme(QStringLiteral("system-reboot"))); | ||||
108 | connect(m_restartButton, &QPushButton::clicked, | ||||
109 | this, &SambaUserSharePlugin::reboot); | ||||
110 | vJustInstalledLayout->addWidget(m_restartButton); | ||||
111 | vJustInstalledLayout->addStretch(); | ||||
112 | m_restartButton->setDefault(false); | ||||
113 | m_justInstalledSambaWidgets->hide(); | ||||
114 | | ||||
98 | m_installSambaButton = new QPushButton(i18n("Install Samba"), m_installSambaWidgets); | 115 | m_installSambaButton = new QPushButton(i18n("Install Samba"), m_installSambaWidgets); | ||
99 | m_installSambaButton->setDefault(false); | 116 | m_installSambaButton->setDefault(false); | ||
100 | vLayout->addWidget(m_installSambaButton); | 117 | vLayout->addWidget(m_installSambaButton); | ||
101 | connect(m_installSambaButton, &QPushButton::clicked, | 118 | connect(m_installSambaButton, &QPushButton::clicked, | ||
102 | this, &SambaUserSharePlugin::installSamba); | 119 | this, &SambaUserSharePlugin::installSamba); | ||
103 | m_installProgress = new QProgressBar(); | 120 | m_installProgress = new QProgressBar(); | ||
104 | vLayout->addWidget(m_installProgress); | 121 | vLayout->addWidget(m_installProgress); | ||
105 | m_installProgress->hide(); | 122 | m_installProgress->hide(); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
179 | } | 196 | } | ||
180 | 197 | | |||
181 | void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status, uint runtime) | 198 | void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status, uint runtime) | ||
182 | { | 199 | { | ||
183 | Q_UNUSED(runtime); | 200 | Q_UNUSED(runtime); | ||
184 | if (status == PackageKit::Transaction::ExitSuccess) { | 201 | if (status == PackageKit::Transaction::ExitSuccess) { | ||
185 | m_installSambaWidgets->hide(); | 202 | m_installSambaWidgets->hide(); | ||
186 | m_failedSambaWidgets->hide(); | 203 | m_failedSambaWidgets->hide(); | ||
187 | m_shareWidgets->show(); | 204 | m_shareWidgets->hide(); | ||
205 | m_justInstalledSambaWidgets->show(); | ||||
188 | } else { | 206 | } else { | ||
189 | m_shareWidgets->hide(); | 207 | m_shareWidgets->hide(); | ||
190 | m_installSambaWidgets->hide(); | 208 | m_installSambaWidgets->hide(); | ||
191 | m_failedSambaWidgets->show(); | 209 | m_failedSambaWidgets->show(); | ||
192 | } | 210 | } | ||
193 | } | 211 | } | ||
212 | | ||||
213 | void SambaUserSharePlugin::reboot() | ||||
214 | { | ||||
215 | QDBusInterface interface(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"), QDBusConnection::sessionBus()); | ||||
216 | interface.asyncCall(QStringLiteral("logout"), 0, 1, 2); // Options: do not ask again | reboot | force | ||||
217 | } | ||||
194 | #endif // SAMBA_INSTALL | 218 | #endif // SAMBA_INSTALL | ||
195 | 219 | | |||
196 | void SambaUserSharePlugin::setupModel() | 220 | void SambaUserSharePlugin::setupModel() | ||
197 | { | 221 | { | ||
198 | model = new UserPermissionModel(shareData, this); | 222 | model = new UserPermissionModel(shareData, this); | ||
199 | } | 223 | } | ||
200 | 224 | | |||
201 | void SambaUserSharePlugin::setupViews() | 225 | void SambaUserSharePlugin::setupViews() | ||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |