GrabBag/GrabBagApp/StyledMessageBox.cpp

55 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include "StyledMessageBox.h"
void StyledMessageBox::information(QWidget* parent, const QString& title, const QString& text)
{
QMessageBox msgBox(parent);
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Information);
applyStyle(msgBox);
setChineseButtonText(msgBox);
msgBox.exec();
}
void StyledMessageBox::warning(QWidget* parent, const QString& title, const QString& text)
{
QMessageBox msgBox(parent);
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Warning);
applyStyle(msgBox);
setChineseButtonText(msgBox);
msgBox.exec();
}
void StyledMessageBox::critical(QWidget* parent, const QString& title, const QString& text)
{
QMessageBox msgBox(parent);
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Critical);
applyStyle(msgBox);
setChineseButtonText(msgBox);
msgBox.exec();
}
void StyledMessageBox::applyStyle(QMessageBox& msgBox)
{
msgBox.setStyleSheet("QMessageBox { background-color: #25262A; color: #EFF1F5; font-size: 16pt; } "
"QMessageBox QLabel { color: #EFF1F5; background-color: transparent; font-size: 16pt; } "
"QMessageBox QPushButton { background-color: #404040; color: #EFF1F5; border: 1px solid #666666; padding: 5px; font-size: 14pt; } "
"QMessageBox QPushButton:hover { background-color: #505050; } "
"QMessageBox .QLabel { font-size: 16pt; } "
"QMessageBox::title { font-size: 16pt; color: #EFF1F5; }");
}
void StyledMessageBox::setChineseButtonText(QMessageBox& msgBox)
{
msgBox.setButtonText(QMessageBox::Ok, "确定");
}