Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / apps / konqueror / shellcmdplugin / kshellcmddialog.cpp
bloba6e903156688b073a6e706247e1b1c8ad973bb89
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.
20 // Own
21 #include "kshellcmddialog.h"
23 // Qt
24 #include <QtGui/QLayout>
25 #include <QtGui/QLabel>
27 // KDE
28 #include <klocale.h>
29 #include <KStandardGuiItem>
30 #include <kpushbutton.h>
32 // Local
33 #include "kshellcmdexecutor.h"
35 KShellCommandDialog::KShellCommandDialog(const QString& title, const QString& command, QWidget* parent, bool modal)
36 :KDialog(parent)
38 setModal( 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 );
64 m_shell->setFocus();
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()
73 delete m_shell;
74 m_shell=0;
77 void KShellCommandDialog::disableStopButton()
79 cancelButton->setEnabled(false);
82 void KShellCommandDialog::slotClose()
84 delete m_shell;
85 m_shell=0;
86 accept();
89 //blocking
90 int KShellCommandDialog::executeCommand()
92 if (m_shell==0)
93 return 0;
94 //kDebug()<<"---------- KShellCommandDialog::executeCommand()";
95 m_shell->exec();
96 return exec();
99 #include "kshellcmddialog.moc"