#include "autobootui.h"
#include <QVBoxLayout>

AutoBootUi::AutoBootUi(QWidget *parent) : QWidget(parent)
{
    initUi();
}

void AutoBootUi::initUi()
{
    QVBoxLayout *vLyt = new QVBoxLayout(this);
    vLyt->setSpacing(8);
    vLyt->setContentsMargins(0, 0, 0, 0);

    TitleLabel *mTitleLabel = new TitleLabel(this);
    //~ contents_path /Autostart/Autostart Settings
    mTitleLabel->setText(tr("Autostart Settings"));

    mAutobootWidget = new SettingGroup(this);

    mAddWidget = new UkccFrame(mAutobootWidget);
    mAddWidget->setLineWidth(0);
    QHBoxLayout *Lyt = new QHBoxLayout(mAddWidget);
    Lyt->setContentsMargins(0, 0, 0, 0);
    mAddBtn = new AddButton(mAddWidget);
    //~ contents_path /Autostart/Add
    tr("Add");       // 用于添加搜索索引
    Lyt->addWidget(mAddBtn);

    vLyt->addWidget(mTitleLabel);
    vLyt->addWidget(mAutobootWidget);
    vLyt->addStretch();
}

void AutoBootUi::resetUi()
{
    if (this->layout() != NULL) {
        QLayoutItem *item;
        while ((item = this->layout()->takeAt(0)) != NULL)
        {
            if(item->widget()) {
               item->widget()->setParent(NULL);
            }
            delete item;
            item = nullptr;
        }
    }
    delete this->layout();
    initUi();
}
