diff options
author | hjk <hjk@qt.io> | 2018-09-07 08:27:44 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-09-10 10:18:27 +0000 |
commit | 097de6c5d0753258c54e517d3f6e3c6b0df1f3ad (patch) | |
tree | a760d449322493efb6a94b1a885793c1f9a9f172 /src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp | |
parent | 53f0e6c0eee68b4c971a01e15cf1277d252edd64 (diff) | |
download | qt-creator-097de6c5d0753258c54e517d3f6e3c6b0df1f3ad.tar.gz |
QmlProjectManager: Aspect-ify runconfiguration
Split the remaining manually managed data into a standard ArgumentsAspect
and a new MainQmlFileAspect.
Change-Id: I8a8fe3f4a08d602a7b6e9c9463d3d7de257b6e6c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp')
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp deleted file mode 100644 index a20b0363b1..0000000000 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "qmlprojectrunconfigurationwidget.h" -#include "qmlprojectrunconfiguration.h" -#include "qmlproject.h" - -#include <coreplugin/icore.h> -#include <projectexplorer/projectexplorer.h> -#include <projectexplorer/target.h> - -#include <utils/algorithm.h> - -#include <QLineEdit> -#include <QComboBox> -#include <QFormLayout> -#include <QLabel> -#include <QStandardItemModel> - - -using Core::ICore; -using ProjectExplorer::ProjectExplorerPlugin; - -namespace QmlProjectManager { -namespace Internal { - -QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc) : - m_runConfiguration(rc), - m_fileListModel(new QStandardItemModel(this)) -{ - auto form = new QFormLayout(this); - rc->qmlViewerAspect()->addToConfigurationLayout(form); - - m_fileListCombo = new QComboBox; - m_fileListCombo->setModel(m_fileListModel); - - connect(m_fileListCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), - this, &QmlProjectRunConfigurationWidget::setMainScript); - connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::fileListChanged, - this, &QmlProjectRunConfigurationWidget::updateFileComboBox); - - QLineEdit *qmlViewerArgs = new QLineEdit; - qmlViewerArgs->setText(rc->m_qmlViewerArgs); - connect(qmlViewerArgs, &QLineEdit::textChanged, - this, &QmlProjectRunConfigurationWidget::onViewerArgsChanged); - - form->addRow(tr("Arguments:"), qmlViewerArgs); - form->addRow(tr("Main QML file:"), m_fileListCombo); - - updateFileComboBox(); - - connect(rc, &QmlProjectRunConfiguration::scriptSourceChanged, - this, &QmlProjectRunConfigurationWidget::updateFileComboBox); -} - -static bool caseInsensitiveLessThan(const QString &s1, const QString &s2) -{ - return s1.toLower() < s2.toLower(); -} - -void QmlProjectRunConfigurationWidget::updateFileComboBox() -{ - ProjectExplorer::Project *project = m_runConfiguration->target()->project(); - QDir projectDir(project->projectDirectory().toString()); - - if (m_runConfiguration->mainScriptSource() == QmlProjectRunConfiguration::FileInProjectFile) { - const QString mainScriptInFilePath - = projectDir.relativeFilePath(m_runConfiguration->mainScript()); - m_fileListModel->clear(); - m_fileListModel->appendRow(new QStandardItem(mainScriptInFilePath)); - m_fileListCombo->setEnabled(false); - return; - } - - m_fileListCombo->setEnabled(true); - m_fileListModel->clear(); - m_fileListModel->appendRow(new QStandardItem(QLatin1String(CURRENT_FILE))); - QModelIndex currentIndex; - - QStringList sortedFiles = Utils::transform(project->files(ProjectExplorer::Project::AllFiles), - &Utils::FileName::toString); - - // make paths relative to project directory - QStringList relativeFiles; - foreach (const QString &fn, sortedFiles) { - relativeFiles += projectDir.relativeFilePath(fn); - } - sortedFiles = relativeFiles; - - std::stable_sort(sortedFiles.begin(), sortedFiles.end(), caseInsensitiveLessThan); - - QString mainScriptPath; - if (m_runConfiguration->mainScriptSource() != QmlProjectRunConfiguration::FileInEditor) - mainScriptPath = projectDir.relativeFilePath(m_runConfiguration->mainScript()); - - foreach (const QString &fn, sortedFiles) { - QFileInfo fileInfo(fn); - if (fileInfo.suffix() != QLatin1String("qml")) - continue; - - QStandardItem *item = new QStandardItem(fn); - m_fileListModel->appendRow(item); - - if (mainScriptPath == fn) - currentIndex = item->index(); - } - - if (currentIndex.isValid()) - m_fileListCombo->setCurrentIndex(currentIndex.row()); - else - m_fileListCombo->setCurrentIndex(0); -} - -void QmlProjectRunConfigurationWidget::setMainScript(int index) -{ - if (index == 0) { - m_runConfiguration->setScriptSource(QmlProjectRunConfiguration::FileInEditor); - } else { - const QString path = m_fileListModel->data(m_fileListModel->index(index, 0)).toString(); - m_runConfiguration->setScriptSource(QmlProjectRunConfiguration::FileInSettings, path); - } -} - -void QmlProjectRunConfigurationWidget::onViewerArgsChanged() -{ - if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender())) - m_runConfiguration->m_qmlViewerArgs = lineEdit->text(); -} - -} // namespace Internal -} // namespace QmlProjectManager |