Commit a8d0b04f authored by Daniel Teske's avatar Daniel Teske Committed by hjk

Show incompatible kits in Add Kit

And implement a tooltip for them

Task-number: QTCREATORBUG-7870
Change-Id: I4975dd24ca2b619ebcbd0393f97311590ed4930f
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 2f3b010d
......@@ -243,9 +243,10 @@ Target *Project::target(Kit *k) const
return 0;
}
bool Project::supportsKit(Kit *k) const
bool Project::supportsKit(Kit *k, QString *errorMessage) const
{
Q_UNUSED(k);
Q_UNUSED(errorMessage);
return true;
}
......
......@@ -90,7 +90,7 @@ public:
void setActiveTarget(Target *target);
Target *target(const Core::Id id) const;
Target *target(Kit *k) const;
virtual bool supportsKit(Kit *k) const;
virtual bool supportsKit(Kit *k, QString *errorMessage = 0) const;
Target *createTarget(Kit *k);
Target *restoreTarget(const QVariantMap &data);
......
......@@ -55,6 +55,7 @@
#include <QStackedWidget>
#include <QToolTip>
#include <QVBoxLayout>
#include <QToolTip>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
......@@ -68,7 +69,8 @@ TargetSettingsPanelWidget::TargetSettingsPanelWidget(Project *project) :
m_currentTarget(0),
m_project(project),
m_selector(0),
m_centralWidget(0)
m_centralWidget(0),
m_lastAction(0)
{
Q_ASSERT(m_project);
......@@ -97,6 +99,33 @@ TargetSettingsPanelWidget::~TargetSettingsPanelWidget()
{
}
bool TargetSettingsPanelWidget::event(QEvent *event)
{
if (event->type() == QEvent::StatusTip) {
QStatusTipEvent *ev = static_cast<QStatusTipEvent *>(event);
ev->accept();
QAction *act = m_addMenu->activeAction();
if (act != m_lastAction)
QToolTip::showText(QPoint(), QString());
m_lastAction = act;
if (act) {
QRect actionRect = m_addMenu->actionGeometry(act);
actionRect.translate(m_addMenu->pos());
QPoint p = QCursor::pos();
if (!actionRect.contains(p))
p = actionRect.center();
p.setY(actionRect.center().y());
QToolTip::showText(p, ev->tip(), m_addMenu, m_addMenu->actionGeometry(act));
} else {
QToolTip::showText(QPoint(), QString());
}
return true;
}
return QWidget::event(event);
}
void TargetSettingsPanelWidget::setupUi()
{
QVBoxLayout *viewLayout = new QVBoxLayout(this);
......@@ -315,11 +344,14 @@ void TargetSettingsPanelWidget::updateTargetAddAndRemoveButtons()
foreach (Kit *k, KitManager::instance()->kits()) {
if (m_project->target(k))
continue;
if (!m_project->supportsKit(k))
continue;
QAction *action = new QAction(k->displayName(), m_addMenu);
action->setData(QVariant::fromValue(k->id()));
QString errorMessage;
if (!m_project->supportsKit(k, &errorMessage)) {
action->setEnabled(false);
action->setStatusTip(errorMessage);
}
bool inserted = false;
foreach (QAction *existing, m_addMenu->actions()) {
......
......@@ -61,6 +61,8 @@ public:
int currentSubIndex() const;
void setCurrentSubIndex(int subIndex);
protected:
bool event(QEvent *event);
private slots:
void currentTargetChanged(int targetIndex, int subIndex);
void removeTarget(int targetIndex);
......@@ -82,6 +84,7 @@ private:
PanelsWidget *m_panelWidgets[2];
QList<Target *> m_targets;
QMenu *m_addMenu;
QAction *m_lastAction;
};
} // namespace Internal
......
......@@ -269,14 +269,19 @@ ProjectExplorer::IProjectManager *QmlProject::projectManager() const
return m_manager;
}
bool QmlProject::supportsKit(ProjectExplorer::Kit *k) const
bool QmlProject::supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const
{
Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
if (errorMessage)
*errorMessage = tr("Device type is not desktop.");
return false;
}
// TODO: Limit supported versions?
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
if (!version && errorMessage)
*errorMessage = tr("No Qt version set in kit.");
return version;
}
......
......@@ -65,7 +65,7 @@ public:
Core::IDocument *document() const;
ProjectExplorer::IProjectManager *projectManager() const;
bool supportsKit(ProjectExplorer::Kit *k) const;
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const;
QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
......
......@@ -864,9 +864,11 @@ Qt4Manager *Qt4Project::qt4ProjectManager() const
return m_manager;
}
bool Qt4Project::supportsKit(Kit *k) const
bool Qt4Project::supportsKit(Kit *k, QString *errorMessage) const
{
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
if (!version && errorMessage)
*errorMessage = tr("No Qt version set in kit.");
return version;
}
......
......@@ -83,7 +83,7 @@ public:
ProjectExplorer::IProjectManager *projectManager() const;
Qt4Manager *qt4ProjectManager() const;
bool supportsKit(ProjectExplorer::Kit *k) const;
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const;
ProjectExplorer::ProjectNode *rootProjectNode() const;
Qt4ProFileNode *rootQt4ProjectNode() const;
......
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