#include "bottom_widget.h"
BottomWidget::BottomWidget(QWidget *parent)
: QWidget(parent)
{
this->setFixedHeight(50);
login_button = new QPushButton();
corner_back_button = new PushButton();
corner_right_buttom = new PushButton();
corner_back_button->setPicName(QString(":/login/corner_back"));
corner_right_buttom->setPicName(QString(":/login/corner_right"));
login_button->setFixedSize(160, 40);
login_button->setText(tr("login"));
login_button->setObjectName("loginButton");
connect(login_button, &QPushButton::clicked, this, &BottomWidget::login);
connect(corner_back_button, &PushButton::clicked, this, &BottomWidget::turnAccountWidget);
connect(corner_right_buttom, &PushButton::clicked, this, &BottomWidget::turnLoadingWidget);
QHBoxLayout *login_layout = new QHBoxLayout();
login_layout->addWidget(corner_back_button, 0, Qt::AlignBottom);
login_layout->addStretch();
login_layout->addWidget(login_button);
login_layout->addStretch();
login_layout->addWidget(corner_right_buttom);
login_layout->setSpacing(0);
login_layout->setContentsMargins(1, 0, 10, 1);
this->setLayout(login_layout);
}
BottomWidget::~BottomWidget()
{
}
//改变左边按钮图标
void BottomWidget::setPixmap(QString pixmap_name)
{
corner_back_button->setPicName(pixmap_name);
}
//is_hidden为true,则隐藏左右按钮,并设置“登录”文本为“取消”,否则显示,设置为“登录”
void BottomWidget::setHidden(bool is_hidden)
{
corner_back_button->setHidden(is_hidden);
corner_right_buttom->setHidden(is_hidden);
if(is_hidden)
{
login_button->setText(tr("cancel"));
}
else
{
login_button->setText(tr("login"));
}
}
//隐藏底部所有组件
void BottomWidget::setAllHidden(bool is_hidden)
{
corner_back_button->setHidden(is_hidden);
corner_right_buttom->setHidden(is_hidden);
login_button->setHidden(is_hidden);
}
//判断是否所有组件都已经隐藏
bool BottomWidget::isAllHidden()
{
bool is_corner_back_hidden = corner_back_button->isHidden();
bool is_corner_right_hidden = corner_right_buttom->isHidden();
bool is_login_hidden = login_button->isHidden();
return is_corner_back_hidden && is_corner_right_hidden && is_login_hidden;
}
注:技术在于交流、在于沟通,分享内容请勿用作商业途径,转载请说明出处,违者必究!