UninstallHelperDialog::UninstallHelperDialog(QWidget *parent) : QDialog(parent) { setupUi(this); setWindowIcon(QIcon(":/images/seafile.png")); setWindowTitle(tr("Uninstall %1").arg(getBrand())); mText->setText(tr("Do you want to remove the %1 account information?").arg(getBrand())); loadQss("qt.css") || loadQss(":/qt.css"); #if defined(Q_WS_WIN) loadQss("qt-win.css") || loadQss(":/qt-win.css"); #elif defined(Q_WS_X11) loadQss("qt-linux.css") || loadQss(":/qt-linux.css"); #else loadQss("qt-mac.css") || loadQss(":/qt-mac.css"); #endif const QRect screen = QApplication::desktop()->screenGeometry(); move(screen.center() - this->rect().center()); connect(mYesBtn, SIGNAL(clicked()), this, SLOT(onYesClicked())); connect(mNoBtn, SIGNAL(clicked()), this, SLOT(doExit())); }
MyMessageBox::MyMessageBox(QWidget *parent, MyMessageBoxType type, const QString &text): MyDialog(parent) { label = new QLabel(text, this); label->setWordWrap(true); // upperLayout = new QVBoxLayout(); layout = new QVBoxLayout(this); lowerLayout = new QHBoxLayout(); layout->addWidget(label); //upperLayout->addStretch(); switch(type) { case MB_OK: case MB_ERROR: okButton = new QPushButton(tr("OK"), this); lowerLayout->addWidget(okButton); connect(okButton, SIGNAL(clicked()), this, SLOT(onOkClicked())); break; case MB_QUESTION: yesButton = new QPushButton(tr("Yes"), this); noButton = new QPushButton(tr("No"), this); lowerLayout->addWidget(yesButton); lowerLayout->addWidget(noButton); connect(yesButton, SIGNAL(clicked()), this, SLOT(onYesClicked())); connect(noButton, SIGNAL(clicked()), this, SLOT(onNoClicked())); break; default: break; } // layout->addLayout(upperLayout); layout->addLayout(lowerLayout); this->setLayout(layout); }
void MyMessageBox::onYesClicked() { disconnect(yesButton, SIGNAL(clicked()), this, SLOT(onYesClicked())); mRetCode = QDialog::Accepted; close(); }