#ifndef SIZE_PARA_H
#define SIZE_PARA_H
#include <QString>
#include <QSize>
#include <QColor>
#include "xatom-helper.h"
// 添加窗管协议
#define UKUI_WIN_CONTROL_PROTOOL(winId)                                         \
        do                                                                      \
        {                                                                       \
                MotifWmHints hints;                                             \
                hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;      \
                hints.functions = MWM_FUNC_ALL;                                 \
                hints.decorations = MWM_DECOR_BORDER;                           \
                XAtomHelper::getInstance()->setWindowMotifHint((winId), hints); \
        } while (0)
const int MAIN_WIN_WIDTH = 900;
const int MAIN_WIN_HEIGHT = 600;
const int NAVIGATION_SECTOR_WIDTH = 300;
const int EXHBITION_SECTOR_WIDTH = 600;
const QSize DEVICE_LIST_SECTION = QSize(286, 500);
const QSize DEVICE_LIST_BTN_SIZE = QSize(268, 60);
const QSize DEVICE_PROPERTY_SECTION = QSize(600, 538);
const QSize TITLE_BTN_SIZE = QSize(24, 24);
const QSize TITLE_ICON_SIZE = QSize(24, 24);
const QSize BTN_ICON_SIZE = QSize(16, 16);
const QSize LARGE_BTN_ICON_SIZE = QSize(48, 48);
const QSize LARGE_BTN_SIZE = QSize(36, 36);
const QSize WIN_BTN_SIZE = QSize(30, 30);
const QSize NORMAL_BTN_SIZE = QSize(120, 36);
const QSize LOGO_ICON_SIZE = QSize(128, 128);
const QSize LOGO_BTN_SIZE = QSize(128, 128);
const QString BTN_TO_LABEL_STYLE = "QPushButton{border:0px;border-radius:4px;background:transparent;}"
                                   "QPushButton:Hover{border:0px;border-radius:4px;background:transparent;}"
                                   "QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
const QString GRAY_TEXT_LABEL_STYLE = "QLabel{color:rgba(140, 140, 140, 1);}";

enum class PropertyBoxStyle : int {
    TEXT_WITH_LINEEDIT_EDITABLE = 0,
    TEXT_WITH_LINEEDIT_UNEDITABLE,
    TEXT_WITH_LINEEDIT_AND_BUTTON,
    TEXT_WITH_COMBOBOX,
    TEXT_WITH_SWITCH,
    LABEL_WITH_STATE,
};
using styleInfoPair = QPair<QString,PropertyBoxStyle> ;

const QMap<QString,PropertyBoxStyle> g_propertyList = {
    std::map<QString, PropertyBoxStyle>::value_type("Name",PropertyBoxStyle::TEXT_WITH_LINEEDIT_UNEDITABLE),
    std::map<QString, PropertyBoxStyle>::value_type("Location",PropertyBoxStyle::TEXT_WITH_LINEEDIT_EDITABLE),
    std::map<QString, PropertyBoxStyle>::value_type("Status",PropertyBoxStyle::LABEL_WITH_STATE),
    std::map<QString, PropertyBoxStyle>::value_type("Driver",PropertyBoxStyle::TEXT_WITH_LINEEDIT_AND_BUTTON),
    std::map<QString, PropertyBoxStyle>::value_type("URI",PropertyBoxStyle::TEXT_WITH_LINEEDIT_EDITABLE),
    std::map<QString, PropertyBoxStyle>::value_type("Resolution",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("PageSize",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Source",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("PageType",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Color",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Direction",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Duplex",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Pages per Side",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Ink Rank",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
    std::map<QString, PropertyBoxStyle>::value_type("Output Order",PropertyBoxStyle::TEXT_WITH_COMBOBOX),
//  std::map<QString, PropertyBoxStyle>::value_type("Scale To Fit Size:",PropertyBoxStyle::TEXT_WITH_SWITCH),
};

template<typename T>
void elideLabelText(T& container,const QString& inputStr)
{
    QFontMetrics fontMetrics(container->font());
    int fontSize = fontMetrics.width(inputStr);

    if(fontSize > container->width())
    {
        QString tmpStr = inputStr;
        tmpStr = fontMetrics.elidedText(inputStr, Qt::ElideRight, container->width());
        container->setText(tmpStr);
        container->setToolTip(inputStr);
    }
    else
    {
        container->setToolTip("");
        container->setText(inputStr);
    }
}

#endif // SIZE_PARA_H
