#include "DialogTemplate.h"
#include "FramelessHelper.h"

#include <QVBoxLayout>

DialogTemplate::DialogTemplate(QWidget *contentWidget, QWidget *parent)
	: QDialog(parent)
	, m_pTitleBar(new TitleBar(this, false))
{
	Q_ASSERT(contentWidget != nullptr);
	
	setAttribute(Qt::WA_TranslucentBackground);

	FramelessHelper *pHelper = new FramelessHelper(this);
	pHelper->setTitleHeight(m_pTitleBar->height());

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->setMargin(0);
	layout->setContentsMargins(0, 0, 0, 0);
	layout->setSpacing(0);
	layout->addWidget(m_pTitleBar);
	layout->addWidget(contentWidget);
	setLayout(layout);

	//setStyleSheet("DialogTemplate{background-color:#535353; padding:1px;}");
	contentWidget->setObjectName("contentWidget");
    contentWidget->setStyleSheet("#contentWidget{border:1px solid #535353; border-top:0px; border-bottom-left-radius:5px; border-bottom-right-radius:5px;background-color:white;}");
	m_pTitleBar->setObjectName("titleBar");
	m_pTitleBar->setStyleSheet("\
		#titleBar{background-color:#2d2d30; border:1px solid #535353; border-bottom:0px; border-top-left-radius:5px; border-top-right-radius:5px;}\
		QLabel{color:#eeeeee}\
		#SACloseWindowButton{border-top-right-radius:5px;}");
}

DialogTemplate::~DialogTemplate()
{
}
