forked from qt-creator/qt-creator
Maemo: Let user choose package manager icon.
Reviewed-by: kh1
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QImageReader>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
@@ -78,6 +80,7 @@ void MaemoPackageCreationWidget::initGui()
|
||||
= m_step->buildConfiguration()->target()->project();
|
||||
updateDebianFileList(project);
|
||||
updateVersionInfo(project);
|
||||
updatePackageManagerIcon(project);
|
||||
connect(m_step, SIGNAL(packageFilePathChanged()), this,
|
||||
SIGNAL(updateSummary()));
|
||||
versionInfoChanged();
|
||||
@@ -87,6 +90,9 @@ void MaemoPackageCreationWidget::initGui()
|
||||
connect(MaemoTemplatesManager::instance(),
|
||||
SIGNAL(changeLogChanged(const ProjectExplorer::Project*)), this,
|
||||
SLOT(updateVersionInfo(const ProjectExplorer::Project*)));
|
||||
connect(MaemoTemplatesManager::instance(),
|
||||
SIGNAL(controlChanged(const ProjectExplorer::Project*)), this,
|
||||
SLOT(updatePackageManagerIcon(const ProjectExplorer::Project*)));
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project)
|
||||
@@ -121,6 +127,37 @@ void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Projec
|
||||
m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer::Project *project)
|
||||
{
|
||||
if (project != m_step->buildConfiguration()->target()->project())
|
||||
return;
|
||||
|
||||
QString error;
|
||||
const QIcon &icon
|
||||
= MaemoTemplatesManager::instance()->packageManagerIcon(project, &error);
|
||||
if (!error.isEmpty())
|
||||
QMessageBox::critical(this, tr("Could not read icon"), error);
|
||||
else
|
||||
m_ui->packageManagerIconButton->setIcon(icon);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::setPackageManagerIcon()
|
||||
{
|
||||
QString imageFilter = tr("Images") + QLatin1String("( ");
|
||||
const QList<QByteArray> &imageTypes = QImageReader::supportedImageFormats();
|
||||
foreach (const QByteArray &imageType, imageTypes)
|
||||
imageFilter += "*." + QString::fromAscii(imageType) + QLatin1Char(' ');
|
||||
imageFilter += QLatin1Char(')');
|
||||
const QString iconFileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Choose image"), QString(), imageFilter);
|
||||
if (!iconFileName.isEmpty()) {
|
||||
QString error;
|
||||
if (!MaemoTemplatesManager::instance()->setPackageManagerIcon(m_step->
|
||||
buildConfiguration()->target()->project(), iconFileName, &error))
|
||||
QMessageBox::critical(this, tr("Could not set new icon"), error);
|
||||
}
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationWidget::summaryText() const
|
||||
{
|
||||
return tr("<b>Create Package:</b> ") + QDir::toNativeSeparators(m_step->packageFilePath());
|
||||
|
||||
Reference in New Issue
Block a user