1
/* This file is part of the KDE project
2
Copyright (C) 2001-2002 Bernd Gehrmann <bernd@kdevelop.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., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#include "runoptionswidget.h"
23
#include <kfiledialog.h>
24
#include <kurlrequester.h>
25
#include <kurlcompletion.h>
26
#include <klineedit.h>
29
#include <qlistview.h>
30
#include <qgroupbox.h>
31
#include <qcheckbox.h>
32
#include <qradiobutton.h>
33
#include <qpushbutton.h>
34
#include <qbuttongroup.h>
38
#include "environmentvariableswidget.h"
41
RunOptionsWidget::RunOptionsWidget(QDomDocument &dom, const QString &configGroup,
42
const QString &buildDirectory, QWidget *parent, const char *name)
43
: RunOptionsWidgetBase(parent, name),
44
m_dom(dom), m_configGroup(configGroup)
46
// Create the "Environment Variables" GUI
47
env_var_group->setColumnLayout( 1, Qt::Vertical );
48
m_environmentVariablesWidget = new EnvironmentVariablesWidget( dom, configGroup + "/run/envvars", env_var_group );
50
mainprogram_edit->completionObject()->setMode(KURLCompletion::FileCompletion);
51
mainprogram_edit->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
52
if( DomUtil::readEntry(dom, configGroup + "/run/mainprogram").isEmpty() && QFileInfo( buildDirectory ).exists() )
54
mainprogram_edit->setURL( buildDirectory );
55
mainprogram_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
56
}else if ( QFileInfo( DomUtil::readEntry(dom, configGroup + "/run/mainprogram") ).exists() )
58
QString program = DomUtil::readEntry(dom, configGroup + "/run/mainprogram");
59
if( QDir::isRelativePath(program) )
60
program = buildDirectory + "/" + program;
61
mainprogram_edit->setURL(program);
62
mainprogram_edit->fileDialog()->setURL( program );
65
mainprogram_edit->setURL(QString());
66
mainprogram_edit->fileDialog()->setURL(QString());
69
cwd_edit->completionObject()->setMode(KURLCompletion::DirCompletion);
70
cwd_edit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
71
if( DomUtil::readEntry(dom, configGroup + "/run/globalcwd").isEmpty() && QFileInfo( buildDirectory ).exists() )
73
cwd_edit->setURL( buildDirectory );
74
cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
75
}else if( QFileInfo( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ).exists() )
77
cwd_edit->setURL(DomUtil::readEntry(dom, configGroup + "/run/globalcwd"));
78
cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ) );
81
cwd_edit->setURL(QString());
82
cwd_edit->fileDialog()->setURL(QString());
85
if( configGroup == "/kdevautoproject" || configGroup == "/kdevtrollproject" )
87
mainProgramGroupBox->setCheckable(true);
88
mainProgramGroupBox->setChecked( DomUtil::readBoolEntry(dom, configGroup+"/run/useglobalprogram", false ) );
94
// Read the main program command line arguments and store them in the edit box
96
runargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/programargs"));
97
debugargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/globaldebugarguments"));
99
startinterminal_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/terminal"));
100
autocompile_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autocompile", false));
101
autoinstall_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autoinstall", false));
102
autokdesu_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autokdesu", false));
106
RunOptionsWidget::~RunOptionsWidget()
110
void RunOptionsWidget::accept()
112
DomUtil::writeEntry(m_dom, m_configGroup + "/run/mainprogram", mainprogram_edit->url());
113
DomUtil::writeEntry(m_dom, m_configGroup + "/run/programargs", runargs_edit->text());
114
DomUtil::writeEntry(m_dom, m_configGroup + "/run/globaldebugarguments", debugargs_edit->text());
115
DomUtil::writeEntry(m_dom, m_configGroup + "/run/globalcwd", cwd_edit->url());
116
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/useglobalprogram", mainProgramGroupBox->isChecked());
117
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/terminal", startinterminal_box->isChecked());
118
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autocompile", autocompile_box->isChecked());
119
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autoinstall", autoinstall_box->isChecked());
120
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autokdesu", autokdesu_box->isChecked());
122
m_environmentVariablesWidget->accept();
125
void RunOptionsWidget::mainProgramChanged( )
128
if( mainProgramGroupBox->isChecked() && mainprogram_edit->url().isEmpty() )
130
mainprogram_label->setPaletteForegroundColor(QColor("#ff0000"));
134
mainprogram_label->unsetPalette();
138
#include "runoptionswidget.moc"