forked from qt-creator/qt-creator
Maemo: Add GUI element to set project description.
This commit is contained in:
@@ -103,6 +103,9 @@ void MaemoPackageCreationWidget::initGui()
|
|||||||
SIGNAL(controlChanged(const ProjectExplorer::Project*)), this,
|
SIGNAL(controlChanged(const ProjectExplorer::Project*)), this,
|
||||||
SLOT(handleControlFileUpdate(const ProjectExplorer::Project*)));
|
SLOT(handleControlFileUpdate(const ProjectExplorer::Project*)));
|
||||||
connect(m_ui->nameLineEdit, SIGNAL(editingFinished()), SLOT(setName()));
|
connect(m_ui->nameLineEdit, SIGNAL(editingFinished()), SLOT(setName()));
|
||||||
|
m_ui->shortDescriptionLineEdit->setMaxLength(60);
|
||||||
|
connect(m_ui->shortDescriptionLineEdit, SIGNAL(editingFinished()),
|
||||||
|
SLOT(setShortDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project)
|
void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project)
|
||||||
@@ -164,8 +167,8 @@ void MaemoPackageCreationWidget::updateName(const Project *project)
|
|||||||
|
|
||||||
void MaemoPackageCreationWidget::updateShortDescription(const Project *project)
|
void MaemoPackageCreationWidget::updateShortDescription(const Project *project)
|
||||||
{
|
{
|
||||||
// TODO: Implment
|
m_ui->shortDescriptionLineEdit
|
||||||
Q_UNUSED(project);
|
->setText(MaemoTemplatesManager::instance()->shortDescription(project));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoPackageCreationWidget::setPackageManagerIcon()
|
void MaemoPackageCreationWidget::setPackageManagerIcon()
|
||||||
@@ -197,7 +200,11 @@ void MaemoPackageCreationWidget::setName()
|
|||||||
|
|
||||||
void MaemoPackageCreationWidget::setShortDescription()
|
void MaemoPackageCreationWidget::setShortDescription()
|
||||||
{
|
{
|
||||||
|
if (!MaemoTemplatesManager::instance()->setShortDescription(thisProject(),
|
||||||
|
m_ui->shortDescriptionLineEdit->text())) {
|
||||||
|
QMessageBox::critical(this, tr("File Error"),
|
||||||
|
tr("Could not set project description."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoPackageCreationWidget::handleToolchainChanged()
|
void MaemoPackageCreationWidget::handleToolchainChanged()
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>505</width>
|
<width>584</width>
|
||||||
<height>189</height>
|
<height>230</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -27,22 +27,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<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>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" 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>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
@@ -156,14 +156,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="nameLabel">
|
<widget class="QLabel" name="nameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Name for Package Manager:</b></string>
|
<string><b>Name for Package Manager:</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="nameLineEdit"/>
|
<widget class="QLineEdit" name="nameLineEdit"/>
|
||||||
@@ -183,7 +183,34 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="shortDescriptionLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string><b>Short description for Package Manager:</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="shortDescriptionLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<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>
|
||||||
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="packageManagerIconLabel">
|
<widget class="QLabel" name="packageManagerIconLabel">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -196,7 +223,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="5" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="packageManagerIconButton">
|
<widget class="QToolButton" name="packageManagerIconButton">
|
||||||
@@ -235,14 +262,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="editDebianFileLabel">
|
<widget class="QLabel" name="editDebianFileLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Adapt Debian file:</b></string>
|
<string><b>Adapt Debian file:</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="6" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="debianFilesComboBox"/>
|
<widget class="QComboBox" name="debianFilesComboBox"/>
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ namespace Internal {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QByteArray IconFieldName("XB-Maemo-Icon-26:");
|
const QByteArray IconFieldName("XB-Maemo-Icon-26:");
|
||||||
const QByteArray DescriptionFieldName("XB-Maemo-Display-Name");
|
const QByteArray NameFieldName("XB-Maemo-Display-Name");
|
||||||
|
const QByteArray ShortDescriptionFieldName("Description");
|
||||||
const QLatin1String PackagingDirName("qtc_packaging");
|
const QLatin1String PackagingDirName("qtc_packaging");
|
||||||
const QLatin1String DebianDirNameFremantle("debian_fremantle");
|
const QLatin1String DebianDirNameFremantle("debian_fremantle");
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -261,7 +262,7 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
|
|||||||
|
|
||||||
adaptControlFileField(controlContents, "Section", "user/hidden");
|
adaptControlFileField(controlContents, "Section", "user/hidden");
|
||||||
adaptControlFileField(controlContents, "Priority", "optional");
|
adaptControlFileField(controlContents, "Priority", "optional");
|
||||||
adaptControlFileField(controlContents, DescriptionFieldName,
|
adaptControlFileField(controlContents, NameFieldName,
|
||||||
project->displayName().toUtf8());
|
project->displayName().toUtf8());
|
||||||
const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
|
const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
|
||||||
if (buildDependsOffset == -1) {
|
if (buildDependsOffset == -1) {
|
||||||
@@ -288,21 +289,29 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoTemplatesManager::adaptControlFileField(QByteArray &document,
|
bool MaemoTemplatesManager::adaptControlFileField(QByteArray &document,
|
||||||
const QByteArray &fieldName, const QByteArray &newFieldValue)
|
const QByteArray &fieldName, const QByteArray &newFieldValue)
|
||||||
{
|
{
|
||||||
QByteArray adaptedLine = fieldName + ": " + newFieldValue;
|
QByteArray adaptedLine = fieldName + ": " + newFieldValue;
|
||||||
const int lineOffset = document.indexOf(fieldName + ":");
|
const int lineOffset = document.indexOf(fieldName + ":");
|
||||||
if (lineOffset == -1) {
|
if (lineOffset == -1) {
|
||||||
document.append(adaptedLine).append('\n');
|
document.append(adaptedLine).append('\n');
|
||||||
} else {
|
return true;
|
||||||
int newlineOffset = document.indexOf('\n', lineOffset);
|
|
||||||
if (newlineOffset == -1) {
|
|
||||||
newlineOffset = document.length();
|
|
||||||
adaptedLine += '\n';
|
|
||||||
}
|
|
||||||
document.replace(lineOffset, newlineOffset - lineOffset, adaptedLine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int newlineOffset = document.indexOf('\n', lineOffset);
|
||||||
|
bool updated = false;
|
||||||
|
if (newlineOffset == -1) {
|
||||||
|
newlineOffset = document.length();
|
||||||
|
adaptedLine += '\n';
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
const int replaceCount = newlineOffset - lineOffset;
|
||||||
|
if (!updated && document.mid(lineOffset, replaceCount) != adaptedLine)
|
||||||
|
updated = true;
|
||||||
|
if (updated)
|
||||||
|
document.replace(lineOffset, replaceCount, adaptedLine);
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaemoTemplatesManager::updateDesktopFiles(const Qt4Target *target)
|
bool MaemoTemplatesManager::updateDesktopFiles(const Qt4Target *target)
|
||||||
@@ -571,19 +580,37 @@ bool MaemoTemplatesManager::setPackageManagerIcon(const Project *project,
|
|||||||
|
|
||||||
QString MaemoTemplatesManager::name(const Project *project) const
|
QString MaemoTemplatesManager::name(const Project *project) const
|
||||||
{
|
{
|
||||||
return controlFileFieldValue(project, DescriptionFieldName);
|
return controlFileFieldValue(project, NameFieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaemoTemplatesManager::setName(const Project *project,
|
bool MaemoTemplatesManager::setName(const Project *project, const QString &name)
|
||||||
|
{
|
||||||
|
return setFieldValue(project, NameFieldName, name.toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MaemoTemplatesManager::shortDescription(const Project *project) const
|
||||||
|
{
|
||||||
|
return controlFileFieldValue(project, ShortDescriptionFieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaemoTemplatesManager::setShortDescription(const Project *project,
|
||||||
const QString &description)
|
const QString &description)
|
||||||
|
{
|
||||||
|
return setFieldValue(project, ShortDescriptionFieldName,
|
||||||
|
description.toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaemoTemplatesManager::setFieldValue(const Project *project,
|
||||||
|
const QByteArray &fieldName, const QByteArray &fieldValue)
|
||||||
{
|
{
|
||||||
QFile controlFile(controlFilePath(project));
|
QFile controlFile(controlFilePath(project));
|
||||||
if (!controlFile.open(QIODevice::ReadWrite))
|
if (!controlFile.open(QIODevice::ReadWrite))
|
||||||
return false;
|
return false;
|
||||||
QByteArray contents = controlFile.readAll();
|
QByteArray contents = controlFile.readAll();
|
||||||
adaptControlFileField(contents, DescriptionFieldName, description.toUtf8());
|
if (adaptControlFileField(contents, fieldName, fieldValue)) {
|
||||||
controlFile.resize(0);
|
controlFile.resize(0);
|
||||||
controlFile.write(contents);
|
controlFile.write(contents);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ public:
|
|||||||
|
|
||||||
QString name(const ProjectExplorer::Project *project) const;
|
QString name(const ProjectExplorer::Project *project) const;
|
||||||
bool setName(const ProjectExplorer::Project *project,
|
bool setName(const ProjectExplorer::Project *project,
|
||||||
|
const QString &name);
|
||||||
|
|
||||||
|
QString shortDescription(const ProjectExplorer::Project *project) const;
|
||||||
|
bool setShortDescription(const ProjectExplorer::Project *project,
|
||||||
const QString &description);
|
const QString &description);
|
||||||
|
|
||||||
QString controlFileFieldValue(const ProjectExplorer::Project *project,
|
QString controlFileFieldValue(const ProjectExplorer::Project *project,
|
||||||
@@ -105,10 +109,12 @@ private:
|
|||||||
int &lineEndPos, int &valuePos);
|
int &lineEndPos, int &valuePos);
|
||||||
bool adaptRulesFile(const ProjectExplorer::Project *project);
|
bool adaptRulesFile(const ProjectExplorer::Project *project);
|
||||||
bool adaptControlFile(const ProjectExplorer::Project *project);
|
bool adaptControlFile(const ProjectExplorer::Project *project);
|
||||||
void adaptControlFileField(QByteArray &document, const QByteArray &fieldName,
|
bool adaptControlFileField(QByteArray &document, const QByteArray &fieldName,
|
||||||
const QByteArray &newFieldValue);
|
const QByteArray &newFieldValue);
|
||||||
QSharedPointer<QFile> openFile(const QString &filePath,
|
QSharedPointer<QFile> openFile(const QString &filePath,
|
||||||
QIODevice::OpenMode mode, QString *error) const;
|
QIODevice::OpenMode mode, QString *error) const;
|
||||||
|
bool setFieldValue(const ProjectExplorer::Project *project,
|
||||||
|
const QByteArray &fieldName, const QByteArray &fieldValue);
|
||||||
|
|
||||||
static MaemoTemplatesManager *m_instance;
|
static MaemoTemplatesManager *m_instance;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user