#pragma once

#include <QGroupBox>
#include <QMainWindow>
#include <QSplashScreen>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QTextEdit>
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QComboBox>
#include <QGridLayout>
#include <QLineEdit>
#include <QWidget>
#include <QPalette>
#include <QTableWidget>
#include <QHeaderView>
#include <QDialog>

#include <memory>
#include <string>
#include <vector>
#include <map>
using namespace std;

extern const string QSS_GROUP;

extern const string QSS_BTN;
extern const string QSS_BTN_ACTIVE;
extern const string QSS_BTN_MENU;
extern const string QSS_BTN_MENU_ACTIVE;
extern const string QSS_BTN_TAB;
extern const string QSS_LINE;

extern const string QSS_TABLE;
extern const string QSS_BTN_COMBOX;

class LabelPair
{
public:
    LabelPair(QWidget* parent, int x, int y, int w, int h)
    {
        title.setParent(parent);
        value.setParent(&title);
        title.setGeometry(x, y, w, h);
        value.setGeometry(80, 0, w-80, h);
        title.show();
        value.show();
    }

    void setTitle(string text)
    {
        title.setText(text.c_str());
    }

    void setValue(string text)
    {
        value.setText(text.c_str());
    }

    QLabel title;
    QLabel value;
};

class MyWidget : public QWidget
{
    Q_OBJECT
public:
    MyWidget(QWidget* parent);
    virtual void onTimer() {};
};

using MyPairLabelLine = pair<shared_ptr<QLabel>, shared_ptr<QLineEdit>>;

class MyQUI
{
public:
    static shared_ptr<QWidget> Widget(QWidget* parent, string objectName, string qss);
    static shared_ptr<QPushButton> Button(QWidget* parent, int x, int y, int w, int h, string title);

	static shared_ptr<QGroupBox> GroupBox(QWidget* parent, int x, int y, int w, int h, string title);

    static MyPairLabelLine PairLine(QWidget* parent, int x, int y, string k, string v, bool readonly=true);

    static shared_ptr<QTableWidget> TableWidget(QWidget* parent, int x, int y, int w, int h);

    static void setTableCellText(shared_ptr<QTableWidget> table, int row, int col, string text, string style = "");

    static void setTableCellButton(shared_ptr<QTableWidget> table, int row, int col, const vector<string>& items, QObject* obj, function<void(string)> cb);
   
    
};