Commit 50cabb92 authored by hjk's avatar hjk
Browse files

debugger: progress in action reorganisation

parent 889fe3eb
...@@ -117,10 +117,7 @@ QString QtcSettingsItem::text() const ...@@ -117,10 +117,7 @@ QString QtcSettingsItem::text() const
void QtcSettingsItem::setText(const QString &value) void QtcSettingsItem::setText(const QString &value)
{ {
if (!value.isEmpty() && !m_textPattern.isEmpty()) m_action->setText(value);
m_action->setText(m_textPattern.arg(value));
else
m_action->setText(value);
} }
QString QtcSettingsItem::textPattern() const QString QtcSettingsItem::textPattern() const
...@@ -133,6 +130,25 @@ void QtcSettingsItem::setTextPattern(const QString &value) ...@@ -133,6 +130,25 @@ void QtcSettingsItem::setTextPattern(const QString &value)
m_textPattern = 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) void QtcSettingsItem::readSettings(QSettings *settings)
{ {
if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty()) if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty())
...@@ -153,7 +169,7 @@ void QtcSettingsItem::writeSettings(QSettings *settings) ...@@ -153,7 +169,7 @@ void QtcSettingsItem::writeSettings(QSettings *settings)
settings->endGroup(); settings->endGroup();
} }
QAction *QtcSettingsItem::action() const QAction *QtcSettingsItem::action()
{ {
return m_action; return m_action;
} }
...@@ -355,6 +371,13 @@ QtcSettingsPool *theDebuggerSettings() ...@@ -355,6 +371,13 @@ QtcSettingsPool *theDebuggerSettings()
instance->insertItem(RemoveWatchExpression, item); instance->insertItem(RemoveWatchExpression, item);
item->setTextPattern(QObject::tr("Remove watch expression \"%1\"")); 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); item = new QtcSettingsItem(instance);
instance->insertItem(SettingsDialog, item); instance->insertItem(SettingsDialog, item);
item->setText(QObject::tr("Debugger properties...")); item->setText(QObject::tr("Debugger properties..."));
......
...@@ -59,7 +59,8 @@ public: ...@@ -59,7 +59,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() const; virtual QAction *action();
virtual QAction *updatedAction(const QString &newText);
// used for persistency // used for persistency
virtual QString settingsKey() const; virtual QString settingsKey() const;
...@@ -99,6 +100,7 @@ private: ...@@ -99,6 +100,7 @@ private:
QString m_settingsKey; QString m_settingsKey;
QString m_settingsGroup; QString m_settingsGroup;
QString m_textPattern; QString m_textPattern;
QString m_textData;
QAction *m_action; QAction *m_action;
QHash<QObject *, ApplyMode> m_applyModes; QHash<QObject *, ApplyMode> m_applyModes;
}; };
...@@ -145,6 +147,7 @@ enum DebuggerSettingsCode ...@@ -145,6 +147,7 @@ enum DebuggerSettingsCode
// Watchers & Locals // Watchers & Locals
WatchExpression, WatchExpression,
WatchExpressionInWindow,
RemoveWatchExpression, RemoveWatchExpression,
WatchModelUpdate, WatchModelUpdate,
RecheckDumpers, RecheckDumpers,
......
...@@ -115,19 +115,17 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -115,19 +115,17 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QModelIndex mi1 = idx.sibling(idx.row(), 0); QModelIndex mi1 = idx.sibling(idx.row(), 0);
QString value = model()->data(mi1).toString(); QString value = model()->data(mi1).toString();
bool visual = false; bool visual = false;
if (idx.isValid()) {
menu.addSeparator(); menu.addSeparator();
int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression; int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression;
QAction *act3 = theDebuggerSetting(type)->action(); menu.addAction(theDebuggerSetting(type)->updatedAction(exp));
act3->setText(exp);
menu.addAction(act3); visual = model()->data(mi0, VisualRole).toBool();
//act4 = theDebuggerSetting(WatchExpressionInWindow)->action();
visual = model()->data(mi0, VisualRole).toBool(); //act4->setCheckable(true);
act4 = new QAction("Watch expression '" + exp + "' in separate widget", &menu); //act4->setChecked(visual);
act4->setCheckable(true); // FIXME: menu.addAction(act4);
act4->setChecked(visual);
// FIXME: menu.addAction(act4);
}
menu.addSeparator(); menu.addSeparator();
menu.addAction(theDebuggerSetting(RecheckDumpers)->action()); menu.addAction(theDebuggerSetting(RecheckDumpers)->action());
menu.addAction(theDebuggerSetting(UseDumpers)->action()); menu.addAction(theDebuggerSetting(UseDumpers)->action());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment