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:
Kai Koehne
2012-03-13 13:50:05 +01:00
parent dbcaadd8af
commit 2af301e253
11 changed files with 78 additions and 16 deletions

View File

@@ -36,10 +36,13 @@
#include <windows.h>
#endif
#include <QtDebug>
#include <QEvent>
#include <QCoreApplication>
#ifdef Q_WS_X11
#include <QX11Info>
#endif
namespace Utils {
/* 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
bool AppMainWindow::event(QEvent *event)
{

View File

@@ -38,17 +38,14 @@
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
{
Q_OBJECT
public:
AppMainWindow();
void raiseWindow();
signals:
void deviceChange();

View File

@@ -72,6 +72,8 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
m_ui.checkBoxCloseBuffersOnExit);
m_group->insert(dc->action(SwitchModeOnExit),
m_ui.checkBoxSwitchModeOnExit);
m_group->insert(dc->action(RaiseOnInterrupt),
m_ui.checkBoxBringToForegroundOnInterrrupt);
m_group->insert(dc->action(FontSizeFollowsEditor),
m_ui.checkBoxFontSizeFollowsEditor);
m_group->insert(dc->action(AutoDerefPointers), 0);
@@ -120,6 +122,7 @@ QString CommonOptionsPageWidget::searchKeyWords() const
<< sep << m_ui.checkBoxCloseBuffersOnExit->text()
<< sep << m_ui.checkBoxSwitchModeOnExit->text()
<< sep << m_ui.labelMaximalStackDepth->text()
<< sep << m_ui.checkBoxBringToForegroundOnInterrrupt->text()
;
rc.remove(QLatin1Char('&'));
return rc;

View File

@@ -65,16 +65,6 @@
</property>
</widget>
</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">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -130,6 +120,23 @@
</item>
</layout>
</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>
</widget>
</item>

View File

@@ -397,6 +397,12 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
item->setDefaultValue(false);
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->setSettingsKey(debugModeGroup, QLatin1String("AutoQuit"));
item->setText(tr("Automatically Quit Debugger"));

View File

@@ -100,6 +100,7 @@ enum DebuggerActionCode
OperateByInstruction,
CloseBuffersOnExit,
SwitchModeOnExit,
RaiseOnInterrupt,
UseDebuggingHelpers,

View File

@@ -1038,6 +1038,8 @@ void DebuggerEngine::notifyInferiorSpontaneousStop()
QTC_ASSERT(state() == InferiorRunOk, qDebug() << this << state());
showStatusMessage(tr("Stopped."));
setState(InferiorStopOk);
if (debuggerCore()->boolSetting(RaiseOnInterrupt))
emit raiseWindow();
}
void DebuggerEngine::notifyInferiorStopFailed()

View File

@@ -302,6 +302,7 @@ signals:
* a server start script should be used, but none is given.
*/
void requestRemoteSetup();
void raiseWindow();
protected:
// The base notify*() function implementation should be sufficient

View File

@@ -32,7 +32,9 @@
#include "debuggermainwindow.h"
#include "debuggercore.h"
#include "debuggerengine.h"
#include <utils/appmainwindow.h>
#include <utils/styledbar.h>
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
@@ -141,6 +143,8 @@ public:
Project *m_previousProject;
Target *m_previousTarget;
RunConfiguration *m_previousRunConfiguration;
DebuggerEngine *m_engine;
};
DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *mw)
@@ -157,6 +161,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *mw)
, m_previousProject(0)
, m_previousTarget(0)
, m_previousRunConfiguration(0)
, m_engine(0)
{
createViewsMenuItems();
addLanguage(CppLanguage, Context(C_CPPDEBUGGER));
@@ -271,6 +276,15 @@ DebuggerMainWindow::~DebuggerMainWindow()
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
{
return d->m_activeDebugLanguages;
@@ -559,6 +573,14 @@ void DebuggerMainWindow::writeSettings() const
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()
{
QSettings *settings = ICore::settings();

View File

@@ -45,6 +45,8 @@ class IMode;
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerMainWindowPrivate;
}
@@ -57,6 +59,8 @@ public:
DebuggerMainWindow();
~DebuggerMainWindow();
void setCurrentEngine(DebuggerEngine *engine);
// Debugger toolbars are registered with this function.
void setToolBar(DebuggerLanguage language, QWidget *widget);
@@ -81,6 +85,9 @@ public:
void readSettings();
void writeSettings() const;
private slots:
void raiseDebuggerWindow();
signals:
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages);

View File

@@ -2100,6 +2100,7 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
engine->watchHandler()->rebuildModel();
mainWindow()->setEngineDebugLanguages(engine->languages());
mainWindow()->setCurrentEngine(engine);
}
static void changeFontSize(QWidget *widget, qreal size)