2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at qt-sales@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
#include "qt4projectconfigwidget.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
|
|
|
|
#include "makestep.h"
|
|
|
|
|
#include "qmakestep.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4project.h"
|
2009-01-20 11:52:04 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanager.h"
|
2009-04-20 16:38:10 +02:00
|
|
|
#include "ui_qt4projectconfigwidget.h"
|
2009-01-20 11:52:04 +01:00
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2009-01-16 15:26:34 +01:00
|
|
|
#include <coreplugin/mainwindow.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
bool debug = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
|
2008-12-02 12:01:29 +01:00
|
|
|
: BuildStepConfigWidget(),
|
|
|
|
|
m_pro(project)
|
|
|
|
|
{
|
2009-04-20 16:38:10 +02:00
|
|
|
m_ui = new Ui::Qt4ProjectConfigWidget();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->setupUi(this);
|
2008-12-19 18:25:20 +01:00
|
|
|
m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory"));
|
|
|
|
|
m_ui->shadowBuildDirEdit->setExpectedKind(Core::Utils::PathChooser::Directory);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->invalidQtWarningLabel->setVisible(false);
|
|
|
|
|
|
|
|
|
|
connect(m_ui->nameLineEdit, SIGNAL(textEdited(QString)),
|
|
|
|
|
this, SLOT(changeConfigName(QString)));
|
|
|
|
|
|
|
|
|
|
connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)),
|
|
|
|
|
this, SLOT(shadowBuildCheckBoxClicked(bool)));
|
|
|
|
|
|
2008-12-19 18:25:20 +01:00
|
|
|
connect(m_ui->shadowBuildDirEdit, SIGNAL(beforeBrowsing()),
|
|
|
|
|
this, SLOT(onBeforeBeforeShadowBuildDirBrowsed()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-19 18:25:20 +01:00
|
|
|
connect(m_ui->shadowBuildDirEdit, SIGNAL(changed()),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SLOT(shadowBuildLineEditTextChanged()));
|
|
|
|
|
|
|
|
|
|
connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
|
|
|
|
|
this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
|
|
|
|
|
|
|
|
|
|
connect(m_ui->importLabel, SIGNAL(linkActivated(QString)),
|
|
|
|
|
this, SLOT(importLabelClicked()));
|
|
|
|
|
|
2009-01-16 15:26:34 +01:00
|
|
|
connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(manageQtVersions()));
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_pro->qt4ProjectManager()->versionManager(), SIGNAL(qtVersionsChanged()),
|
|
|
|
|
this, SLOT(setupQtVersionsComboBox()));
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::manageQtVersions()
|
2009-01-16 15:26:34 +01:00
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
Core::ICore *core = Core::ICore::instance();
|
2009-01-16 15:26:34 +01:00
|
|
|
core->showOptionsDialog(Constants::QT_CATEGORY, Constants::QTVERSION_PAGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
QString Qt4ProjectConfigWidget::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return tr("General");
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::init(const QString &buildConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (debug)
|
2009-04-20 16:38:10 +02:00
|
|
|
qDebug() << "Qt4ProjectConfigWidget::init()";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
m_buildConfiguration = buildConfiguration;
|
|
|
|
|
|
|
|
|
|
m_ui->nameLineEdit->setText(m_pro->displayNameFor(m_buildConfiguration));
|
|
|
|
|
|
|
|
|
|
setupQtVersionsComboBox();
|
|
|
|
|
|
|
|
|
|
bool shadowBuild = m_pro->value(buildConfiguration, "useShadowBuild").toBool();
|
|
|
|
|
m_ui->shadowBuildCheckBox->setChecked(shadowBuild);
|
2008-12-19 18:25:20 +01:00
|
|
|
m_ui->shadowBuildDirEdit->setEnabled(shadowBuild);
|
|
|
|
|
m_ui->shadowBuildDirEdit->setPath(m_pro->buildDirectory(buildConfiguration));
|
2009-03-19 15:04:43 +01:00
|
|
|
updateImportLabel();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::changeConfigName(const QString &newName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_pro->setDisplayNameFor(m_buildConfiguration, newName);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::setupQtVersionsComboBox()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (m_buildConfiguration.isEmpty()) // not yet initialized
|
|
|
|
|
return;
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
disconnect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
|
|
|
|
|
this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
m_ui->qtVersionComboBox->clear();
|
|
|
|
|
m_ui->qtVersionComboBox->addItem(tr("Default Qt Version"), 0);
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
if (m_pro->qtVersionId(m_buildConfiguration) == 0) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->qtVersionComboBox->setCurrentIndex(0);
|
|
|
|
|
m_ui->invalidQtWarningLabel->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
// Add Qt Versions to the combo box
|
|
|
|
|
QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
|
|
|
|
|
const QList<QtVersion *> &versions = vm->versions();
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i < versions.size(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->qtVersionComboBox->addItem(versions.at(i)->name(), versions.at(i)->uniqueId());
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
if (versions.at(i)->uniqueId() == m_pro->qtVersionId(m_buildConfiguration)) {
|
|
|
|
|
m_ui->qtVersionComboBox->setCurrentIndex(i + 1);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->invalidQtWarningLabel->setVisible(!versions.at(i)->isValid());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And connect again
|
2008-12-09 11:07:24 +01:00
|
|
|
connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
|
|
|
|
|
this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::onBeforeBeforeShadowBuildDirBrowsed()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-19 18:25:20 +01:00
|
|
|
QString initialDirectory = QFileInfo(m_pro->file()->fileName()).absolutePath();
|
|
|
|
|
if (!initialDirectory.isEmpty())
|
|
|
|
|
m_ui->shadowBuildDirEdit->setInitialBrowsePathBackup(initialDirectory);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::shadowBuildCheckBoxClicked(bool checked)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-19 18:25:20 +01:00
|
|
|
m_ui->shadowBuildDirEdit->setEnabled(checked);
|
2008-12-02 12:01:29 +01:00
|
|
|
bool b = m_ui->shadowBuildCheckBox->isChecked();
|
|
|
|
|
m_pro->setValue(m_buildConfiguration, "useShadowBuild", b);
|
|
|
|
|
if (b)
|
2008-12-19 18:25:20 +01:00
|
|
|
m_pro->setValue(m_buildConfiguration, "buildDirectory", m_ui->shadowBuildDirEdit->path());
|
2008-12-02 12:01:29 +01:00
|
|
|
else
|
|
|
|
|
m_pro->setValue(m_buildConfiguration, "buildDirectory", QVariant(QString::null));
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::updateImportLabel()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_ui->importLabel->setVisible(false);
|
|
|
|
|
if (m_ui->shadowBuildCheckBox->isChecked()) {
|
2008-12-19 18:25:20 +01:00
|
|
|
QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
|
2008-12-09 11:07:24 +01:00
|
|
|
if (!qtPath.isEmpty()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui->importLabel->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-03-19 15:04:43 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::shadowBuildLineEditTextChanged()
|
2009-03-19 15:04:43 +01:00
|
|
|
{
|
|
|
|
|
if (m_pro->value(m_buildConfiguration, "buildDirectory").toString() == m_ui->shadowBuildDirEdit->path())
|
2009-03-23 15:35:01 +01:00
|
|
|
return;
|
2009-03-19 15:04:43 +01:00
|
|
|
m_pro->setValue(m_buildConfiguration, "buildDirectory", m_ui->shadowBuildDirEdit->path());
|
|
|
|
|
// if the directory already exists
|
|
|
|
|
// check if we have a build in there and
|
|
|
|
|
// offer to import it
|
|
|
|
|
updateImportLabel();
|
|
|
|
|
|
|
|
|
|
m_pro->invalidateCachedTargetInformation();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-19 18:25:20 +01:00
|
|
|
// QFileInfo fi(m_ui->shadowBuildDirEdit->path());
|
2008-12-02 12:01:29 +01:00
|
|
|
// if (fi.exists()) {
|
|
|
|
|
// m_ui->shadowBuildLineEdit->setStyleSheet("");
|
|
|
|
|
// m_ui->shadowBuildLineEdit->setToolTip("");
|
|
|
|
|
// } else {
|
|
|
|
|
// m_ui->shadowBuildLineEdit->setStyleSheet("background: red;");
|
|
|
|
|
// m_ui->shadowBuildLineEdit->setToolTip(tr("Directory does not exist."));
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::importLabelClicked()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (m_ui->shadowBuildCheckBox->isChecked()) {
|
2008-12-19 18:25:20 +01:00
|
|
|
QString directory = m_ui->shadowBuildDirEdit->path();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!directory.isEmpty()) {
|
|
|
|
|
QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
|
|
|
|
|
QString qtPath = vm->findQtVersionFromMakefile(directory);
|
|
|
|
|
if (!qtPath.isEmpty()) {
|
|
|
|
|
QtVersion *version = vm->qtVersionForDirectory(qtPath);
|
|
|
|
|
if (!version) {
|
|
|
|
|
version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath);
|
|
|
|
|
vm->addVersion(version);
|
|
|
|
|
}
|
|
|
|
|
QtVersion::QmakeBuildConfig qmakeBuildConfig = version->defaultBuildConfig();
|
|
|
|
|
qmakeBuildConfig = vm->scanMakefileForQmakeConfig(directory, qmakeBuildConfig);
|
|
|
|
|
|
|
|
|
|
// So we got all the information now apply it...
|
|
|
|
|
m_pro->setQtVersion(m_buildConfiguration, version->uniqueId());
|
|
|
|
|
// Combo box will be updated at the end
|
|
|
|
|
|
|
|
|
|
// Find qmakestep...
|
|
|
|
|
QMakeStep *qmakeStep = m_pro->qmakeStep();
|
|
|
|
|
MakeStep *makeStep = m_pro->makeStep();
|
|
|
|
|
|
|
|
|
|
qmakeStep->setValue(m_buildConfiguration, "buildConfiguration", int(qmakeBuildConfig));
|
|
|
|
|
// Adjust command line arguments, this is ugly as hell
|
|
|
|
|
// If we are switching to BuildAll we want "release" in there and no "debug"
|
|
|
|
|
// or "debug" in there and no "release"
|
|
|
|
|
// If we are switching to not BuildAl we want neither "release" nor "debug" in there
|
|
|
|
|
QStringList makeCmdArguments = makeStep->value(m_buildConfiguration, "makeargs").toStringList();
|
|
|
|
|
bool debug = qmakeBuildConfig & QtVersion::DebugBuild;
|
|
|
|
|
if (qmakeBuildConfig & QtVersion::BuildAll) {
|
|
|
|
|
makeCmdArguments.removeAll(debug ? "release" : "debug");
|
|
|
|
|
if (!makeCmdArguments.contains(debug ? "debug" : "release"))
|
|
|
|
|
makeCmdArguments.append(debug ? "debug" : "release");
|
|
|
|
|
} else {
|
|
|
|
|
makeCmdArguments.removeAll("debug");
|
|
|
|
|
makeCmdArguments.removeAll("remove");
|
|
|
|
|
}
|
|
|
|
|
makeStep->setValue(m_buildConfiguration, "makeargs", makeCmdArguments);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setupQtVersionsComboBox();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 16:38:10 +02:00
|
|
|
void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString &)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
//Qt Version
|
|
|
|
|
int newQtVersion;
|
|
|
|
|
if (m_ui->qtVersionComboBox->currentIndex() == 0) {
|
|
|
|
|
newQtVersion = 0;
|
|
|
|
|
} else {
|
|
|
|
|
newQtVersion = m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->currentIndex()).toInt();
|
|
|
|
|
}
|
|
|
|
|
bool isValid = m_pro->qt4ProjectManager()->versionManager()->version(newQtVersion)->isValid();
|
|
|
|
|
m_ui->invalidQtWarningLabel->setVisible(!isValid);
|
2008-12-09 11:07:24 +01:00
|
|
|
if (newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_pro->setQtVersion(m_buildConfiguration, newQtVersion);
|
|
|
|
|
m_pro->update();
|
|
|
|
|
}
|
|
|
|
|
}
|