Commit 6ef67df8 authored by goro's avatar goro
Browse files

PathChooser migration for Qt4 build config page

parent b462482c
......@@ -90,6 +90,7 @@ struct PathChooserPrivate
PathValidatingLineEdit *m_lineEdit;
PathChooser::Kind m_acceptingKind;
QString m_dialogTitleOverride;
QString m_initialBrowsePathOverride;
};
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
......@@ -143,9 +144,15 @@ void PathChooser::setPath(const QString &path)
void PathChooser::slotBrowse()
{
emit beforeBrowsing();
QString predefined = path();
if (!predefined.isEmpty() && !QFileInfo(predefined).isDir())
predefined.clear();
if ((predefined.isEmpty() || !QFileInfo(predefined).isDir())
&& !m_d->m_initialBrowsePathOverride.isNull()) {
predefined = m_d->m_initialBrowsePathOverride;
if (!QFileInfo(predefined).isDir())
predefined.clear();
}
// Prompt for a file/dir
QString dialogTitle;
......@@ -271,6 +278,11 @@ void PathChooser::setPromptDialogTitle(const QString &title)
m_d->m_dialogTitleOverride = title;
}
void PathChooser::setInitialBrowsePathBackup(const QString &path)
{
m_d->m_initialBrowsePathOverride = path;
}
QString PathChooser::makeDialogTitle(const QString &title)
{
if (m_d->m_dialogTitleOverride.isNull())
......
......@@ -71,6 +71,8 @@ public:
void setPromptDialogTitle(const QString &title);
void setInitialBrowsePathBackup(const QString &path);
bool isValid() const;
QString errorMessage() const;
......@@ -91,6 +93,7 @@ private:
signals:
void validChanged();
void changed();
void beforeBrowsing();
void browsingFinished();
void returnPressed();
......
......@@ -54,6 +54,8 @@ Qt4BuildConfigWidget::Qt4BuildConfigWidget(Qt4Project *project)
{
m_ui = new Ui::Qt4BuildConfigWidget();
m_ui->setupUi(this);
m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory"));
m_ui->shadowBuildDirEdit->setExpectedKind(Core::Utils::PathChooser::Directory);
m_ui->invalidQtWarningLabel->setVisible(false);
connect(m_ui->nameLineEdit, SIGNAL(textEdited(QString)),
......@@ -62,10 +64,10 @@ Qt4BuildConfigWidget::Qt4BuildConfigWidget(Qt4Project *project)
connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)),
this, SLOT(shadowBuildCheckBoxClicked(bool)));
connect(m_ui->shadowBuildButton, SIGNAL(clicked(bool)),
this, SLOT(shadowBuildButtonClicked()));
connect(m_ui->shadowBuildDirEdit, SIGNAL(beforeBrowsing()),
this, SLOT(onBeforeBeforeShadowBuildDirBrowsed()));
connect(m_ui->shadowBuildLineEdit, SIGNAL(textEdited(QString)),
connect(m_ui->shadowBuildDirEdit, SIGNAL(changed()),
this, SLOT(shadowBuildLineEditTextChanged()));
connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
......@@ -102,10 +104,9 @@ void Qt4BuildConfigWidget::init(const QString &buildConfiguration)
bool shadowBuild = m_pro->value(buildConfiguration, "useShadowBuild").toBool();
m_ui->shadowBuildCheckBox->setChecked(shadowBuild);
m_ui->shadowBuildLineEdit->setEnabled(shadowBuild);
m_ui->shadowBuildLineEdit->setText(m_pro->buildDirectory(buildConfiguration));
m_ui->shadowBuildDirEdit->setEnabled(shadowBuild);
m_ui->shadowBuildDirEdit->setPath(m_pro->buildDirectory(buildConfiguration));
shadowBuildLineEditTextChanged(); // Update the import label
m_ui->shadowBuildButton->setEnabled(shadowBuild);
}
void Qt4BuildConfigWidget::changeConfigName(const QString &newName)
......@@ -145,47 +146,39 @@ void Qt4BuildConfigWidget::setupQtVersionsComboBox()
this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
}
void Qt4BuildConfigWidget::shadowBuildButtonClicked()
void Qt4BuildConfigWidget::onBeforeBeforeShadowBuildDirBrowsed()
{
QString initialDirectory = m_ui->shadowBuildLineEdit->text();
if (initialDirectory.isEmpty())
initialDirectory = QFileInfo(m_pro->file()->fileName()).absolutePath();
QString shadowBuildDirectory =
QFileDialog::getExistingDirectory(this, tr("Shadow Build Directory"), initialDirectory );
if (shadowBuildDirectory != QString::null)
m_ui->shadowBuildLineEdit->setText(shadowBuildDirectory);
shadowBuildLineEditTextChanged();
QString initialDirectory = QFileInfo(m_pro->file()->fileName()).absolutePath();
if (!initialDirectory.isEmpty())
m_ui->shadowBuildDirEdit->setInitialBrowsePathBackup(initialDirectory);
}
void Qt4BuildConfigWidget::shadowBuildCheckBoxClicked(bool checked)
{
m_ui->shadowBuildLineEdit->setEnabled(checked);
m_ui->shadowBuildButton->setEnabled(checked);
m_ui->shadowBuildDirEdit->setEnabled(checked);
bool b = m_ui->shadowBuildCheckBox->isChecked();
m_pro->setValue(m_buildConfiguration, "useShadowBuild", b);
if (b)
m_pro->setValue(m_buildConfiguration, "buildDirectory", m_ui->shadowBuildLineEdit->text());
m_pro->setValue(m_buildConfiguration, "buildDirectory", m_ui->shadowBuildDirEdit->path());
else
m_pro->setValue(m_buildConfiguration, "buildDirectory", QVariant(QString::null));
}
void Qt4BuildConfigWidget::shadowBuildLineEditTextChanged()
{
m_pro->setValue(m_buildConfiguration, "buildDirectory", m_ui->shadowBuildLineEdit->text());
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
m_ui->importLabel->setVisible(false);
if (m_ui->shadowBuildCheckBox->isChecked()) {
QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildLineEdit->text());
QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
if (!qtPath.isEmpty()) {
m_ui->importLabel->setVisible(true);
}
}
// QFileInfo fi(m_ui->shadowBuildLineEdit->text());
// QFileInfo fi(m_ui->shadowBuildDirEdit->path());
// if (fi.exists()) {
// m_ui->shadowBuildLineEdit->setStyleSheet("");
// m_ui->shadowBuildLineEdit->setToolTip("");
......@@ -198,7 +191,7 @@ void Qt4BuildConfigWidget::shadowBuildLineEditTextChanged()
void Qt4BuildConfigWidget::importLabelClicked()
{
if (m_ui->shadowBuildCheckBox->isChecked()) {
QString directory = m_ui->shadowBuildLineEdit->text();
QString directory = m_ui->shadowBuildDirEdit->path();
if (!directory.isEmpty()) {
QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
QString qtPath = vm->findQtVersionFromMakefile(directory);
......
......@@ -61,6 +61,7 @@ private slots:
void setupQtVersionsComboBox();
void shadowBuildCheckBoxClicked(bool checked);
void shadowBuildButtonClicked();
void onBeforeBeforeShadowBuildDirBrowsed();
void shadowBuildLineEditTextChanged();
void importLabelClicked();
void qtVersionComboBoxCurrentIndexChanged(const QString &);
......
......@@ -110,39 +110,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="shadowBuildLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="shadowBuildButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QLabel" name="importLabel">
<property name="text">
......@@ -153,6 +120,16 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Core::Utils::PathChooser" name="shadowBuildDirEdit" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
......@@ -186,6 +163,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment