forked from qt-creator/qt-creator
Maemo: Let user edit Debian files via the packaging widget.
This will give an additional hint to users that they can and should adapt the Debian template files. Reviewed-by: kh1
This commit is contained in:
@@ -43,11 +43,13 @@
|
||||
#include "ui_maemopackagecreationwidget.h"
|
||||
|
||||
#include "maemopackagecreationstep.h"
|
||||
#include "maemotemplatesmanager.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QMessageBox>
|
||||
@@ -63,14 +65,14 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
|
||||
m_ui->setupUi(this);
|
||||
m_ui->skipCheckBox->setChecked(!m_step->isPackagingEnabled());
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QTimer::singleShot(0, this, SLOT(initVersion()));
|
||||
QTimer::singleShot(0, this, SLOT(initGui()));
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::init()
|
||||
{
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::initVersion()
|
||||
void MaemoPackageCreationWidget::initGui()
|
||||
{
|
||||
QString error;
|
||||
QString versionString = m_step->versionString(&error);
|
||||
@@ -86,6 +88,13 @@ void MaemoPackageCreationWidget::initVersion()
|
||||
connect(m_step, SIGNAL(packageFilePathChanged()), this,
|
||||
SIGNAL(updateSummary()));
|
||||
versionInfoChanged();
|
||||
|
||||
const QStringList &debianFiles = MaemoTemplatesManager::instance()
|
||||
->debianFiles(m_step->buildConfiguration()->target()->project());
|
||||
foreach (const QString &fileName, debianFiles) {
|
||||
if (fileName != QLatin1String("compat"))
|
||||
m_ui->debianFilesComboBox->addItem(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationWidget::summaryText() const
|
||||
@@ -103,6 +112,8 @@ void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked)
|
||||
m_ui->major->setEnabled(!checked);
|
||||
m_ui->minor->setEnabled(!checked);
|
||||
m_ui->patch->setEnabled(!checked);
|
||||
m_ui->debianFilesComboBox->setEnabled(!checked);
|
||||
m_ui->editDebianFileButton->setEnabled(!checked);
|
||||
m_step->setPackagingEnabled(!checked);
|
||||
}
|
||||
|
||||
@@ -116,5 +127,13 @@ void MaemoPackageCreationWidget::versionInfoChanged()
|
||||
QMessageBox::critical(this, tr("Could not set version number"), error);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::editDebianFile()
|
||||
{
|
||||
const QString debianFilePath = MaemoTemplatesManager::instance()
|
||||
->debianDirPath(m_step->buildConfiguration()->target()->project())
|
||||
+ QLatin1Char('/') + m_ui->debianFilesComboBox->currentText();
|
||||
Core::EditorManager::instance()->openEditor(debianFilePath);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -65,8 +65,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void handleSkipButtonToggled(bool checked);
|
||||
void editDebianFile();
|
||||
void versionInfoChanged();
|
||||
void initVersion();
|
||||
void initGui();
|
||||
|
||||
private:
|
||||
MaemoPackageCreationStep * const m_step;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="skipCheckBox">
|
||||
<property name="toolTip">
|
||||
@@ -28,27 +28,27 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -60,28 +60,12 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Version number:</string>
|
||||
<string><b>Version number:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
@@ -175,22 +159,43 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="editDebianFileLabel">
|
||||
<property name="text">
|
||||
<string><b>Adapt Debian file:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="debianFilesComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<widget class="QPushButton" name="editDebianFileButton">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
@@ -217,8 +222,8 @@
|
||||
<slot>versionInfoChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>83</x>
|
||||
<y>73</y>
|
||||
<x>241</x>
|
||||
<y>70</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>461</x>
|
||||
@@ -233,8 +238,8 @@
|
||||
<slot>versionInfoChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>233</x>
|
||||
<y>94</y>
|
||||
<x>338</x>
|
||||
<y>70</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>5</x>
|
||||
@@ -249,8 +254,8 @@
|
||||
<slot>versionInfoChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>339</x>
|
||||
<y>94</y>
|
||||
<x>435</x>
|
||||
<y>70</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>466</x>
|
||||
@@ -258,11 +263,28 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>editDebianFileButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>MaemoPackageCreationWidget</receiver>
|
||||
<slot>editDebianFile()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>293</x>
|
||||
<y>94</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>8</x>
|
||||
<y>86</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>addFile()</slot>
|
||||
<slot>removeFile()</slot>
|
||||
<slot>handleSkipButtonToggled(bool)</slot>
|
||||
<slot>versionInfoChanged()</slot>
|
||||
<slot>editDebianFile()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
@@ -146,7 +146,10 @@ void MaemoTemplatesManager::createTemplatesIfNecessary(ProjectExplorer::Target *
|
||||
const QStringList &files = debianDir.entryList(QDir::Files);
|
||||
QStringList filesToAddToProject;
|
||||
foreach (const QString &fileName, files) {
|
||||
if (fileName.endsWith(QLatin1String(".ex"), Qt::CaseInsensitive)) {
|
||||
if (fileName.endsWith(QLatin1String(".ex"), Qt::CaseInsensitive)
|
||||
|| fileName.compare(QLatin1String("README.debian"), Qt::CaseInsensitive) == 0
|
||||
|| fileName.compare(QLatin1String("dirs"), Qt::CaseInsensitive) == 0
|
||||
|| fileName.compare(QLatin1String("docs"), Qt::CaseInsensitive) == 0) {
|
||||
debianDir.remove(fileName);
|
||||
} else
|
||||
filesToAddToProject << debianDir.absolutePath()
|
||||
@@ -185,8 +188,7 @@ QString MaemoTemplatesManager::version(const Project *project,
|
||||
QString *error) const
|
||||
{
|
||||
const QString changeLogFilePath
|
||||
= project->projectDirectory() + QLatin1Char('/') + PackagingDirName
|
||||
+ QLatin1String("/debian/changelog");
|
||||
= debianDirPath(project) + QLatin1String("/changelog");
|
||||
const QString nativePath = QDir::toNativeSeparators(changeLogFilePath);
|
||||
QFile changeLog(changeLogFilePath);
|
||||
if (!changeLog.exists()) {
|
||||
@@ -218,9 +220,8 @@ QString MaemoTemplatesManager::version(const Project *project,
|
||||
bool MaemoTemplatesManager::setVersion(const Project *project,
|
||||
const QString &version, QString *error) const
|
||||
{
|
||||
const QString debianDir = project->projectDirectory() + QLatin1Char('/')
|
||||
+ PackagingDirName + QLatin1String("/debian/");
|
||||
const QString changeLogFilePath = debianDir + QLatin1String("changelog");
|
||||
const QString changeLogFilePath
|
||||
= debianDirPath(project) + QLatin1String("/changelog");
|
||||
const QString nativePath = QDir::toNativeSeparators(changeLogFilePath);
|
||||
QFile changeLog(changeLogFilePath);
|
||||
if (!changeLog.exists()) {
|
||||
@@ -247,6 +248,18 @@ bool MaemoTemplatesManager::setVersion(const Project *project,
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
|
||||
{
|
||||
return QDir(debianDirPath(project))
|
||||
.entryList(QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
}
|
||||
|
||||
QString MaemoTemplatesManager::debianDirPath(const Project *project) const
|
||||
{
|
||||
return project->projectDirectory() + QLatin1Char('/')
|
||||
+ PackagingDirName + QLatin1String("/debian");
|
||||
}
|
||||
|
||||
void MaemoTemplatesManager::raiseError(const QString &reason)
|
||||
{
|
||||
QMessageBox::critical(0, tr("Error creating Maemo templates"), reason);
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
bool setVersion(const ProjectExplorer::Project *project,
|
||||
const QString &version, QString *error) const;
|
||||
|
||||
QString debianDirPath(const ProjectExplorer::Project *project) const;
|
||||
QStringList debianFiles(const ProjectExplorer::Project *project) const;
|
||||
|
||||
static const QLatin1String PackagingDirName;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user