1 /* This file is part of the KDE project
2 Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #include "kshellcmddialog.h"
24 #include <QtGui/QLayout>
25 #include <QtGui/QLabel>
29 #include <KStandardGuiItem>
30 #include <kpushbutton.h>
33 #include "kshellcmdexecutor.h"
35 KShellCommandDialog::KShellCommandDialog(const QString
& title
, const QString
& command
, QWidget
* parent
, bool modal
)
39 QVBoxLayout
* box
= new QVBoxLayout (this);
40 box
->setMargin(marginHint());
41 box
->setSpacing(spacingHint());
43 QLabel
*label
=new QLabel(title
,this);
44 m_shell
=new KShellCommandExecutor(command
,this);
46 cancelButton
= new KPushButton(KStandardGuiItem::cancel(), this);
47 closeButton
= new KPushButton(KStandardGuiItem::close(), this);
48 closeButton
->setDefault(true);
50 label
->resize(label
->sizeHint());
51 m_shell
->resize(m_shell
->sizeHint());
52 closeButton
->setFixedSize(closeButton
->sizeHint());
53 cancelButton
->setFixedSize(cancelButton
->sizeHint());
55 box
->addWidget(label
,0);
56 box
->addWidget(m_shell
,1);
58 QHBoxLayout
* hlayout
= new QHBoxLayout();
59 box
->addItem(hlayout
);
60 hlayout
->setSpacing( spacingHint() );
61 hlayout
->addWidget( cancelButton
);
62 hlayout
->addWidget( closeButton
);
66 connect(cancelButton
, SIGNAL(clicked()), m_shell
, SLOT(slotFinished()));
67 connect(m_shell
, SIGNAL(finished()), this, SLOT(disableStopButton()));
68 connect(closeButton
,SIGNAL(clicked()), this, SLOT(slotClose()));
71 KShellCommandDialog::~KShellCommandDialog()
77 void KShellCommandDialog::disableStopButton()
79 cancelButton
->setEnabled(false);
82 void KShellCommandDialog::slotClose()
90 int KShellCommandDialog::executeCommand()
94 //kDebug()<<"---------- KShellCommandDialog::executeCommand()";
99 #include "kshellcmddialog.moc"