korganizer

komessagebox.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include <kmessagebox.h>
00026 #include <kdialogbase.h>
00027 #include <qpushbutton.h>
00028 
00029 #include "komessagebox.h"
00030 
00031 int KOMessageBox::fourBtnMsgBox( QWidget *parent, QMessageBox::Icon type, 
00032             const QString &text, const QString &caption, 
00033             const KGuiItem &button1, const KGuiItem &button2, 
00034             const KGuiItem &button3, int options)
00035 {
00036   KDialogBase *dialog= new KDialogBase( parent, "KOMessageBox", true,
00037                      caption.isEmpty() ? "" : caption,
00038                      KDialogBase::Yes | KDialogBase::No | KDialogBase::Ok | KDialogBase::Cancel,
00039                      KDialogBase::Yes, 
00040                      true/*, button1, button2, button3*/);
00041   dialog->setButtonOK( button3 );
00042   dialog->setButtonText( KDialogBase::Yes, button1.text() );
00043   dialog->setButtonText( KDialogBase::No, button2.text() );
00044   QObject::connect( dialog->actionButton( KDialogBase::Yes ), SIGNAL( clicked() ), dialog, SLOT(slotYes()));
00045   QObject::connect( dialog->actionButton( KDialogBase::No ), SIGNAL( clicked() ), dialog, SLOT(slotNo()));
00046 //  QObject::connect( dialog, SIGNAL( noClicked() ), dialog, SLOT(slotNo()));
00047   
00048 
00049   bool checkboxResult = false;
00050   int result = KMessageBox::createKMessageBox(dialog, type, text, QStringList(),
00051                      QString::null, &checkboxResult, options);
00052   switch (result) {
00053     case KDialogBase::Yes: result = KMessageBox::Yes; break;
00054     case KDialogBase::No: result = KMessageBox::No; break;
00055     case KDialogBase::Ok: result = KMessageBox::Continue; break;
00056     case KDialogBase::Cancel: result = KMessageBox::Cancel; break;
00057     default: break;
00058   }
00059 
00060   return result;
00061 }
00062 
00063 
KDE Home | KDE Accessibility Home | Description of Access Keys