#include "popupmenu.h"

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFrame>
#include <QPushButton>
#include <QGroupBox>

PopupMenu::PopupMenu(QWidget *parent)
    : CFramelessWindow(parent)
{
    initUI();
}

PopupMenu::~PopupMenu()
{

}

void PopupMenu::setOut(bool out)
{
    mOut = out;
}

bool PopupMenu::isOut()
{
    return mOut;
}

void PopupMenu::initUI()
{
    mCentralWidget = new QWidget;
    mCentralWidget->setObjectName("PopupMenuCentralWidget");

    mMainHLayout = new QHBoxLayout;
    mCentralWidget->setLayout(mMainHLayout);

    mGroupBox = new QGroupBox;
    mGroupBox->setObjectName("PopupMenuGroupBox");

    mGroupBox->setTitle("功能开关");
    mMainHLayout->addWidget(mGroupBox);

    mButton1 = new QPushButton;
    mButton1->setText("功能1");
    mButton1->setObjectName("PopupMenuButton");
    mButton2 = new QPushButton;
    mButton2->setText("功能2");
    mButton2->setObjectName("PopupMenuButton");
    mButton3 = new QPushButton;
    mButton3->setText("功能3");
    mButton3->setObjectName("PopupMenuButton");
    mReturnButton = new QPushButton;
    mReturnButton->setText("返回");
    mReturnButton->setObjectName("PopupMenuButton");

    mVerticalLine = new QFrame;
    mVerticalLine->setFrameShape(QFrame::HLine);

    mMainVLayout = new QVBoxLayout;
    mMainVLayout->addWidget(mButton1);
    mMainVLayout->addWidget(mButton2);
    mMainVLayout->addWidget(mButton3);
    mMainVLayout->addWidget(mVerticalLine);
    mMainVLayout->addWidget(mReturnButton);

    mGroupBox->setLayout(mMainVLayout);

    this->setCentralWidget(mCentralWidget);

    mOut = false;

    connect(mButton1, &QPushButton::clicked, this, &PopupMenu::clicked1);
    connect(mButton2, &QPushButton::clicked, this, &PopupMenu::clicked2);
    connect(mReturnButton, &QPushButton::clicked, this, &PopupMenu::clickedReturn);
    this->setObjectName("PopuMenu");
}

