~ubuntu-sdk-team/qtcreator-plugin-remotelinux/trunk

« back to all changes in this revision

Viewing changes to src/qnx/bardescriptoreditorentrypointwidget.cpp

  • Committer: CI bot
  • Author(s): Benjamin Zeller
  • Date: 2014-06-16 10:28:43 UTC
  • mfrom: (4.2.4 remotelinux)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616102843-8juvmjvzwlzsboyw
Migrating to Qt5.3 and QtC 3.1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    m_ui->setupUi(this);
58
58
 
59
59
    m_ui->iconFilePath->setExpectedKind(Utils::PathChooser::File);
 
60
    m_ui->iconFilePath->setHistoryCompleter(QLatin1String("Qmake.Icon.History"));
60
61
    m_ui->iconFilePath->setPromptDialogFilter(tr("Images (*.jpg *.png)"));
61
62
 
62
63
    m_ui->iconWarningLabel->setVisible(false);
65
66
    m_ui->splashScreenWarningLabel->setVisible(false);
66
67
    m_ui->splashScreenWarningPixmap->setVisible(false);
67
68
 
68
 
    connect(m_ui->applicationName, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
69
 
    connect(m_ui->applicationDescription, SIGNAL(textChanged()), this, SIGNAL(changed()));
70
 
 
71
69
    connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(handleIconChanged(QString)));
72
70
    connect(m_ui->iconClearButton, SIGNAL(clicked()), this, SLOT(clearIcon()));
73
71
 
75
73
    m_ui->splashScreensView->setModel(m_splashScreenModel);
76
74
    connect(m_ui->addSplashScreen, SIGNAL(clicked()), this, SLOT(browseForSplashScreen()));
77
75
    connect(m_ui->removeSplashScreen, SIGNAL(clicked()), this, SLOT(removeSelectedSplashScreen()));
78
 
    connect(m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
79
76
    connect(m_ui->splashScreensView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSplashScreenSelectionChanged(QItemSelection,QItemSelection)));
 
77
 
 
78
    addSignalMapping(BarDescriptorDocument::name, m_ui->applicationName, SIGNAL(textChanged(QString)));
 
79
    addSignalMapping(BarDescriptorDocument::description, m_ui->applicationDescription, SIGNAL(textChanged()));
 
80
    addSignalMapping(BarDescriptorDocument::icon, m_ui->iconFilePath, SIGNAL(changed(QString)));
 
81
    addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
 
82
    addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(rowsRemoved(QModelIndex,int,int)));
 
83
    addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(rowsInserted(QModelIndex,int,int)));
80
84
}
81
85
 
82
86
BarDescriptorEditorEntryPointWidget::~BarDescriptorEditorEntryPointWidget()
84
88
    delete m_ui;
85
89
}
86
90
 
87
 
void BarDescriptorEditorEntryPointWidget::clear()
88
 
{
89
 
    setPathChooserBlocked(m_ui->iconFilePath, QString());
90
 
    setApplicationIconPreview(QString());
91
 
 
92
 
    disconnect(m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
93
 
    m_splashScreenModel->setStringList(QStringList());
94
 
    connect(m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
95
 
    setImagePreview(m_ui->splashScreenPreviewLabel, QString());
96
 
}
97
 
 
98
 
QString BarDescriptorEditorEntryPointWidget::applicationName() const
99
 
{
100
 
    return m_ui->applicationName->text();
101
 
}
102
 
 
103
 
void BarDescriptorEditorEntryPointWidget::setApplicationName(const QString &applicationName)
104
 
{
105
 
    setLineEditBlocked(m_ui->applicationName, applicationName);
106
 
}
107
 
 
108
 
QString BarDescriptorEditorEntryPointWidget::applicationDescription() const
109
 
{
110
 
    return m_ui->applicationDescription->toPlainText();
111
 
}
112
 
 
113
 
void BarDescriptorEditorEntryPointWidget::setApplicationDescription(const QString &applicationDescription)
114
 
{
115
 
    setTextEditBlocked(m_ui->applicationDescription, applicationDescription);
116
 
}
117
 
 
118
 
QString BarDescriptorEditorEntryPointWidget::applicationIconFileName() const
119
 
{
120
 
    return QFileInfo(m_ui->iconFilePath->path()).fileName();
121
 
}
122
 
 
123
 
void BarDescriptorEditorEntryPointWidget::setApplicationIcon(const QString &iconPath)
124
 
{
125
 
    // During file loading, the assets might not have been read yet
126
 
    QMetaObject::invokeMethod(this, "setApplicationIconDelayed", Qt::QueuedConnection, Q_ARG(QString, iconPath));
127
 
}
128
 
 
129
 
QStringList BarDescriptorEditorEntryPointWidget::splashScreens() const
130
 
{
131
 
    QStringList result;
132
 
 
133
 
    foreach (const QString &splashScreen, m_splashScreenModel->stringList())
134
 
        result << QFileInfo(splashScreen).fileName();
135
 
 
136
 
    return result;
137
 
}
138
 
 
139
 
void BarDescriptorEditorEntryPointWidget::appendSplashScreen(const QString &splashScreenPath)
140
 
{
141
 
    QMetaObject::invokeMethod(this, "appendSplashScreenDelayed", Qt::QueuedConnection, Q_ARG(QString, splashScreenPath));
142
 
}
143
 
 
144
91
void BarDescriptorEditorEntryPointWidget::setAssetsModel(QStandardItemModel *assetsModel)
145
92
{
146
93
    m_assetsModel = QWeakPointer<QStandardItemModel>(assetsModel);
147
94
}
148
95
 
 
96
void BarDescriptorEditorEntryPointWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value)
 
97
{
 
98
    // During file loading, the assets might not have been read yet
 
99
    if (tag == BarDescriptorDocument::icon) {
 
100
        QMetaObject::invokeMethod(this, "setApplicationIconDelayed", Qt::QueuedConnection, Q_ARG(QString, value.toString()));
 
101
    } else if (tag == BarDescriptorDocument::splashScreens) {
 
102
        QStringList splashScreens = value.toStringList();
 
103
        foreach (const QString &splashScreen, splashScreens)
 
104
            QMetaObject::invokeMethod(this, "appendSplashScreenDelayed", Qt::QueuedConnection, Q_ARG(QString, splashScreen));
 
105
    } else {
 
106
        BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value);
 
107
    }
 
108
}
 
109
 
 
110
void BarDescriptorEditorEntryPointWidget::emitChanged(BarDescriptorDocument::Tag tag)
 
111
{
 
112
    if (tag == BarDescriptorDocument::icon) {
 
113
        emit changed(tag, QFileInfo(m_ui->iconFilePath->path()).fileName());
 
114
    } else if (tag == BarDescriptorDocument::splashScreens) {
 
115
        QStringList list;
 
116
        foreach (const QString &splashScreen, m_splashScreenModel->stringList())
 
117
            list << QFileInfo(splashScreen).fileName();
 
118
 
 
119
        emit changed(tag, list);
 
120
    } else {
 
121
        BarDescriptorEditorAbstractPanelWidget::emitChanged(tag);
 
122
    }
 
123
}
 
124
 
149
125
void BarDescriptorEditorEntryPointWidget::setApplicationIconPreview(const QString &path)
150
126
{
151
127
    setImagePreview(m_ui->iconPreviewLabel, path);
164
140
    setApplicationIconPreview(path);
165
141
    validateIconSize(path);
166
142
 
167
 
    emit changed();
168
 
    emit imageRemoved(m_prevIconPath);
 
143
    if (!m_splashScreenModel->stringList().contains(m_prevIconPath))
 
144
        emit imageRemoved(m_prevIconPath);
169
145
 
170
146
    m_prevIconPath = path;
171
147
    if (QFileInfo(path).exists())
200
176
 
201
177
    foreach (const QModelIndex &index, selectedIndexes) {
202
178
        QString path = m_splashScreenModel->data(index, Qt::DisplayRole).toString();
203
 
        emit imageRemoved(path);
 
179
        if (path != m_ui->iconFilePath->path())
 
180
            emit imageRemoved(path);
204
181
 
205
182
        m_splashScreenModel->removeRow(index.row());
206
183
    }
230
207
    if (fullSplashScreenPath.isEmpty())
231
208
        return;
232
209
 
233
 
    disconnect(m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
 
210
    blockSignalMapping(BarDescriptorDocument::splashScreens);
234
211
    int rowCount = m_splashScreenModel->rowCount();
235
212
    m_splashScreenModel->insertRow(rowCount);
236
213
    m_splashScreenModel->setData(m_splashScreenModel->index(rowCount), fullSplashScreenPath);
237
 
    connect(m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
 
214
    unblockSignalMapping(BarDescriptorDocument::splashScreens);
238
215
}
239
216
 
240
217
void BarDescriptorEditorEntryPointWidget::setImagePreview(QLabel *previewLabel, const QString &path)
309
286
    if (fullIconPath.isEmpty())
310
287
        return;
311
288
 
312
 
    setPathChooserBlocked(m_ui->iconFilePath, fullIconPath);
 
289
    blockSignalMapping(BarDescriptorDocument::icon);
 
290
    m_ui->iconFilePath->setPath(fullIconPath);
313
291
    setApplicationIconPreview(fullIconPath);
314
292
    validateIconSize(fullIconPath);
 
293
    unblockSignalMapping(BarDescriptorDocument::icon);
315
294
}
316
295
 
317
296
QString BarDescriptorEditorEntryPointWidget::localAssetPathFromDestination(const QString &destination)