Commit 3e38a059 authored by hjk's avatar hjk
Browse files

debugger: make user visible strings translatable

parent 7a77f837
......@@ -85,15 +85,15 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
{
QMenu menu;
QModelIndex index = indexAt(ev->pos());
QAction *act0 = new QAction("Delete breakpoint", &menu);
QAction *act0 = new QAction(tr("Delete breakpoint"), &menu);
act0->setEnabled(index.isValid());
QAction *act1 = new QAction("Adjust column widths to contents", &menu);
QAction *act2 = new QAction("Always adjust column widths to contents", &menu);
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);
QAction *act2 = new QAction(tr("Always adjust column widths to contents"), &menu);
act2->setCheckable(true);
act2->setChecked(m_alwaysResizeColumnsToContents);
QAction *act3 = new QAction("Edit condition...", &menu);
QAction *act3 = new QAction(tr("Edit condition..."), &menu);
act0->setEnabled(index.isValid());
QAction *act4 = new QAction("Syncronize breakpoints", &menu);
QAction *act4 = new QAction(tr("Syncronize breakpoints"), &menu);
menu.addAction(act0);
menu.addAction(act3);
......
......@@ -96,16 +96,7 @@ QString DebuggerSettings::dump()
return out;
}
//////////////////////////////////////////////////////////////////////////
//
// Debugger specific actions and settings
//
//////////////////////////////////////////////////////////////////////////
DebuggerSettings *theDebuggerSettings()
DebuggerSettings *DebuggerSettings::instance()
{
static DebuggerSettings *instance = 0;
if (instance)
......@@ -117,18 +108,18 @@ DebuggerSettings *theDebuggerSettings()
item = new SavedAction(instance);
instance->insertItem(SettingsDialog, item);
item->setText(QObject::tr("Debugger properties..."));
item->setText(tr("Debugger properties..."));
//
// View
//
item = new SavedAction(instance);
instance->insertItem(AdjustColumnWidths, item);
item->setText(QObject::tr("Adjust column widths to contents"));
item->setText(tr("Adjust column widths to contents"));
item = new SavedAction(instance);
instance->insertItem(AlwaysAdjustColumnWidths, item);
item->setText(QObject::tr("Always adjust column widths to contents"));
item->setText(tr("Always adjust column widths to contents"));
item->setCheckable(true);
//
......@@ -136,15 +127,15 @@ DebuggerSettings *theDebuggerSettings()
//
item = new SavedAction(instance);
instance->insertItem(WatchExpression, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\""));
item->setTextPattern(tr("Watch expression \"%1\""));
item = new SavedAction(instance);
instance->insertItem(RemoveWatchExpression, item);
item->setTextPattern(QObject::tr("Remove watch expression \"%1\""));
item->setTextPattern(tr("Remove watch expression \"%1\""));
item = new SavedAction(instance);
instance->insertItem(WatchExpressionInWindow, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\" in separate window"));
item->setTextPattern(tr("Watch expression \"%1\" in separate window"));
item = new SavedAction(instance);
instance->insertItem(AssignValue, item);
......@@ -154,11 +145,11 @@ DebuggerSettings *theDebuggerSettings()
item = new SavedAction(instance);
instance->insertItem(ExpandItem, item);
item->setText(QObject::tr("Expand item"));
item->setText(tr("Expand item"));
item = new SavedAction(instance);
instance->insertItem(CollapseItem, item);
item->setText(QObject::tr("Collapse item"));
item->setText(tr("Collapse item"));
//
// DebuggingHelper
......@@ -167,7 +158,7 @@ DebuggerSettings *theDebuggerSettings()
instance->insertItem(UseDebuggingHelpers, item);
item->setDefaultValue(true);
item->setSettingsKey("DebugMode", "UseDebuggingHelper");
item->setText(QObject::tr("Use Debugging Helper"));
item->setText(tr("Use Debugging Helper"));
item->setCheckable(true);
item->setDefaultValue(true);
......@@ -183,19 +174,19 @@ DebuggerSettings *theDebuggerSettings()
item = new SavedAction(instance);
instance->insertItem(DebugDebuggingHelpers, item);
item->setSettingsKey("DebugMode", "DebugDebuggingHelpers");
item->setText(QObject::tr("Debug debugging helper"));
item->setText(tr("Debug debugging helper"));
item->setCheckable(true);
item = new SavedAction(instance);
item->setText(QObject::tr("Recheck debugging helper availability"));
item->setText(tr("Recheck debugging helper availability"));
instance->insertItem(RecheckDebuggingHelpers, item);
//
// Breakpoints
//
item = new SavedAction(instance);
item->setText(QObject::tr("Syncronize breakpoints"));
item->setText(tr("Syncronize breakpoints"));
instance->insertItem(SynchronizeBreakpoints, item);
//
......@@ -206,7 +197,7 @@ DebuggerSettings *theDebuggerSettings()
registerFormatGroup->setExclusive(true);
item = new SavedAction(instance);
item->setText(QObject::tr("Hexadecimal"));
item->setText(tr("Hexadecimal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatHexadecimal");
item->setChecked(true);
......@@ -214,35 +205,35 @@ DebuggerSettings *theDebuggerSettings()
registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(QObject::tr("Decimal"));
item->setText(tr("Decimal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatDecimal");
instance->insertItem(FormatDecimal, item);
registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(QObject::tr("Octal"));
item->setText(tr("Octal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatOctal");
instance->insertItem(FormatOctal, item);
registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(QObject::tr("Binary"));
item->setText(tr("Binary"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatBinary");
instance->insertItem(FormatBinary, item);
registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(QObject::tr("Raw"));
item->setText(tr("Raw"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatRaw");
instance->insertItem(FormatRaw, item);
registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(QObject::tr("Natural"));
item->setText(tr("Natural"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatNatural");
instance->insertItem(FormatNatural, item);
......@@ -266,13 +257,13 @@ DebuggerSettings *theDebuggerSettings()
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "AutoQuit");
item->setText(QObject::tr("Automatically quit debugger"));
item->setText(tr("Automatically quit debugger"));
item->setCheckable(true);
instance->insertItem(AutoQuit, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "UseToolTips");
item->setText(QObject::tr("Use tooltips when debugging"));
item->setText(tr("Use tooltips when debugging"));
item->setCheckable(true);
instance->insertItem(UseToolTips, item);
......@@ -283,13 +274,13 @@ DebuggerSettings *theDebuggerSettings()
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "ListSourceFiles");
item->setText(QObject::tr("List source files"));
item->setText(tr("List source files"));
item->setCheckable(true);
instance->insertItem(ListSourceFiles, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "SkipKnownFrames");
item->setText(QObject::tr("Skip known frames"));
item->setText(tr("Skip known frames"));
item->setCheckable(true);
instance->insertItem(SkipKnownFrames, item);
......@@ -315,29 +306,35 @@ DebuggerSettings *theDebuggerSettings()
instance->insertItem(MaximalStackDepth, item);
item = new SavedAction(instance);
item->setText(QObject::tr("Reload full stack"));
item->setText(tr("Reload full stack"));
instance->insertItem(ExpandStack, item);
item = new SavedAction(instance);
item->setText(QObject::tr("Execute line"));
item->setText(tr("Execute line"));
instance->insertItem(ExecuteCommand, item);
return instance;
}
//////////////////////////////////////////////////////////////////////////
//
// DebuggerActions
//
//////////////////////////////////////////////////////////////////////////
SavedAction *theDebuggerAction(int code)
{
return theDebuggerSettings()->item(code);
return DebuggerSettings::instance()->item(code);
}
bool theDebuggerBoolSetting(int code)
{
return theDebuggerSettings()->item(code)->value().toBool();
return DebuggerSettings::instance()->item(code)->value().toBool();
}
QString theDebuggerStringSetting(int code)
{
return theDebuggerSettings()->item(code)->value().toString();
return DebuggerSettings::instance()->item(code)->value().toString();
}
} // namespace Internal
......
......@@ -50,6 +50,8 @@ public:
QString dump();
static DebuggerSettings *instance();
public slots:
void readSettings(QSettings *settings);
void writeSettings(QSettings *settings);
......@@ -121,7 +123,6 @@ enum DebuggerActionCode
};
// singleton access
DebuggerSettings *theDebuggerSettings();
Core::Utils::SavedAction *theDebuggerAction(int code);
// convienience
......
......@@ -498,8 +498,9 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
// FIXME: make this a global action
m_breakpointMarginAction = new QAction(this);
m_breakpointMarginAction->setText("Toggle Breakpoint");
m_breakpointMarginAction->setText(tr("Toggle Breakpoint"));
//m_breakpointMarginAction->setIcon(QIcon(":/gdbdebugger/images/breakpoint.svg"));
connect(m_breakpointMarginAction, SIGNAL(triggered()),
this, SLOT(breakpointMarginActionTriggered()));
......@@ -976,7 +977,7 @@ void DebuggerPlugin::writeSettings() const
QTC_ASSERT(m_manager->mainWindow(), return);
QSettings *s = settings();
theDebuggerSettings()->writeSettings(s);
DebuggerSettings::instance()->writeSettings(s);
s->beginGroup(QLatin1String("DebugMode"));
s->setValue("State", m_manager->mainWindow()->saveState());
s->setValue("Locked", m_toggleLockedAction->isChecked());
......@@ -986,7 +987,7 @@ void DebuggerPlugin::writeSettings() const
void DebuggerPlugin::readSettings()
{
QSettings *s = settings();
theDebuggerSettings()->readSettings(s);
DebuggerSettings::instance()->readSettings(s);
QString defaultCommand("gdb");
#if defined(Q_OS_WIN32)
......
......@@ -121,13 +121,11 @@ QVariant DisassemblerModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
static const char * const headers[] = {
QT_TR_NOOP("Address"),
QT_TR_NOOP("Symbol"),
QT_TR_NOOP("Mnemonic"),
switch (section) {
case 1: return DisassemblerHandler::tr("Address");
case 2: return DisassemblerHandler::tr("Symbol");
case 3: return DisassemblerHandler::tr("Mnemonic");
};
if (section < 3)
return tr(headers[section]);
}
return QVariant();
}
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "disassemblerwindow.h"
#include "debuggeractions.h"
#include <QAction>
#include <QDebug>
......@@ -68,24 +69,23 @@ void DisassemblerWindow::resizeEvent(QResizeEvent *ev)
void DisassemblerWindow::contextMenuEvent(QContextMenuEvent *ev)
{
QMenu menu;
//QTreeWidgetItem *item = itemAt(ev->pos());
QAction *act1 = new QAction("Adjust column widths to contents", &menu);
QAction *act2 = new QAction("Always adjust column widths to contents", &menu);
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);
QAction *act2 = new QAction(tr("Always adjust column widths to contents"), &menu);
act2->setCheckable(true);
// FIXME: make this a SavedAction
act2->setChecked(m_alwaysResizeColumnsToContents);
QAction *act3 = new QAction("Reload disassembler listing", &menu);
QAction *act4 = new QAction("Always reload disassembler listing", &menu);
QAction *act3 = new QAction(tr("Reload disassembler listing"), &menu);
QAction *act4 = new QAction(tr("Always reload disassembler listing"), &menu);
act4->setCheckable(true);
act4->setChecked(m_alwaysReloadContents);
//if (item) {
// menu.addAction(act0);
// menu.addSeparator();
//}
menu.addAction(act3);
//menu.addAction(act4);
menu.addSeparator();
menu.addAction(act1);
menu.addAction(act2);
menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
......
......@@ -1534,7 +1534,7 @@ int GdbEngine::currentFrame() const
bool GdbEngine::startDebugger()
{
debugMessage(theDebuggerSettings()->dump());
debugMessage(DebuggerSettings::instance()->dump());
QStringList gdbArgs;
if (m_gdbProc.state() != QProcess::NotRunning) {
......@@ -2727,7 +2727,7 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
if (!hasLetterOrNumber(exp)) {
QToolTip::showText(m_toolTipPos,
"'" + exp + "' contains no identifier");
tr("'%1' contains no identifier").arg(exp));
return;
}
......@@ -2750,8 +2750,8 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
if (hasSideEffects(exp)) {
QToolTip::showText(m_toolTipPos,
"Cowardly refusing to evaluate expression '" + exp
+ "' with potential side effects");
tr("Cowardly refusing to evaluate expression '%1' "
"with potential side effects").arg(exp));
return;
}
......@@ -2763,7 +2763,7 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
qDebug() << "THIS IN ROW " << i;
if (m_currentLocals.childAt(i).type.startsWith(exp)) {
QToolTip::showText(m_toolTipPos,
exp + ": type of current 'this'");
tr("%1: type of current 'this'").arg(exp));
qDebug() << " TOOLTIP CRASH SUPPRESSED";
return;
}
......@@ -3329,7 +3329,7 @@ void GdbEngine::updateWatchModel2()
"(" + data->type + ") " + data->exp + " = " + data->value);
} else {
QToolTip::showText(m_toolTipPos,
"Cannot evaluate expression: " + m_toolTipExpression);
tr("Cannot evaluate expression: %1").arg(m_toolTipExpression));
}
}
}
......
......@@ -75,10 +75,8 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0:
return reg.name;
case 1:
return reg.value;
case 0: return reg.name;
case 1: return reg.value;
}
}
if (role == Qt::TextColorRole && reg.changed && index.column() == 1)
......@@ -90,12 +88,10 @@ QVariant RegisterHandler::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
static const char * const headers[] = {
QT_TR_NOOP("Name"),
QT_TR_NOOP("Value"),
switch (section) {
case 0: return tr("Name");
case 1: return tr("Value");
};
if (section < 2)
return tr(headers[section]);
}
return QVariant();
}
......
......@@ -81,15 +81,15 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
//QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString();
//qDebug() << "FORMAT: " << format;
actions[Adjust] = menu.addAction("Adjust column widths to contents");
actions[Adjust] = menu.addAction(tr("Adjust column widths to contents"));
actions[AlwaysAdjust] = menu.addAction("Always adjust column widths to contents");
actions[AlwaysAdjust] = menu.addAction(tr("Always adjust column widths to contents"));
actions[AlwaysAdjust]->setCheckable(true);
actions[AlwaysAdjust]->setChecked(m_alwaysResizeColumnsToContents);
actions[Reload] = menu.addAction("Reload register listing");
actions[Reload] = menu.addAction(tr("Reload register listing"));
actions[AlwaysReload] = menu.addAction("Always reload register listing");
actions[AlwaysReload] = menu.addAction(tr("Always reload register listing"));
actions[AlwaysReload]->setCheckable(true);
actions[AlwaysReload]->setChecked(m_alwaysReloadContents);
......
......@@ -489,8 +489,8 @@ void ScriptEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
if (hasSideEffects(exp)) {
QToolTip::showText(m_toolTipPos,
"Cowardly refusing to evaluate expression '" + exp
+ "' with potential side effects");
tr("Cowardly refusing to evaluate expression '%1' "
"with potential side effects").arg(exp));
return;
}
......
......@@ -232,7 +232,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
return "???";
}
} else if (role == Qt::ToolTipRole) {
return "Thread: " + QString::number(m_threads.at(index.row()).id);
return tr("Thread: %1").arg(m_threads.at(index.row()).id);
} else if (role == Qt::DecorationRole && index.column() == 0) {
// Return icon that indicates whether this is the active stack frame
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
......@@ -244,11 +244,8 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
QVariant ThreadsHandler::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
static const char * const headers[] = {
QT_TR_NOOP("Thread ID"),
};
if (section < 1)
return tr(headers[section]);
return tr("Thread ID");
}
return QVariant();
}
......
......@@ -293,7 +293,7 @@ static QList<WatchData> initialSet()
root.state = 0;
root.level = 0;
root.row = 0;
root.name = QLatin1String("Root");
root.name = WatchHandler::tr("Root");
root.parentIndex = -1;
root.childIndex.append(1);
root.childIndex.append(2);
......@@ -302,7 +302,7 @@ static QList<WatchData> initialSet()
WatchData local;
local.iname = QLatin1String("local");
local.name = QLatin1String("Locals");
local.name = WatchHandler::tr("Locals");
local.state = 0;
local.level = 1;
local.row = 0;
......@@ -311,7 +311,7 @@ static QList<WatchData> initialSet()
WatchData tooltip;
tooltip.iname = QLatin1String("tooltip");
tooltip.name = QLatin1String("Tooltip");
tooltip.name = WatchHandler::tr("Tooltip");
tooltip.state = 0;
tooltip.level = 1;
tooltip.row = 1;
......@@ -320,7 +320,7 @@ static QList<WatchData> initialSet()
WatchData watch;
watch.iname = QLatin1String("watch");
watch.name = QLatin1String("Watchers");
watch.name = WatchHandler::tr("Watchers");
watch.state = 0;
watch.level = 1;
watch.row = 2;
......@@ -711,13 +711,13 @@ void WatchHandler::rebuildModel()
dummy.row = 0;
if (i == 1) {
dummy.iname = QLatin1String("local.dummy");
dummy.name = QLatin1String("<No Locals>");
dummy.name = tr("<No Locals>");
} else if (i == 2) {
dummy.iname = QLatin1String("tooltip.dummy");
dummy.name = QLatin1String("<No Tooltip>");
dummy.name = tr("<No Tooltip>");
} else {
dummy.iname = QLatin1String("watch.dummy");
dummy.name = QLatin1String("<No Watchers>");
dummy.name = tr("<No Watchers>");
}
dummy.level = 2;
dummy.parentIndex = i;
......
......@@ -164,8 +164,8 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev)
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
{
QMenu menu;
QAction *act1 = new QAction("Adjust column widths to contents", &menu);
QAction *act2 = new QAction("Always adjust column widths to contents", &menu);
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);
QAction *act2 = new QAction(tr("Always adjust column widths to contents"), &menu);
act2->setCheckable(true);
act2->setChecked(m_alwaysResizeColumnsToContents);
......@@ -201,7 +201,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == act2)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == act3)
theDebuggerAction(WatchExpression)->trigger("<Edit>");
theDebuggerAction(WatchExpression)->trigger(tr("<Edit>"));
}
void WatchWindow::resizeColumnsToContents()
......
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