You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1072 lines
39 KiB
1072 lines
39 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; version 2
|
||
|
of the License.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqguardedptr.h>
|
||
|
#include <tqhbox.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqmessagebox.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqvbox.h>
|
||
|
#include <tqvgroupbox.h>
|
||
13 years ago
|
#include <tqstylesheet.h>
|
||
15 years ago
|
#include <tqsimplerichtext.h>
|
||
|
#include <tqpushbutton.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <kdialogbase.h>
|
||
|
#include <kguiitem.h>
|
||
12 years ago
|
#include <tdelistbox.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
|
#include <tdemessagebox.h>
|
||
15 years ago
|
#include <knotifyclient.h>
|
||
|
#include <kstdguiitem.h>
|
||
|
#include <kactivelabel.h>
|
||
|
#include <kiconloader.h>
|
||
12 years ago
|
#include <tdeglobalsettings.h>
|
||
15 years ago
|
|
||
|
#ifdef Q_WS_X11
|
||
|
#include <X11/Xlib.h>
|
||
|
#endif
|
||
|
|
||
|
/**
|
||
|
* Easy MessageBox Dialog.
|
||
|
*
|
||
|
* Provides convenience functions for some i18n'ed standard dialogs,
|
||
|
* as well as audible notification via @ref KNotifyClient
|
||
|
*
|
||
|
* @author Waldo Bastian (bastian@kde.org)
|
||
|
*/
|
||
|
|
||
|
static bool KMessageBox_queue = false;
|
||
|
|
||
15 years ago
|
static TQPixmap themedMessageBoxIcon(TQMessageBox::Icon icon)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString icon_name;
|
||
15 years ago
|
|
||
|
switch(icon)
|
||
|
{
|
||
15 years ago
|
case TQMessageBox::NoIcon:
|
||
|
return TQPixmap();
|
||
15 years ago
|
break;
|
||
15 years ago
|
case TQMessageBox::Information:
|
||
15 years ago
|
icon_name = "messagebox_info";
|
||
|
break;
|
||
15 years ago
|
case TQMessageBox::Warning:
|
||
15 years ago
|
icon_name = "messagebox_warning";
|
||
|
break;
|
||
15 years ago
|
case TQMessageBox::Critical:
|
||
15 years ago
|
icon_name = "messagebox_critical";
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQPixmap ret = TDEGlobal::iconLoader()->loadIcon(icon_name, TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, 0, true);
|
||
15 years ago
|
|
||
|
if (ret.isNull())
|
||
15 years ago
|
return TQMessageBox::standardIcon(icon);
|
||
15 years ago
|
else
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
15 years ago
|
static void sendNotification( TQString message,
|
||
|
const TQStringList& strlist,
|
||
|
TQMessageBox::Icon icon,
|
||
15 years ago
|
WId parent_id )
|
||
|
{
|
||
|
// create the message for KNotify
|
||
15 years ago
|
TQString messageType;
|
||
15 years ago
|
switch ( icon )
|
||
|
{
|
||
15 years ago
|
case TQMessageBox::Warning:
|
||
15 years ago
|
messageType = "messageWarning";
|
||
|
break;
|
||
15 years ago
|
case TQMessageBox::Critical:
|
||
15 years ago
|
messageType = "messageCritical";
|
||
|
break;
|
||
15 years ago
|
case TQMessageBox::Question:
|
||
15 years ago
|
messageType = "messageQuestion";
|
||
|
break;
|
||
|
default:
|
||
|
messageType = "messageInformation";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if ( !strlist.isEmpty() )
|
||
|
{
|
||
15 years ago
|
for ( TQStringList::ConstIterator it = strlist.begin(); it != strlist.end(); ++it )
|
||
15 years ago
|
message += "\n" + *it;
|
||
|
}
|
||
|
|
||
|
if ( !message.isEmpty() )
|
||
|
KNotifyClient::event( (int)parent_id, messageType, message );
|
||
|
}
|
||
|
|
||
15 years ago
|
static TQString qrichtextify( const TQString& text )
|
||
15 years ago
|
{
|
||
|
if ( text.isEmpty() || text[0] == '<' )
|
||
|
return text;
|
||
|
|
||
15 years ago
|
TQStringList lines = TQStringList::split('\n', text);
|
||
|
for(TQStringList::Iterator it = lines.begin(); it != lines.end(); ++it)
|
||
15 years ago
|
{
|
||
15 years ago
|
*it = TQStyleSheet::convertFromPlainText( *it, TQStyleSheetItem::WhiteSpaceNormal );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
return lines.join(TQString::null);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
int KMessageBox::createKMessageBox(KDialogBase *dialog, TQMessageBox::Icon icon,
|
||
|
const TQString &text, const TQStringList &strlist,
|
||
|
const TQString &ask, bool *checkboxReturn,
|
||
|
int options, const TQString &details)
|
||
15 years ago
|
{
|
||
|
return createKMessageBox(dialog, themedMessageBoxIcon(icon), text, strlist,
|
||
|
ask, checkboxReturn, options, details, icon);
|
||
|
}
|
||
|
|
||
15 years ago
|
int KMessageBox::createKMessageBox(KDialogBase *dialog, TQPixmap icon,
|
||
|
const TQString &text, const TQStringList &strlist,
|
||
|
const TQString &ask, bool *checkboxReturn, int options,
|
||
|
const TQString &details, TQMessageBox::Icon notifyType)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQVBox *topcontents = new TQVBox (dialog);
|
||
15 years ago
|
topcontents->setSpacing(KDialog::spacingHint()*2);
|
||
|
topcontents->setMargin(KDialog::marginHint());
|
||
|
|
||
15 years ago
|
TQWidget *contents = new TQWidget(topcontents);
|
||
|
TQHBoxLayout * lay = new TQHBoxLayout(contents);
|
||
15 years ago
|
lay->setSpacing(KDialog::spacingHint());
|
||
|
|
||
15 years ago
|
TQLabel *label1 = new TQLabel( contents);
|
||
15 years ago
|
|
||
|
if (!icon.isNull())
|
||
|
label1->setPixmap(icon);
|
||
|
|
||
|
lay->addWidget( label1, 0, Qt::AlignCenter );
|
||
|
lay->addSpacing(KDialog::spacingHint());
|
||
|
// Enforce <p>text</p> otherwise the word-wrap doesn't work well
|
||
15 years ago
|
TQString qt_text = qrichtextify( text );
|
||
15 years ago
|
|
||
|
int pref_width = 0;
|
||
|
int pref_height = 0;
|
||
|
// Calculate a proper size for the text.
|
||
|
{
|
||
15 years ago
|
TQSimpleRichText rt(qt_text, dialog->font());
|
||
12 years ago
|
TQRect d = TDEGlobalSettings::desktopGeometry(dialog);
|
||
15 years ago
|
|
||
|
pref_width = d.width() / 3;
|
||
|
rt.setWidth(pref_width);
|
||
|
int used_width = rt.widthUsed();
|
||
|
pref_height = rt.height();
|
||
|
if (3*pref_height > 2*d.height())
|
||
|
{
|
||
|
// Very high dialog.. make it wider
|
||
|
pref_width = d.width() / 2;
|
||
|
rt.setWidth(pref_width);
|
||
|
used_width = rt.widthUsed();
|
||
|
pref_height = rt.height();
|
||
|
}
|
||
|
if (used_width <= pref_width)
|
||
|
{
|
||
|
while(true)
|
||
|
{
|
||
|
int new_width = (used_width * 9) / 10;
|
||
|
rt.setWidth(new_width);
|
||
|
int new_height = rt.height();
|
||
|
if (new_height > pref_height)
|
||
|
break;
|
||
|
used_width = rt.widthUsed();
|
||
|
if (used_width > new_width)
|
||
|
break;
|
||
|
}
|
||
|
pref_width = used_width;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (used_width > (pref_width *2))
|
||
|
pref_width = pref_width *2;
|
||
|
else
|
||
|
pref_width = used_width;
|
||
|
}
|
||
|
}
|
||
|
KActiveLabel *label2 = new KActiveLabel( qt_text, contents );
|
||
|
if (!(options & KMessageBox::AllowLink))
|
||
|
{
|
||
15 years ago
|
TQObject::disconnect(label2, TQT_SIGNAL(linkClicked(const TQString &)),
|
||
|
label2, TQT_SLOT(openLink(const TQString &)));
|
||
15 years ago
|
}
|
||
|
|
||
|
// We add 10 pixels extra to compensate for some KActiveLabel margins.
|
||
14 years ago
|
// TODO: find out why this is 10.
|
||
15 years ago
|
label2->setFixedSize(TQSize(pref_width+10, pref_height));
|
||
15 years ago
|
lay->addWidget( label2 );
|
||
|
lay->addStretch();
|
||
|
|
||
12 years ago
|
TDEListBox *listbox = 0;
|
||
15 years ago
|
if (!strlist.isEmpty())
|
||
|
{
|
||
12 years ago
|
listbox=new TDEListBox( topcontents );
|
||
15 years ago
|
listbox->insertStringList( strlist );
|
||
15 years ago
|
listbox->setSelectionMode( TQListBox::NoSelection );
|
||
15 years ago
|
topcontents->setStretchFactor(listbox, 1);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQGuardedPtr<TQCheckBox> checkbox = 0;
|
||
15 years ago
|
if (!ask.isEmpty())
|
||
|
{
|
||
15 years ago
|
checkbox = new TQCheckBox(ask, topcontents);
|
||
15 years ago
|
if (checkboxReturn)
|
||
|
checkbox->setChecked(*checkboxReturn);
|
||
|
}
|
||
|
|
||
|
if (!details.isEmpty())
|
||
|
{
|
||
15 years ago
|
TQVGroupBox *detailsGroup = new TQVGroupBox( i18n("Details"), dialog);
|
||
15 years ago
|
if ( details.length() < 512 ) {
|
||
|
KActiveLabel *label3 = new KActiveLabel(qrichtextify(details),
|
||
|
detailsGroup);
|
||
13 years ago
|
label3->setMinimumSize(label3->sizeHint());
|
||
15 years ago
|
if (!(options & KMessageBox::AllowLink))
|
||
|
{
|
||
15 years ago
|
TQObject::disconnect(label3, TQT_SIGNAL(linkClicked(const TQString &)),
|
||
|
label3, TQT_SLOT(openLink(const TQString &)));
|
||
15 years ago
|
}
|
||
|
} else {
|
||
15 years ago
|
TQTextEdit* te = new TQTextEdit(details, TQString::null, detailsGroup);
|
||
15 years ago
|
te->setReadOnly( true );
|
||
|
te->setMinimumHeight( te->fontMetrics().lineSpacing() * 11 );
|
||
|
}
|
||
|
dialog->setDetailsWidget(detailsGroup);
|
||
|
}
|
||
|
|
||
|
dialog->setMainWidget(topcontents);
|
||
|
dialog->enableButtonSeparator(false);
|
||
|
if (!listbox)
|
||
|
dialog->disableResize();
|
||
|
|
||
|
const KDialogBase::ButtonCode buttons[] = {
|
||
|
KDialogBase::Help,
|
||
|
KDialogBase::Default,
|
||
|
KDialogBase::Ok,
|
||
|
KDialogBase::Apply,
|
||
|
KDialogBase::Try,
|
||
|
KDialogBase::Cancel,
|
||
|
KDialogBase::Close,
|
||
|
KDialogBase::User1,
|
||
|
KDialogBase::User2,
|
||
|
KDialogBase::User3,
|
||
|
KDialogBase::No,
|
||
|
KDialogBase::Yes,
|
||
|
KDialogBase::Details };
|
||
|
for( unsigned int i = 0;
|
||
|
i < sizeof( buttons )/sizeof( buttons[ 0 ] );
|
||
|
++i )
|
||
15 years ago
|
if( TQPushButton* btn = dialog->actionButton( buttons[ i ] ))
|
||
15 years ago
|
if( btn->isDefault())
|
||
|
btn->setFocus();
|
||
|
|
||
|
if ( (options & KMessageBox::Notify) )
|
||
13 years ago
|
sendNotification( text, strlist, notifyType, dialog->topLevelWidget()->winId());
|
||
15 years ago
|
|
||
|
if (KMessageBox_queue)
|
||
|
{
|
||
|
KDialogQueue::queueDialog(dialog);
|
||
|
return KMessageBox::Cancel; // We have to return something.
|
||
|
}
|
||
|
|
||
|
if ( (options & KMessageBox::NoExec) )
|
||
|
{
|
||
|
return KMessageBox::Cancel; // We have to return something.
|
||
|
}
|
||
|
|
||
15 years ago
|
// We use a TQGuardedPtr because the dialog may get deleted
|
||
15 years ago
|
// during exec() if the parent of the dialog gets deleted.
|
||
|
// In that case the guarded ptr will reset to 0.
|
||
15 years ago
|
TQGuardedPtr<KDialogBase> guardedDialog = dialog;
|
||
15 years ago
|
|
||
|
int result = guardedDialog->exec();
|
||
|
if (checkbox && checkboxReturn)
|
||
|
*checkboxReturn = checkbox->isChecked();
|
||
|
delete (KDialogBase *) guardedDialog;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::questionYesNo(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return questionYesNoList(parent, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::questionYesNoWId(WId parent_id, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return questionYesNoListWId(parent_id, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
bool
|
||
15 years ago
|
KMessageBox::shouldBeShownYesNo(const TQString &dontShowAgainName,
|
||
15 years ago
|
ButtonCode &result)
|
||
|
{
|
||
|
if ( dontShowAgainName.isEmpty() ) return true;
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
TQString dontAsk = config->readEntry(dontShowAgainName).lower();
|
||
15 years ago
|
if (dontAsk == "yes") {
|
||
|
result = Yes;
|
||
|
return false;
|
||
|
}
|
||
|
if (dontAsk == "no") {
|
||
|
result = No;
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool
|
||
15 years ago
|
KMessageBox::shouldBeShownContinue(const TQString &dontShowAgainName)
|
||
15 years ago
|
{
|
||
|
if ( dontShowAgainName.isEmpty() ) return true;
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
return config->readBoolEntry(dontShowAgainName, true);
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::saveDontShowAgainYesNo(const TQString &dontShowAgainName,
|
||
15 years ago
|
ButtonCode result)
|
||
|
{
|
||
|
if ( dontShowAgainName.isEmpty() ) return;
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
config->writeEntry( dontShowAgainName, result==Yes ? "yes" : "no", true, (dontShowAgainName[0] == ':'));
|
||
|
config->sync();
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::saveDontShowAgainContinue(const TQString &dontShowAgainName)
|
||
15 years ago
|
{
|
||
|
if ( dontShowAgainName.isEmpty() ) return;
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
config->writeEntry( dontShowAgainName, false, true, (dontShowAgainName[0] == ':'));
|
||
|
config->sync();
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEConfig* KMessageBox::againConfig = NULL;
|
||
15 years ago
|
void
|
||
12 years ago
|
KMessageBox::setDontShowAskAgainConfig(TDEConfig* cfg)
|
||
15 years ago
|
{
|
||
|
againConfig = cfg;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::questionYesNoList(TQWidget *parent, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{ // in order to avoid code duplication, convert to WId, it will be converted back
|
||
|
return questionYesNoListWId( parent ? parent->winId() : 0, text, strlist,
|
||
|
caption, buttonYes, buttonNo, dontAskAgainName, options );
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::questionYesNoListWId(WId parent_id, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
ButtonCode res;
|
||
|
if ( !shouldBeShownYesNo(dontAskAgainName, res) )
|
||
|
return res;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Question") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::No,
|
||
|
KDialogBase::Yes, KDialogBase::No,
|
||
|
parent, "questionYesNo", true, true,
|
||
|
buttonYes, buttonNo);
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
15 years ago
|
int result = createKMessageBox(dialog, TQMessageBox::Information, text, strlist,
|
||
|
dontAskAgainName.isEmpty() ? TQString::null : i18n("Do not ask again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
res = (result==KDialogBase::Yes ? Yes : No);
|
||
|
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainYesNo(dontAskAgainName, res);
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::questionYesNoCancel(TQWidget *parent,
|
||
|
const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
return questionYesNoCancelWId( parent ? parent->winId() : 0, text, caption, buttonYes, buttonNo,
|
||
|
dontAskAgainName, options );
|
||
|
}
|
||
|
|
||
|
int
|
||
|
KMessageBox::questionYesNoCancelWId(WId parent_id,
|
||
15 years ago
|
const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
ButtonCode res;
|
||
|
if ( !shouldBeShownYesNo(dontAskAgainName, res) )
|
||
|
return res;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Question") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::No | KDialogBase::Cancel,
|
||
|
KDialogBase::Yes, KDialogBase::Cancel,
|
||
|
parent, "questionYesNoCancel", true, true,
|
||
|
buttonYes, buttonNo);
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
15 years ago
|
int result = createKMessageBox(dialog, TQMessageBox::Information,
|
||
|
text, TQStringList(),
|
||
|
dontAskAgainName.isEmpty() ? TQString::null : i18n("Do not ask again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
if ( result==KDialogBase::Cancel ) return Cancel;
|
||
|
res = (result==KDialogBase::Yes ? Yes : No);
|
||
|
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainYesNo(dontAskAgainName, res);
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNo(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningYesNoList(parent, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoWId(WId parent_id, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningYesNoListWId(parent_id, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoList(TQWidget *parent, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
return warningYesNoListWId( parent ? parent->winId() : 0, text, strlist, caption,
|
||
|
buttonYes, buttonNo, dontAskAgainName, options );
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoListWId(WId parent_id, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
// warningYesNo and warningYesNoList are always "dangerous"
|
||
|
// ### Remove this line for KDE 4, when the 'options' default parameter
|
||
|
// takes effects.
|
||
|
options |= Dangerous;
|
||
|
|
||
|
ButtonCode res;
|
||
|
if ( !shouldBeShownYesNo(dontAskAgainName, res) )
|
||
|
return res;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Warning") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::No,
|
||
|
KDialogBase::No, KDialogBase::No,
|
||
|
parent, "warningYesNoList", true, true,
|
||
|
buttonYes, buttonNo);
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
15 years ago
|
int result = createKMessageBox(dialog, TQMessageBox::Warning, text, strlist,
|
||
|
dontAskAgainName.isEmpty() ? TQString::null : i18n("Do not ask again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
res = (result==KDialogBase::Yes ? Yes : No);
|
||
|
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainYesNo(dontAskAgainName, res);
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningContinueCancel(TQWidget *parent,
|
||
|
const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonContinue,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningContinueCancelList(parent, text, TQStringList(), caption,
|
||
15 years ago
|
buttonContinue, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
|
KMessageBox::warningContinueCancelWId(WId parent_id,
|
||
15 years ago
|
const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonContinue,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningContinueCancelListWId(parent_id, text, TQStringList(), caption,
|
||
15 years ago
|
buttonContinue, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningContinueCancelList(TQWidget *parent, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonContinue,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
return warningContinueCancelListWId( parent ? parent->winId() : 0, text, strlist,
|
||
|
caption, buttonContinue, dontAskAgainName, options );
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningContinueCancelListWId(WId parent_id, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonContinue,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
if ( !shouldBeShownContinue(dontAskAgainName) )
|
||
|
return Continue;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Warning") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::No,
|
||
|
KDialogBase::Yes, KDialogBase::No,
|
||
|
parent, "warningYesNo", true, true,
|
||
|
buttonContinue, KStdGuiItem::cancel() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
15 years ago
|
int result = createKMessageBox(dialog, TQMessageBox::Warning, text, strlist,
|
||
|
dontAskAgainName.isEmpty() ? TQString::null : i18n("Do not ask again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
|
||
|
if ( result==KDialogBase::No )
|
||
|
return Cancel;
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainContinue(dontAskAgainName);
|
||
|
return Continue;
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoCancel(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningYesNoCancelList(parent, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoCancelWId(WId parent_id, const TQString &text,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
15 years ago
|
return warningYesNoCancelListWId(parent_id, text, TQStringList(), caption,
|
||
15 years ago
|
buttonYes, buttonNo, dontAskAgainName, options);
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoCancelList(TQWidget *parent, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
return warningYesNoCancelListWId( parent ? parent->winId() : 0, text, strlist,
|
||
|
caption, buttonYes, buttonNo, dontAskAgainName, options );
|
||
|
}
|
||
|
|
||
|
int
|
||
15 years ago
|
KMessageBox::warningYesNoCancelListWId(WId parent_id, const TQString &text,
|
||
|
const TQStringList &strlist,
|
||
|
const TQString &caption,
|
||
15 years ago
|
const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo,
|
||
15 years ago
|
const TQString &dontAskAgainName,
|
||
15 years ago
|
int options)
|
||
|
{
|
||
|
ButtonCode res;
|
||
|
if ( !shouldBeShownYesNo(dontAskAgainName, res) )
|
||
|
return res;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Warning") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::No | KDialogBase::Cancel,
|
||
|
KDialogBase::Yes, KDialogBase::Cancel,
|
||
|
parent, "warningYesNoCancel", true, true,
|
||
|
buttonYes, buttonNo);
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
15 years ago
|
int result = createKMessageBox(dialog, TQMessageBox::Warning, text, strlist,
|
||
|
dontAskAgainName.isEmpty() ? TQString::null : i18n("Do not ask again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
if ( result==KDialogBase::Cancel ) return Cancel;
|
||
|
res = (result==KDialogBase::Yes ? Yes : No);
|
||
|
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainYesNo(dontAskAgainName, res);
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::error(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
15 years ago
|
return errorListWId( parent ? parent->winId() : 0, text, TQStringList(), caption, options );
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::errorWId(WId parent_id, const TQString &text,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
15 years ago
|
errorListWId( parent_id, text, TQStringList(), caption, options );
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::errorList(TQWidget *parent, const TQString &text, const TQStringList &strlist,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
|
return errorListWId( parent ? parent->winId() : 0, text, strlist, caption, options );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::errorListWId(WId parent_id, const TQString &text, const TQStringList &strlist,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Error") : caption,
|
||
|
KDialogBase::Yes,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "error", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, TQMessageBox::Critical, text, strlist, TQString::null, 0, options);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::detailedError(TQWidget *parent, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
|
return detailedErrorWId( parent ? parent->winId() : 0, text, details, caption, options );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::detailedErrorWId(WId parent_id, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Error") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::Details,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "error", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, TQMessageBox::Critical, text, TQStringList(), TQString::null, 0, options, details);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::queuedDetailedError(TQWidget *parent, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption)
|
||
15 years ago
|
{
|
||
|
return queuedDetailedErrorWId( parent ? parent->winId() : 0, text, details, caption );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::queuedDetailedErrorWId(WId parent_id, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption)
|
||
15 years ago
|
{
|
||
|
KMessageBox_queue = true;
|
||
|
(void) detailedErrorWId(parent_id, text, details, caption);
|
||
|
KMessageBox_queue = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::sorry(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
|
return sorryWId( parent ? parent->winId() : 0, text, caption, options );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::sorryWId(WId parent_id, const TQString &text,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Sorry") : caption,
|
||
|
KDialogBase::Yes,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "sorry", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, TQMessageBox::Warning, text, TQStringList(), TQString::null, 0, options);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::detailedSorry(TQWidget *parent, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
|
return detailedSorryWId( parent ? parent->winId() : 0, text, details, caption, options );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::detailedSorryWId(WId parent_id, const TQString &text,
|
||
|
const TQString &details,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Sorry") : caption,
|
||
|
KDialogBase::Yes | KDialogBase::Details,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "sorry", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, TQMessageBox::Warning, text, TQStringList(), TQString::null, 0, options, details);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::information(TQWidget *parent,const TQString &text,
|
||
|
const TQString &caption, const TQString &dontShowAgainName, int options)
|
||
15 years ago
|
{
|
||
15 years ago
|
informationList(parent, text, TQStringList(), caption, dontShowAgainName, options);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::informationWId(WId parent_id,const TQString &text,
|
||
|
const TQString &caption, const TQString &dontShowAgainName, int options)
|
||
15 years ago
|
{
|
||
15 years ago
|
informationListWId(parent_id, text, TQStringList(), caption, dontShowAgainName, options);
|
||
15 years ago
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::informationList(TQWidget *parent,const TQString &text, const TQStringList & strlist,
|
||
|
const TQString &caption, const TQString &dontShowAgainName, int options)
|
||
15 years ago
|
{
|
||
|
return informationListWId( parent ? parent->winId() : 0, text, strlist, caption,
|
||
|
dontShowAgainName, options );
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::informationListWId(WId parent_id,const TQString &text, const TQStringList & strlist,
|
||
|
const TQString &caption, const TQString &dontShowAgainName, int options)
|
||
15 years ago
|
{
|
||
|
if ( !shouldBeShownContinue(dontShowAgainName) )
|
||
|
return;
|
||
|
|
||
14 years ago
|
TQWidget* parent = TQT_TQWIDGET(TQWidget::find( parent_id ));
|
||
15 years ago
|
KDialogBase *dialog= new KDialogBase(
|
||
|
caption.isEmpty() ? i18n("Information") : caption,
|
||
|
KDialogBase::Yes,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "information", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
if( options & PlainCaption )
|
||
|
dialog->setPlainCaption( caption );
|
||
|
#ifdef Q_WS_X11
|
||
|
if( parent == NULL && parent_id )
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), dialog->winId(), parent_id );
|
||
15 years ago
|
#endif
|
||
|
|
||
|
bool checkboxResult = false;
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, TQMessageBox::Information, text, strlist,
|
||
|
dontShowAgainName.isEmpty() ? TQString::null : i18n("Do not show this message again"),
|
||
15 years ago
|
&checkboxResult, options);
|
||
|
|
||
|
if (checkboxResult)
|
||
|
saveDontShowAgainContinue(dontShowAgainName);
|
||
|
}
|
||
|
|
||
|
void
|
||
|
KMessageBox::enableAllMessages()
|
||
|
{
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
15 years ago
|
if (!config->hasGroup(grpNotifMsgs))
|
||
|
return;
|
||
|
|
||
12 years ago
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
|
||
15 years ago
|
typedef TQMap<TQString, TQString> configMap;
|
||
15 years ago
|
|
||
|
configMap map = config->entryMap(grpNotifMsgs);
|
||
|
|
||
|
configMap::Iterator it;
|
||
|
for (it = map.begin(); it != map.end(); ++it)
|
||
|
config->deleteEntry( it.key() );
|
||
|
config->sync();
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::enableMessage(const TQString &dontShowAgainName)
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfig *config = againConfig ? againConfig : TDEGlobal::config();
|
||
13 years ago
|
TQString grpNotifMsgs = TQString::fromLatin1("Notification Messages");
|
||
15 years ago
|
if (!config->hasGroup(grpNotifMsgs))
|
||
|
return;
|
||
|
|
||
12 years ago
|
TDEConfigGroupSaver saver( config, grpNotifMsgs );
|
||
15 years ago
|
|
||
|
config->deleteEntry(dontShowAgainName);
|
||
|
config->sync();
|
||
|
}
|
||
|
|
||
|
void
|
||
15 years ago
|
KMessageBox::about(TQWidget *parent, const TQString &text,
|
||
|
const TQString &caption, int options)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString _caption = caption;
|
||
15 years ago
|
if (_caption.isEmpty())
|
||
|
_caption = i18n("About %1").arg(kapp->caption());
|
||
|
|
||
|
KDialogBase *dialog = new KDialogBase(
|
||
|
caption,
|
||
|
KDialogBase::Yes,
|
||
|
KDialogBase::Yes, KDialogBase::Yes,
|
||
|
parent, "about", true, true,
|
||
|
KStdGuiItem::ok() );
|
||
|
|
||
12 years ago
|
TQPixmap ret = TDEApplication::kApplication()->icon();
|
||
15 years ago
|
if (ret.isNull())
|
||
15 years ago
|
ret = TQMessageBox::standardIcon(TQMessageBox::Information);
|
||
15 years ago
|
dialog->setIcon(ret);
|
||
|
|
||
15 years ago
|
createKMessageBox(dialog, ret, text, TQStringList(), TQString::null, 0, options);
|
||
15 years ago
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
15 years ago
|
int KMessageBox::messageBox( TQWidget *parent, DialogType type, const TQString &text,
|
||
|
const TQString &caption, const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo, const TQString &dontShowAskAgainName,
|
||
15 years ago
|
int options )
|
||
|
{
|
||
|
return messageBoxWId( parent ? parent->winId() : 0, type, text, caption,
|
||
|
buttonYes, buttonNo, dontShowAskAgainName, options );
|
||
|
}
|
||
|
|
||
15 years ago
|
int KMessageBox::messageBox( TQWidget *parent, DialogType type, const TQString &text,
|
||
|
const TQString &caption, const KGuiItem &buttonYes,
|
||
15 years ago
|
const KGuiItem &buttonNo, int options )
|
||
|
{
|
||
|
return messageBoxWId( parent ? parent->winId() : 0, type, text, caption,
|
||
15 years ago
|
buttonYes, buttonNo, TQString::null, options );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
int KMessageBox::messageBoxWId( WId parent_id, DialogType type, const TQString &text,
|
||
|
const TQString &caption, const KGuiItem &buttonYes,
|
||
|
const KGuiItem &buttonNo, const TQString &dontShow,
|
||
15 years ago
|
int options )
|
||
|
{
|
||
|
switch (type) {
|
||
|
case QuestionYesNo:
|
||
|
return KMessageBox::questionYesNoWId( parent_id,
|
||
|
text, caption, buttonYes, buttonNo, dontShow, options );
|
||
|
case QuestionYesNoCancel:
|
||
|
return KMessageBox::questionYesNoCancelWId( parent_id,
|
||
|
text, caption, buttonYes, buttonNo, dontShow, options );
|
||
|
case WarningYesNo:
|
||
|
return KMessageBox::warningYesNoWId( parent_id,
|
||
|
text, caption, buttonYes, buttonNo, dontShow, options );
|
||
|
case WarningContinueCancel:
|
||
|
return KMessageBox::warningContinueCancelWId( parent_id,
|
||
|
text, caption, buttonYes.text(), dontShow, options );
|
||
|
case WarningYesNoCancel:
|
||
|
return KMessageBox::warningYesNoCancelWId( parent_id,
|
||
|
text, caption, buttonYes, buttonNo, dontShow, options );
|
||
|
case Information:
|
||
|
KMessageBox::informationWId( parent_id,
|
||
|
text, caption, dontShow, options );
|
||
|
return KMessageBox::Ok;
|
||
|
|
||
|
case Error:
|
||
|
KMessageBox::errorWId( parent_id, text, caption, options );
|
||
|
return KMessageBox::Ok;
|
||
|
|
||
|
case Sorry:
|
||
|
KMessageBox::sorryWId( parent_id, text, caption, options );
|
||
|
return KMessageBox::Ok;
|
||
|
}
|
||
|
return KMessageBox::Cancel;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMessageBox::queuedMessageBox( TQWidget *parent, DialogType type, const TQString &text, const TQString &caption, int options )
|
||
15 years ago
|
{
|
||
|
return queuedMessageBoxWId( parent ? parent->winId() : 0, type, text, caption, options );
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMessageBox::queuedMessageBoxWId( WId parent_id, DialogType type, const TQString &text, const TQString &caption, int options )
|
||
15 years ago
|
{
|
||
|
KMessageBox_queue = true;
|
||
|
(void) messageBoxWId(parent_id, type, text, caption, KStdGuiItem::yes(),
|
||
15 years ago
|
KStdGuiItem::no(), TQString::null, options);
|
||
15 years ago
|
KMessageBox_queue = false;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMessageBox::queuedMessageBox( TQWidget *parent, DialogType type, const TQString &text, const TQString &caption )
|
||
15 years ago
|
{
|
||
|
return queuedMessageBoxWId( parent ? parent->winId() : 0, type, text, caption );
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMessageBox::queuedMessageBoxWId( WId parent_id, DialogType type, const TQString &text, const TQString &caption )
|
||
15 years ago
|
{
|
||
|
KMessageBox_queue = true;
|
||
|
(void) messageBoxWId(parent_id, type, text, caption);
|
||
|
KMessageBox_queue = false;
|
||
|
}
|