Пример #1
0
void DialogEidtUser::InitLayout()
{
	//this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint );
	//this->setWindowModality(Qt::ApplicationModal);

	m_lineEditPassword->setEchoMode(QLineEdit::Password);
	m_lineEditConfirmPassword->setEchoMode(QLineEdit::Password);

	User user = TeachingBoxContext::GetInstance()->GetUser();

	/*添加权限,最大权限不得超过当前用户的权限*/
	for (int i = 1; i <= user.GetAuthority(); ++i)
	{
		m_comboBoxAuthority->addItem(QString::number(i));
	}

	m_comboBoxLanguage->addItem(Language::English());
	m_comboBoxLanguage->addItem(Language::Chinese());
	m_comboBoxLanguage->setCurrentText(user.GetLanguage());

	/*布局*/
	QVBoxLayout* layoutMain = new QVBoxLayout(this);
	QGridLayout* layoutUser = new QGridLayout;
	QHBoxLayout* layoutButton = new QHBoxLayout;

	layoutMain->addLayout(layoutUser);
	layoutMain->addLayout(layoutButton);
	layoutMain->setStretch(0, 1);

	layoutUser->setMargin(10);
	layoutUser->setSpacing(10);

	layoutUser->addWidget(m_lbName, 0, 0);
	layoutUser->addWidget(m_lbPassword, 1, 0);
	layoutUser->addWidget(m_lbConfirmPassword, 2, 0);
	layoutUser->addWidget(m_lbAuthority, 3, 0);
	layoutUser->addWidget(m_lbLanguage, 4, 0);

	layoutUser->addWidget(m_lineEditName, 0, 1);
	layoutUser->addWidget(m_lineEditPassword, 1, 1);
	layoutUser->addWidget(m_lineEditConfirmPassword, 2, 1);
	layoutUser->addWidget(m_comboBoxAuthority, 3, 1);
	layoutUser->addWidget(m_comboBoxLanguage, 4, 1);

	layoutButton->addStretch(0);
	layoutButton->addWidget(m_btnConfirm);
	layoutButton->addStretch(0);
	layoutButton->addWidget(m_btnCancel);
	layoutButton->addStretch(0);

}
Пример #2
0
void ScreenSetting::UpdateState(const User& user)
{
	m_cmbUser->setCurrentText(user.GetName());
	m_ltAuthorityValue->setText(QString::number(user.GetAuthority()));
	m_cmbLanguage->setCurrentText(user.GetLanguage());

	if (user.GetName().size()==0)
	{
		m_btnLogout->setEnabled(false);
	}
	else
	{
		m_btnLogout->setEnabled(true);
	}

	emit(TeachingBoxBroadcast::GetInstance()->CurrentUserChanged());
}
Пример #3
0
void ScreenSetting::showEvent(QShowEvent *)
{
	m_cmbUser->clear();
	m_cmbUser->addItem("");
	auto users = Database::UserDatabase::SelectAllUsers();
	for (auto u:users)
	{
		m_cmbUser->addItem(u.GetName());
	}

	User user = TeachingBoxContext::GetInstance()->GetUser();

	m_cmbUser->setCurrentText(user.GetName());
	m_ltAuthorityValue->setText(QString::number(user.GetAuthority()));
	m_cmbLanguage->setCurrentText(TeachingBoxContext::GetInstance()->GetLanguage());

	connect(TeachingBoxBroadcast::GetInstance(), &TeachingBoxBroadcast::DateTimeChanged, this, [this](const QDateTime& dateTime){
		m_ltDateValue->setText(dateTime.toString("yyyy-MM-dd"));
		m_ltTimeValue->setText(dateTime.toString("hh::mm::ss"));
	});
}
Пример #4
0
void DialogEidtUser::InitUser()
{
	switch (m_type)
	{
	case DialogEidtUser::EDIT:
	{
		User user = UserDatabase::SelectUser(m_oldName);
		m_lineEditName->setText(user.GetName());
		m_lineEditPassword->setText(user.GetPassword());
		m_lineEditConfirmPassword->setText(user.GetPassword());
		m_comboBoxAuthority->setCurrentText(QString::number(user.GetAuthority()));
		m_comboBoxLanguage->setCurrentText(user.GetLanguage());

		/*若编辑对象为自身,则禁止修改名字与权限*/
		if (m_oldName==TeachingBoxContext::GetInstance()->GetUser().GetName())
		{
			m_lineEditName->setEnabled(false);
			m_comboBoxAuthority->setEnabled(false);
		}
	}break;
	default:
		break;
	}
}