1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/* This file is part of the KDE project
Copyright (C) 2001-2002 Bernd Gehrmann <bernd@tdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "runoptionswidget.h"
#include <klocale.h>
#include <tdefiledialog.h>
#include <kurlrequester.h>
#include <kurlcompletion.h>
#include <klineedit.h>
#include <urlutil.h>
#include <tqlistview.h>
#include <tqgroupbox.h>
#include <tqcheckbox.h>
#include <tqradiobutton.h>
#include <tqpushbutton.h>
#include <tqbuttongroup.h>
#include <tqlabel.h>
#include "domutil.h"
#include "environmentvariableswidget.h"
RunOptionsWidget::RunOptionsWidget(TQDomDocument &dom, const TQString &configGroup,
const TQString &buildDirectory, TQWidget *parent, const char *name)
: RunOptionsWidgetBase(parent, name),
m_dom(dom), m_configGroup(configGroup)
{
// Create the "Environment Variables" GUI
env_var_group->setColumnLayout( 1, Qt::Vertical );
m_environmentVariablesWidget = new EnvironmentVariablesWidget( dom, configGroup + "/run/envvars", env_var_group );
mainprogram_edit->completionObject()->setMode(KURLCompletion::FileCompletion);
mainprogram_edit->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
if( DomUtil::readEntry(dom, configGroup + "/run/mainprogram").isEmpty() && TQFileInfo( buildDirectory ).exists() )
{
mainprogram_edit->setURL( buildDirectory );
mainprogram_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
}else if ( TQFileInfo( DomUtil::readEntry(dom, configGroup + "/run/mainprogram") ).exists() )
{
TQString program = DomUtil::readEntry(dom, configGroup + "/run/mainprogram");
if( TQDir::isRelativePath(program) )
program = buildDirectory + "/" + program;
mainprogram_edit->setURL(program);
mainprogram_edit->fileDialog()->setURL( program );
}else
{
mainprogram_edit->setURL(TQString());
mainprogram_edit->fileDialog()->setURL(TQString());
}
cwd_edit->completionObject()->setMode(KURLCompletion::DirCompletion);
cwd_edit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
if( DomUtil::readEntry(dom, configGroup + "/run/globalcwd").isEmpty() && TQFileInfo( buildDirectory ).exists() )
{
cwd_edit->setURL( buildDirectory );
cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
}else if( TQFileInfo( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ).exists() )
{
cwd_edit->setURL(DomUtil::readEntry(dom, configGroup + "/run/globalcwd"));
cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ) );
}else
{
cwd_edit->setURL(TQString());
cwd_edit->fileDialog()->setURL(TQString());
}
if( configGroup == "/kdevautoproject" || configGroup == "/kdevtrollproject" )
{
mainProgramGroupBox->setCheckable(true);
mainProgramGroupBox->setChecked( DomUtil::readBoolEntry(dom, configGroup+"/run/useglobalprogram", false ) );
}else
{
delete notelabel;
}
// Read the main program command line arguments and store them in the edit box
runargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/programargs"));
debugargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/globaldebugarguments"));
startinterminal_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/terminal"));
autocompile_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autocompile", false));
autoinstall_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autoinstall", false));
autotdesu_box->setChecked(DomUtil::readBoolEntry(dom, configGroup + "/run/autotdesu", false));
}
RunOptionsWidget::~RunOptionsWidget()
{}
void RunOptionsWidget::accept()
{
DomUtil::writeEntry(m_dom, m_configGroup + "/run/mainprogram", mainprogram_edit->url());
DomUtil::writeEntry(m_dom, m_configGroup + "/run/programargs", runargs_edit->text());
DomUtil::writeEntry(m_dom, m_configGroup + "/run/globaldebugarguments", debugargs_edit->text());
DomUtil::writeEntry(m_dom, m_configGroup + "/run/globalcwd", cwd_edit->url());
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/useglobalprogram", mainProgramGroupBox->isChecked());
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/terminal", startinterminal_box->isChecked());
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autocompile", autocompile_box->isChecked());
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autoinstall", autoinstall_box->isChecked());
DomUtil::writeBoolEntry(m_dom, m_configGroup + "/run/autotdesu", autotdesu_box->isChecked());
m_environmentVariablesWidget->accept();
}
void RunOptionsWidget::mainProgramChanged( )
{
if( mainProgramGroupBox->isChecked() && mainprogram_edit->url().isEmpty() )
{
mainprogram_label->setPaletteForegroundColor(TQColor("#ff0000"));
}
else
{
mainprogram_label->unsetPalette();
}
}
#include "runoptionswidget.moc"
|