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
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
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
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
#include "targetsettingswidget.h"
|
|
|
|
|
#include "ui_targetsettingswidget.h"
|
|
|
|
|
|
2010-02-10 17:29:08 +01:00
|
|
|
static int WIDTH = 900;
|
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);
|
|
|
|
|
ui->separator->setStyleSheet(QLatin1String("* { "
|
|
|
|
|
"background-image: url(:/projectexplorer/images/targetseparatorbackground.png);"
|
|
|
|
|
"}"));
|
|
|
|
|
m_targetSelector->raise();
|
2010-02-10 17:29:08 +01:00
|
|
|
connect(m_targetSelector, SIGNAL(removeButtonClicked()),
|
|
|
|
|
this, SIGNAL(removeButtonClicked()));
|
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
|
|
|
|
|
|
|
|
m_shadow = new QWidget(this);
|
|
|
|
|
|
|
|
|
|
// Create shadow below targetselector
|
|
|
|
|
m_targetSelector->raise();
|
|
|
|
|
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);
|
|
|
|
|
m_shadow->setPalette(shadowPal);
|
|
|
|
|
m_shadow->setAutoFillBackground(true);
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
updateTargetSelector();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
updateTargetSelector();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void TargetSettingsWidget::renameTarget(int index, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->renameTarget(index, name);
|
|
|
|
|
// geometry won't change, so no need to updateTargetSelector()
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
void TargetSettingsWidget::removeTarget(int index)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->removeTarget(index);
|
2010-02-22 14:41:34 +01:00
|
|
|
updateTargetSelector();
|
2010-01-18 12:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->setAddButtonEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
void TargetSettingsWidget::setAddButtonMenu(QMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->setAddButtonMenu(menu);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 17:29:08 +01:00
|
|
|
void TargetSettingsWidget::setRemoveButtonEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
m_targetSelector->setRemoveButtonEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 17:29:08 +01:00
|
|
|
bool TargetSettingsWidget::isAddButtonEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->isAddButtonEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TargetSettingsWidget::isRemoveButtonEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetSelector->isRemoveButtonEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-07 16:48:33 +02:00
|
|
|
void TargetSettingsWidget::resizeEvent(QResizeEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QWidget::resizeEvent(e);
|
|
|
|
|
m_shadow->setGeometry(0, m_targetSelector->height() + 3, width(), 2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:48:27 +01:00
|
|
|
void TargetSettingsWidget::updateTargetSelector()
|
|
|
|
|
{
|
2010-05-07 16:48:33 +02:00
|
|
|
m_targetSelector->setGeometry((WIDTH-m_targetSelector->minimumSizeHint().width())/2, 13,
|
2010-01-18 12:48:27 +01:00
|
|
|
m_targetSelector->minimumSizeHint().width(),
|
|
|
|
|
m_targetSelector->minimumSizeHint().height());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsWidget::changeEvent(QEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
|
switch (e->type()) {
|
|
|
|
|
case QEvent::LanguageChange:
|
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|