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 setButtons( KDialog::None
);
40 QWidget
*w
= new QWidget( this );
41 QVBoxLayout
* box
= new QVBoxLayout
;
42 box
->setMargin(marginHint());
43 box
->setSpacing(spacingHint());
47 QLabel
*label
=new QLabel(title
,this);
48 m_shell
=new KShellCommandExecutor(command
,this);
50 cancelButton
= new KPushButton(KStandardGuiItem::cancel(), this);
51 closeButton
= new KPushButton(KStandardGuiItem::close(), this);
52 closeButton
->setDefault(true);
54 label
->resize(label
->sizeHint());
55 m_shell
->resize(m_shell
->sizeHint());
56 closeButton
->setFixedSize(closeButton
->sizeHint());
57 cancelButton
->setFixedSize(cancelButton
->sizeHint());
59 box
->addWidget(label
,0);
60 box
->addWidget(m_shell
,1);
62 QHBoxLayout
* hlayout
= new QHBoxLayout();
63 box
->addItem(hlayout
);
64 hlayout
->setSpacing( spacingHint() );
65 hlayout
->addWidget( cancelButton
);
66 hlayout
->addWidget( closeButton
);
70 connect(cancelButton
, SIGNAL(clicked()), m_shell
, SLOT(slotFinished()));
71 connect(m_shell
, SIGNAL(finished()), this, SLOT(disableStopButton()));
72 connect(closeButton
,SIGNAL(clicked()), this, SLOT(slotClose()));
75 KShellCommandDialog::~KShellCommandDialog()
81 void KShellCommandDialog::disableStopButton()
83 cancelButton
->setEnabled(false);
86 void KShellCommandDialog::slotClose()
94 int KShellCommandDialog::executeCommand()
98 //kDebug()<<"---------- KShellCommandDialog::executeCommand()";
103 #include "kshellcmddialog.moc"