#ifndef MAINTAINMODE_H
#define MAINTAINMODE_H

#include <QComboBox>
#include <QDBusUnixFileDescriptor>
#include <QFrame>
#include <QLabel>
#include <QObject>
#include <QPushButton>
#include <QRadioButton>
#include <QWidget>
#include <QtDBus/QDBusInterface>
#include <QtPlugin>

#include "component/DrownLabel/drownlabel.h"
#include "interface.h"
#include "kswitchbutton.h"
#include "lightlabel.h"
#include "titlelabel.h"

class MaintainMode : public QObject, CommonInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
    Q_INTERFACES(CommonInterface)

public:
    explicit MaintainMode();
    ~MaintainMode();

    QString plugini18nName() Q_DECL_OVERRIDE;
    int pluginTypes() Q_DECL_OVERRIDE;
    QWidget *pluginUi() Q_DECL_OVERRIDE;
    const QString name() const Q_DECL_OVERRIDE;
    bool isShowOnHomePage() const Q_DECL_OVERRIDE;
    QIcon icon() const Q_DECL_OVERRIDE;
    bool isEnable() const Q_DECL_OVERRIDE;
    QString translationPath() const Q_DECL_OVERRIDE;
    QRadioButton *radioGreen;
    QRadioButton *radioRed;
    bool isRedButton;

private:
    QString pluginName;
    int pluginType;
    QWidget *pluginWidget;
    QDBusInterface *iface;
    QDBusInterface *wmIface;

private:
    bool mFirstLoad = true;
    void initUI(QWidget *widget);
    //    Title Area
    TitleLabel *mTitleLabel;
    //    Master Area
    QFrame *mMasterFrame;
    QLabel *mMasterLabel;
    QFrame *mEnableFrame;
    QLabel *mEnableLabel;
    LightLabel *mEnbleSubLabel;
    kdk::KSwitchButton *mEnableButton;
    bool mEnableButtonStatus = false;
    //    Expand Area_1
    QFrame *mLineUnderEnableFrame;
    QFrame *inline1;
    QFrame *inline2;
    QFrame *mExpandFrame_1;
    QLabel *mExpandLabel_1;
    LightLabel *mExpandSubLabel_1;
    kdk::KSwitchButton *mExpandButton_1;
    //    Expand Area_2
    QFrame *mLineUnderExpandArea1;
    QFrame *mExpandFrame_2;
    QLabel *mExpandLabel_2;
    DrownLabel *mExpandButton_2;
    //    Expand Area_3
    QFrame *mLineUnderExpandArea2;
    QFrame *mExpandFrame_3;
    QLabel *mExpandLabel_3_Color;
    QLabel *mExpandLabel_3_Font;
    QComboBox *mFontBox;
    QLabel *mExpandLabel_3_Posision;
    QComboBox *mPosisionBox;
    QDBusUnixFileDescriptor m_inhibitFileDescriptor;

private:
    inline void setFrameNoFrame(QFrame *frame);
    inline QFrame *setLine(QFrame *frame);
    inline QVariant readIniFile(const QString &filepath, const QString &group, const QString &key);
    void normalExitMaintain();
    bool enterMaintainWarning();
    bool polkitEdit();
    void inhibit();
    void uninhibit();

signals:
    void inHibitChanged(bool changed);

private slots:
    bool mEnableButtonComfirmSlot(void);
    bool mEnableButtonSlot(bool status);
    void mSendSignalOfWatermask();
    void mInhibitStatus(bool status);
};
#endif // MAINTAINMODE_H
