Skip to content
Snippets Groups Projects
Commit 3a73f7df authored by Jarek Kobus's avatar Jarek Kobus
Browse files

Support pkg-config in AddLibraryWizard


Reviewed-by: default avatardt <qtc-committer@nokia.com>
Task-number: QTCREATORBUG-2378
parent 0caf52f6
No related branches found
No related tags found
No related merge requests found
......@@ -112,18 +112,17 @@ LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
QVBoxLayout *layout = new QVBoxLayout(this);
m_systemRadio = new QRadioButton(tr("System library"), this);
m_systemRadio->setChecked(true);
layout->addWidget(m_systemRadio);
m_internalRadio = new QRadioButton(tr("Internal library"), this);
layout->addWidget(m_internalRadio);
QLabel *systemLabel = new QLabel(tr("Links to a system library."
"\nNeither the path to the "
"library nor the path to its "
"includes is added to the .pro file."));
QLabel *internalLabel = new QLabel(tr("Links to a library "
"that is located in your build "
"tree.\nAdds the library and "
"include paths to the .pro file."));
systemLabel->setWordWrap(true);
systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
layout->addWidget(systemLabel);
internalLabel->setWordWrap(true);
internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
layout->addWidget(internalLabel);
m_externalRadio = new QRadioButton(tr("External library"), this);
layout->addWidget(m_externalRadio);
......@@ -137,26 +136,45 @@ LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
externalLabel->setAttribute(Qt::WA_MacSmallSize, true);
layout->addWidget(externalLabel);
m_internalRadio = new QRadioButton(tr("Internal library"), this);
layout->addWidget(m_internalRadio);
m_systemRadio = new QRadioButton(tr("System library"), this);
layout->addWidget(m_systemRadio);
QLabel *internalLabel = new QLabel(tr("Links to a library "
"that is located in your build "
"tree.\nAdds the library and "
"include paths to the .pro file."));
QLabel *systemLabel = new QLabel(tr("Links to a system library."
"\nNeither the path to the "
"library nor the path to its "
"includes is added to the .pro file."));
internalLabel->setWordWrap(true);
internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
layout->addWidget(internalLabel);
systemLabel->setWordWrap(true);
systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
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
{
if (m_internalRadio->isChecked())
return AddLibraryWizard::InternalLibrary;
if (m_externalRadio->isChecked())
return AddLibraryWizard::ExternalLibrary;
if (m_systemRadio->isChecked())
return AddLibraryWizard::SystemLibrary;
return AddLibraryWizard::ExternalLibrary;
return AddLibraryWizard::PackageLibrary;
}
int LibraryTypePage::nextId() const
......@@ -201,10 +219,10 @@ void DetailsPage::initializePage()
QString title;
QString subTitle;
switch (m_libraryWizard->libraryKind()) {
case AddLibraryWizard::SystemLibrary:
title = tr("System Library");
subTitle = tr("Specify the library to link to");
m_libraryDetailsController = new SystemLibraryDetailsController(
case AddLibraryWizard::InternalLibrary:
title = tr("Internal Library");
subTitle = tr("Choose the project file of the library to link to");
m_libraryDetailsController = new InternalLibraryDetailsController(
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
break;
case AddLibraryWizard::ExternalLibrary:
......@@ -213,10 +231,16 @@ void DetailsPage::initializePage()
m_libraryDetailsController = new ExternalLibraryDetailsController(
m_libraryDetailsWidget, m_libraryWizard->proFile(), this);
break;
case AddLibraryWizard::InternalLibrary:
title = tr("Internal Library");
subTitle = tr("Choose the project file of the library to link to");
m_libraryDetailsController = new InternalLibraryDetailsController(
case AddLibraryWizard::SystemLibrary:
title = tr("System Library");
subTitle = tr("Specify the library to link to");
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);
break;
default:
......@@ -261,6 +285,7 @@ void SummaryPage::initializePage()
str << "<code>";
QString text = m_snippet;
text.replace(QLatin1Char('\n'), QLatin1String("<br>"));
text.replace(QLatin1Char(' '), QLatin1String("&nbsp;"));
str << text;
str << "</code>";
}
......
......@@ -34,9 +34,10 @@ public:
};
enum LibraryKind {
SystemLibrary,
InternalLibrary,
ExternalLibrary,
InternalLibrary
SystemLibrary,
PackageLibrary
};
enum LinkageType {
......@@ -87,9 +88,10 @@ public:
virtual int nextId() const;
private:
QRadioButton *m_systemRadio;
QRadioButton *m_externalRadio;
QRadioButton *m_internalRadio;
QRadioButton *m_externalRadio;
QRadioButton *m_systemRadio;
QRadioButton *m_packageRadio;
};
class DetailsPage : public QWizardPage
......
......@@ -57,6 +57,11 @@ LibraryDetailsController::LibraryDetailsController(
m_creatorPlatform = CreatorLinux;
#endif
setPlatformsVisible(true);
setLinkageGroupVisible(true);
setMacLibraryGroupVisible(true);
setPackageLineEditVisible(false);
if (creatorPlatform() == CreatorMac)
setMacLibraryRadiosVisible(false);
......@@ -230,6 +235,11 @@ void LibraryDetailsController::showMacLibraryType(
libraryDetailsWidget()->macGroupBox->setTitle(libraryTypeTitle);
}
void LibraryDetailsController::setPlatformsVisible(bool ena)
{
libraryDetailsWidget()->platformGroupBox->setVisible(ena);
}
void LibraryDetailsController::setLinkageRadiosVisible(bool ena)
{
m_linkageRadiosVisible = ena;
......@@ -237,6 +247,12 @@ void LibraryDetailsController::setLinkageRadiosVisible(bool ena)
libraryDetailsWidget()->dynamicRadio->setVisible(ena);
}
void LibraryDetailsController::setLinkageGroupVisible(bool ena)
{
setLinkageRadiosVisible(ena);
libraryDetailsWidget()->linkageGroupBox->setVisible(ena);
}
void LibraryDetailsController::setMacLibraryRadiosVisible(bool ena)
{
m_macLibraryRadiosVisible = ena;
......@@ -244,6 +260,12 @@ void LibraryDetailsController::setMacLibraryRadiosVisible(bool ena)
libraryDetailsWidget()->libraryRadio->setVisible(ena);
}
void LibraryDetailsController::setMacLibraryGroupVisible(bool ena)
{
setMacLibraryRadiosVisible(ena);
libraryDetailsWidget()->macGroupBox->setVisible(ena);
}
void LibraryDetailsController::setLibraryPathChooserVisible(bool ena)
{
libraryDetailsWidget()->libraryPathChooser->setVisible(ena);
......@@ -256,6 +278,12 @@ void LibraryDetailsController::setLibraryComboBoxVisible(bool ena)
libraryDetailsWidget()->libraryLabel->setVisible(ena);
}
void LibraryDetailsController::setPackageLineEditVisible(bool ena)
{
libraryDetailsWidget()->packageLineEdit->setVisible(ena);
libraryDetailsWidget()->packageLabel->setVisible(ena);
}
void LibraryDetailsController::setIncludePathVisible(bool 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(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent)
......
......@@ -51,10 +51,14 @@ protected:
void setIgnoreGuiSignals(bool ignore);
void setPlatformsVisible(bool ena);
void setLinkageRadiosVisible(bool ena);
void setLinkageGroupVisible(bool ena);
void setMacLibraryRadiosVisible(bool ena);
void setMacLibraryGroupVisible(bool ena);
void setLibraryPathChooserVisible(bool ena);
void setLibraryComboBoxVisible(bool ena);
void setPackageLineEditVisible(bool ena);
void setIncludePathVisible(bool ena);
void setWindowsGroupVisible(bool ena);
void setRemoveSuffixVisible(bool ena);
......@@ -113,6 +117,19 @@ private slots:
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
{
Q_OBJECT
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>306</height>
<width>455</width>
<height>370</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
......@@ -33,16 +33,26 @@
<item row="1" column="1">
<widget class="Qt4ProjectManager::Internal::LibraryPathChooser" name="libraryPathChooser" native="true"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="includeLabel">
<property name="text">
<string>Include path:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="Utils::PathChooser" name="includePathChooser" native="true"/>
</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>
</item>
<item row="1" column="0">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment