Commit 17fd00b6 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Fix missing puppet error dialog



Task-number: QTCREATORBUG-11786
Change-Id: Idabd190f3bd8f02ebcc24e4f6be27ca8784d283f
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 03a1361f
......@@ -77,7 +77,8 @@ SOURCES += $$PWD/model/abstractview.cpp \
$$PWD/exceptions/rewritingexception.cpp \
$$PWD/model/viewmanager.cpp \
$$PWD/model/signalhandlerproperty.cpp \
$$PWD/model/internalsignalhandlerproperty.cpp
$$PWD/model/internalsignalhandlerproperty.cpp \
$$PWD/instances/puppetdialog.cpp
HEADERS += $$PWD/include/qmldesignercorelib_global.h \
$$PWD/include/abstractview.h \
......@@ -148,7 +149,12 @@ HEADERS += $$PWD/include/qmldesignercorelib_global.h \
$$PWD/include/rewritingexception.h \
$$PWD/include/viewmanager.h \
$$PWD/include/signalhandlerproperty.h \
$$PWD/model/internalsignalhandlerproperty.h
$$PWD/model/internalsignalhandlerproperty.h \
$$PWD/instances/puppetdialog.h
FORMS += \
$$PWD/instances/puppetdialog.ui
contains(CONFIG, plugin) {
# If core.pri has been included in the qmldesigner plugin
......
......@@ -69,6 +69,8 @@
#include "nodeinstanceview.h"
#include "puppetdialog.h"
#include "import.h"
#include "qmldesignerplugin.h"
......@@ -275,13 +277,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
}
} else {
QMessageBox::warning(Core::ICore::dialogParent(),
tr("Cannot Start QML Puppet Executable"),
missingQmlPuppetErrorMessage(pathToQt,
tr("The executable of the QML Puppet process (%1) cannot be started. "
"Please check your installation. "
"QML Puppet is a process which runs in the background to render the items."
).arg(applicationPath)));
PuppetDialog::warning(Core::ICore::dialogParent(),
tr("Cannot Start QML Puppet Executable"),
missingQmlPuppetErrorMessage(tr("The executable of the QML Puppet process (%1) cannot be started. "
"Please check your installation. "
"QML Puppet is a process which runs in the background to render the items."
).arg(applicationPath)),
copyAndPasterMessage(pathToQt));
QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
......@@ -289,20 +291,21 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_localServer->close();
} else {
QMessageBox::warning(Core::ICore::dialogParent(),
tr("Wrong QML Puppet Executable Version"),
missingQmlPuppetErrorMessage(pathToQt,
tr("The QML Puppet version is incompatible with the Qt Creator version.")));
PuppetDialog::warning(Core::ICore::dialogParent(),
tr("Wrong QML Puppet Executable Version"),
missingQmlPuppetErrorMessage(tr("The QML Puppet version is incompatible with the Qt Creator version.")),
copyAndPasterMessage(pathToQt)
);
QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
} else {
QMessageBox::warning(Core::ICore::dialogParent(),
tr("Cannot Find QML Puppet Executable"),
missingQmlPuppetErrorMessage(pathToQt,
tr("The executable of the QML Puppet process (<code>%1</code>) cannot be found. "
"Check your installation. "
PuppetDialog::warning(Core::ICore::dialogParent(),
tr("Cannot Find QML Puppet Executable"),
missingQmlPuppetErrorMessage(tr("The executable of the QML Puppet process (<code>%1</code>) cannot be found. "
"Check your installation. "
"QML Puppet is a process which runs in the background to render the items.").
arg(QDir::toNativeSeparators(applicationPath))) );
arg(QDir::toNativeSeparators(applicationPath))),
copyAndPasterMessage(pathToQt));
QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
......@@ -383,13 +386,14 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const
static QString generatePuppetCompilingHelp(const QString &puppetName, const QString &pathToQt)
{
QString buildDirectory = QDir::toNativeSeparators(QDir::tempPath() + QStringLiteral("/") + puppetName);
QString qmakePath = QDir::toNativeSeparators(pathToQt + QStringLiteral("/bin/qmake -r "));
QString projectPath = QDir::toNativeSeparators(sharedDirPath() + QStringLiteral("/qml/qmlpuppet/%1/%1.pro\n"));
QString buildDirectory = QDir::toNativeSeparators(QDir::cleanPath(QDir::tempPath() + QStringLiteral("/") + puppetName));
QString qmakePath = QDir::toNativeSeparators(QDir::cleanPath(pathToQt + QStringLiteral("/bin/qmake -r ")));
QString projectPath = QDir::toNativeSeparators(QDir::cleanPath(sharedDirPath() + QStringLiteral("/qml/qmlpuppet/%1/%1.pro\n")));
QString puppetCompileHelp;
puppetCompileHelp.append(QStringLiteral("<p><code><pre>"));
puppetCompileHelp.append(QStringLiteral("<form><input></input></form>"));
puppetCompileHelp.append(QStringLiteral("mkdir ") + buildDirectory+ QStringLiteral("\n"));
puppetCompileHelp.append(QStringLiteral("cd ") + buildDirectory + QStringLiteral("\n"));
puppetCompileHelp.append(qmakePath + projectPath);
......@@ -403,35 +407,50 @@ static QString generatePuppetCompilingHelp(const QString &puppetName, const QStr
static void formatQmlPuppetCompilationMessage(const QString &puppetName,
const QString &sharedDirPath,
const QString &pathToQt,
QTextStream &messageStream)
{
const QString sourcePath = sharedDirPath + QStringLiteral("/qml/qmlpuppet/") + puppetName + QLatin1Char('/');
messageStream << "<p>"
//: %1 Puppet binary name ("qmlpuppet", "qml2puppet"), %2 source path.
<< NodeInstanceServerProxy::tr("You can build <code>%1</code> yourself with Qt 5.2.0 or higher. "
"The source can be found in <code>%2</code>.")
.arg(puppetName, QDir::toNativeSeparators(sourcePath))
<< "</p><p>"
<< NodeInstanceServerProxy::tr("<code>%1</code> will be installed to the <code>bin</code> directory of your Qt version. "
"Qt Quick Designer will check the <code>bin</code> directory of the currently active Qt version "
"of your project.").arg(puppetName)
<< "</p>"
<< generatePuppetCompilingHelp(puppetName, pathToQt);
//: %1 Puppet binary name ("qmlpuppet", "qml2puppet"), %2 source path.
messageStream << QChar(' ') << NodeInstanceServerProxy::tr("You can build <code>%1</code> yourself with Qt 5.2.0 or higher. "
"The source can be found in <code>%2</code>.")
.arg(puppetName, QDir::toNativeSeparators(sourcePath))
<< QChar(' ') << NodeInstanceServerProxy::tr("<code>%1</code> will be installed to the <code>bin</code> directory of your Qt version. "
"Qt Quick Designer will check the <code>bin</code> directory of the currently active Qt version "
"of your project.").arg(puppetName);
}
QString NodeInstanceServerProxy::missingQmlPuppetErrorMessage(const QString &pathToQt, const QString &preMessage) const
QString NodeInstanceServerProxy::missingQmlPuppetErrorMessage(const QString &preMessage) const
{
QString message;
QTextStream messageStream(&message);
messageStream << "<html><head/><body><p>"
<< preMessage
<< "</p>";
messageStream << QStringLiteral("<html><head/><body><p>")
<< preMessage;
if (hasQtQuick2(m_nodeInstanceView.data()))
formatQmlPuppetCompilationMessage(QStringLiteral("qml2puppet"), sharedDirPath(), pathToQt, messageStream);
formatQmlPuppetCompilationMessage(QStringLiteral("qml2puppet"), sharedDirPath(), messageStream);
else if (hasQtQuick1(m_nodeInstanceView.data()))
formatQmlPuppetCompilationMessage(QStringLiteral("qmlpuppet"), sharedDirPath(), pathToQt, messageStream);
messageStream << "</p></body></html>";
formatQmlPuppetCompilationMessage(QStringLiteral("qmlpuppet"), sharedDirPath(), messageStream);
messageStream << QStringLiteral("</p></body></html>");
return message;
}
QString NodeInstanceServerProxy::copyAndPasterMessage(const QString &pathToQt) const
{
QString message;
QTextStream messageStream(&message);
messageStream << QStringLiteral("<html><head/><body>");
if (hasQtQuick2(m_nodeInstanceView.data()))
messageStream << generatePuppetCompilingHelp(QStringLiteral("qmlpuppet2"), pathToQt);
else if (hasQtQuick1(m_nodeInstanceView.data()))
messageStream << generatePuppetCompilingHelp(QStringLiteral("qmlpuppet"), pathToQt);
messageStream << QStringLiteral("</body></html>");
return message;
}
......
......@@ -75,7 +75,8 @@ protected:
void writeCommand(const QVariant &command);
void dispatchCommand(const QVariant &command);
NodeInstanceClientInterface *nodeInstanceClient() const;
QString missingQmlPuppetErrorMessage(const QString &pathToQt, const QString &preMessage) const;
QString missingQmlPuppetErrorMessage(const QString &preMessage) const;
QString copyAndPasterMessage(const QString &pathToQt) const;
QString qmlPuppetApplicationName() const;
QString macOSBundlePath(const QString &path) const;
QString creatorQmlPuppetPath();
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "puppetdialog.h"
#include "ui_puppetdialog.h"
PuppetDialog::PuppetDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PuppetDialog)
{
ui->setupUi(this);
}
PuppetDialog::~PuppetDialog()
{
delete ui;
}
void PuppetDialog::setDescription(const QString &description)
{
ui->descriptionLabel->setText(description);
}
void PuppetDialog::setCopyAndPasteCode(const QString &text)
{
ui->copyAndPasteTextEdit->setText(text);
}
void PuppetDialog::warning(QWidget *parent, const QString &title, const QString &description, const QString &copyAndPasteCode)
{
PuppetDialog dialog(parent);
dialog.setWindowTitle(title);
dialog.setDescription(description);
dialog.setCopyAndPasteCode(copyAndPasteCode);
dialog.exec();
}
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef PUPPETDIALOG_H
#define PUPPETDIALOG_H
#include <QDialog>
namespace Ui {
class PuppetDialog;
}
class PuppetDialog : public QDialog
{
Q_OBJECT
public:
explicit PuppetDialog(QWidget *parent = 0);
~PuppetDialog();
void setDescription(const QString &description);
void setCopyAndPasteCode(const QString &text);
static void warning(QWidget *parent,
const QString &title,
const QString &description,
const QString &copyAndPasteCode);
private:
Ui::PuppetDialog *ui;
};
#endif // PUPPETDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PuppetDialog</class>
<widget class="QDialog" name="PuppetDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1148</width>
<height>344</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="copyAndPasteTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PuppetDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PuppetDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Supports Markdown
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