OSDN Git Service

QmlProject: Always use qmlobserver for debugging projects
authorKai Koehne <kai.koehne@nokia.com>
Mon, 4 Oct 2010 13:13:31 +0000 (15:13 +0200)
committerKai Koehne <kai.koehne@nokia.com>
Mon, 4 Oct 2010 14:59:58 +0000 (16:59 +0200)
Also only warn about missing qmlobserver when actually trying to
debug a .qmlproject.

Reviewed-by: Christiaan Janssen
src/plugins/debugger/debuggeractions.cpp
src/plugins/debugger/debuggeractions.h
src/plugins/debugger/debuggerengine.cpp
src/plugins/debugger/debuggerengine.h
src/plugins/debugger/debuggerplugin.cpp
src/plugins/debugger/dumperoptionpage.ui
src/plugins/debugger/qml/qmlengine.cpp
src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
src/plugins/qmlprojectmanager/qmlprojectruncontrol.h

index 5d4b8d1..424abcd 100644 (file)
@@ -307,14 +307,6 @@ DebuggerSettings *DebuggerSettings::instance()
     instance->insertItem(DebugDebuggingHelpers, item);
 
     item = new SavedAction(instance);
-    item->setSettingsKey(debugModeGroup, QLatin1String("UseQmlObserver"));
-    item->setText(tr("Use QML Observer"));
-    item->setCheckable(true);
-    item->setDefaultValue(true);
-    item->setValue(true);
-    instance->insertItem(UseQmlObserver, item);
-
-    item = new SavedAction(instance);
     item->setSettingsKey(debugModeGroup, QLatin1String("UseCodeModel"));
     item->setText(tr("Use Code Model"));
     item->setToolTip(tr("Selecting this causes the C++ Code Model being asked "
index aa59ee4..bf8f54a 100644 (file)
@@ -99,8 +99,6 @@ enum DebuggerActionCode
     CustomDebuggingHelperLocation,
     DebugDebuggingHelpers,
 
-    UseQmlObserver,
-
     UseCodeModel,
 
     UseToolTipsInMainEditor,
index 2bc8006..023929a 100644 (file)
@@ -1053,35 +1053,6 @@ void DebuggerEngine::showQtDumperLibraryWarning(const QString &details)
     }
 }
 
-void DebuggerEngine::showQmlObserverToolWarning()
-{
-    QMessageBox dialog(plugin()->mainWindow());
-    QPushButton *qtPref = dialog.addButton(tr("Open Qt4 Options"),
-        QMessageBox::ActionRole);
-    QPushButton *helperOff = dialog.addButton(tr("Turn off QML Observer Usage"),
-        QMessageBox::ActionRole);
-    QPushButton *justContinue = dialog.addButton(tr("Continue Anyway"),
-        QMessageBox::AcceptRole);
-    dialog.setDefaultButton(justContinue);
-    dialog.setWindowTitle(tr("QML Observer Missing"));
-    dialog.setText(tr("QML Observer could not be found."));
-    dialog.setInformativeText(tr(
-        "QML Observer is used to offer additional debugging features for "
-        "QML applications, such as interactive debugging and inspection tools."
-        "It must be compiled for each used Qt version separately. "
-        "On the Qt4 options page, select a Qt installation "
-        "and click Rebuild."));
-    dialog.exec();
-    if (dialog.clickedButton() == qtPref) {
-        Core::ICore::instance()->showOptionsDialog(
-            _(Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY),
-            _(Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID));
-    } else if (dialog.clickedButton() == helperOff) {
-        theDebuggerAction(UseQmlObserver)
-            ->setValue(qVariantFromValue(false), false);
-    }
-}
-
 QString DebuggerEngine::qtDumperLibraryName() const
 {
     if (theDebuggerAction(UseCustomDebuggingHelperLocation)->value().toBool())
index 2753a65..f42ffd2 100644 (file)
@@ -84,7 +84,6 @@ public:
     quint16 qmlServerPort;
     QString projectBuildDir;
     QString projectDir;
-    bool qmlObserverAvailable;
     // for cpp+qml debugging
     DebuggerEngineType cppEngineType;
 
@@ -265,7 +264,6 @@ public:
     QString qtDumperLibraryName() const;
     QStringList qtDumperLibraryLocations() const;
     void showQtDumperLibraryWarning(const QString &details);
-    void showQmlObserverToolWarning();
 
     static const char *stateName(int s);
 
index 161546f..760506c 100644 (file)
@@ -668,9 +668,6 @@ QWidget *DebuggingHelperOptionPage::createPage(QWidget *parent)
     m_group.insert(theDebuggerAction(UseCodeModel),
         m_ui.checkBoxUseCodeModel);
 
-    m_group.insert(theDebuggerAction(UseQmlObserver),
-        m_ui.checkBoxUseQmlObserver);
-
 #ifdef QT_DEBUG
     m_group.insert(theDebuggerAction(DebugDebuggingHelpers),
         m_ui.checkBoxDebugDebuggingHelpers);
@@ -694,8 +691,7 @@ QWidget *DebuggingHelperOptionPage::createPage(QWidget *parent)
                 << ' ' << m_ui.customLocationGroupBox->title()
                 << ' ' << m_ui.dumperLocationLabel->text()
                 << ' ' << m_ui.checkBoxUseCodeModel->text()
-                << ' ' << m_ui.checkBoxDebugDebuggingHelpers->text()
-                << ' ' << m_ui.checkBoxUseQmlObserver->text();
+                << ' ' << m_ui.checkBoxDebugDebuggingHelpers->text();
         m_searchKeywords.remove(QLatin1Char('&'));
     }
     return w;
index 8d64f35..59ff2d9 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>529</width>
-    <height>411</height>
+    <height>303</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_3">
     </widget>
    </item>
    <item>
-    <widget class="QLabel" name="label_2">
-     <property name="text">
-      <string>QML Observer is used to offer additional debugging facilities to QML applications, such as interactive preview of code changes and inspection tools.
-
-It is not strictly necessary for debugging with Qt Creator.</string>
-     </property>
-     <property name="wordWrap">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QCheckBox" name="checkBoxUseQmlObserver">
-     <property name="text">
-      <string>Use QML Observer</string>
-     </property>
-    </widget>
-   </item>
-   <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -123,6 +104,10 @@ It is not strictly necessary for debugging with Qt Creator.</string>
    <extends>QWidget</extends>
    <header location="global">utils/pathchooser.h</header>
    <container>1</container>
+   <slots>
+    <signal>editingFinished()</signal>
+    <signal>browsingFinished()</signal>
+   </slots>
   </customwidget>
  </customwidgets>
  <resources/>
index b85302b..5e546d1 100644 (file)
@@ -322,13 +322,6 @@ void QmlEngine::shutdownEngine()
 
 void QmlEngine::setupEngine()
 {
-    if (!d->m_attachToRunningExternalApp
-     && !startParameters().qmlObserverAvailable
-     && Internal::theDebuggerBoolSetting(Internal::UseQmlObserver))
-    {
-        showQmlObserverToolWarning();
-    }
-
     d->m_adapter->setMaxConnectionAttempts(MaxConnectionAttempts);
     d->m_adapter->setConnectionAttemptInterval(ConnectionAttemptDefaultInterval);
     connect(d->m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
index d41ac9d..84a07c2 100644 (file)
 #include <debugger/debuggeruiswitcher.h>
 #include <debugger/debuggerengine.h>
 #include <qmljsinspector/qmljsinspectorconstants.h>
+#include <qt4projectmanager/qt4projectmanagerconstants.h>
 
+#include <QApplication>
 #include <QDir>
 #include <QLabel>
 #include <QMessageBox>
+#include <QPushButton>
 
 using ProjectExplorer::RunConfiguration;
 using ProjectExplorer::RunControl;
@@ -62,7 +65,11 @@ QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QStri
     m_applicationLauncher.setEnvironment(environment.toStringList());
     m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory());
 
-    m_executable = runConfiguration->viewerPath();
+    if (mode == ProjectExplorer::Constants::RUNMODE) {
+        m_executable = runConfiguration->viewerPath();
+    } else {
+        m_executable = runConfiguration->observerPath();
+    }
     m_commandLineArguments = runConfiguration->viewerArguments();
 
     connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,bool)),
@@ -137,10 +144,12 @@ bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration,
 {
     QmlProjectRunConfiguration *config = qobject_cast<QmlProjectRunConfiguration*>(runConfiguration);
     if (mode == ProjectExplorer::Constants::RUNMODE) {
-        return config != 0;
-    } else if (mode == ProjectExplorer::Constants::DEBUGMODE) {
+        return config != 0 && !config->viewerPath().isEmpty();
+    } else {
         bool qmlDebugSupportInstalled = Debugger::DebuggerUISwitcher::instance()->supportedLanguages()
                                         & Debugger::QmlLanguage;
+        // don't check for qmlobserver already here because we can't update the run buttons
+        // if it has been built in the meantime
         return (config != 0) && qmlDebugSupportInstalled;
     }
 
@@ -156,7 +165,7 @@ RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration,
     RunControl *runControl = 0;
     if (mode == ProjectExplorer::Constants::RUNMODE) {
        runControl = new QmlRunControl(config, mode);
-    } else {
+    } else if (mode == ProjectExplorer::Constants::DEBUGMODE) {
         runControl = createDebugRunControl(config);
     }
     return runControl;
@@ -178,20 +187,46 @@ ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProj
     Utils::Environment environment = Utils::Environment::systemEnvironment();
     Debugger::DebuggerStartParameters params;
     params.startMode = Debugger::StartInternal;
-    params.executable = runConfig->viewerPath();
+    params.executable = runConfig->observerPath();
     params.qmlServerAddress = "127.0.0.1";
     params.qmlServerPort = runConfig->qmlDebugServerPort();
-    params.qmlObserverAvailable = runConfig->qmlObserverAvailable();
     params.processArgs = runConfig->viewerArguments();
     params.processArgs.append(QLatin1String("-qmljsdebugger=port:") + QString::number(runConfig->qmlDebugServerPort()));
     params.workingDirectory = runConfig->workingDirectory();
     params.environment = environment.toStringList();
     params.displayName = runConfig->displayName();
 
+    if (params.executable.isEmpty()) {
+        showQmlObserverToolWarning();
+        return 0;
+    }
+
     Debugger::DebuggerRunControl *debuggerRunControl = Debugger::DebuggerPlugin::createDebugger(params, runConfig);
     return debuggerRunControl;
 }
 
+void QmlRunControlFactory::showQmlObserverToolWarning() {
+    QMessageBox dialog(QApplication::activeWindow());
+    QPushButton *qtPref = dialog.addButton(tr("Open Qt4 Options"),
+                                           QMessageBox::ActionRole);
+    dialog.addButton(tr("Cancel"), QMessageBox::ActionRole);
+    dialog.setDefaultButton(qtPref);
+    dialog.setWindowTitle(tr("QML Observer Missing"));
+    dialog.setText(tr("QML Observer could not be found."));
+    dialog.setInformativeText(tr(
+                                  "QML Observer is used to offer debugging features for "
+                                  "QML applications, such as interactive debugging and inspection tools."
+                                  "It must be compiled for each used Qt version separately. "
+                                  "On the Qt4 options page, select the current Qt installation "
+                                  "and click Rebuild."));
+    dialog.exec();
+    if (dialog.clickedButton() == qtPref) {
+        Core::ICore::instance()->showOptionsDialog(
+                    Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY,
+                    Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID);
+    }
+}
+
 } // namespace Internal
 } // namespace QmlProjectManager
 
index cf260c2..9254bec 100644 (file)
@@ -78,6 +78,7 @@ public:
 
 private:
     ProjectExplorer::RunControl *createDebugRunControl(QmlProjectRunConfiguration *runConfig);
+    static void showQmlObserverToolWarning();
 };
 
 } // namespace Internal