/*
  Copyright (C) 2026 Erich Eickmeyer <eeickmeyer@ubuntu.com>

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License as
  published by the Free Software Foundation; either version 2 of
  the License or (at your option) version 3 or any later version
  accepted by the membership of KDE e.V. (or its successor approved
  by the membership of KDE e.V.), which shall act as a proxy
  defined in Section 14 of version 3 of the license.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef L10NINSTALLGUI_H
#define L10NINSTALLGUI_H

#include <QDialog>
#include <QStringList>

class QLabel;
class QListWidget;
class QListWidgetItem;
class QProgressBar;
class QDialogButtonBox;
class QPushButton;

namespace PackageKit {
class Transaction;
}

class L10nInstallGui : public QObject
{
    Q_OBJECT
public:
    L10nInstallGui(QObject *parent, const QStringList &packageNames);
    ~L10nInstallGui();

private Q_SLOTS:
    void packageToggled(QListWidgetItem *item);
    void startInstall();
    void onPackageResolved(int info, const QString &packageID, const QString &summary);
    void onResolveFinished(int status, uint runtime);
    void onInstallPercentage(int percentage);
    void onInstallStatusChanged(int status);
    void onInstallFinished(int status, uint runtime);
    void onInstallErrorCode(int code, const QString &details);
    void cleanUpDialog();

private:
    void setUiInstalling(bool installing);
    QString transactionStatusText(int status) const;

    QDialog *m_dialog;
    QLabel *m_headerLabel;
    QListWidget *m_listWidget;
    QProgressBar *m_progressBar;
    QLabel *m_statusLabel;
    QDialogButtonBox *m_buttonBox;
    QPushButton *m_installButton;

    QStringList m_selectedPackages;
    QStringList m_resolvedPackageIDs;
    PackageKit::Transaction *m_currentTransaction;
};

#endif // L10NINSTALLGUI_H
