forked from qt-creator/qt-creator
QNX: Added warning messages when icon/splashscreens are too big
Change-Id: Idbad2d7c4760188c01c463a48317a407dc496914 Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
committed by
Nicolas Arnaud-Cormos
parent
e39ce66723
commit
11eba85988
@@ -83,6 +83,16 @@ void setCheckBoxBlocked(QCheckBox *checkBox, bool check)
|
|||||||
checkBox->setChecked(check);
|
checkBox->setChecked(check);
|
||||||
checkBox->blockSignals(blocked);
|
checkBox->blockSignals(blocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recommended maximum size for icons according to
|
||||||
|
// http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/r_barfile_dtd_ref_image.html
|
||||||
|
static int AppIconMaxWidth = 114;
|
||||||
|
static int AppIconMaxHeight = 114;
|
||||||
|
|
||||||
|
// Recommended maximum size for splashscreens according to
|
||||||
|
// http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/r_barfile_dtd_ref_splashscreens.html
|
||||||
|
static int SplashScreenMaxWidth = 1280;
|
||||||
|
static int SplashScreenMaxHeight = 1280;
|
||||||
}
|
}
|
||||||
|
|
||||||
BarDescriptorEditorWidget::BarDescriptorEditorWidget(QWidget *parent)
|
BarDescriptorEditorWidget::BarDescriptorEditorWidget(QWidget *parent)
|
||||||
@@ -166,12 +176,19 @@ void BarDescriptorEditorWidget::initApplicationPage()
|
|||||||
m_ui->iconFilePath->setExpectedKind(Utils::PathChooser::File);
|
m_ui->iconFilePath->setExpectedKind(Utils::PathChooser::File);
|
||||||
m_ui->iconFilePath->setPromptDialogFilter(tr("Images (*.jpg *.png)"));
|
m_ui->iconFilePath->setPromptDialogFilter(tr("Images (*.jpg *.png)"));
|
||||||
|
|
||||||
|
m_ui->iconWarningLabel->setVisible(false);
|
||||||
|
m_ui->iconWarningPixmap->setVisible(false);
|
||||||
|
|
||||||
|
m_ui->splashScreenWarningLabel->setVisible(false);
|
||||||
|
m_ui->splashScreenWarningPixmap->setVisible(false);
|
||||||
|
|
||||||
connect(m_ui->applicationName, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
|
connect(m_ui->applicationName, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
|
||||||
connect(m_ui->applicationDescription, SIGNAL(textChanged()), this, SLOT(setDirty()));
|
connect(m_ui->applicationDescription, SIGNAL(textChanged()), this, SLOT(setDirty()));
|
||||||
|
|
||||||
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(setDirty()));
|
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(setDirty()));
|
||||||
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(addImageAsAsset(QString)));
|
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(addImageAsAsset(QString)));
|
||||||
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(setApplicationIconPreview(QString)));
|
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(setApplicationIconPreview(QString)));
|
||||||
|
connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(validateIconSize(QString)));
|
||||||
connect(m_ui->iconClearButton, SIGNAL(clicked()), m_ui->iconFilePath->lineEdit(), SLOT(clear()));
|
connect(m_ui->iconClearButton, SIGNAL(clicked()), m_ui->iconFilePath->lineEdit(), SLOT(clear()));
|
||||||
|
|
||||||
m_splashScreenModel = new QStringListModel(this);
|
m_splashScreenModel = new QStringListModel(this);
|
||||||
@@ -452,6 +469,7 @@ void BarDescriptorEditorWidget::setApplicationIconDelayed(const QString &iconPat
|
|||||||
const QString fullIconPath = localAssetPathFromDestination(iconPath);
|
const QString fullIconPath = localAssetPathFromDestination(iconPath);
|
||||||
setPathBlocked(m_ui->iconFilePath, fullIconPath);
|
setPathBlocked(m_ui->iconFilePath, fullIconPath);
|
||||||
setApplicationIconPreview(fullIconPath);
|
setApplicationIconPreview(fullIconPath);
|
||||||
|
validateIconSize(fullIconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BarDescriptorEditorWidget::setImagePreview(QLabel *previewLabel, const QString &path)
|
void BarDescriptorEditorWidget::setImagePreview(QLabel *previewLabel, const QString &path)
|
||||||
@@ -477,11 +495,54 @@ void BarDescriptorEditorWidget::setImagePreview(QLabel *previewLabel, const QStr
|
|||||||
previewLabel->setPixmap(scaledPixmap);
|
previewLabel->setPixmap(scaledPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BarDescriptorEditorWidget::validateImage(const QString &path, QLabel *warningMessage, QLabel *warningPixmap, const QSize &maximumSize)
|
||||||
|
{
|
||||||
|
ImageValidationResult result = Valid;
|
||||||
|
|
||||||
|
QSize actualSize;
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
QImage img(path);
|
||||||
|
if (img.isNull()) {
|
||||||
|
result = CouldNotLoad;
|
||||||
|
} else {
|
||||||
|
actualSize = img.size();
|
||||||
|
if (actualSize.width() > maximumSize.width() || actualSize.height() > maximumSize.height())
|
||||||
|
result = IncorrectSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case CouldNotLoad:
|
||||||
|
warningMessage->setText(tr("<font color=\"red\">Could not open '%1' for reading.</font>").arg(path));
|
||||||
|
warningMessage->setVisible(true);
|
||||||
|
warningPixmap->setVisible(true);
|
||||||
|
break;
|
||||||
|
case IncorrectSize: {
|
||||||
|
warningMessage->setText(tr("<font color=\"red\">The selected image is too big (%1x%2). The maximum size is %3x%4 pixels.</font>")
|
||||||
|
.arg(actualSize.width()).arg(actualSize.height())
|
||||||
|
.arg(maximumSize.width()).arg(maximumSize.height()));
|
||||||
|
warningMessage->setVisible(true);
|
||||||
|
warningPixmap->setVisible(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Valid:
|
||||||
|
default:
|
||||||
|
warningMessage->setVisible(false);
|
||||||
|
warningPixmap->setVisible(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BarDescriptorEditorWidget::setApplicationIconPreview(const QString &path)
|
void BarDescriptorEditorWidget::setApplicationIconPreview(const QString &path)
|
||||||
{
|
{
|
||||||
setImagePreview(m_ui->iconPreviewLabel, path);
|
setImagePreview(m_ui->iconPreviewLabel, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BarDescriptorEditorWidget::validateIconSize(const QString &path)
|
||||||
|
{
|
||||||
|
validateImage(path, m_ui->iconWarningLabel, m_ui->iconWarningPixmap, QSize(AppIconMaxWidth, AppIconMaxHeight));
|
||||||
|
}
|
||||||
|
|
||||||
void BarDescriptorEditorWidget::appendSplashScreenDelayed(const QString &splashScreenPath)
|
void BarDescriptorEditorWidget::appendSplashScreenDelayed(const QString &splashScreenPath)
|
||||||
{
|
{
|
||||||
const QString fullSplashScreenPath = localAssetPathFromDestination(splashScreenPath);
|
const QString fullSplashScreenPath = localAssetPathFromDestination(splashScreenPath);
|
||||||
@@ -538,11 +599,19 @@ void BarDescriptorEditorWidget::handleSplashScreenSelectionChanged(const QItemSe
|
|||||||
if (!emptySelection) {
|
if (!emptySelection) {
|
||||||
QString path = m_splashScreenModel->data(selected.indexes().at(0), Qt::DisplayRole).toString();
|
QString path = m_splashScreenModel->data(selected.indexes().at(0), Qt::DisplayRole).toString();
|
||||||
setImagePreview(m_ui->splashScreenPreviewLabel, path);
|
setImagePreview(m_ui->splashScreenPreviewLabel, path);
|
||||||
|
validateSplashScreenSize(path);
|
||||||
} else {
|
} else {
|
||||||
setImagePreview(m_ui->splashScreenPreviewLabel, QString());
|
setImagePreview(m_ui->splashScreenPreviewLabel, QString());
|
||||||
|
m_ui->splashScreenWarningLabel->setVisible(false);
|
||||||
|
m_ui->splashScreenWarningPixmap->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BarDescriptorEditorWidget::validateSplashScreenSize(const QString &path)
|
||||||
|
{
|
||||||
|
validateImage(path, m_ui->splashScreenWarningLabel, m_ui->splashScreenWarningPixmap, QSize(SplashScreenMaxWidth, SplashScreenMaxHeight));
|
||||||
|
}
|
||||||
|
|
||||||
void BarDescriptorEditorWidget::addAsset(const BarDescriptorAsset &asset)
|
void BarDescriptorEditorWidget::addAsset(const BarDescriptorAsset &asset)
|
||||||
{
|
{
|
||||||
disconnectAssetsModel();
|
disconnectAssetsModel();
|
||||||
|
|||||||
@@ -146,13 +146,21 @@ private slots:
|
|||||||
|
|
||||||
void setApplicationIconDelayed(const QString &iconPath);
|
void setApplicationIconDelayed(const QString &iconPath);
|
||||||
void setApplicationIconPreview(const QString &path);
|
void setApplicationIconPreview(const QString &path);
|
||||||
|
void validateIconSize(const QString &path);
|
||||||
|
|
||||||
void appendSplashScreenDelayed(const QString &splashScreenPath);
|
void appendSplashScreenDelayed(const QString &splashScreenPath);
|
||||||
void browseForSplashScreen();
|
void browseForSplashScreen();
|
||||||
void removeSelectedSplashScreen();
|
void removeSelectedSplashScreen();
|
||||||
void handleSplashScreenSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void handleSplashScreenSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void validateSplashScreenSize(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum ImageValidationResult {
|
||||||
|
Valid,
|
||||||
|
CouldNotLoad,
|
||||||
|
IncorrectSize
|
||||||
|
};
|
||||||
|
|
||||||
BarDescriptorEditor *createEditor();
|
BarDescriptorEditor *createEditor();
|
||||||
|
|
||||||
void initGeneralPage();
|
void initGeneralPage();
|
||||||
@@ -172,6 +180,7 @@ private:
|
|||||||
QString localAssetPathFromDestination(const QString &path);
|
QString localAssetPathFromDestination(const QString &path);
|
||||||
|
|
||||||
void setImagePreview(QLabel *previewLabel, const QString &path);
|
void setImagePreview(QLabel *previewLabel, const QString &path);
|
||||||
|
void validateImage(const QString &path, QLabel *warningMessage, QLabel *warningPixmap, const QSize &maximumSize);
|
||||||
|
|
||||||
mutable Core::IEditor *m_editor;
|
mutable Core::IEditor *m_editor;
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1014</width>
|
<width>1014</width>
|
||||||
<height>810</height>
|
<height>854</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
@@ -231,14 +231,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Splash screens:</string>
|
<string>Splash screens:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
<item row="9" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="splashScreensView"/>
|
<widget class="QListView" name="splashScreensView"/>
|
||||||
@@ -325,6 +325,40 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QLabel" name="iconWarningLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="iconWarningPixmap">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_warning.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QLabel" name="splashScreenWarningPixmap">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_warning.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1">
|
||||||
|
<widget class="QLabel" name="splashScreenWarningLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -542,6 +576,8 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../projectexplorer/projectexplorer.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user