2011-02-18 10:36:52 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-02-18 10:36:52 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
#include "targetsettingswidget.h"
|
|
|
|
|
#include "ui_targetsettingswidget.h"
|
|
|
|
|
|
2012-08-10 03:01:56 +02:00
|
|
|
#include <QPushButton>
|
2010-01-18 12:48:27 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
TargetSettingsWidget::TargetSettingsWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
ui(new Ui::TargetSettingsWidget),
|
|
|
|
|
m_targetSelector(new TargetSelector(this))
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2012-08-10 03:01:56 +02:00
|
|
|
ui->header->setStyleSheet(QLatin1String("QWidget#header {"
|
|
|
|
|
"border-image: url(:/projectexplorer/images/targetseparatorbackground.png) 43 0 0 0 repeat;"
|
2010-01-18 12:48:27 +01:00
|
|
|
"}"));
|
2012-08-10 03:01:56 +02:00
|
|
|
|
|
|
|
|
QHBoxLayout *headerLayout = new QHBoxLayout;
|
|
|
|
|
headerLayout->setContentsMargins(5, 3, 0, 0);
|
|
|
|
|
ui->header->setLayout(headerLayout);
|
|
|
|
|
|
|
|
|
|
QWidget *buttonWidget = new QWidget(ui->header);
|
|
|
|
|
QVBoxLayout *buttonLayout = new QVBoxLayout;
|
|
|
|
|
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
buttonLayout->setSpacing(4);
|
|
|
|
|
buttonWidget->setLayout(buttonLayout);
|
|
|
|
|
m_addButton = new QPushButton(tr("Add"), buttonWidget);
|
|
|
|
|
buttonLayout->addWidget(m_addButton);
|
|
|
|
|
m_manageButton = new QPushButton(tr("Manage ..."), buttonWidget);
|
|
|
|
|
connect(m_manageButton, SIGNAL(clicked()), this, SIGNAL(manageButtonClicked()));
|
|
|
|
|
buttonLayout->addWidget(m_manageButton);
|
|
|
|
|
headerLayout->addWidget(buttonWidget, 0, Qt::AlignVCenter);
|
|
|
|
|
|
|
|
|
|
headerLayout->addWidget(m_targetSelector, 0, Qt::AlignBottom);
|
|
|
|
|
headerLayout->addStretch(10);
|
|
|
|
|
connect(m_targetSelector, SIGNAL(removeButtonClicked(int)),
|
|
|
|
|
this, SIGNAL(removeButtonClicked(int)));
|
2010-02-26 13:45:07 +01:00
|
|
|
connect(m_targetSelector, SIGNAL(currentChanged(int,int)),
|
|
|
|
|
this, SIGNAL(currentChanged(int,int)));
|
2010-05-07 16:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
QPalette shadowPal = palette();
|
|
|
|
|
QLinearGradient grad(0, 0, 0, 2);
|
|
|
|
|
grad.setColorAt(0, QColor(0, 0, 0, 60));
|
|
|
|
|
grad.setColorAt(1, Qt::transparent);
|
|
|
|
|
shadowPal.setBrush(QPalette::All, QPalette::Window, grad);
|
2012-08-10 03:01:56 +02:00
|
|
|
ui->shadow->setPalette(shadowPal);
|
|
|
|
|
ui->shadow->setAutoFillBackground(true);
|
2010-01-18 12:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TargetSettingsWidget::~TargetSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-22 14:41:34 +01:00
|
|
|
void TargetSettingsWidget::insertTarget(int index, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->insertTarget(index, name);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void TargetSettingsWidget::renameTarget(int index, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->renameTarget(index, name);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
void TargetSettingsWidget::removeTarget(int index)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->removeTarget(index);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void TargetSettingsWidget::setCurrentIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsWidget::setCurrentSubIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->setCurrentSubIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 17:29:08 +01:00
|
|
|
void TargetSettingsWidget::setAddButtonEnabled(bool enabled)
|
|
|
|
|
{
|
2012-08-10 03:01:56 +02:00
|
|
|
m_addButton->setEnabled(enabled);
|
2010-02-10 17:29:08 +01:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
void TargetSettingsWidget::setAddButtonMenu(QMenu *menu)
|
|
|
|
|
{
|
2012-08-10 03:01:56 +02:00
|
|
|
m_addButton->setMenu(menu);
|
2010-02-10 17:29:08 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
QString TargetSettingsWidget::targetNameAt(int index) const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->targetAt(index).name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsWidget::setCentralWidget(QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
ui->scrollArea->setWidget(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TargetSettingsWidget::targetCount() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->targetCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TargetSettingsWidget::currentIndex() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->currentIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TargetSettingsWidget::currentSubIndex() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->currentSubIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsWidget::changeEvent(QEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
|
switch (e->type()) {
|
|
|
|
|
case QEvent::LanguageChange:
|
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|