KHtml

errordlg.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2000-2001 Harri Porten ([email protected])
4  * Copyright (C) 2001,2003 Peter Kelly ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "errordlg.h"
22 
23 #include <QLabel>
24 #include <QBoxLayout>
25 
26 #include <klocalizedstring.h>
27 #include <kiconloader.h>
28 
29 namespace KJSDebugger
30 {
31 
32 KJSErrorDialog::KJSErrorDialog(QWidget *parent, const QString &errorMessage, bool showDebug)
33  : KDialog(parent)
34 {
35  setCaption(i18n("JavaScript Error"));
36  setModal(true);
37  setButtons(showDebug ? KDialog::Ok | KDialog::User1 : KDialog::Ok);
38  setButtonGuiItem(KDialog::User1, KGuiItem("&Debug", "system-run"));
39  setDefaultButton(KDialog::Ok);
40 
41  QWidget *page = new QWidget(this);
42  setMainWidget(page);
43 
44  QLabel *iconLabel = new QLabel("", page);
45  iconLabel->setPixmap(SmallIcon("dialog-error", KIconLoader::SizeMedium));
46 
47  QWidget *contents = new QWidget(page);
48  QLabel *label = new QLabel(errorMessage, contents);
49  m_dontShowAgainCb = new QCheckBox(i18n("&Do not show this message again"), contents);
50 
51  QVBoxLayout *vl = new QVBoxLayout(contents);
52  vl->setContentsMargins(0, 0, 0, 0);
53  vl->addWidget(label);
54  vl->addWidget(m_dontShowAgainCb);
55 
56  QHBoxLayout *topLayout = new QHBoxLayout(page);
57  topLayout->setContentsMargins(0, 0, 0, 0);
58  topLayout->addWidget(iconLabel);
59  topLayout->addWidget(contents);
60  topLayout->addStretch(10);
61 
62  m_debugSelected = false;
63  connect(this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()));
64 }
65 
66 KJSErrorDialog::~KJSErrorDialog()
67 {
68 }
69 
70 void KJSErrorDialog::slotUser1()
71 {
72  m_debugSelected = true;
73  close();
74 }
75 
76 }
void setContentsMargins(int left, int top, int right, int bottom)
void setPixmap(const QPixmap &)
const QList< QKeySequence > & close()
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QString label(StandardShortcut id)
QString i18n(const char *text, const TYPE &arg...)
void addStretch(int stretch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.