forked from qt-creator/qt-creator
debugger: merge the 'Change Format for {Object,Type}' l&w context menu entries
This commit is contained in:
@@ -274,63 +274,55 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
const int effectiveIndividualFormat =
|
const int effectiveIndividualFormat =
|
||||||
individualFormat == -1 ? typeFormat : individualFormat;
|
individualFormat == -1 ? typeFormat : individualFormat;
|
||||||
|
|
||||||
QMenu typeFormatMenu;
|
QMenu formatMenu;
|
||||||
QList<QAction *> typeFormatActions;
|
QList<QAction *> typeFormatActions;
|
||||||
|
QList<QAction *> individualFormatActions;
|
||||||
QAction *clearTypeFormatAction = 0;
|
QAction *clearTypeFormatAction = 0;
|
||||||
if (idx.isValid()) {
|
QAction *clearIndividualFormatAction = 0;
|
||||||
typeFormatMenu.setTitle(
|
formatMenu.setTitle(tr("Change Display Format..."));
|
||||||
|
if (idx.isValid() && !alternativeFormats.isEmpty()) {
|
||||||
|
QAction *dummy = formatMenu.addAction(
|
||||||
tr("Change Display for Type \"%1\"").arg(type));
|
tr("Change Display for Type \"%1\"").arg(type));
|
||||||
if (alternativeFormats.isEmpty()) {
|
dummy->setEnabled(false);
|
||||||
typeFormatMenu.setEnabled(false);
|
formatMenu.addSeparator();
|
||||||
} else {
|
clearTypeFormatAction = formatMenu.addAction(tr("Automatic"));
|
||||||
clearTypeFormatAction = typeFormatMenu.addAction(tr("Automatic"));
|
//clearTypeFormatAction->setEnabled(typeFormat != -1);
|
||||||
clearTypeFormatAction->setEnabled(typeFormat != -1);
|
//clearTypeFormatAction->setEnabled(individualFormat != -1);
|
||||||
clearTypeFormatAction->setCheckable(true);
|
clearTypeFormatAction->setCheckable(true);
|
||||||
clearTypeFormatAction->setChecked(typeFormat == -1);
|
clearTypeFormatAction->setChecked(typeFormat == -1);
|
||||||
typeFormatMenu.addSeparator();
|
formatMenu.addSeparator();
|
||||||
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
||||||
const QString format = alternativeFormats.at(i);
|
const QString format = alternativeFormats.at(i);
|
||||||
QAction *act = new QAction(format, &typeFormatMenu);
|
QAction *act = new QAction(format, &formatMenu);
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
|
//act->setEnabled(individualFormat != -1);
|
||||||
if (i == typeFormat)
|
if (i == typeFormat)
|
||||||
act->setChecked(true);
|
act->setChecked(true);
|
||||||
typeFormatMenu.addAction(act);
|
formatMenu.addAction(act);
|
||||||
typeFormatActions.append(act);
|
typeFormatActions.append(act);
|
||||||
}
|
}
|
||||||
}
|
formatMenu.addSeparator();
|
||||||
} else {
|
dummy = formatMenu.addAction(
|
||||||
typeFormatMenu.setTitle(tr("Change Display for Type"));
|
|
||||||
typeFormatMenu.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu individualFormatMenu;
|
|
||||||
QList<QAction *> individualFormatActions;
|
|
||||||
QAction *clearIndividualFormatAction = 0;
|
|
||||||
if (idx.isValid()) {
|
|
||||||
individualFormatMenu.setTitle(
|
|
||||||
tr("Change Display for Object Named \"%1\"").arg(mi0.data().toString()));
|
tr("Change Display for Object Named \"%1\"").arg(mi0.data().toString()));
|
||||||
if (alternativeFormats.isEmpty()) {
|
dummy->setEnabled(false);
|
||||||
individualFormatMenu.setEnabled(false);
|
formatMenu.addSeparator();
|
||||||
} else {
|
|
||||||
clearIndividualFormatAction
|
clearIndividualFormatAction
|
||||||
= individualFormatMenu.addAction(tr("Automatic"));
|
= formatMenu.addAction(tr("Use Display Format Based on Type"));
|
||||||
clearIndividualFormatAction->setEnabled(individualFormat != -1);
|
//clearIndividualFormatAction->setEnabled(individualFormat != -1);
|
||||||
clearIndividualFormatAction->setCheckable(true);
|
clearIndividualFormatAction->setCheckable(true);
|
||||||
clearIndividualFormatAction->setChecked(individualFormat == -1);
|
clearIndividualFormatAction->setChecked(effectiveIndividualFormat == -1);
|
||||||
individualFormatMenu.addSeparator();
|
formatMenu.addSeparator();
|
||||||
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
||||||
const QString format = alternativeFormats.at(i);
|
const QString format = alternativeFormats.at(i);
|
||||||
QAction *act = new QAction(format, &individualFormatMenu);
|
QAction *act = new QAction(format, &formatMenu);
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
if (i == effectiveIndividualFormat)
|
if (i == effectiveIndividualFormat)
|
||||||
act->setChecked(true);
|
act->setChecked(true);
|
||||||
individualFormatMenu.addAction(act);
|
formatMenu.addAction(act);
|
||||||
individualFormatActions.append(act);
|
individualFormatActions.append(act);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
individualFormatMenu.setTitle(tr("Change Display for Object"));
|
formatMenu.setEnabled(false);
|
||||||
individualFormatMenu.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool actionsEnabled = engine->debuggerActionsEnabled();
|
const bool actionsEnabled = engine->debuggerActionsEnabled();
|
||||||
@@ -406,8 +398,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
|
|
||||||
menu.addAction(actInsertNewWatchItem);
|
menu.addAction(actInsertNewWatchItem);
|
||||||
menu.addAction(actSelectWidgetToWatch);
|
menu.addAction(actSelectWidgetToWatch);
|
||||||
menu.addMenu(&typeFormatMenu);
|
menu.addMenu(&formatMenu);
|
||||||
menu.addMenu(&individualFormatMenu);
|
|
||||||
if (actOpenMemoryEditAtVariableAddress)
|
if (actOpenMemoryEditAtVariableAddress)
|
||||||
menu.addAction(actOpenMemoryEditAtVariableAddress);
|
menu.addAction(actOpenMemoryEditAtVariableAddress);
|
||||||
if (actOpenMemoryEditAtPointerValue)
|
if (actOpenMemoryEditAtPointerValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user