File indexing completed on 2024-12-01 09:50:26

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (C) 2000-2001 Harri Porten (porten@kde.org)
0004  *  Copyright (C) 2001,2003 Peter Kelly (pmk@post.com)
0005  *
0006  *  This library is free software; you can redistribute it and/or
0007  *  modify it under the terms of the GNU Library General Public
0008  *  License as published by the Free Software Foundation; either
0009  *  version 2 of the License, or (at your option) any later version.
0010  *
0011  *  This library is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  *  Library General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU Library General Public
0017  *  License along with this library; if not, write to the Free Software
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #include "errordlg.h"
0022 
0023 #include <QLabel>
0024 #include <QBoxLayout>
0025 
0026 #include <klocalizedstring.h>
0027 #include <kiconloader.h>
0028 
0029 namespace KJSDebugger
0030 {
0031 
0032 KJSErrorDialog::KJSErrorDialog(QWidget *parent, const QString &errorMessage, bool showDebug)
0033     : KDialog(parent)
0034 {
0035     setCaption(i18n("JavaScript Error"));
0036     setModal(true);
0037     setButtons(showDebug ? KDialog::Ok | KDialog::User1 : KDialog::Ok);
0038     setButtonGuiItem(KDialog::User1, KGuiItem("&Debug", "system-run"));
0039     setDefaultButton(KDialog::Ok);
0040 
0041     QWidget *page = new QWidget(this);
0042     setMainWidget(page);
0043 
0044     QLabel *iconLabel = new QLabel("", page);
0045     iconLabel->setPixmap(SmallIcon("dialog-error", KIconLoader::SizeMedium));
0046 
0047     QWidget *contents = new QWidget(page);
0048     QLabel *label = new QLabel(errorMessage, contents);
0049     m_dontShowAgainCb = new QCheckBox(i18n("&Do not show this message again"), contents);
0050 
0051     QVBoxLayout *vl = new QVBoxLayout(contents);
0052     vl->setContentsMargins(0, 0, 0, 0);
0053     vl->addWidget(label);
0054     vl->addWidget(m_dontShowAgainCb);
0055 
0056     QHBoxLayout *topLayout = new QHBoxLayout(page);
0057     topLayout->setContentsMargins(0, 0, 0, 0);
0058     topLayout->addWidget(iconLabel);
0059     topLayout->addWidget(contents);
0060     topLayout->addStretch(10);
0061 
0062     m_debugSelected = false;
0063     connect(this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()));
0064 }
0065 
0066 KJSErrorDialog::~KJSErrorDialog()
0067 {
0068 }
0069 
0070 void KJSErrorDialog::slotUser1()
0071 {
0072     m_debugSelected = true;
0073     close();
0074 }
0075 
0076 }
0077 
0078 #include "moc_errordlg.cpp"