ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action) : QDialog(parent) , m_ui(new Ui::confirmShutdownDlg) , m_timeout(15) , m_action(action) { m_ui->setupUi(this); initText(); QIcon warningIcon(style()->standardIcon(QStyle::SP_MessageBoxWarning)); m_ui->warningLabel->setPixmap(warningIcon.pixmap(32)); if (m_action == ShutdownDialogAction::Exit) m_ui->neverShowAgainCheckbox->setVisible(true); else m_ui->neverShowAgainCheckbox->setVisible(false); // Cancel Button QPushButton *cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); cancelButton->setFocus(); cancelButton->setDefault(true); // Always on top setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); move(Utils::Misc::screenCenter(this)); m_timer.setInterval(1000); // 1sec connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds())); Utils::Gui::resize(this); }
// static function: pop up a simple modal message box void MessageDialog::message(const char *caption, const char *text, const char *buttonText, QPixmap *icon) { (void)buttonText; int type = 0; if(icon == warningIcon()) type = KMsgBox::STOP; KMsgBox::message(kapp->mainWidget(), caption, text, type); }
void Dialog::clearInfo() { QIcon warningIcon(":/Icon/warningIcon.png"); QPixmap warningPixmap(":/Icon/warningIcon.png"); QMessageBox help(this); help.setStandardButtons(QMessageBox::NoButton); help.setWindowIcon(warningIcon); help.setWindowTitle("Warning"); help.setIconPixmap(warningPixmap); help.setText("Warning, do you want to clear all the level info?(The icon will be updated in a new game.)"); help.addButton("Yes", QMessageBox::AcceptRole); help.addButton("No", QMessageBox::RejectRole); connect(&help, SIGNAL(rejected()), this, SLOT(clear())); help.exec(); }