/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
 *
 * 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) any later version.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef NETDETAIL_H
#define NETDETAIL_H

#include <QDialog>
#include <QPainter>
#include <QObject>
#include <QStackedWidget>
#include <QLayout>
#include <QLabel>
#include <QPushButton>
#include <QVariantMap>
#include <QGuiApplication>
#include <QScreen>
#include <QApplication>
#include <QDebug>
#include <QSettings>

#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <QCloseEvent>
#include <kylin-nm/kylin-nm-interface.h>

#include "detailpage.h"
#include "ipv4page.h"
#include "ipv6page.h"
#include "coninfo.h"
#include "kwidget.h"
#include "ktabbar.h"

using namespace kdk;

class NetDetail : public QWidget
{
    Q_OBJECT

public:
    NetDetail(PluginType type, QString interface, QString name, QString uuid, bool isPppoe, ConInfo info, QWidget *parent = nullptr);

    void updateConnect(KyConnectSetting &connetSetting);
    QString getInterface() {
        return m_deviceName;
    }
protected:
    void paintEvent(QPaintEvent *event);
    void closeEvent(QCloseEvent *event);
    bool eventFilter(QObject *w, QEvent *event);

private:
    void initUI();
    void centerToScreen();
    void initComponent();
    void loadPage();
    void pagePadding();

    void setConfirmEnable();

    void setNetdetailSomeEnable(bool on);

    void checkNeedUpdate();
private:

    QStackedWidget * stackWidget;

    DetailPage     * detailPage;
    Ipv4Page       * ipv4Page;
    Ipv6Page       * ipv6Page;

    QWidget      * centerWidget;
    QWidget      * bottomWidget;

    QPushButton  * cancelBtn;
    QPushButton  * forgetBtn;
    QPushButton  * confimBtn;

    QFrame       * pageFrame;
    KTabBar      *m_netTabBar = nullptr;

    QString      m_name;
    QString      m_uuid;
    QString      m_deviceName;
    PluginType   m_pluginType;

    bool         m_isPppoe;

    bool         isIpv4Ok;
    bool         isIpv6Ok;
    bool         isConfirmBtnEnable;

    ConInfo      m_info;

private Q_SLOTS:
    void on_btnConfirm_clicked();
    void on_btnForget_clicked();
    void onPaletteChanged();

protected Q_SLOTS:
    void currentRowChangeSlot(int row);

Q_SIGNALS:
    void detailPageClose(QString, QString);
    void currentChanged(int);
    void deleteConnect(QString);
    void needUpdate(QString, QString);
};



#endif // NETDETAIL_H
