forked from qt-creator/qt-creator
Debugger: Bring Qt Creator to foreground if app interrupts
Change-Id: I07795f61b79cce9687d0ae2bff3cc19534ec08d6 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
@@ -36,10 +36,13 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtDebug>
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
/* The notification signal is delayed by using a custom event
|
/* The notification signal is delayed by using a custom event
|
||||||
@@ -56,6 +59,18 @@ AppMainWindow::AppMainWindow() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppMainWindow::raiseWindow()
|
||||||
|
{
|
||||||
|
setWindowState(windowState() & ~Qt::WindowMinimized);
|
||||||
|
|
||||||
|
raise();
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
// work around QTBUG-24932
|
||||||
|
QX11Info::setAppUserTime(0);
|
||||||
|
#endif
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool AppMainWindow::event(QEvent *event)
|
bool AppMainWindow::event(QEvent *event)
|
||||||
{
|
{
|
||||||
|
@@ -38,17 +38,14 @@
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
/*!
|
|
||||||
* This class only exists because we can't include windows.h in mainwindow.cpp
|
|
||||||
* because windows defines an IContext...
|
|
||||||
*/
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT AppMainWindow : public QMainWindow
|
class QTCREATOR_UTILS_EXPORT AppMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AppMainWindow();
|
AppMainWindow();
|
||||||
|
|
||||||
|
void raiseWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceChange();
|
void deviceChange();
|
||||||
|
|
||||||
|
@@ -72,6 +72,8 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
|
|||||||
m_ui.checkBoxCloseBuffersOnExit);
|
m_ui.checkBoxCloseBuffersOnExit);
|
||||||
m_group->insert(dc->action(SwitchModeOnExit),
|
m_group->insert(dc->action(SwitchModeOnExit),
|
||||||
m_ui.checkBoxSwitchModeOnExit);
|
m_ui.checkBoxSwitchModeOnExit);
|
||||||
|
m_group->insert(dc->action(RaiseOnInterrupt),
|
||||||
|
m_ui.checkBoxBringToForegroundOnInterrrupt);
|
||||||
m_group->insert(dc->action(FontSizeFollowsEditor),
|
m_group->insert(dc->action(FontSizeFollowsEditor),
|
||||||
m_ui.checkBoxFontSizeFollowsEditor);
|
m_ui.checkBoxFontSizeFollowsEditor);
|
||||||
m_group->insert(dc->action(AutoDerefPointers), 0);
|
m_group->insert(dc->action(AutoDerefPointers), 0);
|
||||||
@@ -120,6 +122,7 @@ QString CommonOptionsPageWidget::searchKeyWords() const
|
|||||||
<< sep << m_ui.checkBoxCloseBuffersOnExit->text()
|
<< sep << m_ui.checkBoxCloseBuffersOnExit->text()
|
||||||
<< sep << m_ui.checkBoxSwitchModeOnExit->text()
|
<< sep << m_ui.checkBoxSwitchModeOnExit->text()
|
||||||
<< sep << m_ui.labelMaximalStackDepth->text()
|
<< sep << m_ui.labelMaximalStackDepth->text()
|
||||||
|
<< sep << m_ui.checkBoxBringToForegroundOnInterrrupt->text()
|
||||||
;
|
;
|
||||||
rc.remove(QLatin1Char('&'));
|
rc.remove(QLatin1Char('&'));
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -65,16 +65,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QCheckBox" name="checkBoxRegisterForPostMortem">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Register Qt Creator for debugging crashed applications.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Use Qt Creator for post-mortem debugging</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -130,6 +120,23 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkBoxRegisterForPostMortem">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Register Qt Creator for debugging crashed applications.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use Qt Creator for post-mortem debugging</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkBoxBringToForegroundOnInterrrupt">
|
||||||
|
<property name="text">
|
||||||
|
<string>Bring Qt Creator to foreground when application interrupts</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@@ -397,6 +397,12 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
|||||||
item->setDefaultValue(false);
|
item->setDefaultValue(false);
|
||||||
insertItem(SwitchModeOnExit, item);
|
insertItem(SwitchModeOnExit, item);
|
||||||
|
|
||||||
|
item = new SavedAction(this);
|
||||||
|
item->setSettingsKey(debugModeGroup, QLatin1String("RaiseOnInterrupt"));
|
||||||
|
item->setCheckable(true);
|
||||||
|
item->setDefaultValue(true);
|
||||||
|
insertItem(RaiseOnInterrupt, item);
|
||||||
|
|
||||||
item = new SavedAction(this);
|
item = new SavedAction(this);
|
||||||
item->setSettingsKey(debugModeGroup, QLatin1String("AutoQuit"));
|
item->setSettingsKey(debugModeGroup, QLatin1String("AutoQuit"));
|
||||||
item->setText(tr("Automatically Quit Debugger"));
|
item->setText(tr("Automatically Quit Debugger"));
|
||||||
|
@@ -100,6 +100,7 @@ enum DebuggerActionCode
|
|||||||
OperateByInstruction,
|
OperateByInstruction,
|
||||||
CloseBuffersOnExit,
|
CloseBuffersOnExit,
|
||||||
SwitchModeOnExit,
|
SwitchModeOnExit,
|
||||||
|
RaiseOnInterrupt,
|
||||||
|
|
||||||
UseDebuggingHelpers,
|
UseDebuggingHelpers,
|
||||||
|
|
||||||
|
@@ -1038,6 +1038,8 @@ void DebuggerEngine::notifyInferiorSpontaneousStop()
|
|||||||
QTC_ASSERT(state() == InferiorRunOk, qDebug() << this << state());
|
QTC_ASSERT(state() == InferiorRunOk, qDebug() << this << state());
|
||||||
showStatusMessage(tr("Stopped."));
|
showStatusMessage(tr("Stopped."));
|
||||||
setState(InferiorStopOk);
|
setState(InferiorStopOk);
|
||||||
|
if (debuggerCore()->boolSetting(RaiseOnInterrupt))
|
||||||
|
emit raiseWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerEngine::notifyInferiorStopFailed()
|
void DebuggerEngine::notifyInferiorStopFailed()
|
||||||
|
@@ -302,6 +302,7 @@ signals:
|
|||||||
* a server start script should be used, but none is given.
|
* a server start script should be used, but none is given.
|
||||||
*/
|
*/
|
||||||
void requestRemoteSetup();
|
void requestRemoteSetup();
|
||||||
|
void raiseWindow();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The base notify*() function implementation should be sufficient
|
// The base notify*() function implementation should be sufficient
|
||||||
|
@@ -32,7 +32,9 @@
|
|||||||
|
|
||||||
#include "debuggermainwindow.h"
|
#include "debuggermainwindow.h"
|
||||||
#include "debuggercore.h"
|
#include "debuggercore.h"
|
||||||
|
#include "debuggerengine.h"
|
||||||
|
|
||||||
|
#include <utils/appmainwindow.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
@@ -141,6 +143,8 @@ public:
|
|||||||
Project *m_previousProject;
|
Project *m_previousProject;
|
||||||
Target *m_previousTarget;
|
Target *m_previousTarget;
|
||||||
RunConfiguration *m_previousRunConfiguration;
|
RunConfiguration *m_previousRunConfiguration;
|
||||||
|
|
||||||
|
DebuggerEngine *m_engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *mw)
|
DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *mw)
|
||||||
@@ -157,6 +161,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *mw)
|
|||||||
, m_previousProject(0)
|
, m_previousProject(0)
|
||||||
, m_previousTarget(0)
|
, m_previousTarget(0)
|
||||||
, m_previousRunConfiguration(0)
|
, m_previousRunConfiguration(0)
|
||||||
|
, m_engine(0)
|
||||||
{
|
{
|
||||||
createViewsMenuItems();
|
createViewsMenuItems();
|
||||||
addLanguage(CppLanguage, Context(C_CPPDEBUGGER));
|
addLanguage(CppLanguage, Context(C_CPPDEBUGGER));
|
||||||
@@ -271,6 +276,15 @@ DebuggerMainWindow::~DebuggerMainWindow()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerMainWindow::setCurrentEngine(DebuggerEngine *engine)
|
||||||
|
{
|
||||||
|
if (d->m_engine)
|
||||||
|
disconnect(d->m_engine, SIGNAL(raiseWindow()), this, SLOT(raiseDebuggerWindow()));
|
||||||
|
d->m_engine = engine;
|
||||||
|
if (d->m_engine)
|
||||||
|
connect(d->m_engine, SIGNAL(raiseWindow()), this, SLOT(raiseDebuggerWindow()));
|
||||||
|
}
|
||||||
|
|
||||||
DebuggerLanguages DebuggerMainWindow::activeDebugLanguages() const
|
DebuggerLanguages DebuggerMainWindow::activeDebugLanguages() const
|
||||||
{
|
{
|
||||||
return d->m_activeDebugLanguages;
|
return d->m_activeDebugLanguages;
|
||||||
@@ -559,6 +573,14 @@ void DebuggerMainWindow::writeSettings() const
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerMainWindow::raiseDebuggerWindow()
|
||||||
|
{
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
Utils::AppMainWindow *appMainWindow = qobject_cast<Utils::AppMainWindow*>(core->mainWindow());
|
||||||
|
QTC_ASSERT(appMainWindow, return)
|
||||||
|
appMainWindow->raiseWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::readSettings()
|
void DebuggerMainWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
|
@@ -45,6 +45,8 @@ class IMode;
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
|
class DebuggerEngine;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class DebuggerMainWindowPrivate;
|
class DebuggerMainWindowPrivate;
|
||||||
}
|
}
|
||||||
@@ -57,6 +59,8 @@ public:
|
|||||||
DebuggerMainWindow();
|
DebuggerMainWindow();
|
||||||
~DebuggerMainWindow();
|
~DebuggerMainWindow();
|
||||||
|
|
||||||
|
void setCurrentEngine(DebuggerEngine *engine);
|
||||||
|
|
||||||
// Debugger toolbars are registered with this function.
|
// Debugger toolbars are registered with this function.
|
||||||
void setToolBar(DebuggerLanguage language, QWidget *widget);
|
void setToolBar(DebuggerLanguage language, QWidget *widget);
|
||||||
|
|
||||||
@@ -81,6 +85,9 @@ public:
|
|||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings() const;
|
void writeSettings() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void raiseDebuggerWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages);
|
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages);
|
||||||
|
|
||||||
|
@@ -2100,6 +2100,7 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
|
|||||||
engine->watchHandler()->rebuildModel();
|
engine->watchHandler()->rebuildModel();
|
||||||
|
|
||||||
mainWindow()->setEngineDebugLanguages(engine->languages());
|
mainWindow()->setEngineDebugLanguages(engine->languages());
|
||||||
|
mainWindow()->setCurrentEngine(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void changeFontSize(QWidget *widget, qreal size)
|
static void changeFontSize(QWidget *widget, qreal size)
|
||||||
|
Reference in New Issue
Block a user