#ifndef CHANGE_OTHER_USER_PASSWORD_PANEL_H
#define CHANGE_OTHER_USER_PASSWORD_PANEL_H

#include "../PanelBase/overlay-panel-base.h"
#include <QLineEdit>
#include <QProcess>
#include "../DialogButton/dialog-button.h"
#include <QLabel>

class ChangeOtherUserPasswordPanel : public OverlayPanelBase {
    Q_OBJECT
public:
    explicit ChangeOtherUserPasswordPanel(const QString &username, QWidget *parent = nullptr);
    ~ChangeOtherUserPasswordPanel() override;

signals:
    void passwordChanged(const QString &username);
    void passwordChangeFailed(const QString &message);
    // requestClose() signal inherited from OverlayPanelBase

private slots:
    void validateInputs();
    void onConfirm();

private:
    QString m_username;
    class PasswordLineEdit *m_newPasswordEdit{nullptr};
    QString m_lastError;
    DialogButton *m_confirmButton{nullptr};
    DialogButton *m_cancelButton{nullptr};
    QProcess *m_process{nullptr};
    bool m_finished{false};
    void setInputsEnabled(bool enabled);
    void showPopupError(const QString &title, const QString &msg);
    void showFieldError(QWidget *field, const QString &msg);
    void cleanupProcess();
};

#endif // CHANGE_OTHER_USER_PASSWORD_PANEL_H