GUI: Allow user to choose any available library file
This commit is contained in:
parent
582baa5648
commit
bf8bb29938
|
@ -59,7 +59,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="librariesLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -67,34 +67,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="mChkboxGtk">
|
|
||||||
<property name="text">
|
|
||||||
<string>gtk</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="mChkboxPosix">
|
|
||||||
<property name="text">
|
|
||||||
<string>posix</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="mChkboxQt">
|
|
||||||
<property name="text">
|
|
||||||
<string>qt</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="mChkboxWindows">
|
|
||||||
<property name="text">
|
|
||||||
<string>windows</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -33,12 +33,33 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
|
|
||||||
QFileInfo inf(path);
|
const QFileInfo inf(path);
|
||||||
QString filename = inf.fileName();
|
QString filename = inf.fileName();
|
||||||
QString title = tr("Project file: %1").arg(filename);
|
QString title = tr("Project file: %1").arg(filename);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
|
||||||
|
// Checkboxes for the libraries..
|
||||||
|
const QString applicationFilePath = QCoreApplication::applicationFilePath();
|
||||||
|
const QString appPath = QFileInfo(applicationFilePath).canonicalPath();
|
||||||
|
const QString searchPaths[] = { appPath, appPath + "/cfg", inf.canonicalPath() };
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
QDir dir(searchPaths[i]);
|
||||||
|
dir.setSorting(QDir::Name);
|
||||||
|
dir.setNameFilters(QStringList("*.cfg"));
|
||||||
|
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
foreach(QFileInfo item, dir.entryInfoList()) {
|
||||||
|
QString library = item.fileName();
|
||||||
|
library.chop(4);
|
||||||
|
if (library.compare("std", Qt::CaseInsensitive) == 0)
|
||||||
|
continue;
|
||||||
|
QCheckBox *checkbox = new QCheckBox(this);
|
||||||
|
checkbox->setText(library);
|
||||||
|
mUI.librariesLayout->addWidget(checkbox);
|
||||||
|
mLibraryCheckboxes << checkbox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));
|
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));
|
||||||
connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath()));
|
connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath()));
|
||||||
|
@ -163,10 +184,9 @@ QStringList ProjectFileDialog::GetExcludedPaths() const
|
||||||
QStringList ProjectFileDialog::GetLibraries() const
|
QStringList ProjectFileDialog::GetLibraries() const
|
||||||
{
|
{
|
||||||
QStringList libraries;
|
QStringList libraries;
|
||||||
const QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows };
|
for (int i = 0; i < mLibraryCheckboxes.size(); i++) {
|
||||||
for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++) {
|
if (mLibraryCheckboxes[i]->isChecked())
|
||||||
if (c[i]->isChecked())
|
libraries << mLibraryCheckboxes[i]->text();
|
||||||
libraries << c[i]->text();
|
|
||||||
}
|
}
|
||||||
return libraries;
|
return libraries;
|
||||||
}
|
}
|
||||||
|
@ -214,9 +234,10 @@ void ProjectFileDialog::SetExcludedPaths(const QStringList &paths)
|
||||||
|
|
||||||
void ProjectFileDialog::SetLibraries(const QStringList &libraries)
|
void ProjectFileDialog::SetLibraries(const QStringList &libraries)
|
||||||
{
|
{
|
||||||
QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows };
|
for (int i = 0; i < mLibraryCheckboxes.size(); i++) {
|
||||||
for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++)
|
QCheckBox *checkbox = mLibraryCheckboxes[i];
|
||||||
c[i]->setChecked(libraries.contains(c[i]->text()));
|
checkbox->setChecked(libraries.contains(checkbox->text()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::AddIncludeDir()
|
void ProjectFileDialog::AddIncludeDir()
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "ui_projectfile.h"
|
#include "ui_projectfile.h"
|
||||||
|
|
||||||
|
@ -206,6 +207,9 @@ private:
|
||||||
* @brief Projectfile path.
|
* @brief Projectfile path.
|
||||||
*/
|
*/
|
||||||
QString mFilePath;
|
QString mFilePath;
|
||||||
|
|
||||||
|
/** @brief Library checkboxes */
|
||||||
|
QList<QCheckBox*> mLibraryCheckboxes;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
Loading…
Reference in New Issue