1 /*************************************************************************
2 ConfirmCancelProxy.cpp - ask for confirm before cancelling an action
3 -------------------
4 begin : Fri Apr 26 2002
5 copyright : (C) 2002 by Thomas Eschenbacher
6 email : Thomas.Eschenbacher@gmx.de
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "config.h"
19 #include <QObject>
20 #include <QString>
21 #include <QWidget>
22
23 #include <KLocalizedString>
24
25 #include "libkwave/ConfirmCancelProxy.h"
26 #include "libkwave/MessageBox.h"
27
28 //***************************************************************************
ConfirmCancelProxy(QWidget * widget,QObject * sender,const char * signal,QObject * receiver,const char * slot)29 Kwave::ConfirmCancelProxy::ConfirmCancelProxy(QWidget *widget,
30 QObject *sender, const char *signal,
31 QObject *receiver, const char *slot)
32 :QObject(), m_widget(widget)
33 {
34 Q_ASSERT(receiver);
35 if (!receiver) return;
36
37 if (sender) QObject::connect(sender, signal, this, SLOT(cancel()));
38 QObject::connect(this, SIGNAL(canceled()), receiver, slot);
39 }
40
41 //***************************************************************************
~ConfirmCancelProxy()42 Kwave::ConfirmCancelProxy::~ConfirmCancelProxy()
43 {
44 }
45
46 //***************************************************************************
cancel()47 void Kwave::ConfirmCancelProxy::cancel()
48 {
49 if (Kwave::MessageBox::questionYesNo(m_widget,
50 i18n("Do you really want to abort the current action?"))
51 != KMessageBox::Yes) return; // no cancel
52 emit canceled();
53 }
54
55 //***************************************************************************
56 //***************************************************************************
57