diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 0a4cd6083cffc412297b83dc773103b817b258e7..9132db0fc4d7816a73c45bc6abc72a827447c47a 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -117,10 +117,7 @@ QString QtcSettingsItem::text() const void QtcSettingsItem::setText(const QString &value) { - if (!value.isEmpty() && !m_textPattern.isEmpty()) - m_action->setText(m_textPattern.arg(value)); - else - m_action->setText(value); + m_action->setText(value); } QString QtcSettingsItem::textPattern() const @@ -133,6 +130,25 @@ void QtcSettingsItem::setTextPattern(const QString &value) m_textPattern = value; } +QAction *QtcSettingsItem::updatedAction(const QString &text0) +{ + QString text = text0; + bool enabled = true; + if (!m_textPattern.isEmpty()) { + if (text.isEmpty()) { + text = m_textPattern; + text.remove("\"%1\""); + text.remove("%1"); + enabled = false; + } else { + text = m_textPattern.arg(text0); + } + } + m_action->setEnabled(enabled); + m_action->setText(text); + return m_action; +} + void QtcSettingsItem::readSettings(QSettings *settings) { if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty()) @@ -153,7 +169,7 @@ void QtcSettingsItem::writeSettings(QSettings *settings) settings->endGroup(); } -QAction *QtcSettingsItem::action() const +QAction *QtcSettingsItem::action() { return m_action; } @@ -355,6 +371,13 @@ QtcSettingsPool *theDebuggerSettings() instance->insertItem(RemoveWatchExpression, item); item->setTextPattern(QObject::tr("Remove watch expression \"%1\"")); + item = new QtcSettingsItem(instance); + instance->insertItem(WatchExpressionInWindow, item); + item->setTextPattern(QObject::tr("Watch expression \"%1\" in separate window")); + + // + // Dumpers + // item = new QtcSettingsItem(instance); instance->insertItem(SettingsDialog, item); item->setText(QObject::tr("Debugger properties...")); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index faf187f7229410018942c66f5d12f5ab4d202f61..49ae6ed116f471b2880aeb561ed1c00ac45bf1c0 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -59,7 +59,8 @@ public: virtual QVariant defaultValue() const; Q_SLOT virtual void setDefaultValue(const QVariant &value); - virtual QAction *action() const; + virtual QAction *action(); + virtual QAction *updatedAction(const QString &newText); // used for persistency virtual QString settingsKey() const; @@ -99,6 +100,7 @@ private: QString m_settingsKey; QString m_settingsGroup; QString m_textPattern; + QString m_textData; QAction *m_action; QHash<QObject *, ApplyMode> m_applyModes; }; @@ -145,6 +147,7 @@ enum DebuggerSettingsCode // Watchers & Locals WatchExpression, + WatchExpressionInWindow, RemoveWatchExpression, WatchModelUpdate, RecheckDumpers, diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 30060e171987496a27af90182287b87de106047e..e06becfa5d813ea224d0bf71ddd4e637728b4e4b 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -115,19 +115,17 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QModelIndex mi1 = idx.sibling(idx.row(), 0); QString value = model()->data(mi1).toString(); bool visual = false; - if (idx.isValid()) { - menu.addSeparator(); - int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression; - QAction *act3 = theDebuggerSetting(type)->action(); - act3->setText(exp); - menu.addAction(act3); - - visual = model()->data(mi0, VisualRole).toBool(); - act4 = new QAction("Watch expression '" + exp + "' in separate widget", &menu); - act4->setCheckable(true); - act4->setChecked(visual); - // FIXME: menu.addAction(act4); - } + + menu.addSeparator(); + int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression; + menu.addAction(theDebuggerSetting(type)->updatedAction(exp)); + + visual = model()->data(mi0, VisualRole).toBool(); + //act4 = theDebuggerSetting(WatchExpressionInWindow)->action(); + //act4->setCheckable(true); + //act4->setChecked(visual); + // FIXME: menu.addAction(act4); + menu.addSeparator(); menu.addAction(theDebuggerSetting(RecheckDumpers)->action()); menu.addAction(theDebuggerSetting(UseDumpers)->action());