Commit 1abcf0fb authored by Eike Ziller's avatar Eike Ziller

Android: Add configure Android item to "Add kit" menu in projects mode

Change-Id: Icab9df511d0cab349aaeb9420ae437af36836733
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 919cad1f
......@@ -46,7 +46,25 @@
using namespace Android;
using namespace Android::Internal;
QString AndroidPotentialKit::displayName() const
{
return tr("Configure Android...");
}
void Android::Internal::AndroidPotentialKit::executeFromMenu()
{
Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_CATEGORY,
Constants::ANDROID_SETTINGS_ID);
}
QWidget *AndroidPotentialKit::createWidget(QWidget *parent) const
{
if (!isEnabled())
return 0;
return new AndroidPotentialKitWidget(parent);
}
bool AndroidPotentialKit::isEnabled() const
{
QList<ProjectExplorer::Kit *> kits = ProjectExplorer::KitManager::kits();
foreach (ProjectExplorer::Kit *kit, kits) {
......@@ -54,7 +72,7 @@ QWidget *AndroidPotentialKit::createWidget(QWidget *parent) const
if (kit->isAutoDetected()
&& deviceId == Core::Id(Constants::ANDROID_DEVICE_ID)
&& !kit->isSdkProvided()) {
return 0;
return false;
}
}
......@@ -66,10 +84,7 @@ QWidget *AndroidPotentialKit::createWidget(QWidget *parent) const
}
}
if (!found) // no android qt
return 0;
return new AndroidPotentialKitWidget(parent);
return found;
}
AndroidPotentialKitWidget::AndroidPotentialKitWidget(QWidget *parent)
......
......@@ -40,7 +40,10 @@ class AndroidPotentialKit : public ProjectExplorer::IPotentialKit
{
Q_OBJECT
public:
QString displayName() const;
void executeFromMenu();
QWidget *createWidget(QWidget *parent) const;
bool isEnabled() const;
};
class AndroidPotentialKitWidget : public Utils::DetailsWidget
......
......@@ -40,7 +40,10 @@ class PROJECTEXPLORER_EXPORT IPotentialKit : public QObject
Q_OBJECT
public:
virtual ~IPotentialKit();
virtual QString displayName() const = 0;
virtual void executeFromMenu() = 0;
virtual QWidget *createWidget(QWidget *parent) const = 0;
virtual bool isEnabled() const = 0;
};
}
......
......@@ -31,6 +31,7 @@
#include "buildinfo.h"
#include "buildsettingspropertiespage.h"
#include "ipotentialkit.h"
#include "kitoptionspage.h"
#include "project.h"
#include "projectimporter.h"
......@@ -303,13 +304,20 @@ void TargetSettingsPanelWidget::duplicateActionTriggered(QAction *action)
void TargetSettingsPanelWidget::addActionTriggered(QAction *action)
{
Kit *k = KitManager::find(action->data().value<Core::Id>());
QTC_ASSERT(!m_project->target(k), return);
const QVariant data = action->data();
if (data.canConvert<Core::Id>()) { // id of kit
Kit *k = KitManager::find(action->data().value<Core::Id>());
QTC_ASSERT(!m_project->target(k), return);
Target *target = m_project->createTarget(k);
if (!target)
return;
m_project->addTarget(target);
Target *target = m_project->createTarget(k);
if (!target)
return;
m_project->addTarget(target);
} else {
QTC_ASSERT(data.canConvert<IPotentialKit *>(), return);
IPotentialKit *potentialKit = data.value<IPotentialKit *>();
potentialKit->executeFromMenu();
}
}
Target *TargetSettingsPanelWidget::cloneTarget(Target *sourceTarget, Kit *k)
......@@ -562,10 +570,19 @@ void TargetSettingsPanelWidget::updateTargetButtons()
m_addMenu->clear();
m_targetMenu->clear();
if (m_importAction) {
if (m_importAction)
m_addMenu->addAction(m_importAction);
m_addMenu->addSeparator();
const QList<IPotentialKit *> potentialKits
= ExtensionSystem::PluginManager::getObjects<IPotentialKit>();
foreach (IPotentialKit *potentialKit, potentialKits) {
if (!potentialKit->isEnabled())
continue;
QAction *action = new QAction(potentialKit->displayName(), m_addMenu);
action->setData(QVariant::fromValue(potentialKit));
m_addMenu->addAction(action);
}
if (!m_addMenu->actions().isEmpty())
m_addMenu->addSeparator();
m_changeMenu = m_targetMenu->addMenu(tr("Change Kit"));
m_duplicateMenu = m_targetMenu->addMenu(tr("Copy to Kit"));
......@@ -589,7 +606,6 @@ void TargetSettingsPanelWidget::updateTargetButtons()
createAction(k, m_changeMenu);
createAction(k, m_duplicateMenu);
}
if (m_changeMenu->actions().isEmpty())
m_changeMenu->setEnabled(false);
if (m_duplicateMenu->actions().isEmpty())
......
......@@ -165,8 +165,8 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
QList<IPotentialKit *> potentialKits =
ExtensionSystem::PluginManager::instance()->getObjects<IPotentialKit>();
foreach (IPotentialKit *pk, potentialKits)
if (QWidget *w = pk->createWidget(this))
m_potentialWidgets.append(w);
if (pk->isEnabled())
m_potentialWidgets.append(pk->createWidget(this));
setUseScrollArea(true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment