123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include "querydialog.h"
- #include <QPushButton>
- #include <QDebug>
- QueryDialog::QueryDialog(QObject *parent) :
- QObject(parent)
- {
- m_acceptButtonText = tr("Yes");
- m_rejectButtonText = tr("No");
- }
- void QueryDialog::open() {
- m_icon.load(this->m_icon_path);
- mbox.setWindowTitle(this->m_titleText);
- mbox.setText(this->m_message);
- mbox.setIconPixmap(m_icon);
- const QString yes(m_acceptButtonText);
- const QString no(m_rejectButtonText);
- QPushButton *acceptButton = mbox.addButton(yes, QMessageBox::AcceptRole);
- QPushButton *rejectButton = mbox.addButton(no, QMessageBox::RejectRole);
- //QPushButton *rejectButton = mbox.addButton(QMessageBox::Abort);
- mbox.exec();
- if (mbox.clickedButton() == acceptButton) {
- qDebug()<< ">>>>>yes";
- emit accepted();
- } else if (mbox.clickedButton() == rejectButton) {
- qDebug()<< ">>>>>>no";
- emit rejected();
- }
- }
- QString QueryDialog::text(){
- return this->m_message;
- }
- void QueryDialog::setText(QString value){
- this->m_message = value;
- }
- QString QueryDialog::titleText(){
- return m_titleText;
- }
- void QueryDialog::setTitleText(QString value){
- this->m_titleText = value;
- }
- QString QueryDialog::icon(){
- return this->m_icon_path;
- }
- void QueryDialog::setIcon(QString value){
- this->m_icon_path = value;
- }
- QString QueryDialog::acceptButtonText(){
- return this->m_acceptButtonText;
- }
- void QueryDialog::setAcceptButtonText(QString value){
- this->m_acceptButtonText = value;
- }
- QString QueryDialog::rejectButtonText(){
- return m_rejectButtonText;
- }
- void QueryDialog::setRejectButtonText(QString value){
- this->m_rejectButtonText = value;
- }
|