Commit d64a4ffa authored by Daniel Teske's avatar Daniel Teske

Move filterForQmakeFileDialog to a place where it can be reused

Change-Id: Ie53e611b0f042b025bddb5432d8690e5bcced390
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 40d112d5
......@@ -141,6 +141,27 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
return QString();
}
QString BuildableHelperLibrary::filterForQmakeFileDialog()
{
QString filter = QLatin1String("qmake (");
const QStringList commands = possibleQMakeCommands();
for (int i = 0; i < commands.size(); ++i) {
if (i)
filter += QLatin1Char(' ');
if (HostOsInfo::isMacHost())
// work around QTBUG-7739 that prohibits filters that don't start with *
filter += QLatin1Char('*');
filter += commands.at(i);
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
// kde bug, we need at least one wildcard character
// see QTCREATORBUG-7771
filter += QLatin1Char('*');
}
filter += QLatin1Char(')');
return filter;
}
QStringList BuildableHelperLibrary::possibleQMakeCommands()
{
// On Windows it is always "qmake.exe"
......
......@@ -50,6 +50,7 @@ public:
static QString qtVersionForQMake(const QString &qmakePath);
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
static QStringList possibleQMakeCommands();
static QString filterForQmakeFileDialog();
static QString byInstallDataHelper(const QString &sourcePath,
const QStringList &sourceFileNames,
......
......@@ -581,33 +581,13 @@ QtOptionsPageWidget::~QtOptionsPageWidget()
qDeleteAll(m_versions);
}
static QString filterForQmakeFileDialog()
{
QString filter = QLatin1String("qmake (");
const QStringList commands = BuildableHelperLibrary::possibleQMakeCommands();
for (int i = 0; i < commands.size(); ++i) {
if (i)
filter += QLatin1Char(' ');
if (HostOsInfo::isMacHost())
// work around QTBUG-7739 that prohibits filters that don't start with *
filter += QLatin1Char('*');
filter += commands.at(i);
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
// kde bug, we need at least one wildcard character
// see QTCREATORBUG-7771
filter += QLatin1Char('*');
}
filter += QLatin1Char(')');
return filter;
}
void QtOptionsPageWidget::addQtDir()
{
FileName qtVersion = FileName::fromString(
QFileDialog::getOpenFileName(this,
tr("Select a qmake Executable"),
QString(),
filterForQmakeFileDialog(),
BuildableHelperLibrary::filterForQmakeFileDialog(),
0,
QFileDialog::DontResolveSymlinks));
if (qtVersion.isNull())
......@@ -673,7 +653,7 @@ void QtOptionsPageWidget::editPath()
QFileDialog::getOpenFileName(this,
tr("Select a qmake Executable"),
dir,
filterForQmakeFileDialog(),
BuildableHelperLibrary::filterForQmakeFileDialog(),
0,
QFileDialog::DontResolveSymlinks));
if (qtVersion.isNull())
......
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