Commit f7de570f authored by Kai Koehne's avatar Kai Koehne Committed by Eike Ziller

MobileWizards: Add option for booster to harmattan configure page

Split up maemo- and harmattan wizard pages, and add a checkbox
for enabling booster specifically for harmattan.

Change-Id: If5653abbf6d29b5f946718d10bc12404df19c16c
Reviewed-on: http://codereview.qt.nokia.com/3731Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent d687d112
......@@ -137,6 +137,7 @@ FORMS += makestep.ui \
wizards/mobileappwizardgenericoptionspage.ui \
wizards/mobileappwizardsymbianoptionspage.ui \
wizards/mobileappwizardmaemooptionspage.ui \
wizards/mobileappwizardharmattanoptionspage.ui \
wizards/qtquickcomponentsetoptionspage.ui
RESOURCES += qt4projectmanager.qrc \
......
......@@ -42,6 +42,7 @@
#endif // CREATORLESSTEST
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
namespace Qt4ProjectManager {
......@@ -62,8 +63,11 @@ const QString AbstractMobileApp::FileStubVersion(QLatin1String("version"));
const int AbstractMobileApp::StubVersion = 6;
AbstractMobileApp::AbstractMobileApp()
: m_orientation(ScreenOrientationAuto)
: QObject()
, m_canSupportMeegoBooster(false)
, m_orientation(ScreenOrientationAuto)
, m_networkEnabled(true)
, m_supportsMeegoBooster(false)
{
}
......@@ -209,7 +213,10 @@ QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage, int fil
} else if (fileType == AbstractGeneratedFileInfo::DesktopFileHarmattan) {
desktopFileContent.replace("Icon=thisApp",
"Icon=/usr/share/icons/hicolor/80x80/apps/" + projectName().toUtf8() + "80.png");
desktopFileContent.replace("Exec=", "Exec=/usr/bin/single-instance ");
if (m_supportsMeegoBooster)
desktopFileContent.replace("Exec=", "Exec=/usr/bin/invoker --type=d -s ");
else
desktopFileContent.replace("Exec=", "Exec=/usr/bin/single-instance ");
}
return desktopFileContent.replace("thisApp", projectName().toUtf8());
}
......@@ -416,6 +423,22 @@ QString AbstractMobileApp::error() const
return m_error;
}
bool AbstractMobileApp::canSupportMeegoBooster() const
{
return m_canSupportMeegoBooster;
}
bool AbstractMobileApp::supportsMeegoBooster() const
{
return m_supportsMeegoBooster;
}
void AbstractMobileApp::setSupportsMeegoBooster(bool supportMeegoBooster)
{
QTC_ASSERT(canSupportMeegoBooster(), return);
m_supportsMeegoBooster = supportMeegoBooster;
}
QByteArray AbstractMobileApp::readBlob(const QString &filePath,
QString *errorMsg) const
{
......
......@@ -133,6 +133,10 @@ public:
QString path(int fileType) const;
QString error() const;
bool canSupportMeegoBooster() const;
bool supportsMeegoBooster() const;
void setSupportsMeegoBooster(bool supportBooster);
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
......@@ -168,6 +172,8 @@ protected:
static const int StubVersion;
QString m_error;
bool m_canSupportMeegoBooster;
private:
QByteArray generateDesktopFile(QString *errorMessage, int fileType) const;
QByteArray generateMainCpp(QString *errorMessage) const;
......@@ -194,6 +200,7 @@ private:
QString m_symbianTargetUid;
ScreenOrientation m_orientation;
bool m_networkEnabled;
bool m_supportsMeegoBooster;
};
} // namespace Qt4ProjectManager
......
......@@ -70,8 +70,8 @@ AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent, co
m_genericOptionsPage = new Internal::MobileAppWizardGenericOptionsPage;
m_symbianOptionsPage = new Internal::MobileAppWizardSymbianOptionsPage;
m_maemoOptionsPage = new Internal::MobileAppWizardMaemoOptionsPage(64);
m_harmattanOptionsPage = new Internal::MobileAppWizardMaemoOptionsPage(80);
m_maemoOptionsPage = new Internal::MobileAppWizardMaemoOptionsPage;
m_harmattanOptionsPage = new Internal::MobileAppWizardHarmattanOptionsPage;
}
void AbstractMobileAppWizardDialog::addMobilePages()
......@@ -241,6 +241,7 @@ QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
wdlg->m_symbianOptionsPage->setNetworkEnabled(app()->networkEnabled());
wdlg->m_maemoOptionsPage->setPngIcon(app()->maemoPngIcon64());
wdlg->m_harmattanOptionsPage->setPngIcon(app()->maemoPngIcon80());
wdlg->m_harmattanOptionsPage->setBoosterOptionEnabled(app()->canSupportMeegoBooster());
connect(wdlg, SIGNAL(projectParametersChanged(QString, QString)),
SLOT(useProjectPath(QString, QString)));
foreach (QWizardPage *p, extensionPages)
......@@ -259,6 +260,9 @@ Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizar
app()->setNetworkEnabled(wdlg->m_symbianOptionsPage->networkEnabled());
app()->setMaemoPngIcon64(wdlg->m_maemoOptionsPage->pngIcon());
app()->setMaemoPngIcon80(wdlg->m_harmattanOptionsPage->pngIcon());
if (wdlg->isHarmattanTargetSelected())
app()->setSupportsMeegoBooster(wdlg->isHarmattanTargetSelected()
&& wdlg->m_harmattanOptionsPage->supportsBooster());
prepareGenerateFiles(wizard, errorMessage);
return app()->generateFiles(errorMessage);
}
......
......@@ -48,6 +48,7 @@ namespace Internal {
class MobileAppWizardGenericOptionsPage;
class MobileAppWizardSymbianOptionsPage;
class MobileAppWizardMaemoOptionsPage;
class MobileAppWizardHarmattanOptionsPage;
}
/// \internal
......@@ -82,7 +83,7 @@ private:
Internal::MobileAppWizardGenericOptionsPage *m_genericOptionsPage;
Internal::MobileAppWizardSymbianOptionsPage *m_symbianOptionsPage;
Internal::MobileAppWizardMaemoOptionsPage *m_maemoOptionsPage;
Internal::MobileAppWizardMaemoOptionsPage *m_harmattanOptionsPage;
Internal::MobileAppWizardHarmattanOptionsPage *m_harmattanOptionsPage;
TargetSetupPage *m_targetsPage;
int m_genericOptionsPageId;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileAppWizardHarmattanOptionsPage</class>
<widget class="QWizardPage" name="MobileAppWizardHarmattanOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="appIconLabel">
<property name="text">
<string>Application icon (80x80):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="pngIconButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="makeBoostableCheckBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Generate code to speed up the launching on the device.</string>
</property>
<property name="text">
<string>Make application boostable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -17,7 +17,7 @@
<item row="0" column="0">
<widget class="QLabel" name="appIconLabel">
<property name="text">
<string>Application icon (%%w%%x%%h%%):</string>
<string>Application icon (64x64):</string>
</property>
</widget>
</item>
......
......@@ -33,6 +33,7 @@
#include "mobileappwizardpages.h"
#include "ui_mobileappwizardgenericoptionspage.h"
#include "ui_mobileappwizardmaemooptionspage.h"
#include "ui_mobileappwizardharmattanoptionspage.h"
#include "ui_mobileappwizardsymbianoptionspage.h"
#include <coreplugin/coreconstants.h>
#include <utils/fileutils.h>
......@@ -67,6 +68,14 @@ class MobileAppWizardMaemoOptionsPagePrivate
friend class MobileAppWizardMaemoOptionsPage;
};
class MobileAppWizardHarmattanOptionsPagePrivate
{
Ui::MobileAppWizardHarmattanOptionsPage ui;
QSize iconSize;
QString pngIcon;
friend class MobileAppWizardHarmattanOptionsPage;
};
MobileAppWizardGenericOptionsPage::MobileAppWizardGenericOptionsPage(QWidget *parent)
: QWizardPage(parent)
, m_d(new MobileAppWizardGenericOptionsPagePrivate)
......@@ -167,18 +176,12 @@ void MobileAppWizardSymbianOptionsPage::openSvgIcon()
setSvgIcon(svgIcon);
}
MobileAppWizardMaemoOptionsPage::MobileAppWizardMaemoOptionsPage(int appIconSize,
QWidget *parent)
MobileAppWizardMaemoOptionsPage::MobileAppWizardMaemoOptionsPage(QWidget *parent)
: QWizardPage(parent)
, m_d(new MobileAppWizardMaemoOptionsPagePrivate)
{
m_d->ui.setupUi(this);
QString iconLabelText = m_d->ui.appIconLabel->text();
iconLabelText.replace(QLatin1String("%%w%%"), QString::number(appIconSize));
iconLabelText.replace(QLatin1String("%%h%%"), QString::number(appIconSize));
m_d->ui.appIconLabel->setText(iconLabelText);
m_d->iconSize = QSize(appIconSize, appIconSize);
m_d->iconSize = QSize(64, 64);
m_d->ui.pngIconButton->setIconSize(m_d->iconSize);
connect(m_d->ui.pngIconButton, SIGNAL(clicked()), this, SLOT(openPngIcon()));
}
......@@ -193,42 +196,66 @@ QString MobileAppWizardMaemoOptionsPage::pngIcon() const
return m_d->pngIcon;
}
void MobileAppWizardMaemoOptionsPage::setPngIcon(const QString &icon)
class PngIconScaler : public QObject
{
QString error;
QPixmap iconPixmap(icon);
if (iconPixmap.isNull()) {
QMessageBox::critical(this, tr("Invalid Icon"),
tr("The file is not a valid image."));
return;
Q_OBJECT
public:
PngIconScaler(const QSize &expectedSize, const QString &iconPath)
: m_expectedSize(expectedSize)
, m_iconPath(iconPath)
, m_pixmap(iconPath)
{
}
QString actualIconPath;
if (iconPixmap.size() == m_d->iconSize) {
actualIconPath = icon;
} else {
const QMessageBox::StandardButton button = QMessageBox::warning(this,
tr("Wrong Icon Size"), tr("The icon needs to be %1x%2 pixels big, "
"but is not. Do you want Creator to scale it?")
.arg(m_d->iconSize.width()).arg(m_d->iconSize.height()),
QMessageBox::Ok | QMessageBox::Cancel);
bool hasRightSize() const { return m_expectedSize == m_pixmap.size(); }
QPixmap pixmap() const { return m_pixmap; }
bool scale(QString *newPath) {
const QMessageBox::StandardButton button
= QMessageBox::warning(QApplication::activeWindow(),
tr("Wrong Icon Size"),
tr("The icon needs to be %1x%2 pixels big, "
"but is not. Do you want Qt Creator to scale it?")
.arg(m_expectedSize.width()).arg(m_expectedSize.height()),
QMessageBox::Ok | QMessageBox::Cancel);
if (button != QMessageBox::Ok)
return;
iconPixmap = iconPixmap.scaled(m_d->iconSize);
return false;
m_pixmap = m_pixmap.scaled(m_expectedSize);
Utils::TempFileSaver saver;
saver.setAutoRemove(false);
if (!saver.hasError())
saver.setResult(iconPixmap.save(
saver.file(), QFileInfo(icon).suffix().toAscii().constData()));
saver.setResult(m_pixmap.save(
saver.file(), QFileInfo(m_iconPath).suffix().toAscii().constData()));
if (!saver.finalize()) {
QMessageBox::critical(this, tr("File Error"),
tr("Could not copy icon file: %1").arg(saver.errorString()));
return;
QMessageBox::critical(QApplication::activeWindow(),
tr("File Error"),
tr("Could not copy icon file: %1").arg(saver.errorString()));
return false;
}
actualIconPath = saver.fileName();
*newPath = saver.fileName();
return true;
}
private:
QSize m_expectedSize;
QString m_iconPath;
QPixmap m_pixmap;
};
m_d->ui.pngIconButton->setIcon(iconPixmap);
void MobileAppWizardMaemoOptionsPage::setPngIcon(const QString &icon)
{
QString actualIconPath;
PngIconScaler scaler(m_d->iconSize, icon);
if (scaler.hasRightSize()) {
actualIconPath = icon;
} else {
if (!scaler.scale(&actualIconPath))
return;
}
m_d->ui.pngIconButton->setIcon(scaler.pixmap());
m_d->pngIcon = actualIconPath;
}
......@@ -241,5 +268,62 @@ void MobileAppWizardMaemoOptionsPage::openPngIcon()
setPngIcon(iconPath);
}
MobileAppWizardHarmattanOptionsPage::MobileAppWizardHarmattanOptionsPage(QWidget *parent)
: QWizardPage(parent)
, m_d(new MobileAppWizardHarmattanOptionsPagePrivate)
{
m_d->ui.setupUi(this);
m_d->iconSize = QSize(80, 80);
m_d->ui.pngIconButton->setIconSize(m_d->iconSize);
connect(m_d->ui.pngIconButton, SIGNAL(clicked()), this, SLOT(openPngIcon()));
}
MobileAppWizardHarmattanOptionsPage::~MobileAppWizardHarmattanOptionsPage()
{
delete m_d;
}
QString MobileAppWizardHarmattanOptionsPage::pngIcon() const
{
return m_d->pngIcon;
}
void MobileAppWizardHarmattanOptionsPage::setPngIcon(const QString &icon)
{
QString actualIconPath;
PngIconScaler scaler(m_d->iconSize, icon);
if (scaler.hasRightSize()) {
actualIconPath = icon;
} else {
if (!scaler.scale(&actualIconPath))
return;
}
m_d->ui.pngIconButton->setIcon(scaler.pixmap());
m_d->pngIcon = actualIconPath;
}
void MobileAppWizardHarmattanOptionsPage::openPngIcon()
{
const QString iconPath = QFileDialog::getOpenFileName(this,
m_d->ui.appIconLabel->text(), m_d->pngIcon,
QLatin1String("*.png"));
if (!iconPath.isEmpty())
setPngIcon(iconPath);
}
void MobileAppWizardHarmattanOptionsPage::setBoosterOptionEnabled(bool enable)
{
m_d->ui.makeBoostableCheckBox->setEnabled(enable);
m_d->ui.makeBoostableCheckBox->setChecked(enable);
}
bool MobileAppWizardHarmattanOptionsPage::supportsBooster() const
{
return m_d->ui.makeBoostableCheckBox->isChecked();
}
} // namespace Internal
} // namespace Qt4ProjectManager
#include "mobileappwizardpages.moc"
......@@ -85,8 +85,7 @@ class MobileAppWizardMaemoOptionsPage : public QWizardPage
Q_DISABLE_COPY(MobileAppWizardMaemoOptionsPage)
public:
explicit MobileAppWizardMaemoOptionsPage(int appIconSize,
QWidget *parent = 0);
explicit MobileAppWizardMaemoOptionsPage(QWidget *parent = 0);
virtual ~MobileAppWizardMaemoOptionsPage();
QString pngIcon() const;
......@@ -99,6 +98,27 @@ private:
class MobileAppWizardMaemoOptionsPagePrivate *m_d;
};
class MobileAppWizardHarmattanOptionsPage : public QWizardPage
{
Q_OBJECT
public:
explicit MobileAppWizardHarmattanOptionsPage(QWidget *parent = 0);
virtual ~MobileAppWizardHarmattanOptionsPage();
QString pngIcon() const;
void setPngIcon(const QString &icon);
void setBoosterOptionEnabled(bool enable);
bool supportsBooster() const;
private slots:
void openPngIcon();
private:
class MobileAppWizardHarmattanOptionsPagePrivate *m_d;
};
} // namespace Internal
} // namespace Qt4ProjectManager
......
......@@ -102,6 +102,7 @@ QtQuickApp::QtQuickApp()
, m_mainQmlMode(ModeGenerate)
, m_componentSet(QtQuick10Components)
{
m_canSupportMeegoBooster = true;
}
QtQuickApp::~QtQuickApp()
......@@ -226,16 +227,16 @@ QString QtQuickApp::mainWindowClassName() const
bool QtQuickApp::adaptCurrentMainCppTemplateLine(QString &line) const
{
const QLatin1Char quote('"');
bool adaptLine = true;
if (line.contains(QLatin1String("// MAINQML"))) {
insertParameter(line, quote + path(MainQmlDeployed) + quote);
} else if (line.contains(QLatin1String("// ADDIMPORTPATH"))) {
if (m_modules.isEmpty())
adaptLine = false;
return false;
else
insertParameter(line, quote + path(ModulesDir) + quote);
}
return adaptLine;
return true;
}
void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line,
......@@ -263,6 +264,11 @@ void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line,
if (componentSet() == Symbian10Components)
nextLine.remove(0, 2); // remove comment
proFile << nextLine << endl;
} else if (line.contains(QLatin1String("# HARMATTAN_BOOSTABLE"))) {
QString nextLine = proFileTemplate.readLine(); // eats '# CONFIG += qdeclarative-boostable'
if (supportsMeegoBooster())
nextLine.remove(0, 2); // remove comment
proFile << nextLine << endl;
}
}
......
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