From 9a1e869cb48439b4dbe0d663b9377fb7f80b926d Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <daniel.molkentin@nokia.com>
Date: Mon, 18 May 2009 14:58:19 +0200
Subject: [PATCH] Always show a selection of the MSVC versions available, even
 for one.

Also, warn if no MSVC version could be detected even though the Qt
version was build with MSVC. This should make the tracing of problem
a bit easier. Before, we have hidden the GUI elements if only one
compiler version could be found. This looks inconsistent and causes
confusion.
---
 .../qt4projectmanager/qtoptionspage.cpp       |  24 ++-
 src/plugins/qt4projectmanager/qtoptionspage.h |   1 +
 .../qt4projectmanager/qtversionmanager.ui     | 138 ++++++++++++------
 3 files changed, 108 insertions(+), 55 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp
index 59efc8f678f..e61904d1df8 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.cpp
+++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp
@@ -5,6 +5,7 @@
 #include "qtversionmanager.h"
 #include <coreplugin/coreconstants.h>
 
+#include <QtCore/QDebug>
 #include <QtCore/QDir>
 
 using namespace Qt4ProjectManager;
@@ -254,25 +255,32 @@ void QtOptionsPageWidget::makeMingwVisible(bool visible)
     m_ui->mingwPath->setVisible(visible);
 }
 
+void QtOptionsPageWidget::makeMSVCVisible(bool visible)
+{
+    m_ui->msvcLabel->setVisible(visible);
+    m_ui->msvcComboBox->setVisible(visible);
+    m_ui->msvcNotFoundLabel->setVisible(false);
+}
+
 void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
 {
-    m_ui->msvcComboBox->setVisible(false);
     if (item) {
         int index = m_ui->qtdirList->indexOfTopLevelItem(item);
         m_ui->errorLabel->setText("");
         ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType();
         if (t == ProjectExplorer::ToolChain::MinGW) {
-            m_ui->msvcComboBox->setVisible(false);
+            makeMSVCVisible(false);
             makeMingwVisible(true);
             m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory());
         } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){
-            m_ui->msvcComboBox->setVisible(false);
+            makeMSVCVisible(false);
             makeMingwVisible(false);
             QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions();
             if (msvcEnvironments.count() == 0) {
-            } else if (msvcEnvironments.count() == 1) {
+                m_ui->msvcLabel->setVisible(true);
+                m_ui->msvcNotFoundLabel->setVisible(true);
             } else {
-                 m_ui->msvcComboBox->setVisible(true);
+                 makeMSVCVisible(true);
                  bool block = m_ui->msvcComboBox->blockSignals(true);
                  m_ui->msvcComboBox->clear();
                  foreach(const QString &msvcenv, msvcEnvironments) {
@@ -284,7 +292,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
                  m_ui->msvcComboBox->blockSignals(block);
             }
         } else if (t == ProjectExplorer::ToolChain::INVALID) {
-            m_ui->msvcComboBox->setVisible(false);
+            makeMSVCVisible(false);
             makeMingwVisible(false);
             if (!m_versions.at(index)->isInstalled())
                 m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install")
@@ -292,14 +300,14 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
             else
                 m_ui->errorLabel->setText(tr("%1 is not a valid Qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path())));
         } else { //ProjectExplorer::ToolChain::GCC
-            m_ui->msvcComboBox->setVisible(false);
+            makeMSVCVisible(false);
             makeMingwVisible(false);
             m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2")
                                      .arg(m_versions.at(index)->qtVersionString(),
                                           m_versions.at(index)->mkspec()));
         }
     } else {
-        m_ui->msvcComboBox->setVisible(false);
+        makeMSVCVisible(false);
         makeMingwVisible(false);
     }
 }
diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h
index be4fee3d8fb..71e0a538e79 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.h
+++ b/src/plugins/qt4projectmanager/qtoptionspage.h
@@ -72,6 +72,7 @@ private slots:
     void removeQtDir();
     void updateState();
     void makeMingwVisible(bool visible);
+    void makeMSVCVisible(bool visible);
     void onQtBrowsed();
     void onMingwBrowsed();
     void defaultChanged(int index);
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui
index 9cf20900683..3f9cc7303ac 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.ui
+++ b/src/plugins/qt4projectmanager/qtversionmanager.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>811</width>
-    <height>505</height>
+    <width>577</width>
+    <height>477</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -16,8 +16,36 @@
      <property name="title">
       <string>Qt versions</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <item row="0" column="3">
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0" colspan="2">
+       <widget class="QTreeWidget" name="qtdirList">
+        <property name="uniformRowHeights">
+         <bool>true</bool>
+        </property>
+        <property name="itemsExpandable">
+         <bool>false</bool>
+        </property>
+        <property name="columnCount">
+         <number>3</number>
+        </property>
+        <column>
+         <property name="text">
+          <string>Name</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>Path</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>Debugging Helper</string>
+         </property>
+        </column>
+       </widget>
+      </item>
+      <item row="0" column="2">
        <layout class="QVBoxLayout">
         <property name="spacing">
          <number>6</number>
@@ -66,34 +94,6 @@
         </item>
        </layout>
       </item>
-      <item row="0" column="0" colspan="3">
-       <widget class="QTreeWidget" name="qtdirList">
-        <property name="uniformRowHeights">
-         <bool>true</bool>
-        </property>
-        <property name="itemsExpandable">
-         <bool>false</bool>
-        </property>
-        <property name="columnCount">
-         <number>3</number>
-        </property>
-        <column>
-         <property name="text">
-          <string>Name</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>Path</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>Debugging Helper</string>
-         </property>
-        </column>
-       </widget>
-      </item>
       <item row="1" column="0">
        <widget class="QLabel" name="versionNameLabel">
         <property name="text">
@@ -101,7 +101,7 @@
         </property>
        </widget>
       </item>
-      <item row="1" column="1" colspan="2">
+      <item row="1" column="1">
        <widget class="QLineEdit" name="nameEdit"/>
       </item>
       <item row="2" column="0">
@@ -111,6 +111,9 @@
         </property>
        </widget>
       </item>
+      <item row="2" column="1">
+       <widget class="Core::Utils::PathChooser" name="qtPath" native="true"/>
+      </item>
       <item row="3" column="0">
        <widget class="QLabel" name="mingwLabel">
         <property name="text">
@@ -118,33 +121,67 @@
         </property>
        </widget>
       </item>
-      <item row="6" column="0" colspan="4">
-       <widget class="QLabel" name="errorLabel">
+      <item row="3" column="1">
+       <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/>
+      </item>
+      <item row="4" column="0">
+       <widget class="QLabel" name="msvcLabel">
         <property name="text">
-         <string/>
+         <string>MSVC Version:</string>
         </property>
        </widget>
       </item>
-      <item row="4" column="1" colspan="2">
-       <widget class="QComboBox" name="msvcComboBox"/>
-      </item>
-      <item row="2" column="1" colspan="2">
-       <widget class="Core::Utils::PathChooser" name="qtPath" native="true"/>
-      </item>
-      <item row="3" column="1" colspan="2">
-       <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/>
+      <item row="4" column="1">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QComboBox" name="msvcComboBox">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="msvcNotFoundLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;Unable to detect MSVC version.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
-      <item row="5" column="0">
+      <item row="6" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
          <string>Debugging Helper:</string>
         </property>
        </widget>
       </item>
-      <item row="5" column="1" colspan="2">
+      <item row="6" column="1">
        <layout class="QHBoxLayout" name="horizontalLayout_2">
         <item>
          <widget class="QLabel" name="debuggingHelperStateLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
           <property name="text">
            <string/>
           </property>
@@ -166,11 +203,18 @@
         </item>
        </layout>
       </item>
+      <item row="7" column="1">
+       <widget class="QLabel" name="errorLabel">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
      <item>
       <widget class="QLabel" name="defaultLabel">
        <property name="text">
-- 
GitLab