1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 SPDX-FileCopyrightText: 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de> 4 SPDX-FileCopyrightText: 2011 Rodrigo Belem <rclbelem@gmail.com> 5 SPDX-FileCopyrightText: 2019 Nate Graham <nate@kde.org> 6 SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org> 7 */ 8 9 #ifndef SAMBAUSERSHAREPLUGIN_H 10 #define SAMBAUSERSHAREPLUGIN_H 11 12 #include <kpropertiesdialog.h> 13 #include <KSambaShareData> 14 15 #include <memory> 16 17 class UserPermissionModel; 18 class ShareContext; 19 class UserManager; 20 21 class SambaUserSharePlugin : public KPropertiesDialogPlugin 22 { 23 Q_OBJECT 24 Q_PROPERTY(bool dirty READ isDirty WRITE setDirty NOTIFY changed) // So qml can mark dirty 25 Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) // intentionally not writable from qml 26 // Expose instance-singleton members so QML may access them. 27 // They aren't application-wide singletons and also cannot easily be ctor'd from QML. 28 Q_PROPERTY(UserManager *userManager MEMBER m_userManager CONSTANT) 29 Q_PROPERTY(UserPermissionModel *userPermissionModel MEMBER m_model CONSTANT) 30 Q_PROPERTY(ShareContext *shareContext MEMBER m_context CONSTANT) 31 public: 32 SambaUserSharePlugin(QObject *parent, const QList<QVariant> &args); 33 ~SambaUserSharePlugin() override = default; 34 void applyChanges() override; 35 36 Q_INVOKABLE static bool isSambaInstalled(); 37 Q_INVOKABLE static void reboot(); 38 Q_INVOKABLE static void showSambaStatus(); 39 40 bool isReady() const; 41 42 Q_SIGNALS: 43 void readyChanged(); 44 45 private: 46 void setReady(bool ready); 47 void reportAdd(KSambaShareData::UserShareError error); 48 void reportRemove(KSambaShareData::UserShareError error); 49 50 const QString m_url; 51 ShareContext *m_context= nullptr; 52 UserPermissionModel *m_model = nullptr; 53 UserManager *m_userManager = nullptr; 54 bool m_ready = false; 55 // Hold the qquickwidget so it gets destroyed with us. Otherwise we'd have bogus reference errors 56 // as the Plugin instance is exposed as contextProperty to qml but the widget is parented to the PropertiesDialog 57 // (i.e. our parent). So the lifetime of the widget would usually exceed ours. 58 std::unique_ptr<QWidget> m_page = nullptr; 59 }; 60 61 #endif // SAMBAUSERSHAREPLUGIN_H 62