internationalization (but no localization yet)

This commit is contained in:
Mathias Panzenböck
2014-02-23 18:27:27 +01:00
parent cad0fc343d
commit 45efb2e941
14 changed files with 111 additions and 97 deletions

View File

@ -282,20 +282,20 @@ QString Axis::status() {
if (mode == Keyboard) {
if (throttle == 0) {
if (puseMouse != nuseMouse) {
result += "KEYBOARD/MOUSE";
result += tr("KEYBOARD/MOUSE");
}
else if (puseMouse) {
result += "MOUSE";
result += tr("MOUSE");
}
else {
result += "KEYBOARD";
result += tr("KEYBOARD");
}
}
else {
result += "THROTTLE";
result += tr("THROTTLE");
}
}
else result += "MOUSE";
else result += tr("MOUSE");
return result + "]";
}

View File

@ -23,26 +23,26 @@ AxisEdit::AxisEdit( Axis* ax )
QVBoxLayout* v2 = new QVBoxLayout();
v2->setMargin(5);
v2->setSpacing(5);
chkGradient = new QCheckBox("&Gradient", this);
chkGradient = new QCheckBox(tr("&Gradient"), this);
chkGradient->setChecked(axis->gradient);
connect(chkGradient, SIGNAL(toggled(bool)), this, SLOT( gradientChanged( bool )));
v2->addWidget(chkGradient);
cmbMode = new QComboBox(this);
cmbMode->insertItem((int) Axis::Keyboard, QString("Keyboard/Mouse Button"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MousePosVert,QString("Mouse (Vert.)"),Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MouseNegVert, QString("Mouse (Vert. Rev.)"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MousePosHor, "Mouse (Hor.)", Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MouseNegHor, QString("Mouse (Hor. Rev.)"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::Keyboard, tr("Keyboard/Mouse Button"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MousePosVert, tr("Mouse (Vert.)"),Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MouseNegVert, tr("Mouse (Vert. Rev.)"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MousePosHor, tr("Mouse (Hor.)"), Qt::DisplayRole);
cmbMode->insertItem((int) Axis::MouseNegHor, tr("Mouse (Hor. Rev.)"), Qt::DisplayRole);
cmbMode->setCurrentIndex( axis->mode );
connect(cmbMode, SIGNAL(activated(int)), this, SLOT( modeChanged( int )));
v2->addWidget(cmbMode);
cmbTransferCurve = new QComboBox(this);
cmbTransferCurve->insertItem(Axis::Linear, QString("Linear"), Qt::DisplayRole);
cmbTransferCurve->insertItem(Axis::Quadratic, QString("Quadratic"),Qt::DisplayRole );
cmbTransferCurve->insertItem(Axis::Cubic, QString("Cubic"),Qt::DisplayRole );
cmbTransferCurve->insertItem(Axis::QuadraticExtreme, QString("Quadratic Extreme"), Qt::DisplayRole);
cmbTransferCurve->insertItem(Axis::PowerFunction, QString("Power Function"), Qt::DisplayRole);
cmbTransferCurve->insertItem(Axis::Linear, tr("Linear"), Qt::DisplayRole);
cmbTransferCurve->insertItem(Axis::Quadratic, tr("Quadratic"), Qt::DisplayRole );
cmbTransferCurve->insertItem(Axis::Cubic, tr("Cubic"), Qt::DisplayRole );
cmbTransferCurve->insertItem(Axis::QuadraticExtreme, tr("Quadratic Extreme"), Qt::DisplayRole);
cmbTransferCurve->insertItem(Axis::PowerFunction, tr("Power Function"), Qt::DisplayRole);
cmbTransferCurve->setCurrentIndex( axis->transferCurve );
cmbTransferCurve->setEnabled(axis->gradient);
connect(cmbTransferCurve, SIGNAL(activated(int)), this, SLOT( transferCurveChanged( int )));
@ -55,14 +55,14 @@ AxisEdit::AxisEdit( Axis* ax )
v2->setSpacing(5);
v2->setMargin(5);
//v2->setAutoAdd(true);
QLabel *mouseLabel = new QLabel("&Mouse Speed", mouseBox);
QLabel *mouseLabel = new QLabel(tr("&Mouse Speed"), mouseBox);
v2->addWidget(mouseLabel);
spinSpeed = new QSpinBox(mouseBox);
spinSpeed->setRange(0,MAXMOUSESPEED);
spinSpeed->setSingleStep(1);
spinSpeed->setValue(axis->maxSpeed);
v2->addWidget(spinSpeed);
lblSensitivity = new QLabel("&Sensitivity", mouseBox);
lblSensitivity = new QLabel(tr("&Sensitivity"), mouseBox);
v2->addWidget(lblSensitivity);
spinSensitivity = new QDoubleSpinBox(mouseBox);
spinSensitivity->setRange(1e-3F, 1e+3F);
@ -86,9 +86,9 @@ AxisEdit::AxisEdit( Axis* ax )
btnNeg = new KeyButton(axis->getName(),axis->nkeycode,keyBox,true,axis->nuseMouse);
cmbThrottle = new QComboBox(keyBox);
cmbThrottle->insertItem(0,"Neg. Throttle",Qt::DisplayRole);
cmbThrottle->insertItem(1,"No Throttle",Qt::DisplayRole);
cmbThrottle->insertItem(2,"Pos. Throttle",Qt::DisplayRole);
cmbThrottle->insertItem(0, tr("Neg. Throttle"), Qt::DisplayRole);
cmbThrottle->insertItem(1, tr("No Throttle"), Qt::DisplayRole);
cmbThrottle->insertItem(2, tr("Pos. Throttle"), Qt::DisplayRole);
cmbThrottle->setCurrentIndex(axis->throttle + 1);
connect( cmbThrottle, SIGNAL( activated( int )), this, SLOT( throttleChanged( int )));

View File

@ -125,10 +125,10 @@ bool Button::isDefault() {
QString Button::status() {
if (useMouse) {
return QString("%1 : Mouse %2").arg(getName()).arg(keycode);
return tr("%1 : Mouse %2").arg(getName()).arg(keycode);
}
else {
return QString("%1 : %2").arg(getName(), ktos(keycode));
return tr("%1 : %2").arg(getName(), ktos(keycode));
}
}

View File

@ -9,7 +9,7 @@ ButtonEdit::ButtonEdit(Button* butt)
setModal(true);
//build the dialog!
button = butt;
setWindowTitle("Set " + button->getName());
setWindowTitle(tr("Set %1").arg(button->getName()));
setWindowIcon(QPixmap(QJOYPAD_ICON24));
QVBoxLayout* v = new QVBoxLayout(this);
@ -20,10 +20,10 @@ ButtonEdit::ButtonEdit(Button* butt)
v->addWidget(btnKey);
QHBoxLayout* h = new QHBoxLayout();
chkSticky = new QCheckBox("&Sticky", this);
chkSticky = new QCheckBox(tr("&Sticky"), this);
chkSticky->setChecked(button->sticky);
h->addWidget(chkSticky);
chkRapid = new QCheckBox("&Rapid Fire", this);
chkRapid = new QCheckBox(tr("&Rapid Fire"), this);
chkRapid->setChecked(button->rapidfire);
h->addWidget(chkRapid);
v->addLayout(h);

View File

@ -7,21 +7,19 @@ GetKey::GetKey( QString button, bool m )
{
//prepare the dialog
mouse = m;
setWindowTitle( "Choose a key" );
setWindowTitle( tr("Choose a key") );
setWindowIcon(QIcon(QJOYPAD_ICON24));
//I'd use a QLabel, but that steals x11Events!
//So, I'll draw the text directly. That means
//I need to resolve the size of the dialog by hand:
text = "Choose a new key ";
if (mouse) text += "or mouse button ";
text += "for " + button;
text = (mouse ? tr("Choose a new key or mouse button for %1") : tr("Choose a new key for %1")).arg(button);
QRect rect = fontMetrics().boundingRect( text );
//I calculate the size based on the first line of text, which is longer.
//The fontMetrics function is dumb and would treat the string with a
//newline in it as a continues flow of characters if I did the whole string
//at once.
text += "\n(Ctrl-X for no key)";
text += tr("\n(Ctrl-X for no key)");
//now I add 20 pixels of padding and double the height to make room for
//two lines.
setFixedSize( QSize( rect.width() + 20, rect.height()*2 + 20 ) );

View File

@ -9,7 +9,7 @@ FloatingIcon::FloatingIcon( const QString &icon, QMenu *popup, QWidget *parent,
setAttribute(Qt::WA_QuitOnClose);
setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);
setWindowTitle(QJOYPAD_NAME " Floating Icon");
setWindowTitle(tr("%1 Floating Icon").arg(QJOYPAD_NAME));
pop = popup;
setFixedSize(this->icon.width(),this->icon.height());

View File

@ -137,14 +137,14 @@ bool JoyPad::readConfig( QTextStream &stream ) {
if (num > 0) {
stream >> ch;
if (ch != ':') {
errorBox("Layout file error", QString("Expected ':', found '%1'.").arg(ch));
errorBox(tr("Layout file error"), tr("Expected ':', found '%1'.").arg(ch));
return false;
}
if (buttons[num-1] == 0) {
buttons.insert(num-1,new Button(num-1,this));
}
if (!buttons[num-1]->read( stream )) {
errorBox("Layout file error", QString("Error reading Button %1").arg(num));
errorBox(tr("Layout file error"), tr("Error reading Button %1").arg(num));
return false;
}
}
@ -157,20 +157,20 @@ bool JoyPad::readConfig( QTextStream &stream ) {
if (num > 0) {
stream >> ch;
if (ch != ':') {
errorBox("Layout file error", QString("Expected ':', found '%1'.").arg(ch));
errorBox(tr("Layout file error"), tr("Expected ':', found '%1'.").arg(ch));
return false;
}
if (axes[num-1] == 0) {
axes.insert(num-1,new Axis(num-1,this));
}
if (!axes[num-1]->read(stream)) {
errorBox("Layout file error", QString("Error reading Axis %1").arg(num));
errorBox(tr("Layout file error"), tr("Error reading Axis %1").arg(num));
return false;
}
}
}
else {
errorBox( "Layout file error", QString("Error while reading layout. Unrecognized word: %1").arg(word) );
errorBox(tr("Layout file error"), tr("Error while reading layout. Unrecognized word: %1").arg(word));
return false;
}
stream >> word;
@ -248,7 +248,7 @@ void JoyPad::handleJoyEvents() {
void JoyPad::releaseWidget() {
//this is how we know that there is no longer a JoyPadWidget around.
jpw = NULL;
jpw = 0;
}
void JoyPad::errorRead() {

View File

@ -42,7 +42,7 @@ class JoyPad : public QObject {
//read the dimensions on the real joystick and use them
void open( int dev );
const QString& getDeviceId() const { return deviceId; }
QString getName() const { return QString("Joystick %1 (%2)").arg(index+1).arg(deviceId); }
QString getName() const { return tr("Joystick %1 (%2)").arg(index+1).arg(deviceId); }
int getIndex() const { return index; }
private:

View File

@ -35,11 +35,11 @@ JoyPadWidget::JoyPadWidget( JoyPad* jp, int i, QWidget* parent )
insertCounter ++;
}
insertCounter += 2;
btnClear = new QPushButton(QIcon::fromTheme("edit-clear"), "Clear", this);
btnClear = new QPushButton(QIcon::fromTheme("edit-clear"), tr("Clear"), this);
connect(btnClear, SIGNAL(clicked()), this, SLOT(clear()));
layoutMain->addWidget(btnClear, insertCounter / 2, insertCounter % 2);
insertCounter++;
btnAll = new QPushButton("Quick Set", this);
btnAll = new QPushButton(tr("Quick Set"), this);
layoutMain->addWidget(btnAll, insertCounter / 2, insertCounter % 2);
connect(btnAll, SIGNAL(clicked()), this, SLOT(setAll()));
}
@ -57,8 +57,9 @@ void JoyPadWidget::flash( bool on ) {
flashcount += (on?1:-1);
//if we were on and should now be off, or visa versa, flash the whole widget
if (wasOn != (flashcount != 0))
if (wasOn != (flashcount != 0)) {
emit flashed(index);
}
}
void JoyPadWidget::update() {

View File

@ -80,7 +80,7 @@ const QString ktos( int keycode )
KeyButton::KeyButton( QString name, int val, QWidget* parent, bool m, bool nowMouse)
:QPushButton(nowMouse?"Mouse " + QString::number(val):QString(ktos(val)), parent) {
:QPushButton(nowMouse?tr("Mouse %1").arg(val):ktos(val), parent) {
mouse = m;
mouseClicked = nowMouse;
buttonname = name;
@ -94,19 +94,19 @@ void KeyButton::onClick() {
// -1 is a special value meaning that the window was simply
// closed so we can ignore this
if(retValue == -1) {
return;
return;
} else {
value = retValue;
value = retValue;
}
//if the return value was a mouse click...
if (value > MOUSE_OFFSET) {
mouseClicked = true;
value -= MOUSE_OFFSET;
setText( "Mouse " + QString::number(value));
setText(tr("Mouse %1").arg(value));
}
//otherwise, it was a key press!
else {
mouseClicked = false;
setText( ktos(value));
setText(ktos(value));
}
}

View File

@ -11,9 +11,9 @@ LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QSt
: devdir(devdir), settingsDir(settingsDir),
layoutGroup(new QActionGroup(this)),
titleAction(new QAction(this)),
updateDevicesAction(new QAction(QIcon::fromTheme("view-refresh"),"Update &Joystick Devices",this)),
updateLayoutsAction(new QAction(QIcon::fromTheme("view-refresh"),"Update &Layout List",this)),
quitAction(new QAction(QIcon::fromTheme("application-exit"),"&Quit",this)),
updateDevicesAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Joystick Devices"),this)),
updateLayoutsAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Layout List"),this)),
quitAction(new QAction(QIcon::fromTheme("application-exit"),tr("&Quit"),this)),
le(0) {
#ifdef WITH_LIBUDEV
@ -22,8 +22,8 @@ LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QSt
monitor = 0;
if (!initUDev()) {
errorBox("UDev Error", "Error creating UDev monitor. "
"QJoyPad will still work, but it won't automatically update the joypad device list.");
errorBox(tr("UDev Error"), tr("Error creating UDev monitor. "
"QJoyPad will still work, but it won't automatically update the joypad device list."));
}
#endif
@ -205,7 +205,7 @@ bool LayoutManager::load(const QString& name) {
num = word.toInt(&okay);
//make sure the number of the joystick is valid
if (!okay || num < 1) {
errorBox( "Load error", QString("Error reading joystick definition. Unexpected token \"%1\". Expected a positive number.").arg(word));
errorBox( tr("Load error"), tr("Error reading joystick definition. Unexpected token \"%1\". Expected a positive number.").arg(word));
if (name != currentLayout) reload();
else clear();
return false;
@ -213,7 +213,7 @@ bool LayoutManager::load(const QString& name) {
stream.skipWhiteSpace();
stream >> ch;
if (ch != QChar('{')) {
errorBox( "Load error", QString("Error reading joystick definition. Unexpected character \"%1\". Expected '{'.").arg(ch));
errorBox( tr("Load error"), tr("Error reading joystick definition. Unexpected character \"%1\". Expected '{'.").arg(ch));
if (name != currentLayout) reload();
else clear();
return false;
@ -225,7 +225,7 @@ bool LayoutManager::load(const QString& name) {
}
//try to read the joypad, report error on fail.
if (!joypads[index]->readConfig(stream)) {
errorBox( "Load error", QString("Error reading definition for joystick %1.").arg(index));
errorBox( tr("Load error"), tr("Error reading definition for joystick %1.").arg(index));
//if this was attempting to change to a new layout and it failed,
//revert back to the old layout.
if (name != currentLayout) reload();
@ -240,7 +240,7 @@ bool LayoutManager::load(const QString& name) {
stream.readLine();
}
else {
errorBox("Load error", QString("Error reading joystick definition. Unexpected token \"%1\". Expected \"Joystick\".").arg(word));
errorBox(tr("Load error"), tr("Error reading joystick definition. Unexpected token \"%1\". Expected \"Joystick\".").arg(word));
if (name != currentLayout) reload();
else clear();
return false;
@ -304,22 +304,26 @@ void LayoutManager::save() {
file.close();
}
//if it's not, error.
else
errorBox("Save error", "Could not open file " + filename + ", layout not saved.");
else {
errorBox(tr("Save error"), tr("Could not open file %1, layout not saved.").arg(filename));
}
}
void LayoutManager::saveAs() {
bool ok;
//request a new name!
QString name = QInputDialog::getText(0, QJOYPAD_NAME" - Name new layout","Enter a name for the new layout:", QLineEdit::Normal, QString::null, &ok );
QString name = QInputDialog::getText(le,
tr("%1 - Name new layout").arg(QJOYPAD_NAME),
tr("Enter a name for the new layout:"),
QLineEdit::Normal, QString::null, &ok );
if (!ok) {
return;
}
QFile file(settingsDir + name + ".lyt");
//don't overwrite an existing layout.
if (file.exists()) {
errorBox("Save error", "That name's already taken!");
errorBox(tr("Save error"), tr("That name's already taken!"));
return;
}
@ -346,12 +350,12 @@ void LayoutManager::saveDefault() {
void LayoutManager::remove() {
if (currentLayout.isNull()) return;
if (QMessageBox::warning(0, QJOYPAD_NAME" - Delete layout?",
QString("Remove layout %1 permanently from your hard drive?").arg(currentLayout), "Delete", "Cancel", 0, 0, 1 ) == 1)
if (QMessageBox::warning(le, tr("%1 - Delete layout?").arg(QJOYPAD_NAME),
tr("Remove layout %1 permanently from your hard drive?").arg(currentLayout), tr("Delete"), tr("Cancel"), 0, 0, 1 ) == 1)
return;
QString filename = getFileName( currentLayout );
if (!QFile(filename).remove()) {
errorBox("Remove error", "Could not remove file " + filename);
errorBox(tr("Remove error"), tr("Could not remove file %1").arg(filename));
}
fillPopup();
@ -392,7 +396,8 @@ void LayoutManager::setLayoutName(const QString& name) {
void LayoutManager::iconClick() {
//don't show the dialog if there aren't any joystick devices plugged in
if (available.isEmpty()) {
errorBox("No joystick devices available","No joystick devices are currently available to configure.\nPlease plug in a gaming device and select\n\"Update Joystick Devices\" from the popup menu.");
errorBox(tr("No joystick devices available"),
tr("No joystick devices are currently available to configure.\nPlease plug in a gaming device and select\n\"Update Joystick Devices\" from the popup menu."));
return;
}
if (le) {
@ -428,14 +433,16 @@ void LayoutManager::fillPopup() {
trayMenu.clear();
//make a list of joystick devices
QString title = "Joysticks: ";
QString title;
if (available.isEmpty()) {
title += "(none)";
title = tr("Joysticks: (none)");
}
else {
QStringList pads;
foreach (JoyPad *joypad, available) {
title += QString("%1 ").arg(joypad->getIndex() + 1);
pads.append(QString::number(joypad->getIndex() + 1));
}
title = tr("Joysticks: %1").arg(pads.join(" "));
}
trayMenu.setTitle(title);
@ -449,7 +456,7 @@ void LayoutManager::fillPopup() {
trayMenu.addSeparator();
//add null layout
QAction *action = trayMenu.addAction("[NO LAYOUT]");
QAction *action = trayMenu.addAction(tr("[NO LAYOUT]"));
action->setCheckable(true);
action->setActionGroup(layoutGroup);
//put a check by the current one ;)

View File

@ -22,16 +22,16 @@ LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) {
g->addWidget(cmbLayouts,0,0,1,4);
//most of these buttons can link directly into slots in the LayoutManager
btnAdd = new QPushButton(QIcon::fromTheme("list-add"), "&Add", frame);
btnAdd = new QPushButton(QIcon::fromTheme("list-add"), tr("&Add"), frame);
connect(btnAdd, SIGNAL(clicked()), lm, SLOT(saveAs()));
g->addWidget(btnAdd,1,0);
btnRem = new QPushButton(QIcon::fromTheme("list-remove"), "&Remove", frame);
btnRem = new QPushButton(QIcon::fromTheme("list-remove"), tr("&Remove"), frame);
connect(btnRem, SIGNAL(clicked()), lm, SLOT(remove()));
g->addWidget(btnRem,1,1);
btnUpd = new QPushButton(QIcon::fromTheme("document-save"), "&Save", frame);
btnUpd = new QPushButton(QIcon::fromTheme("document-save"), tr("&Save"), frame);
connect(btnUpd, SIGNAL(clicked()), lm, SLOT(save()));
g->addWidget(btnUpd,1,2);
btnRev = new QPushButton(QIcon::fromTheme("document-revert"), "Re&vert", frame);
btnRev = new QPushButton(QIcon::fromTheme("document-revert"), tr("Re&vert"), frame);
connect(btnRev, SIGNAL(clicked()), lm, SLOT(reload()));
g->addWidget(btnRev,1,3);
mainLayout->addWidget( frame );
@ -73,10 +73,10 @@ LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) {
QHBoxLayout* h = new QHBoxLayout(0);
h->setMargin(0);
h->setSpacing(5);
QPushButton* close = new QPushButton(QIcon::fromTheme("window-close"), "&Close Dialog", this );
QPushButton* close = new QPushButton(QIcon::fromTheme("window-close"), tr("&Close Dialog"), this );
connect(close, SIGNAL(clicked()), this, SLOT(close()));
h->addWidget(close);
QPushButton* quit = new QPushButton(QIcon::fromTheme("application-exit"), "&Quit", this );
QPushButton* quit = new QPushButton(QIcon::fromTheme("application-exit"), tr("&Quit"), this );
connect( quit, SIGNAL( clicked() ), qApp, SLOT(quit()));
h->addWidget(quit);
mainLayout->addLayout(h);
@ -103,7 +103,7 @@ void LayoutEdit::setLayout(const QString &layout) {
void LayoutEdit::updateLayoutList() {
//blank the list, then load in new names from the LayoutManager.
cmbLayouts->clear();
cmbLayouts->addItem("[NO LAYOUT]", QVariant(QString::null));
cmbLayouts->addItem(tr("[NO LAYOUT]"), QVariant(QString::null));
if (lm->currentLayout.isNull()) {
cmbLayouts->setCurrentIndex(0);
}

View File

@ -9,6 +9,7 @@
#include <QFile>
#include <QSystemTrayIcon>
#include <QPointer>
#include <QFileInfo>
//to load layouts
#include "layout.h"
@ -24,8 +25,7 @@ QPointer<LayoutManager> layoutManagerPtr;
//signal handler for SIGUSR2
//SIGUSR2 means that a new layout should be loaded. It is saved in
// ~/.qjoypad/layout, where the last used layout is put.
void catchSIGUSR2( int sig )
{
void catchSIGUSR2( int sig ) {
if (layoutManagerPtr) layoutManagerPtr->load();
//remember to catch this signal again next time.
signal( sig, catchSIGUSR2 );
@ -62,7 +62,8 @@ int main( int argc, char **argv )
//if there is no new directory and we can't make it, complain
if (!dir.exists() && !dir.mkdir(settingsDir)) {
printf("Couldn't create the QJoyPad save directory (%s)!", settingsDir.toStdString().c_str());
errorBox(app.tr("Couldn't create the QJoyPad save directory"),
app.tr("Couldn't create the QJoyPad save directory: %s").arg(settingsDir));
return 1;
}
@ -93,8 +94,8 @@ int main( int argc, char **argv )
switch (c) {
case 'h':
printf("%s\n"
"Usage: %s [--device=\"/device/path\"] [--notray|--force-tray] [\"layout name\"]\n"
printf("%s", qPrintable(app.tr("%1\n"
"Usage: %2 [--device=\"/device/path\"] [--notray|--force-tray] [\"layout name\"]\n"
"\n"
"Options:\n"
" -h, --help Print this help message.\n"
@ -108,15 +109,16 @@ int main( int argc, char **argv )
" list of devices and layouts.\n"
" \"layout name\" Load the given layout in an already running\n"
" instance of QJoyPad, or start QJoyPad using the\n"
" given layout.\n", QJOYPAD_NAME, argc > 0 ? argv[0] : "qjoypad");
" given layout.\n").arg(QJOYPAD_NAME, argc > 0 ? argv[0] : "qjoypad")));
return 0;
case 'd':
if (QFile::exists(optarg)) {
if (QFileInfo(optarg).isDir()) {
devdir = optarg;
}
else {
fprintf(stderr, "No such file or directory: %s\n", optarg);
errorBox(app.tr("Not a directory"),
app.tr("Path is not a directory: %1").arg(optarg));
return 1;
}
break;
@ -188,14 +190,17 @@ int main( int argc, char **argv )
//then prevent two instances from running at once.
//however, if we are setting the layout or updating the device
//list, this is not an error and we shouldn't make one!
if (layout.isEmpty() && update == false)
errorBox("Instance Error","There is already a running instance of QJoyPad; please close\nthe old instance before starting a new one.");
if (layout.isEmpty() && !update)
errorBox(app.tr("Instance Error"),
app.tr("There is already a running instance of QJoyPad; please close\nthe old instance before starting a new one."));
else {
//if one of these is the case, send the approrpriate signal!
if (update == true)
if (update) {
kill(pid,SIGUSR1);
if (!layout.isEmpty())
}
if (!layout.isEmpty()) {
kill(pid,SIGUSR2);
}
}
//and quit. We don't need two instances.
return 0;
@ -211,12 +216,13 @@ int main( int argc, char **argv )
if (forceTrayIcon) {
int sleepCounter = 0;
while(!QSystemTrayIcon::isSystemTrayAvailable()) {
while (!QSystemTrayIcon::isSystemTrayAvailable()) {
sleep(1);
sleepCounter++;
if(sleepCounter > 20) {
printf("Error, we've waited more than 20 seconds, your sys tray probably isn't loading\n");
exit(1);
if (sleepCounter > 20) {
errorBox(app.tr("System tray isn't loading"),
app.tr("Waited more than 20 seconds for the system tray to load. Giving up."));
return 1;
}
}
}

View File

@ -6,15 +6,15 @@ QuickSet::QuickSet( JoyPad* jp, QWidget *parent)
: QDialog(parent) {
setting = false;
joypad = jp;
setWindowTitle("Set " + jp->getName());
setWindowTitle(tr("Set %1").arg(jp->getName()));
QVBoxLayout* LMain = new QVBoxLayout(this);
LMain->setMargin(5);
LMain->setSpacing(5);
//LMain->setAutoAdd(true);
QLabel *temp = new QLabel("Press any button or axis and\nyou will be prompted for a key.",this);
QLabel *temp = new QLabel(tr("Press any button or axis and\nyou will be prompted for a key."),this);
LMain->addWidget(temp);
QPushButton* button = new QPushButton("Done",this);
QPushButton* button = new QPushButton(tr("Done"),this);
LMain->addWidget(button);
connect( button, SIGNAL(clicked()), this, SLOT(accept()));
}
@ -35,12 +35,14 @@ void QuickSet::jsevent(const js_event &msg ) {
setting = false;
//if a mouse button was used,
if (code > MOUSE_OFFSET)
if (code > MOUSE_OFFSET) {
//then tell it to the Button a mouse button
button->setKey(true, code - MOUSE_OFFSET);
else
}
else {
//otherwise, tell it to use a keycode.
button->setKey(false, code);
}
}
else if (type == JS_EVENT_AXIS) {
//require a signal strength of at least 5000 to consider an axis moved.
@ -51,7 +53,7 @@ void QuickSet::jsevent(const js_event &msg ) {
//grab a keycode for that axis and that direction
setting = true;
int code = GetKey(QString("%1, %2").arg(axis->getName(), msg.value > 0 ? "positive" : "negative"), false).exec();
int code = GetKey((msg.value >= 0 ? tr("%1, positive") : tr("%1, negative")).arg(axis->getName()), false).exec();
setting = false;
//assign the key to the axis.