| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** Copyright (C) 2015 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: http://www.qt.io/licensing
 | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** 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 | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** a written agreement between you and The Qt Company.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://www.qt.io/terms-conditions.  For further information
 | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** use the contact form at http://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** General Public License version 2.1 or version 3 as published by the Free | 
					
						
							|  |  |  | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
					
						
							|  |  |  | ** LICENSE.LGPLv3 included in the packaging of this file.  Please review the | 
					
						
							|  |  |  | ** following information to ensure the GNU Lesser General Public License | 
					
						
							|  |  |  | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** In addition, as a special exception, The Qt Company gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in The Qt Company LGPL Exception | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "startremotedialog.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | #include <projectexplorer/kitchooser.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  | #include <ssh/sshconnection.h>
 | 
					
						
							| 
									
										
										
										
											2011-08-17 13:37:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  | #include <QDialogButtonBox>
 | 
					
						
							|  |  |  | #include <QFormLayout>
 | 
					
						
							|  |  |  | #include <QLineEdit>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QPushButton>
 | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  | using namespace ProjectExplorer; | 
					
						
							|  |  |  | using namespace Utils; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | namespace Analyzer { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class StartRemoteDialogPrivate | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-07-20 12:40:28 +03:00
										 |  |  |     KitChooser *kitChooser; | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     QLineEdit *executable; | 
					
						
							|  |  |  |     QLineEdit *arguments; | 
					
						
							|  |  |  |     QLineEdit *workingDirectory; | 
					
						
							|  |  |  |     QDialogButtonBox *buttonBox; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Internal
 | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-04 10:50:44 +02:00
										 |  |  | StartRemoteDialog::StartRemoteDialog(QWidget *parent) | 
					
						
							|  |  |  |     : QDialog(parent) | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     , d(new Internal::StartRemoteDialogPrivate) | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | 
					
						
							|  |  |  |     setWindowTitle(tr("Start Remote Analysis")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 12:40:28 +03:00
										 |  |  |     d->kitChooser = new KitChooser(this); | 
					
						
							|  |  |  |     d->kitChooser->setKitMatcher([](const Kit *kit) { | 
					
						
							|  |  |  |         const IDevice::ConstPtr device = DeviceKitInformation::device(kit); | 
					
						
							|  |  |  |         return kit->isValid() && device && !device->sshParameters().host.isEmpty(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     d->executable = new QLineEdit(this); | 
					
						
							|  |  |  |     d->arguments = new QLineEdit(this); | 
					
						
							|  |  |  |     d->workingDirectory = new QLineEdit(this); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     d->buttonBox = new QDialogButtonBox(this); | 
					
						
							|  |  |  |     d->buttonBox->setOrientation(Qt::Horizontal); | 
					
						
							|  |  |  |     d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     QFormLayout *formLayout = new QFormLayout; | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |     formLayout->addRow(tr("Kit:"), d->kitChooser); | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     formLayout->addRow(tr("Executable:"), d->executable); | 
					
						
							|  |  |  |     formLayout->addRow(tr("Arguments:"), d->arguments); | 
					
						
							|  |  |  |     formLayout->addRow(tr("Working directory:"), d->workingDirectory); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QVBoxLayout *verticalLayout = new QVBoxLayout(this); | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     verticalLayout->addLayout(formLayout); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     verticalLayout->addWidget(d->buttonBox); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2012-01-25 17:39:50 +01:00
										 |  |  |     settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); | 
					
						
							| 
									
										
										
										
											2012-09-11 09:54:18 +02:00
										 |  |  |     d->kitChooser->populate(); | 
					
						
							| 
									
										
										
										
											2013-03-19 12:29:17 +01:00
										 |  |  |     d->kitChooser->setCurrentKitId(Core::Id::fromSetting(settings->value(QLatin1String("profile")))); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     d->executable->setText(settings->value(QLatin1String("executable")).toString()); | 
					
						
							|  |  |  |     d->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString()); | 
					
						
							|  |  |  |     d->arguments->setText(settings->value(QLatin1String("arguments")).toString()); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-29 10:42:16 +01:00
										 |  |  |     connect(d->kitChooser, &KitChooser::activated, this, &StartRemoteDialog::validate); | 
					
						
							|  |  |  |     connect(d->executable, &QLineEdit::textChanged, this, &StartRemoteDialog::validate); | 
					
						
							|  |  |  |     connect(d->workingDirectory, &QLineEdit::textChanged, this, &StartRemoteDialog::validate); | 
					
						
							|  |  |  |     connect(d->arguments, &QLineEdit::textChanged, this, &StartRemoteDialog::validate); | 
					
						
							|  |  |  |     connect(d->buttonBox, &QDialogButtonBox::accepted, this, &StartRemoteDialog::accept); | 
					
						
							|  |  |  |     connect(d->buttonBox, &QDialogButtonBox::rejected, this, &StartRemoteDialog::reject); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     validate(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | StartRemoteDialog::~StartRemoteDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     delete d; | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void StartRemoteDialog::accept() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2012-01-25 17:39:50 +01:00
										 |  |  |     settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |     settings->setValue(QLatin1String("profile"), d->kitChooser->currentKitId().toString()); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     settings->setValue(QLatin1String("executable"), d->executable->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("workingDirectory"), d->workingDirectory->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("arguments"), d->arguments->text()); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QDialog::accept(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void StartRemoteDialog::validate() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     bool valid = !d->executable->text().isEmpty(); | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  | QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |     Kit *kit = d->kitChooser->currentKit(); | 
					
						
							|  |  |  |     IDevice::ConstPtr device = DeviceKitInformation::device(kit); | 
					
						
							| 
									
										
										
										
											2012-07-18 17:08:10 +02:00
										 |  |  |     return device->sshParameters(); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::executable() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     return d->executable->text(); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::arguments() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     return d->arguments->text(); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::workingDirectory() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-28 13:30:09 +02:00
										 |  |  |     return d->workingDirectory->text(); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 15:56:01 +02:00
										 |  |  | } // namespace Analyzer
 |