forked from qt-creator/qt-creator
Support pkg-config in AddLibraryWizard
Reviewed-by: dt <qtc-committer@nokia.com> Task-number: QTCREATORBUG-2378
This commit is contained in:
@@ -112,18 +112,17 @@ LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
|
|||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
m_systemRadio = new QRadioButton(tr("System library"), this);
|
m_internalRadio = new QRadioButton(tr("Internal library"), this);
|
||||||
m_systemRadio->setChecked(true);
|
layout->addWidget(m_internalRadio);
|
||||||
layout->addWidget(m_systemRadio);
|
|
||||||
|
|
||||||
QLabel *systemLabel = new QLabel(tr("Links to a system library."
|
QLabel *internalLabel = new QLabel(tr("Links to a library "
|
||||||
"\nNeither the path to the "
|
"that is located in your build "
|
||||||
"library nor the path to its "
|
"tree.\nAdds the library and "
|
||||||
"includes is added to the .pro file."));
|
"include paths to the .pro file."));
|
||||||
|
|
||||||
systemLabel->setWordWrap(true);
|
internalLabel->setWordWrap(true);
|
||||||
systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
layout->addWidget(systemLabel);
|
layout->addWidget(internalLabel);
|
||||||
|
|
||||||
m_externalRadio = new QRadioButton(tr("External library"), this);
|
m_externalRadio = new QRadioButton(tr("External library"), this);
|
||||||
layout->addWidget(m_externalRadio);
|
layout->addWidget(m_externalRadio);
|
||||||
@@ -137,26 +136,45 @@ LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
|
|||||||
externalLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
externalLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
layout->addWidget(externalLabel);
|
layout->addWidget(externalLabel);
|
||||||
|
|
||||||
m_internalRadio = new QRadioButton(tr("Internal library"), this);
|
m_systemRadio = new QRadioButton(tr("System library"), this);
|
||||||
layout->addWidget(m_internalRadio);
|
layout->addWidget(m_systemRadio);
|
||||||
|
|
||||||
QLabel *internalLabel = new QLabel(tr("Links to a library "
|
QLabel *systemLabel = new QLabel(tr("Links to a system library."
|
||||||
"that is located in your build "
|
"\nNeither the path to the "
|
||||||
"tree.\nAdds the library and "
|
"library nor the path to its "
|
||||||
"include paths to the .pro file."));
|
"includes is added to the .pro file."));
|
||||||
|
|
||||||
internalLabel->setWordWrap(true);
|
systemLabel->setWordWrap(true);
|
||||||
internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
layout->addWidget(internalLabel);
|
layout->addWidget(systemLabel);
|
||||||
|
|
||||||
|
m_packageRadio = new QRadioButton(tr("System package"), this);
|
||||||
|
layout->addWidget(m_packageRadio);
|
||||||
|
|
||||||
|
QLabel *packageLabel = new QLabel(tr("Links to a system library using pkg-config."));
|
||||||
|
|
||||||
|
packageLabel->setWordWrap(true);
|
||||||
|
packageLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
|
layout->addWidget(packageLabel);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
m_packageRadio->setVisible(false);
|
||||||
|
packageLabel->setVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// select the default
|
||||||
|
m_internalRadio->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLibraryWizard::LibraryKind LibraryTypePage::libraryKind() const
|
AddLibraryWizard::LibraryKind LibraryTypePage::libraryKind() const
|
||||||
{
|
{
|
||||||
if (m_internalRadio->isChecked())
|
if (m_internalRadio->isChecked())
|
||||||
return AddLibraryWizard::InternalLibrary;
|
return AddLibraryWizard::InternalLibrary;
|
||||||
|
if (m_externalRadio->isChecked())
|
||||||
|
return AddLibraryWizard::ExternalLibrary;
|
||||||
if (m_systemRadio->isChecked())
|
if (m_systemRadio->isChecked())
|
||||||
return AddLibraryWizard::SystemLibrary;
|
return AddLibraryWizard::SystemLibrary;
|
||||||
return AddLibraryWizard::ExternalLibrary;
|
return AddLibraryWizard::PackageLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LibraryTypePage::nextId() const
|
int LibraryTypePage::nextId() const
|
||||||
@@ -201,10 +219,10 @@ void DetailsPage::initializePage()
|
|||||||
QString title;
|
QString title;
|
||||||
QString subTitle;
|
QString subTitle;
|
||||||
switch (m_libraryWizard->libraryKind()) {
|
switch (m_libraryWizard->libraryKind()) {
|
||||||
case AddLibraryWizard::SystemLibrary:
|
case AddLibraryWizard::InternalLibrary:
|
||||||
title = tr("System Library");
|
title = tr("Internal Library");
|
||||||
subTitle = tr("Specify the library to link to");
|
subTitle = tr("Choose the project file of the library to link to");
|
||||||
m_libraryDetailsController = new SystemLibraryDetailsController(
|
m_libraryDetailsController = new InternalLibraryDetailsController(
|
||||||
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
||||||
break;
|
break;
|
||||||
case AddLibraryWizard::ExternalLibrary:
|
case AddLibraryWizard::ExternalLibrary:
|
||||||
@@ -213,10 +231,16 @@ void DetailsPage::initializePage()
|
|||||||
m_libraryDetailsController = new ExternalLibraryDetailsController(
|
m_libraryDetailsController = new ExternalLibraryDetailsController(
|
||||||
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
||||||
break;
|
break;
|
||||||
case AddLibraryWizard::InternalLibrary:
|
case AddLibraryWizard::SystemLibrary:
|
||||||
title = tr("Internal Library");
|
title = tr("System Library");
|
||||||
subTitle = tr("Choose the project file of the library to link to");
|
subTitle = tr("Specify the library to link to");
|
||||||
m_libraryDetailsController = new InternalLibraryDetailsController(
|
m_libraryDetailsController = new SystemLibraryDetailsController(
|
||||||
|
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
||||||
|
break;
|
||||||
|
case AddLibraryWizard::PackageLibrary:
|
||||||
|
title = tr("System Package");
|
||||||
|
subTitle = tr("Specify the package to link to");
|
||||||
|
m_libraryDetailsController = new PackageLibraryDetailsController(
|
||||||
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -261,6 +285,7 @@ void SummaryPage::initializePage()
|
|||||||
str << "<code>";
|
str << "<code>";
|
||||||
QString text = m_snippet;
|
QString text = m_snippet;
|
||||||
text.replace(QLatin1Char('\n'), QLatin1String("<br>"));
|
text.replace(QLatin1Char('\n'), QLatin1String("<br>"));
|
||||||
|
text.replace(QLatin1Char(' '), QLatin1String(" "));
|
||||||
str << text;
|
str << text;
|
||||||
str << "</code>";
|
str << "</code>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum LibraryKind {
|
enum LibraryKind {
|
||||||
SystemLibrary,
|
InternalLibrary,
|
||||||
ExternalLibrary,
|
ExternalLibrary,
|
||||||
InternalLibrary
|
SystemLibrary,
|
||||||
|
PackageLibrary
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LinkageType {
|
enum LinkageType {
|
||||||
@@ -87,9 +88,10 @@ public:
|
|||||||
virtual int nextId() const;
|
virtual int nextId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRadioButton *m_systemRadio;
|
|
||||||
QRadioButton *m_externalRadio;
|
|
||||||
QRadioButton *m_internalRadio;
|
QRadioButton *m_internalRadio;
|
||||||
|
QRadioButton *m_externalRadio;
|
||||||
|
QRadioButton *m_systemRadio;
|
||||||
|
QRadioButton *m_packageRadio;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DetailsPage : public QWizardPage
|
class DetailsPage : public QWizardPage
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ LibraryDetailsController::LibraryDetailsController(
|
|||||||
m_creatorPlatform = CreatorLinux;
|
m_creatorPlatform = CreatorLinux;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
setPlatformsVisible(true);
|
||||||
|
setLinkageGroupVisible(true);
|
||||||
|
setMacLibraryGroupVisible(true);
|
||||||
|
setPackageLineEditVisible(false);
|
||||||
|
|
||||||
if (creatorPlatform() == CreatorMac)
|
if (creatorPlatform() == CreatorMac)
|
||||||
setMacLibraryRadiosVisible(false);
|
setMacLibraryRadiosVisible(false);
|
||||||
|
|
||||||
@@ -230,6 +235,11 @@ void LibraryDetailsController::showMacLibraryType(
|
|||||||
libraryDetailsWidget()->macGroupBox->setTitle(libraryTypeTitle);
|
libraryDetailsWidget()->macGroupBox->setTitle(libraryTypeTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryDetailsController::setPlatformsVisible(bool ena)
|
||||||
|
{
|
||||||
|
libraryDetailsWidget()->platformGroupBox->setVisible(ena);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryDetailsController::setLinkageRadiosVisible(bool ena)
|
void LibraryDetailsController::setLinkageRadiosVisible(bool ena)
|
||||||
{
|
{
|
||||||
m_linkageRadiosVisible = ena;
|
m_linkageRadiosVisible = ena;
|
||||||
@@ -237,6 +247,12 @@ void LibraryDetailsController::setLinkageRadiosVisible(bool ena)
|
|||||||
libraryDetailsWidget()->dynamicRadio->setVisible(ena);
|
libraryDetailsWidget()->dynamicRadio->setVisible(ena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryDetailsController::setLinkageGroupVisible(bool ena)
|
||||||
|
{
|
||||||
|
setLinkageRadiosVisible(ena);
|
||||||
|
libraryDetailsWidget()->linkageGroupBox->setVisible(ena);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryDetailsController::setMacLibraryRadiosVisible(bool ena)
|
void LibraryDetailsController::setMacLibraryRadiosVisible(bool ena)
|
||||||
{
|
{
|
||||||
m_macLibraryRadiosVisible = ena;
|
m_macLibraryRadiosVisible = ena;
|
||||||
@@ -244,6 +260,12 @@ void LibraryDetailsController::setMacLibraryRadiosVisible(bool ena)
|
|||||||
libraryDetailsWidget()->libraryRadio->setVisible(ena);
|
libraryDetailsWidget()->libraryRadio->setVisible(ena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryDetailsController::setMacLibraryGroupVisible(bool ena)
|
||||||
|
{
|
||||||
|
setMacLibraryRadiosVisible(ena);
|
||||||
|
libraryDetailsWidget()->macGroupBox->setVisible(ena);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryDetailsController::setLibraryPathChooserVisible(bool ena)
|
void LibraryDetailsController::setLibraryPathChooserVisible(bool ena)
|
||||||
{
|
{
|
||||||
libraryDetailsWidget()->libraryPathChooser->setVisible(ena);
|
libraryDetailsWidget()->libraryPathChooser->setVisible(ena);
|
||||||
@@ -256,6 +278,12 @@ void LibraryDetailsController::setLibraryComboBoxVisible(bool ena)
|
|||||||
libraryDetailsWidget()->libraryLabel->setVisible(ena);
|
libraryDetailsWidget()->libraryLabel->setVisible(ena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryDetailsController::setPackageLineEditVisible(bool ena)
|
||||||
|
{
|
||||||
|
libraryDetailsWidget()->packageLineEdit->setVisible(ena);
|
||||||
|
libraryDetailsWidget()->packageLabel->setVisible(ena);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryDetailsController::setIncludePathVisible(bool ena)
|
void LibraryDetailsController::setIncludePathVisible(bool ena)
|
||||||
{
|
{
|
||||||
m_includePathVisible = ena;
|
m_includePathVisible = ena;
|
||||||
@@ -737,6 +765,64 @@ QString NonInternalLibraryDetailsController::snippet() const
|
|||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
|
PackageLibraryDetailsController::PackageLibraryDetailsController(
|
||||||
|
Ui::LibraryDetailsWidget *libraryDetails,
|
||||||
|
const QString &proFile, QObject *parent)
|
||||||
|
: NonInternalLibraryDetailsController(libraryDetails, proFile, parent)
|
||||||
|
{
|
||||||
|
setPlatformsVisible(false);
|
||||||
|
setIncludePathVisible(false);
|
||||||
|
setWindowsGroupVisible(false);
|
||||||
|
setLinkageGroupVisible(false);
|
||||||
|
setMacLibraryGroupVisible(false);
|
||||||
|
setLibraryPathChooserVisible(false);
|
||||||
|
setPackageLineEditVisible(true);
|
||||||
|
|
||||||
|
connect(libraryDetailsWidget()->packageLineEdit, SIGNAL(textChanged(QString)),
|
||||||
|
this, SIGNAL(completeChanged()));
|
||||||
|
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PackageLibraryDetailsController::isComplete() const
|
||||||
|
{
|
||||||
|
return !libraryDetailsWidget()->packageLineEdit->text().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PackageLibraryDetailsController::snippet() const
|
||||||
|
{
|
||||||
|
QString snippetMessage;
|
||||||
|
QTextStream str(&snippetMessage);
|
||||||
|
str << "\n";
|
||||||
|
if (!isLinkPackageGenerated())
|
||||||
|
str << "unix: CONFIG += link_pkgconfig\n";
|
||||||
|
str << "unix: PKGCONFIG += " << libraryDetailsWidget()->packageLineEdit->text() << "\n";
|
||||||
|
return snippetMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PackageLibraryDetailsController::isLinkPackageGenerated() const
|
||||||
|
{
|
||||||
|
const ProjectExplorer::Project *project =
|
||||||
|
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(proFile());
|
||||||
|
if (!project)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const Qt4ProFileNode *rootProject = qobject_cast<const Qt4ProFileNode *>(project->rootProjectNode());
|
||||||
|
if (!rootProject)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const Qt4ProFileNode *currentProject = rootProject->findProFileFor(proFile());
|
||||||
|
if (!currentProject)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QStringList configVar = currentProject->variableValue(ConfigVar);
|
||||||
|
if (configVar.contains(QLatin1String("link_pkgconfig")))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
|
||||||
SystemLibraryDetailsController::SystemLibraryDetailsController(
|
SystemLibraryDetailsController::SystemLibraryDetailsController(
|
||||||
Ui::LibraryDetailsWidget *libraryDetails,
|
Ui::LibraryDetailsWidget *libraryDetails,
|
||||||
const QString &proFile, QObject *parent)
|
const QString &proFile, QObject *parent)
|
||||||
|
|||||||
@@ -51,10 +51,14 @@ protected:
|
|||||||
|
|
||||||
void setIgnoreGuiSignals(bool ignore);
|
void setIgnoreGuiSignals(bool ignore);
|
||||||
|
|
||||||
|
void setPlatformsVisible(bool ena);
|
||||||
void setLinkageRadiosVisible(bool ena);
|
void setLinkageRadiosVisible(bool ena);
|
||||||
|
void setLinkageGroupVisible(bool ena);
|
||||||
void setMacLibraryRadiosVisible(bool ena);
|
void setMacLibraryRadiosVisible(bool ena);
|
||||||
|
void setMacLibraryGroupVisible(bool ena);
|
||||||
void setLibraryPathChooserVisible(bool ena);
|
void setLibraryPathChooserVisible(bool ena);
|
||||||
void setLibraryComboBoxVisible(bool ena);
|
void setLibraryComboBoxVisible(bool ena);
|
||||||
|
void setPackageLineEditVisible(bool ena);
|
||||||
void setIncludePathVisible(bool ena);
|
void setIncludePathVisible(bool ena);
|
||||||
void setWindowsGroupVisible(bool ena);
|
void setWindowsGroupVisible(bool ena);
|
||||||
void setRemoveSuffixVisible(bool ena);
|
void setRemoveSuffixVisible(bool ena);
|
||||||
@@ -113,6 +117,19 @@ private slots:
|
|||||||
void slotLibraryPathChanged();
|
void slotLibraryPathChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PackageLibraryDetailsController : public NonInternalLibraryDetailsController
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit PackageLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
|
||||||
|
const QString &proFile,
|
||||||
|
QObject *parent = 0);
|
||||||
|
virtual bool isComplete() const;
|
||||||
|
virtual QString snippet() const;
|
||||||
|
private:
|
||||||
|
bool isLinkPackageGenerated() const;
|
||||||
|
};
|
||||||
|
|
||||||
class SystemLibraryDetailsController : public NonInternalLibraryDetailsController
|
class SystemLibraryDetailsController : public NonInternalLibraryDetailsController
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>368</width>
|
<width>455</width>
|
||||||
<height>306</height>
|
<height>370</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
@@ -33,16 +33,26 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="Qt4ProjectManager::Internal::LibraryPathChooser" name="libraryPathChooser" native="true"/>
|
<widget class="Qt4ProjectManager::Internal::LibraryPathChooser" name="libraryPathChooser" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="includeLabel">
|
<widget class="QLabel" name="includeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Include path:</string>
|
<string>Include path:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="Utils::PathChooser" name="includePathChooser" native="true"/>
|
<widget class="Utils::PathChooser" name="includePathChooser" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="packageLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Package:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="packageLineEdit"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|||||||
Reference in New Issue
Block a user