Commit 50c3e774 authored by Kai Koehne's avatar Kai Koehne

WelcomeScreen: Show content even for incorrectly capitalized application dir

Work around QTBUG-17529 by normalizing paths first.

Task-number: QTCREATORBUG-6126
Task-number: QTBUG-28230
Change-Id: Ib7a52c81cf546d022b9db8402e225c8d3c10c0ca
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 2b0c1fb3
......@@ -42,6 +42,10 @@
#include <projectexplorer/projectexplorer.h>
#include <sessiondialog.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
namespace ProjectExplorer {
namespace Internal {
......@@ -215,6 +219,16 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
ctx->setContextProperty(QLatin1String("projectWelcomePage"), this);
}
QUrl ProjectWelcomePage::pageLocation() const
{
QString resourcePath = Core::ICore::resourcePath();
#ifdef Q_OS_WIN
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
resourcePath = Utils::normalizePathName(resourcePath);
#endif
return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/develop.qml"));
}
ProjectWelcomePage::Id ProjectWelcomePage::id() const
{
return Develop;
......
......@@ -94,7 +94,7 @@ public:
ProjectWelcomePage();
void facilitateQml(QDeclarativeEngine *engine);
QUrl pageLocation() const { return QUrl::fromLocalFile(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/develop.qml")); }
QUrl pageLocation() const;
QWidget *page() { return 0; }
QString title() const { return tr("Develop"); }
int priority() const { return 20; }
......
......@@ -37,6 +37,10 @@
#include <utils/pathchooser.h>
#include <utils/fileutils.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreplugin.h>
#include <coreplugin/documentmanager.h>
......@@ -203,7 +207,13 @@ GettingStartedWelcomePage::GettingStartedWelcomePage() : m_engine(0)
QUrl GettingStartedWelcomePage::pageLocation() const
{
return QUrl::fromLocalFile(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/gettingstarted.qml"));
QString resourcePath = Core::ICore::resourcePath();
#ifdef Q_OS_WIN
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
resourcePath = Utils::normalizePathName(resourcePath);
#endif
return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/gettingstarted.qml"));
}
QString GettingStartedWelcomePage::title() const
......@@ -262,10 +272,15 @@ QString ExamplesWelcomePage::title() const
QUrl ExamplesWelcomePage::pageLocation() const
{
QString resourcePath = Core::ICore::resourcePath();
#ifdef Q_OS_WIN
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
resourcePath = Utils::normalizePathName(resourcePath);
#endif
if (m_showExamples)
return QUrl::fromLocalFile(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/examples.qml"));
return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/examples.qml"));
else
return QUrl::fromLocalFile(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/tutorials.qml"));
return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/tutorials.qml"));
}
void ExamplesWelcomePage::facilitateQml(QDeclarativeEngine *engine)
......
......@@ -44,6 +44,10 @@
#include <utils/iwelcomepage.h>
#include <utils/networkaccessmanager.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <QScrollArea>
#include <QDesktopServices>
#include <QPainter>
......@@ -193,6 +197,26 @@ void WelcomeMode::facilitateQml(QDeclarativeEngine * /*engine*/)
{
}
static QString applicationDirPath()
{
#ifdef Q_OS_WIN
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
return Utils::normalizePathName(QCoreApplication::applicationDirPath());
#else
return QCoreApplication::applicationDirPath();
#endif
}
static QString resourcePath()
{
#ifdef Q_OS_WIN
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
return Utils::normalizePathName(Core::ICore::resourcePath());
#else
return Core::ICore::resourcePath();
#endif
}
void WelcomeMode::initPlugins()
{
QSettings *settings = Core::ICore::settings();
......@@ -232,12 +256,12 @@ void WelcomeMode::initPlugins()
QDeclarativeEngine *engine = m_welcomePage->engine();
QStringList importPathList = engine->importPathList();
importPathList << Core::ICore::resourcePath() + QLatin1String("/welcomescreen");
importPathList << resourcePath() + QLatin1String("/welcomescreen");
engine->setImportPathList(importPathList);
if (!debug)
engine->setOutputWarningsToStandardError(false);
engine->setNetworkAccessManagerFactory(m_networkAccessManagerFactory);
QString pluginPath = QCoreApplication::applicationDirPath();
QString pluginPath = applicationDirPath();
#ifdef Q_OS_MAC
pluginPath += QLatin1String("/../PlugIns");
#else
......@@ -252,9 +276,11 @@ void WelcomeMode::initPlugins()
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
// finally, load the root page
m_welcomePage->setSource(
QUrl::fromLocalFile(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml")));
QUrl::fromLocalFile(path));
}
QString WelcomeMode::platform() const
......
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