forked from qt-creator/qt-creator
Maemo: Manage project's display name for package manager.
Task-number: QTCREATORBUG-3063
This commit is contained in:
@@ -57,6 +57,8 @@
|
||||
#include <QtGui/QImageReader>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -82,11 +84,9 @@ void MaemoPackageCreationWidget::init()
|
||||
|
||||
void MaemoPackageCreationWidget::initGui()
|
||||
{
|
||||
const ProjectExplorer::Project * const project
|
||||
= m_step->buildConfiguration()->target()->project();
|
||||
updateDebianFileList(project);
|
||||
updateVersionInfo(project);
|
||||
updatePackageManagerIcon(project);
|
||||
updateDebianFileList(thisProject());
|
||||
updateVersionInfo(thisProject());
|
||||
handleControlFileUpdate(thisProject());
|
||||
connect(m_step, SIGNAL(packageFilePathChanged()), this,
|
||||
SIGNAL(updateSummary()));
|
||||
connect(m_step, SIGNAL(qtVersionChanged()), this,
|
||||
@@ -101,14 +101,13 @@ void MaemoPackageCreationWidget::initGui()
|
||||
SLOT(updateVersionInfo(const ProjectExplorer::Project*)));
|
||||
connect(MaemoTemplatesManager::instance(),
|
||||
SIGNAL(controlChanged(const ProjectExplorer::Project*)), this,
|
||||
SLOT(updatePackageManagerIcon(const ProjectExplorer::Project*)));
|
||||
SLOT(handleControlFileUpdate(const ProjectExplorer::Project*)));
|
||||
connect(m_ui->nameLineEdit, SIGNAL(editingFinished()), SLOT(setName()));
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project)
|
||||
{
|
||||
const ProjectExplorer::Project * const ourProject
|
||||
= m_step->buildConfiguration()->target()->project();
|
||||
if (ourProject == project)
|
||||
if (thisProject() == project)
|
||||
m_ui->debianFilesComboBox->clear();
|
||||
const QStringList &debianFiles = MaemoTemplatesManager::instance()
|
||||
->debianFiles(project);
|
||||
@@ -120,7 +119,7 @@ void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Pro
|
||||
|
||||
void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Project *project)
|
||||
{
|
||||
if (project != m_step->buildConfiguration()->target()->project())
|
||||
if (project != thisProject())
|
||||
return;
|
||||
|
||||
QString error;
|
||||
@@ -136,11 +135,17 @@ void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Projec
|
||||
m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer::Project *project)
|
||||
void MaemoPackageCreationWidget::handleControlFileUpdate(const Project *project)
|
||||
{
|
||||
if (project != m_step->buildConfiguration()->target()->project())
|
||||
if (project != thisProject())
|
||||
return;
|
||||
updatePackageManagerIcon(project);
|
||||
updateName(project);
|
||||
updateShortDescription(project);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updatePackageManagerIcon(const Project *project)
|
||||
{
|
||||
QString error;
|
||||
const QIcon &icon
|
||||
= MaemoTemplatesManager::instance()->packageManagerIcon(project, &error);
|
||||
@@ -152,6 +157,17 @@ void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer:
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updateName(const Project *project)
|
||||
{
|
||||
m_ui->nameLineEdit->setText(MaemoTemplatesManager::instance()->name(project));
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::updateShortDescription(const Project *project)
|
||||
{
|
||||
// TODO: Implment
|
||||
Q_UNUSED(project);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::setPackageManagerIcon()
|
||||
{
|
||||
QString imageFilter = tr("Images") + QLatin1String("( ");
|
||||
@@ -164,12 +180,26 @@ void MaemoPackageCreationWidget::setPackageManagerIcon()
|
||||
QString(), imageFilter);
|
||||
if (!iconFileName.isEmpty()) {
|
||||
QString error;
|
||||
if (!MaemoTemplatesManager::instance()->setPackageManagerIcon(m_step->
|
||||
buildConfiguration()->target()->project(), iconFileName, &error))
|
||||
if (!MaemoTemplatesManager::instance()->setPackageManagerIcon(thisProject(),
|
||||
iconFileName, &error))
|
||||
QMessageBox::critical(this, tr("Could Not Set New Icon"), error);
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::setName()
|
||||
{
|
||||
if (!MaemoTemplatesManager::instance()->setName(thisProject(),
|
||||
m_ui->nameLineEdit->text())) {
|
||||
QMessageBox::critical(this, tr("File Error"),
|
||||
tr("Could not set project name."));
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::setShortDescription()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::handleToolchainChanged()
|
||||
{
|
||||
if (!m_step->maemoToolChain())
|
||||
@@ -217,13 +247,18 @@ void MaemoPackageCreationWidget::versionInfoChanged()
|
||||
|
||||
void MaemoPackageCreationWidget::editDebianFile()
|
||||
{
|
||||
const QString debianFilePath = MaemoTemplatesManager::instance()
|
||||
->debianDirPath(m_step->buildConfiguration()->target()->project())
|
||||
+ QLatin1Char('/') + m_ui->debianFilesComboBox->currentText();
|
||||
const QString debianFilePath
|
||||
= MaemoTemplatesManager::instance()->debianDirPath(thisProject())
|
||||
+ QLatin1Char('/') + m_ui->debianFilesComboBox->currentText();
|
||||
Core::EditorManager::instance()->openEditor(debianFilePath,
|
||||
QString(),
|
||||
Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
|
||||
Project *MaemoPackageCreationWidget::thisProject() const
|
||||
{
|
||||
return m_step->buildConfiguration()->target()->project();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -68,13 +68,20 @@ private slots:
|
||||
void editDebianFile();
|
||||
void versionInfoChanged();
|
||||
void initGui();
|
||||
void updateDebianFileList(const ProjectExplorer::Project *project);
|
||||
void updateVersionInfo(const ProjectExplorer::Project *project);
|
||||
void updatePackageManagerIcon(const ProjectExplorer::Project *project);
|
||||
void updateDebianFileList(const ProjectExplorer::Project *thisProject);
|
||||
void updateVersionInfo(const ProjectExplorer::Project *thisProject);
|
||||
void handleControlFileUpdate(const ProjectExplorer::Project *thisProject);
|
||||
void setPackageManagerIcon();
|
||||
void setName();
|
||||
void setShortDescription();
|
||||
void handleToolchainChanged();
|
||||
|
||||
private:
|
||||
void updatePackageManagerIcon(const ProjectExplorer::Project *thisProject);
|
||||
void updateName(const ProjectExplorer::Project *thisProject);
|
||||
void updateShortDescription(const ProjectExplorer::Project *thisProject);
|
||||
ProjectExplorer::Project *thisProject() const;
|
||||
|
||||
MaemoPackageCreationStep * const m_step;
|
||||
Ui::MaemoPackageCreationWidget * const m_ui;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>505</width>
|
||||
<height>162</height>
|
||||
<height>189</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -157,26 +157,19 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="editDebianFileLabel">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string><b>Adapt Debian file:</b></string>
|
||||
<string><b>Name for Package Manager:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QComboBox" name="debianFilesComboBox"/>
|
||||
<widget class="QLineEdit" name="nameLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editDebianFileButton">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -242,6 +235,40 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="editDebianFileLabel">
|
||||
<property name="text">
|
||||
<string><b>Adapt Debian file:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="debianFilesComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editDebianFileButton">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace Internal {
|
||||
|
||||
namespace {
|
||||
const QByteArray IconFieldName("XB-Maemo-Icon-26:");
|
||||
const QByteArray DescriptionFieldName("XB-Maemo-Display-Name");
|
||||
const QLatin1String PackagingDirName("qtc_packaging");
|
||||
const QLatin1String DebianDirNameFremantle("debian_fremantle");
|
||||
} // anonymous namespace
|
||||
@@ -260,6 +261,8 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
|
||||
|
||||
adaptControlFileField(controlContents, "Section", "user/hidden");
|
||||
adaptControlFileField(controlContents, "Priority", "optional");
|
||||
adaptControlFileField(controlContents, DescriptionFieldName,
|
||||
project->displayName().toUtf8());
|
||||
const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
|
||||
if (buildDependsOffset == -1) {
|
||||
qDebug("Unexpected: no Build-Depends field in debian control file.");
|
||||
@@ -566,6 +569,24 @@ bool MaemoTemplatesManager::setPackageManagerIcon(const Project *project,
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MaemoTemplatesManager::name(const Project *project) const
|
||||
{
|
||||
return controlFileFieldValue(project, DescriptionFieldName);
|
||||
}
|
||||
|
||||
bool MaemoTemplatesManager::setName(const Project *project,
|
||||
const QString &description)
|
||||
{
|
||||
QFile controlFile(controlFilePath(project));
|
||||
if (!controlFile.open(QIODevice::ReadWrite))
|
||||
return false;
|
||||
QByteArray contents = controlFile.readAll();
|
||||
adaptControlFileField(contents, DescriptionFieldName, description.toUtf8());
|
||||
controlFile.resize(0);
|
||||
controlFile.write(contents);
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
|
||||
{
|
||||
return QDir(debianDirPath(project))
|
||||
@@ -603,7 +624,7 @@ QString MaemoTemplatesManager::controlFileFieldValue(const Project *project,
|
||||
if (valueEndPos == -1)
|
||||
valueEndPos = contents.count();
|
||||
return QString::fromUtf8(contents.mid(valueStartPos,
|
||||
valueEndPos - valueStartPos));
|
||||
valueEndPos - valueStartPos)).trimmed();
|
||||
}
|
||||
|
||||
void MaemoTemplatesManager::raiseError(const QString &reason)
|
||||
|
||||
@@ -71,6 +71,10 @@ public:
|
||||
bool setPackageManagerIcon(const ProjectExplorer::Project *project,
|
||||
const QString &iconFilePath, QString *error) const;
|
||||
|
||||
QString name(const ProjectExplorer::Project *project) const;
|
||||
bool setName(const ProjectExplorer::Project *project,
|
||||
const QString &description);
|
||||
|
||||
QString controlFileFieldValue(const ProjectExplorer::Project *project,
|
||||
const QString &key) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user