forked from qt-creator/qt-creator
debugger: make QAction a base class of DebuggerAction
This commit is contained in:
@@ -101,7 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
menu.addAction(act1);
|
menu.addAction(act1);
|
||||||
menu.addAction(act2);
|
menu.addAction(act2);
|
||||||
menu.addAction(act4);
|
menu.addAction(act4);
|
||||||
menu.addAction(theDebuggerAction(SettingsDialog)->action());
|
menu.addAction(theDebuggerAction(SettingsDialog));
|
||||||
|
|
||||||
QAction *act = menu.exec(ev->globalPos());
|
QAction *act = menu.exec(ev->globalPos());
|
||||||
|
|
||||||
|
@@ -49,10 +49,9 @@ namespace Internal {
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DebuggerAction::DebuggerAction(QObject *parent)
|
DebuggerAction::DebuggerAction(QObject *parent)
|
||||||
: QObject(parent)
|
: QAction(parent)
|
||||||
{
|
{
|
||||||
m_action = new QAction(this);
|
connect(this, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
|
||||||
connect(m_action, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DebuggerAction::value() const
|
QVariant DebuggerAction::value() const
|
||||||
@@ -64,8 +63,8 @@ void DebuggerAction::setValue(const QVariant &value, bool doemit)
|
|||||||
{
|
{
|
||||||
if (value != m_value) {
|
if (value != m_value) {
|
||||||
m_value = value;
|
m_value = value;
|
||||||
if (m_action->isCheckable())
|
if (this->isCheckable())
|
||||||
m_action->setChecked(m_value.toBool());
|
this->setChecked(m_value.toBool());
|
||||||
if (doemit) {
|
if (doemit) {
|
||||||
emit valueChanged(m_value);
|
emit valueChanged(m_value);
|
||||||
emit boolValueChanged(m_value.toBool());
|
emit boolValueChanged(m_value.toBool());
|
||||||
@@ -110,16 +109,6 @@ void DebuggerAction::setSettingsGroup(const QString &group)
|
|||||||
m_settingsGroup = group;
|
m_settingsGroup = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DebuggerAction::text() const
|
|
||||||
{
|
|
||||||
return m_action->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerAction::setText(const QString &value)
|
|
||||||
{
|
|
||||||
m_action->setText(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DebuggerAction::textPattern() const
|
QString DebuggerAction::textPattern() const
|
||||||
{
|
{
|
||||||
return m_textPattern;
|
return m_textPattern;
|
||||||
@@ -144,10 +133,10 @@ QAction *DebuggerAction::updatedAction(const QString &text0)
|
|||||||
text = m_textPattern.arg(text0);
|
text = m_textPattern.arg(text0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_action->setEnabled(enabled);
|
this->setEnabled(enabled);
|
||||||
m_action->setData(text0);
|
this->setData(text0);
|
||||||
m_action->setText(text);
|
this->setText(text);
|
||||||
return m_action;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerAction::readSettings(QSettings *settings)
|
void DebuggerAction::readSettings(QSettings *settings)
|
||||||
@@ -170,11 +159,6 @@ void DebuggerAction::writeSettings(QSettings *settings)
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *DebuggerAction::action()
|
|
||||||
{
|
|
||||||
return m_action;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode)
|
void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode)
|
||||||
{
|
{
|
||||||
using namespace Core::Utils;
|
using namespace Core::Utils;
|
||||||
@@ -218,7 +202,7 @@ void DebuggerAction::uncheckableButtonClicked()
|
|||||||
QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
|
QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
|
||||||
QTC_ASSERT(button, return);
|
QTC_ASSERT(button, return);
|
||||||
//qDebug() << "UNCHECKABLE BUTTON: " << sender();
|
//qDebug() << "UNCHECKABLE BUTTON: " << sender();
|
||||||
m_action->trigger();
|
QAction::trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerAction::checkableButtonClicked(bool)
|
void DebuggerAction::checkableButtonClicked(bool)
|
||||||
@@ -255,19 +239,16 @@ void DebuggerAction::pathChooserEditingFinished()
|
|||||||
setValue(pathChooser->path());
|
setValue(pathChooser->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerAction::actionTriggered(bool on)
|
void DebuggerAction::actionTriggered(bool)
|
||||||
{
|
{
|
||||||
Q_UNUSED(on);
|
if (this->isCheckable())
|
||||||
if (QAction *action = qobject_cast<QAction *>(sender())) {
|
setValue(this->isChecked());
|
||||||
if (action->isCheckable())
|
|
||||||
setValue(action->isChecked());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerAction::trigger(const QVariant &data) const
|
void DebuggerAction::trigger(const QVariant &data)
|
||||||
{
|
{
|
||||||
m_action->setData(data);
|
setData(data);
|
||||||
m_action->trigger();
|
QAction::trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@@ -345,7 +326,7 @@ DebuggerSettings *theDebuggerSettings()
|
|||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(AlwaysAdjustColumnWidths, item);
|
instance->insertItem(AlwaysAdjustColumnWidths, item);
|
||||||
item->setText(QObject::tr("Always adjust column widths to contents"));
|
item->setText(QObject::tr("Always adjust column widths to contents"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(WatchExpression, item);
|
instance->insertItem(WatchExpression, item);
|
||||||
@@ -372,7 +353,7 @@ DebuggerSettings *theDebuggerSettings()
|
|||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(DebugDumpers, item);
|
instance->insertItem(DebugDumpers, item);
|
||||||
item->setText(QObject::tr("Debug custom dumpers"));
|
item->setText(QObject::tr("Debug custom dumpers"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(RecheckDumpers, item);
|
instance->insertItem(RecheckDumpers, item);
|
||||||
@@ -389,22 +370,22 @@ DebuggerSettings *theDebuggerSettings()
|
|||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(AutoQuit, item);
|
instance->insertItem(AutoQuit, item);
|
||||||
item->setText(QObject::tr("Automatically quit debugger"));
|
item->setText(QObject::tr("Automatically quit debugger"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(SkipKnownFrames, item);
|
instance->insertItem(SkipKnownFrames, item);
|
||||||
item->setText(QObject::tr("Skip known frames"));
|
item->setText(QObject::tr("Skip known frames"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(UseToolTips, item);
|
instance->insertItem(UseToolTips, item);
|
||||||
item->setText(QObject::tr("Use tooltips when debugging"));
|
item->setText(QObject::tr("Use tooltips when debugging"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
instance->insertItem(ListSourceFiles, item);
|
instance->insertItem(ListSourceFiles, item);
|
||||||
item->setText(QObject::tr("List source files"));
|
item->setText(QObject::tr("List source files"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -438,7 +419,7 @@ DebuggerSettings *theDebuggerSettings()
|
|||||||
instance->insertItem(UseDumpers, item);
|
instance->insertItem(UseDumpers, item);
|
||||||
item->setSettingsKey("DebugMode", "UseCustomDumpers");
|
item->setSettingsKey("DebugMode", "UseCustomDumpers");
|
||||||
item->setText(QObject::tr("Use custom dumpers"));
|
item->setText(QObject::tr("Use custom dumpers"));
|
||||||
item->action()->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
|
||||||
|
|
||||||
item = new DebuggerAction(instance);
|
item = new DebuggerAction(instance);
|
||||||
|
@@ -35,8 +35,9 @@
|
|||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ namespace Internal {
|
|||||||
|
|
||||||
enum ApplyMode { ImmediateApply, DeferedApply };
|
enum ApplyMode { ImmediateApply, DeferedApply };
|
||||||
|
|
||||||
class DebuggerAction : public QObject
|
class DebuggerAction : public QAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -59,9 +60,8 @@ public:
|
|||||||
virtual QVariant defaultValue() const;
|
virtual QVariant defaultValue() const;
|
||||||
Q_SLOT virtual void setDefaultValue(const QVariant &value);
|
Q_SLOT virtual void setDefaultValue(const QVariant &value);
|
||||||
|
|
||||||
virtual QAction *action();
|
|
||||||
virtual QAction *updatedAction(const QString &newText);
|
virtual QAction *updatedAction(const QString &newText);
|
||||||
Q_SLOT virtual void trigger(const QVariant &data) const;
|
Q_SLOT virtual void trigger(const QVariant &data);
|
||||||
|
|
||||||
// used for persistency
|
// used for persistency
|
||||||
virtual QString settingsKey() const;
|
virtual QString settingsKey() const;
|
||||||
@@ -77,9 +77,6 @@ public:
|
|||||||
virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply);
|
virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply);
|
||||||
Q_SLOT virtual void apply(QSettings *settings);
|
Q_SLOT virtual void apply(QSettings *settings);
|
||||||
|
|
||||||
virtual QString text() const;
|
|
||||||
Q_SLOT virtual void setText(const QString &value);
|
|
||||||
|
|
||||||
virtual QString textPattern() const;
|
virtual QString textPattern() const;
|
||||||
Q_SLOT virtual void setTextPattern(const QString &value);
|
Q_SLOT virtual void setTextPattern(const QString &value);
|
||||||
|
|
||||||
@@ -102,7 +99,6 @@ private:
|
|||||||
QString m_settingsGroup;
|
QString m_settingsGroup;
|
||||||
QString m_textPattern;
|
QString m_textPattern;
|
||||||
QString m_textData;
|
QString m_textData;
|
||||||
QAction *m_action;
|
|
||||||
QHash<QObject *, ApplyMode> m_applyModes;
|
QHash<QObject *, ApplyMode> m_applyModes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -267,7 +267,7 @@ void DebuggerManager::init()
|
|||||||
this, SIGNAL(sessionValueRequested(QString,QVariant*)));
|
this, SIGNAL(sessionValueRequested(QString,QVariant*)));
|
||||||
connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)),
|
connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)),
|
||||||
this, SIGNAL(setSessionValueRequested(QString,QVariant)));
|
this, SIGNAL(setSessionValueRequested(QString,QVariant)));
|
||||||
connect(theDebuggerAction(AssignValue)->action(), SIGNAL(triggered()),
|
connect(theDebuggerAction(AssignValue), SIGNAL(triggered()),
|
||||||
this, SLOT(assignValueInDebugger()));
|
this, SLOT(assignValueInDebugger()));
|
||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
|
@@ -715,7 +715,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
connect(m_manager, SIGNAL(debugModeRequested()),
|
connect(m_manager, SIGNAL(debugModeRequested()),
|
||||||
this, SLOT(activateDebugMode()));
|
this, SLOT(activateDebugMode()));
|
||||||
|
|
||||||
connect(theDebuggerAction(SettingsDialog)->action(), SIGNAL(triggered()),
|
connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()),
|
||||||
this, SLOT(showSettingsDialog()));
|
this, SLOT(showSettingsDialog()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -289,7 +289,7 @@ void GdbEngine::initializeConnections()
|
|||||||
this, SLOT(setUseDumpers(bool)));
|
this, SLOT(setUseDumpers(bool)));
|
||||||
connect(theDebuggerAction(DebugDumpers), SIGNAL(boolValueChanged(bool)),
|
connect(theDebuggerAction(DebugDumpers), SIGNAL(boolValueChanged(bool)),
|
||||||
this, SLOT(setDebugDumpers(bool)));
|
this, SLOT(setDebugDumpers(bool)));
|
||||||
connect(theDebuggerAction(RecheckDumpers)->action(), SIGNAL(triggered()),
|
connect(theDebuggerAction(RecheckDumpers), SIGNAL(triggered()),
|
||||||
this, SLOT(recheckCustomDumperAvailability()));
|
this, SLOT(recheckCustomDumperAvailability()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -368,10 +368,10 @@ WatchHandler::WatchHandler()
|
|||||||
m_incompleteSet.clear();
|
m_incompleteSet.clear();
|
||||||
m_displaySet = m_completeSet;
|
m_displaySet = m_completeSet;
|
||||||
|
|
||||||
connect(theDebuggerAction(WatchExpression)->action(),
|
connect(theDebuggerAction(WatchExpression),
|
||||||
SIGNAL(triggered()), this, SLOT(watchExpression()));
|
SIGNAL(triggered()), this, SLOT(watchExpression()));
|
||||||
|
|
||||||
connect(theDebuggerAction(RemoveWatchExpression)->action(),
|
connect(theDebuggerAction(RemoveWatchExpression),
|
||||||
SIGNAL(triggered()), this, SLOT(removeWatchExpression()));
|
SIGNAL(triggered()), this, SLOT(removeWatchExpression()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,10 +185,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
//menu.addAction(act3);
|
//menu.addAction(act3);
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(theDebuggerAction(RecheckDumpers)->action());
|
menu.addAction(theDebuggerAction(RecheckDumpers));
|
||||||
menu.addAction(theDebuggerAction(UseDumpers)->action());
|
menu.addAction(theDebuggerAction(UseDumpers));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(theDebuggerAction(SettingsDialog)->action());
|
menu.addAction(theDebuggerAction(SettingsDialog));
|
||||||
|
|
||||||
QAction *act = menu.exec(ev->globalPos());
|
QAction *act = menu.exec(ev->globalPos());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user