~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to buildtools/lib/widgets/runoptionswidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE project
2
 
   Copyright (C) 2001-2002 Bernd Gehrmann <bernd@kdevelop.org>
3
 
 
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.
8
 
 
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.
13
 
 
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.
18
 
*/
19
 
 
20
 
#include "runoptionswidget.h"
21
 
 
22
 
#include <klocale.h>
23
 
#include <kfiledialog.h>
24
 
#include <kurlrequester.h>
25
 
#include <kurlcompletion.h>
26
 
#include <klineedit.h>
27
 
#include <urlutil.h>
28
 
 
29
 
#include <qlistview.h>
30
 
#include <qgroupbox.h>
31
 
#include <qcheckbox.h>
32
 
#include <qradiobutton.h>
33
 
#include <qpushbutton.h>
34
 
#include <qbuttongroup.h>
35
 
#include <qlabel.h>
36
 
 
37
 
#include "domutil.h"
38
 
#include "environmentvariableswidget.h"
39
 
 
40
 
 
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)
45
 
{
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 );
49
 
 
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() )
53
 
    {
54
 
        mainprogram_edit->setURL( buildDirectory );
55
 
        mainprogram_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
56
 
    }else if ( QFileInfo( DomUtil::readEntry(dom, configGroup + "/run/mainprogram") ).exists() )
57
 
    {
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 );
63
 
    }else
64
 
    {
65
 
        mainprogram_edit->setURL(QString());
66
 
        mainprogram_edit->fileDialog()->setURL(QString());
67
 
    }
68
 
 
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() )
72
 
    {
73
 
        cwd_edit->setURL( buildDirectory );
74
 
        cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL(buildDirectory) );
75
 
    }else if( QFileInfo( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ).exists() )
76
 
    {
77
 
        cwd_edit->setURL(DomUtil::readEntry(dom, configGroup + "/run/globalcwd"));
78
 
        cwd_edit->fileDialog()->setURL( KURL::fromPathOrURL( DomUtil::readEntry(dom, configGroup + "/run/globalcwd") ) );
79
 
    }else
80
 
    {
81
 
        cwd_edit->setURL(QString());
82
 
        cwd_edit->fileDialog()->setURL(QString());
83
 
    }
84
 
 
85
 
    if( configGroup == "/kdevautoproject" || configGroup == "/kdevtrollproject" )
86
 
    {
87
 
        mainProgramGroupBox->setCheckable(true);
88
 
        mainProgramGroupBox->setChecked( DomUtil::readBoolEntry(dom, configGroup+"/run/useglobalprogram", false ) );
89
 
    }else
90
 
    {
91
 
        delete notelabel;
92
 
    }
93
 
 
94
 
    // Read the main program command line arguments and store them in the edit box
95
 
 
96
 
    runargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/programargs"));
97
 
    debugargs_edit->setText(DomUtil::readEntry(dom, configGroup + "/run/globaldebugarguments"));
98
 
 
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));
103
 
}
104
 
 
105
 
 
106
 
RunOptionsWidget::~RunOptionsWidget()
107
 
{}
108
 
 
109
 
 
110
 
void RunOptionsWidget::accept()
111
 
{
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());
121
 
 
122
 
    m_environmentVariablesWidget->accept();
123
 
}
124
 
 
125
 
void RunOptionsWidget::mainProgramChanged( )
126
 
{
127
 
 
128
 
    if( mainProgramGroupBox->isChecked() && mainprogram_edit->url().isEmpty() )
129
 
    {
130
 
        mainprogram_label->setPaletteForegroundColor(QColor("#ff0000"));
131
 
    }
132
 
    else
133
 
    {
134
 
        mainprogram_label->unsetPalette();
135
 
    }
136
 
}
137
 
 
138
 
#include "runoptionswidget.moc"