summaryrefslogtreecommitdiffstats
path: root/buildtools/custommakefiles/custombuildoptionswidget.cpp
blob: b06ced1858256c0f4944ded343c7545a9fb43bea (plain)
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
/***************************************************************************
 *   Copyright (C) 2002 by Bernd Gehrmann                                  *
 *   bernd@kdevelop.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "custombuildoptionswidget.h"

#include <tqcheckbox.h>
#include <klineedit.h>
#include <kurlrequester.h>
#include <kurlcompletion.h>
#include <kfiledialog.h>
#include <tqradiobutton.h>
#include <tqtabwidget.h>
#include "domutil.h"


CustomBuildOptionsWidget::CustomBuildOptionsWidget(TQDomDocument &dom,
                                                   TQWidget *tqparent, const char *name)
    : CustomBuildOptionsWidgetBase(tqparent, name),
      m_dom(dom)
{
    ant_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "ant");
    other_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "other");
    if( !DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir").isEmpty()
            && TQFileInfo( DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir") ).exists() )
    {
        builddir_edit->setURL(DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir"));
        builddir_edit->fileDialog()->setURL( DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir") );
    }
    else
    {
        builddir_edit->setURL( TQString() );
        builddir_edit->fileDialog()->setURL( TQString() );
    }
    builddir_edit->completionObject()->setMode(KURLCompletion::DirCompletion);
    builddir_edit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );

    // This connection must not be made before the ant->setChecked() line,
    // because at this time makeToggled() would crash
    connect( make_button, TQT_SIGNAL(toggled(bool)),
            this, TQT_SLOT(makeToggled(bool)) );
    connect( other_button, TQT_SIGNAL(toggled(bool)),
             this, TQT_SLOT(otherToggled(bool)) );
}


CustomBuildOptionsWidget::~CustomBuildOptionsWidget()
{}


void CustomBuildOptionsWidget::accept()
{
    TQString buildtool;
    if (ant_button->isChecked())
    {
        buildtool = "ant";
    }
    else if (other_button->isChecked())
    {
        buildtool = "other";
    }
    else
    {
        buildtool = "make";
    }
    DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/buildtool", buildtool);
    DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/builddir", builddir_edit->url());
}


void CustomBuildOptionsWidget::setMakeOptionsWidget(TQTabWidget *tw, TQWidget *mow, TQWidget* oow)
{
    m_tabWidget = tw;
    m_makeOptions = mow;
    m_otherOptions = oow;
    makeToggled(make_button->isChecked());
    otherToggled(other_button->isChecked());
}

void CustomBuildOptionsWidget::otherToggled(bool b)
{
    m_tabWidget->setTabEnabled(m_otherOptions, b);
}

void CustomBuildOptionsWidget::makeToggled(bool b)
{
    m_tabWidget->setTabEnabled(m_makeOptions, b);
}

#include "custombuildoptionswidget.moc"

// kate: space-indent on; indent-width 4; tab-width 4; tqreplace-tabs on