GUI: Allow user to choose any available library file

This commit is contained in:
Daniel Marjamäki 2013-12-30 00:05:03 +01:00
parent 582baa5648
commit bf8bb29938
3 changed files with 34 additions and 37 deletions

View File

@ -59,7 +59,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QHBoxLayout" name="librariesLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
@ -67,34 +67,6 @@
</property>
</widget>
</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>
</item>
<item>

View File

@ -33,12 +33,33 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
{
mUI.setupUi(this);
QFileInfo inf(path);
const QFileInfo inf(path);
QString filename = inf.fileName();
QString title = tr("Project file: %1").arg(filename);
setWindowTitle(title);
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.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));
connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath()));
@ -163,10 +184,9 @@ QStringList ProjectFileDialog::GetExcludedPaths() const
QStringList ProjectFileDialog::GetLibraries() const
{
QStringList libraries;
const QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows };
for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++) {
if (c[i]->isChecked())
libraries << c[i]->text();
for (int i = 0; i < mLibraryCheckboxes.size(); i++) {
if (mLibraryCheckboxes[i]->isChecked())
libraries << mLibraryCheckboxes[i]->text();
}
return libraries;
}
@ -214,9 +234,10 @@ void ProjectFileDialog::SetExcludedPaths(const QStringList &paths)
void ProjectFileDialog::SetLibraries(const QStringList &libraries)
{
QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows };
for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++)
c[i]->setChecked(libraries.contains(c[i]->text()));
for (int i = 0; i < mLibraryCheckboxes.size(); i++) {
QCheckBox *checkbox = mLibraryCheckboxes[i];
checkbox->setChecked(libraries.contains(checkbox->text()));
}
}
void ProjectFileDialog::AddIncludeDir()

View File

@ -22,6 +22,7 @@
#include <QDialog>
#include <QString>
#include <QStringList>
#include <QCheckBox>
#include "ui_projectfile.h"
@ -206,6 +207,9 @@ private:
* @brief Projectfile path.
*/
QString mFilePath;
/** @brief Library checkboxes */
QList<QCheckBox*> mLibraryCheckboxes;
};
/// @}