Fixed menu items not getting translated.

This commit is contained in:
leo 2015-09-25 06:03:30 +00:00
parent ed70134eef
commit 5149ef3311
5 changed files with 351 additions and 348 deletions

View file

@ -104,8 +104,8 @@ void lcMainWindow::CreateActions()
{
for (int CommandIdx = 0; CommandIdx < LC_NUM_COMMANDS; CommandIdx++)
{
QAction* Action = new QAction(tr(gCommands[CommandIdx].MenuName), this);
Action->setStatusTip(tr(gCommands[CommandIdx].StatusText));
QAction* Action = new QAction(qApp->translate("Menu", gCommands[CommandIdx].MenuName), this);
Action->setStatusTip(qApp->translate("Status", gCommands[CommandIdx].StatusText));
connect(Action, SIGNAL(triggered()), this, SLOT(ActionTriggered()));
addAction(Action);
mActions[CommandIdx] = Action;

View file

@ -34,7 +34,7 @@ void lcResetDefaultKeyboardShortcuts()
void lcResetKeyboardShortcuts(lcKeyboardShortcuts& Shortcuts)
{
for (int CommandIdx = 0; CommandIdx < LC_NUM_COMMANDS; CommandIdx++)
strcpy(Shortcuts.Shortcuts[CommandIdx], gCommands[CommandIdx].DefaultShortcut);
Shortcuts.Shortcuts[CommandIdx] = qApp->translate("Shortcut", gCommands[CommandIdx].DefaultShortcut);
}
bool lcSaveKeyboardShortcuts(const QString& FileName, const lcKeyboardShortcuts& Shortcuts)
@ -53,7 +53,7 @@ bool lcSaveKeyboardShortcuts(lcFile& File, const lcKeyboardShortcuts& Shortcuts)
for (int CommandIdx = 0; CommandIdx < LC_NUM_COMMANDS; CommandIdx++)
{
if (!Shortcuts.Shortcuts[CommandIdx][0])
if (Shortcuts.Shortcuts[CommandIdx].isEmpty())
continue;
sprintf(Line, "%s=%s\n", gCommands[CommandIdx].ID, Shortcuts.Shortcuts[CommandIdx]);
@ -103,7 +103,7 @@ bool lcLoadKeyboardShortcuts(lcFile& File, lcKeyboardShortcuts& Shortcuts)
if (NewLine)
*NewLine = 0;
strncpy(Shortcuts.Shortcuts[CommandIdx], Key, LC_SHORTCUT_LENGTH);
Shortcuts.Shortcuts[CommandIdx] = QString::fromUtf8(Key); // todo: qstring
}
return true;

View file

@ -3,11 +3,9 @@
#include "lc_commands.h"
#define LC_SHORTCUT_LENGTH 32
struct lcKeyboardShortcuts
{
char Shortcuts[LC_NUM_COMMANDS][LC_SHORTCUT_LENGTH];
QString Shortcuts[LC_NUM_COMMANDS];
};
extern lcKeyboardShortcuts gKeyboardShortcuts;

View file

@ -488,7 +488,7 @@ void lcQPreferencesDialog::updateCommandList()
item->setText(1, sequence.toString(QKeySequence::NativeText));
item->setData(0, Qt::UserRole, qVariantFromValue(actionIdx));
if (strcmp(options->KeyboardShortcuts.Shortcuts[actionIdx], gCommands[actionIdx].DefaultShortcut))
if (options->KeyboardShortcuts.Shortcuts[actionIdx] != gCommands[actionIdx].DefaultShortcut)
setShortcutModified(item, true);
sections[section]->addChild(item);
@ -528,11 +528,11 @@ void lcQPreferencesDialog::on_shortcutAssign_clicked()
return;
int shortcutIndex = qvariant_cast<int>(current->data(0, Qt::UserRole));
strcpy(options->KeyboardShortcuts.Shortcuts[shortcutIndex], ui->shortcutEdit->text().toLocal8Bit().data());
options->KeyboardShortcuts.Shortcuts[shortcutIndex] = ui->shortcutEdit->text();
current->setText(1, ui->shortcutEdit->text());
setShortcutModified(current, strcmp(options->KeyboardShortcuts.Shortcuts[shortcutIndex], gCommands[shortcutIndex].DefaultShortcut) != 0);
setShortcutModified(current, options->KeyboardShortcuts.Shortcuts[shortcutIndex] != gCommands[shortcutIndex].DefaultShortcut);
options->ShortcutsModified = true;
options->ShortcutsDefault = false;

File diff suppressed because it is too large Load diff