add more spacing
[personal-kdebase.git] / apps / konqueror / shellcmdplugin / kshellcmddialog.cpp
blobd446faac084a0e4fad6e0abc662f4f76d2249476
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 setButtons( KDialog::None );
40 QWidget *w = new QWidget( this );
41 QVBoxLayout * box= new QVBoxLayout;
42 box->setMargin(marginHint());
43 box->setSpacing(spacingHint());
44 w->setLayout( box );
45 setMainWidget(w);
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 );
68 m_shell->setFocus();
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()
77 delete m_shell;
78 m_shell=0;
81 void KShellCommandDialog::disableStopButton()
83 cancelButton->setEnabled(false);
86 void KShellCommandDialog::slotClose()
88 delete m_shell;
89 m_shell=0;
90 accept();
93 //blocking
94 int KShellCommandDialog::executeCommand()
96 if (m_shell==0)
97 return 0;
98 //kDebug()<<"---------- KShellCommandDialog::executeCommand()";
99 m_shell->exec();
100 return exec();
103 #include "kshellcmddialog.moc"